tangxiaobao
2021-08-19 4cb51a8d6a46993cb30e22dcbaf85424a0ba9d43
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -81,6 +81,10 @@
    @Resource
    private ComMngPopulationHouseUserDAO comMngPopulationHouseUserDAO;
    @Resource
    private ComMngPopulationCommunityTagsDAO comMngPopulationCommunityTagsDAO;
    @Resource
    private ComMngPopulationCommunityTagsService comMngPopulationCommunityTagsService;
    @Resource
    private ComMngPopulationDAO comMngPopulationDAO;
    @Resource
    private ComMngPopulationHouseUserService comMngPopulationHouseUserService;
@@ -213,6 +217,12 @@
        //设置年龄
        if (StringUtils.isNotEmpty(comMngPopulationVO.getBirthday())) {
            comMngPopulationVO.setAge(AgeUtils.getAgeFromBirthTimes(comMngPopulationVO.getBirthday()));
        }
        //设置特殊群体标签
        ComMngPopulationCommunityTagsDO comMngPopulationCommunityTagsDO = comMngPopulationCommunityTagsDAO.selectOne(new QueryWrapper<ComMngPopulationCommunityTagsDO>().
                lambda().eq(ComMngPopulationCommunityTagsDO::getPopulationId, populationId));
        if (null != comMngPopulationCommunityTagsDO) {
            comMngPopulationVO.setLabel(comMngPopulationCommunityTagsDO.getLabel());
        }
        //查询当前用户电子档信息
@@ -496,7 +506,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId){
    public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId, Long userId){
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -505,6 +515,10 @@
        List<ComMngPopulationDO> updateList = new ArrayList<>();
        //需要新增的人口与房屋关系集合
        List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
        //需要新增的人口与社区关系集合
        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
        //需要新增的人口与社区关系集合
        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
        log.info("开始处理导入数据");
        List<ComMngPopulationMistakeExcelVO> mistakes = new ArrayList<>();
@@ -516,7 +530,7 @@
                log.error("未查询到社区信息");
                return R.fail("未查询到社区信息");
            }
            log.info("开始查询社区信息数据完成");
            log.info("查询社区信息数据完成");
            //查询当前社区标签列表
            List<String> labelList = new ArrayList<>();
