package com.yuchen.saas.park.service.service.impl;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.protobuf.ServiceException;
import com.yuchen.saas.integration.feign.api.feign.CommonHikClient;
import com.yuchen.saas.integration.feign.api.util.HikApiUtil;
import com.yuchen.saas.manage.user.api.entity.User;
import com.yuchen.saas.manage.user.api.feign.IUserClient;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.entity.park.*;
import com.yuchen.saas.park.api.vo.responsevo.ResponseVo;
import com.yuchen.saas.park.service.iot.IotClientService;
import com.yuchen.saas.park.service.mapper.PmgBatParkVisitorMapper;
import com.yuchen.saas.park.service.service.*;
import com.yuchen.saas.park.service.util.HikUtils;
import com.yuchen.saas.park.service.util.MianBanJiUtils;
import com.yuchen.saas.park.service.util.PicToBase64Utils;
import com.yuchen.saas.park.service.util.iot.client.ResourceUtils;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.mp.support.Condition;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.secure.ContextUser;
import org.nest.springwrap.core.secure.utils.AuthUtil;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 刘通
 * @date 2020/12/8 11:08
 */
@Slf4j
@Service
public class PmgBatParkVisitorServiceImpl extends BaseServiceImpl<PmgBatParkVisitorMapper, PmgBatParkVisitor>
        implements PmgBatParkVisitorService {
    @Autowired
    private PmgBatSmartEquipmentService pmgBatSmartEquipmentService;
    @Autowired
    private PmgBtnDeviceOtherService pmgBtnDeviceOtherService;
    @Resource
    private CommonHikClient commonHikClient;
    @Autowired
    private IotClientService iotClientService;
    @Autowired
    private PmgBtnPeopleHikService pmgBtnPeopleHikService;
    /**
     * 注入园区信息接口操作
     */
    @Resource
    private PmgBatParkInfoService parkInfoService;
    /**
     * 注入园区企业信息操作接口
     */
    @Resource
    private IParkCompanyService parkCompanyService;
    /**
     * 注入用户信息操作接口
     */
    @Resource
    private IUserClient userClient;

    /**
     * 注入人员类型操作接口
     */
    @Resource
    private PmgBatPeopleTypeService peopleTypeService;

    /**
     * 注入园区人员信息操作接口
     */
    @Resource
    private PmgBatParkPeopleService pmgBatParkPeopleService;
    @Value("${mianBanJi.new-url}")
    private String newUrl;
    @Value("${mianBanJi.old-url}")
    private String oldUrl;

    @Override
    public boolean submit(PmgBatParkVisitor pmgBatParkVisitor) throws ServiceException {
        boolean saveVisiTor = false;
        log.info("pmgBatParkVisitor:" + pmgBatParkVisitor);
        if (Func.isEmpty(pmgBatParkVisitor.getId())) {
            Long visitorId = Long.valueOf(String.valueOf(System.currentTimeMillis()) + "2");
            pmgBatParkVisitor.setId(visitorId);
            //设置园区的租户id
            if (Func.isNotEmpty(pmgBatParkVisitor.getParkId())) {
                PmgBatParkInfo pmgBatParkInfo = parkInfoService.getById(pmgBatParkVisitor.getParkId());
                if (Func.isNotEmpty(pmgBatParkInfo)) {
                    pmgBatParkVisitor.setTenantId(pmgBatParkInfo.getTenantId());
                    pmgBatParkVisitor.setCreateDept(pmgBatParkInfo.getCreateDept());
                }
            }
            saveVisiTor = save(pmgBatParkVisitor);
            if (saveVisiTor) {
                saveVisiTor = propertySet(visitorId);
            }
            return saveVisiTor;
        }
        saveVisiTor = saveOrUpdate(pmgBatParkVisitor);
        if (saveVisiTor) {
            saveVisiTor = propertySet(pmgBatParkVisitor.getId());
        }
        return saveVisiTor;
    }

    @Override
    public boolean propertySet(Long visitorId) throws ServiceException {
        boolean returnBoolean = false;
        log.info("visitorId:" + visitorId);
        // 1、通过可以id 查询用户信息详情。
        PmgBatParkVisitor userInfo = getById(visitorId);
        log.info("userInfo:" + userInfo);
        if (Func.isEmpty(userInfo)) {
            return returnBoolean;
        }
        // 定义保存设备关联信息集合对象
        List<PmgBtnDeviceOther> saveDeviceOtherList
                = new ArrayList<PmgBtnDeviceOther>();
        /******* 面板机开始 *******/
        // 2、获取所有人脸面板机。
        LambdaQueryWrapper<PmgBatSmartEquipment> parkSmartWrapper = Wrappers.lambdaQuery();
        List<PmgBatSmartEquipment> mianBanJi = pmgBatSmartEquipmentService.list(
                parkSmartWrapper.eq(PmgBatSmartEquipment::getProductKey, ResourceUtils.REN_LIAN_MIAN_BAN));
        log.info("mianBanJi:" + mianBanJi);
        HikUtils hikApiUtils = new HikUtils();
        MianBanJiUtils mianBanJiUtils = new MianBanJiUtils();
        // 3、封装面板机报文，下发面板机。
        if (Func.isNotEmpty(mianBanJi) && mianBanJi.size() > 0) {
            for (PmgBatSmartEquipment smartEquipment : mianBanJi) {
                log.info("smartEquipment:" + smartEquipment);
                // 替换人员图片ip端口
                userInfo.setFaceImg(userInfo.getFaceImg().replace(oldUrl, newUrl));
                log.info("userInfo:" + userInfo);
                Map<String, Object> requMap = mianBanJiUtils.mianBanCRUDVisitor(smartEquipment, userInfo,
                        ResourceUtils.POST_FACE_INFO, ResourceUtils.CMD_518);
                System.out.println("req:" + JSON.toJSONString(requMap));
                ResponseVo responseVo = iotClientService.serviceCall(requMap);
                log.info("responseVo:" + responseVo);
                if ("10000".equals(responseVo.getCode())) {
                    Map<String, Object> respData = (Map<String, Object>) responseVo.getData();
                    log.info("respData:" + respData);
                    if (Func.isNotEmpty(respData)
                            && "200".equals(respData.get("code"))) { // 下发成功
                        // 封装保存设备绑定信息
                        PmgBtnDeviceOther deviceOther = new PmgBtnDeviceOther();
                        deviceOther.setDeviceId(String.valueOf(smartEquipment.getId()));
                        deviceOther.setOtherId(String.valueOf(userInfo.getId()));
                        saveDeviceOtherList.add(deviceOther);
                        returnBoolean = true;
                    }
                }
            }
        }
        /******* 面板机结束 *******/
        /******* 海康开始 *******/
        // 4、获取hik人脸识别设备列表，下发海康设备
        List<PmgBatSmartEquipment> haiKang = pmgBatSmartEquipmentService.getDevices(ResourceUtils.REN_LIAN_HIK);
        log.info("haiKang:" + haiKang);
        if (Func.isNotEmpty(haiKang) && haiKang.size() > 0) {
            for (PmgBatSmartEquipment smartEquipment : haiKang) {
                PmgBtnDeviceOther deviceOther = new PmgBtnDeviceOther();
                deviceOther.setDeviceId(String.valueOf(smartEquipment.getId()));
                deviceOther.setOtherId(String.valueOf(userInfo.getId()));
                saveDeviceOtherList.add(deviceOther);
            }
        }
        // (1) 通过人员类型查询海康人员分组唯一编号
        Map<String, Object> peopleType = new HashMap<String, Object>();
        peopleType.put("name", ResourceUtils.FANG_KE);

        Map<String, Object> getGroupMap = new HashMap<String, Object>();
        getGroupMap.put("requestApi", HikApiUtil.GET_FACE_GROUP);
        getGroupMap.put("body", peopleType);
        log.info("getGroupMap:" + getGroupMap);
        R<List<Map<String, Object>>> respGetGroup = commonHikClient.commonHikMethod(getGroupMap);
        log.info("respGetGroup:" + respGetGroup);
        // 定义人脸分组编码对象
        String indexCode = "";
        if (Func.isNotEmpty(respGetGroup)) {
            if (Func.isNotEmpty(respGetGroup) && respGetGroup.getData().size() > 0) {
                indexCode = (String) respGetGroup.getData().get(0).get("indexCode");
            }
        }
        // 判断分组是否为空，为空则返回
        if (Func.isNotEmpty(indexCode)) {
            returnBoolean = true;
        }
        // (2) 封装新增人脸报文，新增人脸
        if (returnBoolean) {
            Map<String, Object> reqMap = hikApiUtils.parkVisitorHikMethod(userInfo, indexCode,
                    ResourceUtils.SHEN_FEN,
                    PicToBase64Utils.imageChangeBase64(userInfo.getFaceImg()),
                    HikApiUtil.ADD_FACE);
            R<Map<String, Object>> respD = commonHikClient.commonHikMethod(reqMap);
            if (Func.isNotEmpty(respD)) {
                if (respD.getCode() == 0 && Func.isNotEmpty(respD.getData())) {
                    Map<String, Object> respAddFace = respD.getData();
                    // 封装人员信息和海康人脸库关联对象
                    PmgBtnPeopleHik peopleHik = new PmgBtnPeopleHik();
                    peopleHik.setPeopleId(String.valueOf(userInfo.getId()));
                    peopleHik.setIndexCode(String.valueOf(respAddFace.get("indexCode")));
                    peopleHik.setFaceGroupIndexCode(String.valueOf(respAddFace.get("faceGroupIndexCode")));
                    // 保存人员信息和海康人脸库关联对象
                    log.info("peopleHik:" + peopleHik);
                    returnBoolean = pmgBtnPeopleHikService.save(peopleHik);
                    if (!returnBoolean) {
                        respD.setMessage("保存人员关联信息失败！");
                    }
                }
            }
        }
        /******* 海康结束 *******/
        if (returnBoolean) {
            // 保存设备关联信息
            if (returnBoolean
                    && Func.isNotEmpty(saveDeviceOtherList)) {
                log.info("saveDeviceOtherList:" + saveDeviceOtherList);
                returnBoolean = pmgBtnDeviceOtherService.saveList(saveDeviceOtherList);
            }
        }
        return returnBoolean;
    }

    @Override
    public boolean deletePeople(List<Long> ids) throws ServiceException {
        if (Func.isEmpty(ids)
                || ids.size() == 0) {
            throw new ServiceException("请求参数为空！");
        }
        boolean returnBoolean = false;
        // 遍历id
        for (Long id : ids) {
            // 1、查询关联的设备
            List<PmgBatSmartEquipment> getSmartList =
                    pmgBtnDeviceOtherService.getParkVisitorListV3(String.valueOf(id));
            PmgBatParkVisitor userInfo = getById(id);
            if (Func.isNotEmpty(getSmartList) && getSmartList.size() > 0) {
                for (PmgBatSmartEquipment smartEquipment : getSmartList) {
                    // 2、删除关联设备的人员
                    if (ResourceUtils.REN_LIAN_MIAN_BAN.equals(smartEquipment.getProductKey())) { // 删除面板机里的人
                        MianBanJiUtils mianBanJi = new MianBanJiUtils();
                        Map<String, Object> requMap = mianBanJi.mianBanCRUDVisitor(smartEquipment,
                                userInfo, ResourceUtils.DELETE_FACE_INFO, ResourceUtils.CMD_519);
                        ResponseVo responseVo = iotClientService.serviceCall(requMap);
                        if (!"200".equals(responseVo.getCode())) {
                            throw new ServiceException("删除人脸面板机数据失败！");
                        }
                    } else if (ResourceUtils.REN_LIAN_HIK.equals(smartEquipment.getProductKey())) { // 海康人脸识别
                        // 通过用户id 查询头像与hik人脸库关联信息
                        LambdaQueryWrapper<PmgBtnPeopleHik> peopleHikWrapper = Wrappers.lambdaQuery();
                        List<PmgBtnPeopleHik> pmgBtnPeopleHikList = pmgBtnPeopleHikService
                                .list(peopleHikWrapper.eq(PmgBtnPeopleHik::getPeopleId, id));
                        // 封装人脸唯一标识集合、hik人脸关联信息ID集合
                        List<String> indexCodes = new ArrayList<String>();
                        List<Long> hikIds = new ArrayList<Long>();
                        String faceGroupIndexCode = "";
                        if (Func.isNotEmpty(pmgBtnPeopleHikList) && pmgBtnPeopleHikList.size() > 0) {
                            for (PmgBtnPeopleHik peopleHik : pmgBtnPeopleHikList) {
                                indexCodes.add(peopleHik.getIndexCode());
                                hikIds.add(peopleHik.getId());
                                faceGroupIndexCode = peopleHik.getFaceGroupIndexCode();
                            }
                        }
                        // 通过人脸唯一标识，删除HIK人脸库中的人脸信息
                        // 封装报文
                        Map<String, Object> body = new HashMap<String, Object>();
                        body.put("indexCodes", indexCodes);
                        body.put("faceGroupIndexCode", faceGroupIndexCode);
                        Map<String, Object> deleteFaceById = new HashMap<String, Object>();
                        deleteFaceById.put("body", body);
                        deleteFaceById.put("requestApi", HikApiUtil.DEL_FACE);

                        R<Map<String, Object>> respD = commonHikClient.commonHikMethod(deleteFaceById);
                        if (Func.isNotEmpty(respD) && respD.getCode() == 0) {
                            // 删除人与人脸库绑定关系
                            returnBoolean = pmgBtnPeopleHikService.deleteLogic(hikIds);
                        }
                    }
                    if (returnBoolean) {
                        // 3、删除设备关联关系
                        LambdaQueryWrapper<PmgBtnDeviceOther> parkSmartWrapper = Wrappers.lambdaQuery();
                        boolean delBl = pmgBtnDeviceOtherService.deleteList(pmgBtnDeviceOtherService.list(
                                parkSmartWrapper.eq(PmgBtnDeviceOther::getOtherId, id)));
                        if (delBl) {
                            returnBoolean = true;
                        }
                    }
                }
                if (returnBoolean) {
                    // 4、删除人员信息
                    returnBoolean = deleteLogic(ids);
                    if (returnBoolean) {
                        returnBoolean = true;
                    }
                }
            } else {
                // 4、删除人员信息
                returnBoolean = deleteLogic(ids);
                if (returnBoolean) {
                    returnBoolean = true;
                }
            }
        }
        return returnBoolean;
    }

    @Override
    public IPage<PmgBatParkVisitor> pageVisitor(Long parkId, String name, Query query) {
        LambdaQueryWrapper<PmgBatParkVisitor> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(null != parkId, PmgBatParkVisitor::getParkId, parkId);
        queryWrapper.like(null != name, PmgBatParkVisitor::getName, name);
        queryWrapper.orderByDesc(PmgBatParkVisitor::getCreateTime);
        return page(Condition.getPage(query), queryWrapper);
    }

    @Override
    public IPage<PmgBatParkVisitor> pageVisitor(String payUserId, Integer current, Integer size) {
        // 分页数据
        Query query = new Query();
        query.setCurrent(current);
        query.setSize(size);        // 开始查询分页数据
        LambdaQueryWrapper<PmgBatParkVisitor> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(null != payUserId, PmgBatParkVisitor::getPayUserId, payUserId);
        queryWrapper.orderByDesc(PmgBatParkVisitor::getCreateTime);
        return page(Condition.getPage(query), queryWrapper);
    }

    @Override
    public Boolean inviteGuests(PmgBatParkVisitor pmgBatParkVisitor) {
        // 添加操作用户信息
        ContextUser contextUser = AuthUtil.getUser();
        pmgBatParkVisitor.setUserId(contextUser.getUserId());
        pmgBatParkVisitor.setUserName(contextUser.getUserName());
        pmgBatParkVisitor.setUserPhone(contextUser.getDetail().getStr("phone"));
        // 先保存访客信息
        // 发送短信
        // 访客补充人脸
        // 下发梯控
        // 下发短信
        return save(pmgBatParkVisitor);
    }

    @Override
    public R visitorRequest(PmgBatParkVisitor pmgBatParkVisitor) {
        // 判断姓名和手机号是否可以找到用户
        R<User> findResult = this.userClient
                .findUserByNameAndPhone(pmgBatParkVisitor.getUserName(), pmgBatParkVisitor.getUserPhone());
        if (findResult.isSuccess() && findResult.getData() != null) {
            return R.error("未找到拜访人，请核对后再提交。");
        }
        // 查询园区信息
        PmgBatParkInfo parkInfo = parkInfoService.getById(pmgBatParkVisitor.getParkId());
        pmgBatParkVisitor.setTenantId(parkInfo.getTenantId());
        pmgBatParkVisitor.setCreateUser(parkInfo.getCreateUser());
        pmgBatParkVisitor.setCreateDept(parkInfo.getCreateDept());
        pmgBatParkVisitor.setUserId(findResult.getData().getId());
        // 根据公司信息 查询楼栋和楼层信息
        PmgBatParkCompany parkCompany = parkCompanyService.getById(pmgBatParkVisitor.getCompanyId());
        pmgBatParkVisitor.setBuildingId(parkCompany.getBuildingId());
        pmgBatParkVisitor.setFloorId(parkCompany.getFloorId());
        // 设置其他内置属性
        pmgBatParkVisitor.setAuditStatus(2);
        pmgBatParkVisitor.setOriginationType(2);
        if (save(pmgBatParkVisitor)) {
            // 将用户信息保存在用户表中
            // 找到之后，根据手机号发送信息给用户进行审核
            // 保存之后，会有访客记录ID，通过ID和手机号进行短信下发
            return R.success();
        }
        return R.error("操作失败，请稍后重试");
    }

    @Override
    public R visitorReview(Long userId, Long id, Integer auditStatus, String auditReason) {
        // 查询数据
        PmgBatParkVisitor pmgBatParkVisitor = getById(id);
        // 判断审核人是否一致
        if (pmgBatParkVisitor.getUserId().equals(userId)) {
            // 判断审核状态  审核状态(1:已拒绝、2：待审核、3：已取消、0：已同意)
            if (pmgBatParkVisitor.getAuditStatus().equals(2)) {
                pmgBatParkVisitor.setAuditStatus(auditStatus);
                pmgBatParkVisitor.setAuditReason(auditReason);
                if (updateById(pmgBatParkVisitor)) {
                    if (auditStatus.equals(1)) {
                        // 拒绝预约
                        // 发送模版消息
                        return R.data("操作成功");
                    }
                    if (auditStatus.equals(0)) {
                        // 保存isc人员信息
                        this.saveIscPeople(pmgBatParkVisitor);
                        // 同意预约
                        // 发送模版消息
                        // 下发门禁
                        return R.data("操作成功");
                    }
                }
                return R.error("审核错误，请稍后重试。");
            }
            return R.error("审核状态错误。");
        }
        return R.error("数据错误。");
    }

    @Override
    public R visitorCancel(String payUserId, Long id) {
        // 查询数据
        PmgBatParkVisitor pmgBatParkVisitor = getById(id);
        // 判断发起类型(1:主动邀约、2：陌生人预约)
        if (pmgBatParkVisitor.getUserId().equals(Long.parseLong(payUserId)) && pmgBatParkVisitor.getOriginationType()
                .equals(1)) {
            pmgBatParkVisitor.setAuditStatus(3);
            return R.status(updateById(pmgBatParkVisitor));
        } else if (pmgBatParkVisitor.getPayUserId().equals(payUserId) && pmgBatParkVisitor.getOriginationType()
                .equals(2)) {
            // 如果是预约访客要判断审核状态
            if (pmgBatParkVisitor.getAuditStatus().equals(2)) {
                pmgBatParkVisitor.setAuditStatus(3);
                return R.status(updateById(pmgBatParkVisitor));
            } else {
                return R.error("该申请已经被审核，禁止取消。");
            }
        } else {
            return R.error("操作用户错误。");
        }
    }

    @Override
    public IPage<PmgBatParkVisitor> pageVisitorReview(String userId, Integer current, Integer size) {
        // 分页数据
        Query query = new Query();
        query.setCurrent(current);
        query.setSize(size);
        // 开始查询分页数据
        LambdaQueryWrapper<PmgBatParkVisitor> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(null != userId, PmgBatParkVisitor::getUserId, userId);
        queryWrapper.orderByDesc(PmgBatParkVisitor::getCreateTime);
        return page(Condition.getPage(query), queryWrapper);
    }

    @Override
    public R visitorInvitation(PmgBatParkVisitor pmgBatParkVisitor) {
        // 根据公司信息 查询楼栋和楼层信息
        PmgBatParkCompany parkCompany = parkCompanyService.getById(pmgBatParkVisitor.getCompanyId());
        pmgBatParkVisitor.setBuildingId(parkCompany.getBuildingId());
        pmgBatParkVisitor.setFloorId(parkCompany.getFloorId());
        pmgBatParkVisitor.setParkId(parkCompany.getParkId());
        // 查询园区信息
        PmgBatParkInfo parkInfo = parkInfoService.getById(pmgBatParkVisitor.getParkId());
        pmgBatParkVisitor.setTenantId(parkInfo.getTenantId());
        pmgBatParkVisitor.setCreateUser(parkInfo.getCreateUser());
        pmgBatParkVisitor.setCreateDept(parkInfo.getCreateDept());
        // 查询用户信息
        R<User> byIdResult = userClient.userInfoById(pmgBatParkVisitor.getUserId());
        if (byIdResult.isSuccess() && byIdResult.getData() != null) {
            pmgBatParkVisitor.setUserId(byIdResult.getData().getId());
        }
        // 设置其他内置属性
        pmgBatParkVisitor.setAuditStatus(0);
        pmgBatParkVisitor.setOriginationType(1);
        if (save(pmgBatParkVisitor)) {
            // 将用户信息保存在用户表中
            // 找到之后，根据手机号发送信息给用户进行审核
            // 保存之后，会有访客记录ID，通过ID和手机号进行短信下发
            return R.success();
        }
        return R.error("操作失败，请稍后重试");
    }

    /**
     * 保存isc人员信息
     * @param pmgBatParkVisitor
     */
    private void saveIscPeople(PmgBatParkVisitor pmgBatParkVisitor) {
        if (StrUtil.isEmpty(pmgBatParkVisitor.getFaceImg())) {
            return;
        }
        // isc人员新增
        PmgBatParkPeople pmgBatParkPeople = new PmgBatParkPeople();//园内人员信息
        // 设置默认值
        pmgBatParkPeople.setParkId(pmgBatParkVisitor.getParkId());//园区id
        pmgBatParkPeople.setName(pmgBatParkVisitor.getName());//访客姓名
        pmgBatParkPeople.setOrgIndexCode("c44f0df5-e02c-4022-a5e5-4d41c4f15c18");//组织
        pmgBatParkPeople.setImgsrc(pmgBatParkVisitor.getFaceImg());//图片地址
        //pmgBatParkPeople.setSex("UNKNOWN");//
        //pmgBatParkPeople.setIdCard("");//
        pmgBatParkPeople.setPhone(pmgBatParkVisitor.getPhone());//手机号
        // 根据类型查询人脸分组信息
        LambdaQueryWrapper<PmgBatPeopleType> query = Wrappers.lambdaQuery();
        query.eq(PmgBatPeopleType::getCode, "20db9e149b7b4e9ea15fba92a685ff3c");
        PmgBatPeopleType peopleType = peopleTypeService.getOne(query);
        pmgBatParkPeople.setPeopleType(peopleType.getId());//人员类型-访客人员

        pmgBatParkPeople.setIdCard(RandomUtil.randomNumbers(18));//设置身份证号
        //pmgBatParkPeople.setBuildingId(pmgBatParkVisitor.getBuildingId());//楼栋id
        //pmgBatParkPeople.setFloorId(pmgBatParkVisitor.getFloorId());//层数id
        //pmgBatParkPeople.setRoomId(pmgBatParkVisitor.getCompanyId());//房间id
        //pmgBatParkPeople.setCompany(pmgBatParkVisitor.getCompanyId());//公司id
        pmgBatParkPeopleService.savePeople(pmgBatParkPeople);//保存isc数据
    }
}