@@ -559,6 +573,12 @@
                houseUserMap.put(key,houseUser);
            });
            List<ComMngPopulationCommunityTagsDO> populationCommunityLists = comMngPopulationCommunityTagsDAO.selectList(null);
            HashMap<String,Object> populationCommunityMap = new HashMap<>();
            populationCommunityLists.forEach(populationCommunity -> {
                String key = populationCommunity.getPopulationId() + populationCommunity.getCommunityId() + "";
                populationCommunityMap.put(key,populationCommunity);
            });
            for (ComMngPopulationServeExcelVO vo : list) {
                if (vo.getDoorNo().contains("号")) {
@@ -607,7 +627,7 @@
                    address.append(vo.getHouseNo()).append("号");
                }
                vo.setAddress(address.toString());
                log.info("开始查询小区街路巷是否存在完成");
                log.info("查询小区街路巷是否存在完成");
                log.info("开始查询房屋是否存在");
                //先判断房屋是否存在
@@ -633,7 +653,7 @@
                    populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey);
                }
                vo.setHouseId(populationHouseDO.getId());
                log.info("开始查询房屋是否存在完成");
                log.info("查询房屋是否存在完成");
                if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) {
                    //空户处理完房屋信息,直接返回
@@ -647,14 +667,14 @@
                if(!isOnly(populationKey,populationMap)){
                    //存在实有人口信息,则更新
                    populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
                    ComMngPopulationDO updatePopulationDO = updatePopulationDO(vo,populationDO,labelList);
                    ComMngPopulationDO updatePopulationDO = updatePopulationDO(vo,populationDO,userId);
                    updateList.add(updatePopulationDO);
                }else{
                    //不存在实有人口,则新增
                    populationDO = savePopulationDO(vo, populationActVO, comMngVillageDO,labelList);
                    populationDO = savePopulationDO(vo, populationActVO, comMngVillageDO, userId);
                    saveList.add(populationDO);
                }
                log.info("开始查询实有人口是否已存在完成");
                log.info("查询实有人口是否已存在完成");
                log.info("开始查询实有人口房屋居住信息");
                //处理实有人口房屋居住信息
@@ -672,7 +692,53 @@
                        houseUserList.add(populationHouseUserDO);
                    }
                }
                log.info("开始查询实有人口房屋居住信息完成");
                log.info("查询实有人口房屋居住信息完成");
                log.info("开始查询实有人口存在社区信息");
                //处理实有人口与社区关系以及对应特殊群体标签
                String populationCommunityKey = populationDO.getId() + populationActVO.getCommunityId() + "";
                if (populationDO != null) {
                    ComMngPopulationCommunityTagsDO cpopulationCommunityTagsDO = null;
                    if(isOnly(populationCommunityKey,populationCommunityMap)){
                        //实有人口不存在于当前社区
                        cpopulationCommunityTagsDO = new ComMngPopulationCommunityTagsDO();
                        cpopulationCommunityTagsDO.setId(Snowflake.getId());
                        cpopulationCommunityTagsDO.setPopulationId(populationDO.getId());
                        cpopulationCommunityTagsDO.setCommunityId(communityId);
                        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
                        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
                        Iterator<String> iterator = userTag.iterator();
                        while (iterator.hasNext()) {
                            String s = iterator.next();
                            if (!labelList.contains(s))
                                iterator.remove();
                        }
                        populationDO.setLabel(Joiner.on(",").join(userTag));
                        populationDO.setCreateBy(userId);
                        savePopulationCommunityList.add(cpopulationCommunityTagsDO);
                    }
                }else {
                    //实有人口存在于当前社区,则更新
                    ComMngPopulationCommunityTagsDO comMngPopulationCommunityTagsDO = (ComMngPopulationCommunityTagsDO)populationCommunityMap.get(populationCommunityKey);
                    List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
                    //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
                    Iterator<String> iterator = userTag.iterator();
                    while (iterator.hasNext()) {
                        String s = iterator.next();
                        if (!labelList.contains(s))
                            iterator.remove();
                    }
                    comMngPopulationCommunityTagsDO.setLabel(Joiner.on(",").join(userTag));
                    comMngPopulationCommunityTagsDO.setUpdateBy(userId);
                    updatePopulationCommunityList.add(comMngPopulationCommunityTagsDO);
                    ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO();
                    BeanUtils.copyProperties(vo,mistake);
                    setMistake(mistake, vo);
                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
                    mistakes.add(mistake);
                }
                log.info("查询实有人口存在社区信息完成");
            }
        }catch (Exception e){
            log.info("出现错误,错误原因:" + e.getMessage());
@@ -683,23 +749,33 @@
        if(!houseList.isEmpty()){
            log.info("执行数据库导入房屋");
            comMngPopulationHouseDAO.insertAll(houseList);
            log.info("执行数据库导入房屋完成");
            log.info("数据库导入房屋完成");
        }
        if(!saveList.isEmpty()){
            log.info("执行数据库导入人口");
            this.baseMapper.insertAll(saveList);
            log.info("执行数据库导入人口完成");
            log.info("数据库导入人口完成");
        }
        if(!updateList.isEmpty()){
            log.info("执行数据库更新人口");
            this.baseMapper.updateAll(updateList);
//            this.updateBatchById(updateList);
            log.info("执行数据库更新人口完成");
            log.info("数据库更新人口完成");
        }
        if(!houseUserList.isEmpty()){
            log.info("执行数据库导入人口房屋关系");
            comMngPopulationHouseUserService.saveBatch(houseUserList);
            log.info("执行数据库导入人口房屋关系完成");
            log.info("数据库导入人口房屋关系完成");
        }
        if(!savePopulationCommunityList.isEmpty()){
            log.info("执行数据库导入人口社区关系");
            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
            log.info("数据库导入人口社区关系完成");
        }
        if(!updatePopulationCommunityList.isEmpty()){
            log.info("执行数据库更新人口社区关系");
            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
            log.info("数据库更新人口社区关系完成");
        }
        log.info("执行数据库导入完成");
@@ -712,7 +788,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveDrugPopulation(List<ComMngPopulationDrugExcelVO> list, Long communityId) {
    public R listSaveDrugPopulation(List<ComMngPopulationDrugExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -928,7 +1004,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveCorrectPopulation(List<ComMngPopulationCorrectExcelVO> list, Long communityId) {
    public R listSaveCorrectPopulation(List<ComMngPopulationCorrectExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -1144,7 +1220,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveMajorPopulation(List<ComMngPopulationMajorExcelVO> list, Long communityId) {
    public R listSaveMajorPopulation(List<ComMngPopulationMajorExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -1360,7 +1436,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveCultPopulation(List<ComMngPopulationCultExcelVO> list, Long communityId) {
    public R listSaveCultPopulation(List<ComMngPopulationCultExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -1576,7 +1652,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveRehabilitationPopulation(List<ComMngPopulationRehabilitationExcelVO> list, Long communityId) {
    public R listSaveRehabilitationPopulation(List<ComMngPopulationRehabilitationExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -1792,7 +1868,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveKeyPopulation(List<ComMngPopulationKeyExcelVO> list, Long communityId) {
    public R listSaveKeyPopulation(List<ComMngPopulationKeyExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -2008,7 +2084,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveSentencePopulation(List<ComMngPopulationSentenceExcelVO> list, Long communityId) {
    public R listSaveSentencePopulation(List<ComMngPopulationSentenceExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -2224,7 +2300,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveVeteransPopulation(List<ComMngPopulationVeteransExcelVO> list, Long communityId) {
    public R listSaveVeteransPopulation(List<ComMngPopulationVeteransExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -2440,7 +2516,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveDisabilityPopulation(List<ComMngPopulationDisabilityExcelVO> list, Long communityId) {
    public R listSaveDisabilityPopulation(List<ComMngPopulationDisabilityExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -2656,7 +2732,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R listSaveLowSecurityPopulation(List<ComMngPopulationLowSecurityExcelVO> list, Long communityId) {
    public R listSaveLowSecurityPopulation(List<ComMngPopulationLowSecurityExcelVO> list, Long communityId, Long userId) {
        //需要新增的房屋集合
        List<ComMngPopulationHouseDO> houseList = new ArrayList<>();
        //需要新增的人口集合
@@ -2875,24 +2951,25 @@
    }
    private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
    private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO, Long userId){
        BeanUtils.copyProperties(vo, populationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            if (!labelList.contains(s))
                iterator.remove();
        }
//        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
//        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
//        Iterator<String> iterator = userTag.iterator();
//        while (iterator.hasNext()) {
//            String s = iterator.next();
//            if (!labelList.contains(s))
//                iterator.remove();
//        }
        String cardNoAES = populationDO.getCardNo();
        try {
            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
        }catch (Exception e){
            log.error("身份证加密失败");
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
//        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        populationDO.setUpdateBy(userId);
        return populationDO;
    }
@@ -2900,7 +2977,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComDrugPopulationDO comDrugPopulationDO = comDrugPopulationDAO.selectOne(new QueryWrapper<ComDrugPopulationDO>().lambda()
                .eq(ComDrugPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comDrugPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -2917,8 +2993,20 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comDrugPopulationDO.setCardNo(cardNoAES);
        comDrugPopulationDAO.updateById(comDrugPopulationDO);
        if (comDrugPopulationDO != null) {
            BeanUtils.copyProperties(vo, comDrugPopulationDO);
            comDrugPopulationDO.setCardNo(cardNoAES);
            comDrugPopulationDAO.updateById(comDrugPopulationDO);
        }else {
            comDrugPopulationDO = new ComDrugPopulationDO();
            BeanUtils.copyProperties(vo, comDrugPopulationDO);
            comDrugPopulationDO.setId(Snowflake.getId());
            comDrugPopulationDO.setPopulationId(populationDO.getId());
            comDrugPopulationDO.setCommunityId(populationDO.getActId());
            comDrugPopulationDO.setStreetId(populationDO.getStreetId());
            comDrugPopulationDAO.insert(comDrugPopulationDO);
        }
        return populationDO;
    }
@@ -2926,7 +3014,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComCorrectPopulationDO comCorrectPopulationDO = comCorrectPopulationDAO.selectOne(new QueryWrapper<ComCorrectPopulationDO>().lambda()
                .eq(ComCorrectPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comCorrectPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -2943,8 +3030,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comCorrectPopulationDO.setCardNo(cardNoAES);
        comCorrectPopulationDAO.updateById(comCorrectPopulationDO);
        if (comCorrectPopulationDO != null) {
            BeanUtils.copyProperties(vo, comCorrectPopulationDO);
            comCorrectPopulationDO.setCardNo(cardNoAES);
            comCorrectPopulationDAO.updateById(comCorrectPopulationDO);
        }else {
            comCorrectPopulationDO = new ComCorrectPopulationDO();
            BeanUtils.copyProperties(vo, comCorrectPopulationDO);
            comCorrectPopulationDO.setId(Snowflake.getId());
            comCorrectPopulationDO.setPopulationId(populationDO.getId());
            comCorrectPopulationDO.setCommunityId(populationDO.getActId());
            comCorrectPopulationDO.setStreetId(populationDO.getStreetId());
            comCorrectPopulationDAO.insert(comCorrectPopulationDO);
        }
        return populationDO;
    }
@@ -2952,7 +3050,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComMajorPopulationDO comMajorPopulationDO = comMajorPopulationDAO.selectOne(new QueryWrapper<ComMajorPopulationDO>().lambda()
                .eq(ComMajorPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comMajorPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -2969,8 +3066,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comMajorPopulationDO.setCardNo(cardNoAES);
        comMajorPopulationDAO.updateById(comMajorPopulationDO);
        if (comMajorPopulationDO != null) {
            BeanUtils.copyProperties(vo, comMajorPopulationDO);
            comMajorPopulationDO.setCardNo(cardNoAES);
            comMajorPopulationDAO.updateById(comMajorPopulationDO);
        }else {
            comMajorPopulationDO = new ComMajorPopulationDO();
            BeanUtils.copyProperties(vo, comMajorPopulationDO);
            comMajorPopulationDO.setId(Snowflake.getId());
            comMajorPopulationDO.setPopulationId(populationDO.getId());
            comMajorPopulationDO.setCommunityId(populationDO.getActId());
            comMajorPopulationDO.setStreetId(populationDO.getStreetId());
            comMajorPopulationDAO.insert(comMajorPopulationDO);
        }
        return populationDO;
    }
@@ -2978,7 +3086,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComCultPopulationDO comCultPopulationDO = comCultPopulationDAO.selectOne(new QueryWrapper<ComCultPopulationDO>().lambda().
                eq(ComCultPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comCultPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -2995,8 +3102,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comCultPopulationDO.setCardNo(cardNoAES);
        comCultPopulationDAO.updateById(comCultPopulationDO);
        if (comCultPopulationDO != null) {
            BeanUtils.copyProperties(vo, comCultPopulationDO);
            comCultPopulationDO.setCardNo(cardNoAES);
            comCultPopulationDAO.updateById(comCultPopulationDO);
        }else {
            comCultPopulationDO = new ComCultPopulationDO();
            BeanUtils.copyProperties(vo, comCultPopulationDO);
            comCultPopulationDO.setId(Snowflake.getId());
            comCultPopulationDO.setPopulationId(populationDO.getId());
            comCultPopulationDO.setCommunityId(populationDO.getActId());
            comCultPopulationDO.setStreetId(populationDO.getStreetId());
            comCultPopulationDAO.insert(comCultPopulationDO);
        }
        return populationDO;
    }
@@ -3004,7 +3122,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComRehabilitationPopulationDO comRehabilitationPopulationDO = comRehabilitationPopulationDAO.selectOne(new QueryWrapper<ComRehabilitationPopulationDO>().lambda().
                eq(ComRehabilitationPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comRehabilitationPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3021,8 +3138,20 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comRehabilitationPopulationDO.setCardNo(cardNoAES);
        comRehabilitationPopulationDAO.updateById(comRehabilitationPopulationDO);
        if (comRehabilitationPopulationDO != null) {
            BeanUtils.copyProperties(vo, comRehabilitationPopulationDO);
            comRehabilitationPopulationDO.setCardNo(cardNoAES);
            comRehabilitationPopulationDAO.updateById(comRehabilitationPopulationDO);
        }else {
            comRehabilitationPopulationDO = new ComRehabilitationPopulationDO();
            BeanUtils.copyProperties(vo, comRehabilitationPopulationDO);
            comRehabilitationPopulationDO.setId(Snowflake.getId());
            comRehabilitationPopulationDO.setPopulationId(populationDO.getId());
            comRehabilitationPopulationDO.setCommunityId(populationDO.getActId());
            comRehabilitationPopulationDO.setStreetId(populationDO.getStreetId());
            comRehabilitationPopulationDAO.insert(comRehabilitationPopulationDO);
        }
        return populationDO;
    }
@@ -3030,7 +3159,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComKeyPopulationDO comKeyPopulationDO = comKeyPopulationDAO.selectOne(new QueryWrapper<ComKeyPopulationDO>().lambda().
                eq(ComKeyPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comKeyPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3047,8 +3175,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comKeyPopulationDO.setCardNo(cardNoAES);
        comKeyPopulationDAO.updateById(comKeyPopulationDO);
        if (comKeyPopulationDO != null) {
            BeanUtils.copyProperties(vo, comKeyPopulationDO);
            comKeyPopulationDO.setCardNo(cardNoAES);
            comKeyPopulationDAO.updateById(comKeyPopulationDO);
        }else {
            comKeyPopulationDO = new ComKeyPopulationDO();
            BeanUtils.copyProperties(vo, comKeyPopulationDO);
            comKeyPopulationDO.setId(Snowflake.getId());
            comKeyPopulationDO.setPopulationId(populationDO.getId());
            comKeyPopulationDO.setCommunityId(populationDO.getActId());
            comKeyPopulationDO.setStreetId(populationDO.getStreetId());
            comKeyPopulationDAO.insert(comKeyPopulationDO);
        }
        return populationDO;
    }
@@ -3056,7 +3195,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComSentencePopulationDO comSentencePopulationDO = comSentencePopulationDAO.selectOne(new QueryWrapper<ComSentencePopulationDO>().lambda().
                eq(ComSentencePopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comSentencePopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3073,8 +3211,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comSentencePopulationDO.setCardNo(cardNoAES);
        comSentencePopulationDAO.updateById(comSentencePopulationDO);
        if (comSentencePopulationDO != null) {
            BeanUtils.copyProperties(vo, comSentencePopulationDO);
            comSentencePopulationDO.setCardNo(cardNoAES);
            comSentencePopulationDAO.updateById(comSentencePopulationDO);
        }else {
            comSentencePopulationDO = new ComSentencePopulationDO();
            BeanUtils.copyProperties(vo, comSentencePopulationDO);
            comSentencePopulationDO.setId(Snowflake.getId());
            comSentencePopulationDO.setPopulationId(populationDO.getId());
            comSentencePopulationDO.setCommunityId(populationDO.getActId());
            comSentencePopulationDO.setStreetId(populationDO.getStreetId());
            comSentencePopulationDAO.insert(comSentencePopulationDO);
        }
        return populationDO;
    }
@@ -3082,7 +3231,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComVeteransPopulationDO comVeteransPopulationDO = comVeteransPopulationDAO.selectOne(new QueryWrapper<ComVeteransPopulationDO>().lambda().
                eq(ComVeteransPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comVeteransPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3099,15 +3247,25 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comVeteransPopulationDO.setCardNo(cardNoAES);
        comVeteransPopulationDAO.updateById(comVeteransPopulationDO);
        if (comVeteransPopulationDO != null) {
            BeanUtils.copyProperties(vo, comVeteransPopulationDO);
            comVeteransPopulationDO.setCardNo(cardNoAES);
            comVeteransPopulationDAO.updateById(comVeteransPopulationDO);
        }else {
            comVeteransPopulationDO = new ComVeteransPopulationDO();
            BeanUtils.copyProperties(vo, comVeteransPopulationDO);
            comVeteransPopulationDO.setId(Snowflake.getId());
            comVeteransPopulationDO.setPopulationId(populationDO.getId());
            comVeteransPopulationDO.setCommunityId(populationDO.getActId());
            comVeteransPopulationDO.setStreetId(populationDO.getStreetId());
            comVeteransPopulationDAO.insert(comVeteransPopulationDO);
        }
        return populationDO;
    }
    private ComMngPopulationDO updateDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
        BeanUtils.copyProperties(vo, populationDO);
        ComDisabilityPopulationDO comDisabilityPopulationDO = comDisabilityPopulationDAO.selectOne(new QueryWrapper<ComDisabilityPopulationDO>().lambda().
                eq(ComDisabilityPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comDisabilityPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3124,8 +3282,19 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comDisabilityPopulationDO.setCardNo(cardNoAES);
        comDisabilityPopulationDAO.updateById(comDisabilityPopulationDO);
        if (comDisabilityPopulationDO != null) {
            BeanUtils.copyProperties(vo, comDisabilityPopulationDO);
            comDisabilityPopulationDO.setCardNo(cardNoAES);
            comDisabilityPopulationDAO.updateById(comDisabilityPopulationDO);
        }else {
            comDisabilityPopulationDO = new ComDisabilityPopulationDO();
            BeanUtils.copyProperties(vo, comDisabilityPopulationDO);
            comDisabilityPopulationDO.setId(Snowflake.getId());
            comDisabilityPopulationDO.setPopulationId(populationDO.getId());
            comDisabilityPopulationDO.setCommunityId(populationDO.getActId());
            comDisabilityPopulationDO.setStreetId(populationDO.getStreetId());
            comDisabilityPopulationDAO.insert(comDisabilityPopulationDO);
        }
        return populationDO;
    }
@@ -3133,7 +3302,6 @@
        BeanUtils.copyProperties(vo, populationDO);
        ComLowSecurityPopulationDO comLowSecurityPopulationDO = comLowSecurityPopulationDAO.selectOne(new QueryWrapper<ComLowSecurityPopulationDO>().lambda().
                eq(ComLowSecurityPopulationDO::getPopulationId, populationDO.getId()));
        BeanUtils.copyProperties(vo, comLowSecurityPopulationDO);
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
@@ -3150,28 +3318,39 @@
        }
        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setCardNo(cardNoAES);
        comLowSecurityPopulationDO.setCardNo(cardNoAES);
        comLowSecurityPopulationDAO.updateById(comLowSecurityPopulationDO);
        if (comLowSecurityPopulationDO != null) {
            BeanUtils.copyProperties(vo, comLowSecurityPopulationDO);
            comLowSecurityPopulationDO.setCardNo(cardNoAES);
            comLowSecurityPopulationDAO.updateById(comLowSecurityPopulationDO);
        }else {
            comLowSecurityPopulationDO = new ComLowSecurityPopulationDO();
            BeanUtils.copyProperties(vo, comLowSecurityPopulationDO);
            comLowSecurityPopulationDO.setId(Snowflake.getId());
            comLowSecurityPopulationDO.setPopulationId(populationDO.getId());
            comLowSecurityPopulationDO.setCommunityId(populationDO.getActId());
            comLowSecurityPopulationDO.setStreetId(populationDO.getStreetId());
            comLowSecurityPopulationDAO.insert(comLowSecurityPopulationDO);
        }
        return populationDO;
    }
    private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
    private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO, Long userId) {
        ComMngPopulationDO populationDO = new ComMngPopulationDO();
        BeanUtils.copyProperties(vo, populationDO);
        populationDO.setId(Snowflake.getId());
        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
        Iterator<String> iterator = userTag.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            if (!labelList.contains(s))
                iterator.remove();
        }
//        List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
//
//        //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除
//        Iterator<String> iterator = userTag.iterator();
//        while (iterator.hasNext()) {
//            String s = iterator.next();
//            if (!labelList.contains(s))
//                iterator.remove();
//        }
        populationDO.setVillageId(comMngVillageDO.getVillageId());
        populationDO.setActId(comActDO.getCommunityId());
        populationDO.setStreetId(comActDO.getStreetId());
        populationDO.setLabel(Joiner.on(",").join(userTag));
//        populationDO.setLabel(Joiner.on(",").join(userTag));
        populationDO.setVillageName(comMngVillageDO.getGroupAt());
        populationDO.setCardNoStr(vo.getCardNo());
        populationDO.setUpdateAt(new Date());
@@ -3183,6 +3362,7 @@
            log.error("身份证加密失败");
        }
        populationDO.setCardNo(cardNoAES);
        populationDO.setCreateBy(userId);
        //新增的时候默认绑定房屋id
//        if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) ||
//                (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) {
@@ -4463,7 +4643,8 @@
            }
        } else {
            //新增
            Integer count = comMngUserTagDAO.selectCount(new QueryWrapper<ComMngUserTagDO>().lambda().eq(ComMngUserTagDO::getTagName, comMngTagVO.getTagName()));
            Integer count = comMngUserTagDAO.selectCount(new QueryWrapper<ComMngUserTagDO>().lambda().eq(ComMngUserTagDO::getTagName, comMngTagVO.getTagName())
            .eq(ComMngUserTagDO::getCommunityId, comMngTagVO.getCommunityId()));
            if (count > 0) {
                return R.fail("该标签已存在,标签名称重复");
            }