From 91275344f85d2777be0f276e9d9da3f6f3fa6728 Mon Sep 17 00:00:00 2001
From: tangxiaobao <303826152@qq.com>
Date: 星期五, 20 八月 2021 18:48:44 +0800
Subject: [PATCH] 实有人口和社区关系以及对应标签修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 2043 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 1,592 insertions(+), 451 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
index 1cdaf08..ee7dd0f 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
+++ b/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;
@@ -214,6 +218,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());
+        }
 
         //查询当前用户电子档信息
         if (!StringUtils.isEmpty(comMngPopulationDO.getCardNo())) {
@@ -244,84 +254,120 @@
         }
 
         //吸毒信息
-        ComDrugPopulationVO comDrugPopulationVO = new ComDrugPopulationVO();
-        ComDrugPopulationDO comDrugPopulationDO = comDrugPopulationDAO.selectOne(new QueryWrapper<ComDrugPopulationDO>().
+        List<ComDrugPopulationVO> comDrugPopulationVOs = new ArrayList<>();
+        List<ComDrugPopulationDO> comDrugPopulationDOs = comDrugPopulationDAO.selectList(new QueryWrapper<ComDrugPopulationDO>().
                 lambda().eq(ComDrugPopulationDO::getPopulationId, populationId));
-        if (null != comDrugPopulationDO) {
-            BeanUtils.copyProperties(comDrugPopulationDO, comDrugPopulationVO);
-            comMngPopulationVO.setComDrugPopulationVO(comDrugPopulationVO);
+        if (!comDrugPopulationDOs.isEmpty()) {
+            comDrugPopulationDOs.forEach(comDrugPopulationDO -> {
+                ComDrugPopulationVO comDrugPopulationVO = new ComDrugPopulationVO();
+                BeanUtils.copyProperties(comDrugPopulationDO, comDrugPopulationVO);
+                comDrugPopulationVOs.add(comDrugPopulationVO);
+                comMngPopulationVO.setComDrugPopulationVOs(comDrugPopulationVOs);
+            });
         }
 
         //社区矫正信息
-        ComCorrectPopulationVO comCorrectPopulationVO = new ComCorrectPopulationVO();
-        ComCorrectPopulationDO comCorrectPopulationDO = comCorrectPopulationDAO.selectOne(new QueryWrapper<ComCorrectPopulationDO>().
+        List<ComCorrectPopulationVO> comCorrectPopulationVOS = new ArrayList<>();
+        List<ComCorrectPopulationDO> comCorrectPopulationDOS = comCorrectPopulationDAO.selectList(new QueryWrapper<ComCorrectPopulationDO>().
                 lambda().eq(ComCorrectPopulationDO::getPopulationId, populationId));
-        if (null != comCorrectPopulationDO) {
-            BeanUtils.copyProperties(comCorrectPopulationDO, comCorrectPopulationVO);
-            comMngPopulationVO.setComCorrectPopulationVO(comCorrectPopulationVO);
+        if (!comCorrectPopulationDOS.isEmpty()) {
+            comCorrectPopulationDOS.forEach(comCorrectPopulationDO -> {
+                ComCorrectPopulationVO comCorrectPopulationVO = new ComCorrectPopulationVO();
+                BeanUtils.copyProperties(comCorrectPopulationDO, comCorrectPopulationVO);
+                comCorrectPopulationVOS.add(comCorrectPopulationVO);
+                comMngPopulationVO.setComCorrectPopulationVOs(comCorrectPopulationVOS);
+            });
         }
 
         //精神障碍信息
-        ComMajorPopulationVO comMajorPopulationVO = new ComMajorPopulationVO();
-        ComMajorPopulationDO comMajorPopulationDO = comMajorPopulationDAO.selectOne(new QueryWrapper<ComMajorPopulationDO>().
+        List<ComMajorPopulationVO> comMajorPopulationVOS = new ArrayList<>();
+        List<ComMajorPopulationDO> comMajorPopulationDOs = comMajorPopulationDAO.selectList(new QueryWrapper<ComMajorPopulationDO>().
                 lambda().eq(ComMajorPopulationDO::getPopulationId, populationId));
-        if (null != comMajorPopulationDO) {
-            BeanUtils.copyProperties(comMajorPopulationDO, comMajorPopulationVO);
-            comMngPopulationVO.setComMajorPopulationVO(comMajorPopulationVO);
+        if (!comMajorPopulationDOs.isEmpty()) {
+            comMajorPopulationDOs.forEach(comMajorPopulationDO -> {
+                ComMajorPopulationVO comMajorPopulationVO = new ComMajorPopulationVO();
+                BeanUtils.copyProperties(comMajorPopulationDO, comMajorPopulationVO);
+                comMajorPopulationVOS.add(comMajorPopulationVO);
+                comMngPopulationVO.setComMajorPopulationVOs(comMajorPopulationVOS);
+            });
         }
 
         //邪教信息
-        ComCultPopulationVO comCultPopulationVO = new ComCultPopulationVO();
-        ComCultPopulationDO comCultPopulationDO = comCultPopulationDAO.selectOne(new QueryWrapper<ComCultPopulationDO>().
+        List<ComCultPopulationVO> comCultPopulationVOS = new ArrayList<>();
+        List<ComCultPopulationDO> comCultPopulationDOS = comCultPopulationDAO.selectList(new QueryWrapper<ComCultPopulationDO>().
                 lambda().eq(ComCultPopulationDO::getPopulationId, populationId));
-        if (null != comCultPopulationDO) {
-            BeanUtils.copyProperties(comCultPopulationDO, comCultPopulationVO);
-            comMngPopulationVO.setComCultPopulationVO(comCultPopulationVO);
+        if (!comCultPopulationDOS.isEmpty()) {
+            comCultPopulationDOS.forEach(comCultPopulationDO -> {
+                ComCultPopulationVO comCultPopulationVO = new ComCultPopulationVO();
+                BeanUtils.copyProperties(comCultPopulationDO, comCultPopulationVO);
+                comCultPopulationVOS.add(comCultPopulationVO);
+                comMngPopulationVO.setComCultPopulationVOs(comCultPopulationVOS);
+            });
         }
 
         //刑释信息
-        ComRehabilitationPopulationVO comRehabilitationPopulationVO = new ComRehabilitationPopulationVO();
-        ComRehabilitationPopulationDO comRehabilitationPopulationDO = comRehabilitationPopulationDAO.selectOne(new QueryWrapper<ComRehabilitationPopulationDO>().
+        List<ComRehabilitationPopulationVO> comRehabilitationPopulationVOS = new ArrayList<>();
+        List<ComRehabilitationPopulationDO> comRehabilitationPopulationDOS = comRehabilitationPopulationDAO.selectList(new QueryWrapper<ComRehabilitationPopulationDO>().
                 lambda().eq(ComRehabilitationPopulationDO::getPopulationId, populationId));
-        if (null != comRehabilitationPopulationDO) {
-            BeanUtils.copyProperties(comRehabilitationPopulationDO, comRehabilitationPopulationVO);
-            comMngPopulationVO.setComRehabilitationPopulationVO(comRehabilitationPopulationVO);
+        if (!comRehabilitationPopulationDOS.isEmpty()) {
+            comRehabilitationPopulationDOS.forEach(comRehabilitationPopulationDO -> {
+                ComRehabilitationPopulationVO comRehabilitationPopulationVO = new ComRehabilitationPopulationVO();
+                BeanUtils.copyProperties(comRehabilitationPopulationDO, comRehabilitationPopulationVO);
+                comRehabilitationPopulationVOS.add(comRehabilitationPopulationVO);
+                comMngPopulationVO.setComRehabilitationPopulationVOs(comRehabilitationPopulationVOS);
+            });
         }
 
         //上访信息
-        ComKeyPopulationVO comKeyPopulationVO = new ComKeyPopulationVO();
-        ComKeyPopulationDO comKeyPopulationDO = comKeyPopulationDAO.selectOne(new QueryWrapper<ComKeyPopulationDO>().
+        List<ComKeyPopulationVO> comKeyPopulationVOS = new ArrayList<>();
+        List<ComKeyPopulationDO> comKeyPopulationDOS = comKeyPopulationDAO.selectList(new QueryWrapper<ComKeyPopulationDO>().
                 lambda().eq(ComKeyPopulationDO::getPopulationId, populationId));
-        if (null != comRehabilitationPopulationDO) {
-            BeanUtils.copyProperties(comKeyPopulationDO, comKeyPopulationVO);
-            comMngPopulationVO.setComKeyPopulationVO(comKeyPopulationVO);
+        if (!comKeyPopulationDOS.isEmpty()) {
+            comKeyPopulationDOS.forEach(comKeyPopulationDO -> {
+                ComKeyPopulationVO comKeyPopulationVO = new ComKeyPopulationVO();
+                BeanUtils.copyProperties(comKeyPopulationDO, comKeyPopulationVO);
+                comKeyPopulationVOS.add(comKeyPopulationVO);
+                comMngPopulationVO.setComKeyPopulationVOs(comKeyPopulationVOS);
+            });
         }
 
         //退役军人信息
-        ComVeteransPopulationVO comVeteransPopulationVO = new ComVeteransPopulationVO();
-        ComVeteransPopulationDO comVeteransPopulationDO = comVeteransPopulationDAO.selectOne(new QueryWrapper<ComVeteransPopulationDO>().
+        List<ComVeteransPopulationVO> comVeteransPopulationVOS = new ArrayList<>();
+        List<ComVeteransPopulationDO> comVeteransPopulationDOS = comVeteransPopulationDAO.selectList(new QueryWrapper<ComVeteransPopulationDO>().
                 lambda().eq(ComVeteransPopulationDO::getPopulationId, populationId));
-        if (null != comRehabilitationPopulationDO) {
-            BeanUtils.copyProperties(comVeteransPopulationDO, comVeteransPopulationVO);
-            comMngPopulationVO.setComVeteransPopulationVO(comVeteransPopulationVO);
+        if (!comVeteransPopulationDOS.isEmpty()) {
+            comVeteransPopulationDOS.forEach(comVeteransPopulationDO -> {
+                ComVeteransPopulationVO comVeteransPopulationVO = new ComVeteransPopulationVO();
+                BeanUtils.copyProperties(comVeteransPopulationDO, comVeteransPopulationVO);
+                comVeteransPopulationVOS.add(comVeteransPopulationVO);
+                comMngPopulationVO.setComVeteransPopulationVOs(comVeteransPopulationVOS);
+            });
         }
 
         //残疾人信息
-        ComDisabilityPopulationVO comDisabilityPopulationVO = new ComDisabilityPopulationVO();
-        ComDisabilityPopulationDO comDisabilityPopulationDO = comDisabilityPopulationDAO.selectOne(new QueryWrapper<ComDisabilityPopulationDO>().
+        List<ComDisabilityPopulationVO> comDisabilityPopulationVOS = new ArrayList<>();
+        List<ComDisabilityPopulationDO> comDisabilityPopulationDOS = comDisabilityPopulationDAO.selectList(new QueryWrapper<ComDisabilityPopulationDO>().
                 lambda().eq(ComDisabilityPopulationDO::getPopulationId, populationId));
-        if (null != comRehabilitationPopulationDO) {
-            BeanUtils.copyProperties(comDisabilityPopulationDO, comDisabilityPopulationVO);
-            comMngPopulationVO.setComDisabilityPopulationVO(comDisabilityPopulationVO);
+        if (!comDisabilityPopulationDOS.isEmpty()) {
+            comDisabilityPopulationDOS.forEach(comDisabilityPopulationDO -> {
+                ComDisabilityPopulationVO comDisabilityPopulationVO = new ComDisabilityPopulationVO();
+                BeanUtils.copyProperties(comDisabilityPopulationDO, comDisabilityPopulationVO);
+                comDisabilityPopulationVOS.add(comDisabilityPopulationVO);
+                comMngPopulationVO.setComDisabilityPopulationVOs(comDisabilityPopulationVOS);
+            });
         }
 
         //低保户信息
-        ComLowSecurityPopulationVO comLowSecurityPopulationVO = new ComLowSecurityPopulationVO();
-        ComLowSecurityPopulationDO comLowSecurityPopulationDO = comLowSecurityPopulationDAO.selectOne(new QueryWrapper<ComLowSecurityPopulationDO>().
+        List<ComLowSecurityPopulationVO> comLowSecurityPopulationVOS = new ArrayList<>();
+        List<ComLowSecurityPopulationDO> comLowSecurityPopulationDOS = comLowSecurityPopulationDAO.selectList(new QueryWrapper<ComLowSecurityPopulationDO>().
                 lambda().eq(ComLowSecurityPopulationDO::getPopulationId, populationId));
-        if (null != comRehabilitationPopulationDO) {
-            BeanUtils.copyProperties(comLowSecurityPopulationDO, comLowSecurityPopulationVO);
-            comMngPopulationVO.setComLowSecurityPopulationVO(comLowSecurityPopulationVO);
+        if (!comLowSecurityPopulationDOS.isEmpty()) {
+            comLowSecurityPopulationDOS.forEach(comLowSecurityPopulationDO -> {
+                ComLowSecurityPopulationVO comLowSecurityPopulationVO = new ComLowSecurityPopulationVO();
+                BeanUtils.copyProperties(comLowSecurityPopulationDO, comLowSecurityPopulationVO);
+                comLowSecurityPopulationVOS.add(comLowSecurityPopulationVO);
+                comMngPopulationVO.setComLowSecurityPopulationVOs(comLowSecurityPopulationVOS);
+            });
         }
         return R.ok(comMngPopulationVO);
     }
@@ -460,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<>();
         //需要新增的人口集合
@@ -469,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<>();
@@ -480,7 +530,7 @@
                 log.error("未查询到社区信息");
                 return R.fail("未查询到社区信息");
             }
-            log.info("开始查询社区信息数据完成");
+            log.info("查询社区信息数据完成");
 
             //查询当前社区标签列表
             List<String> labelList = new ArrayList<>();
@@ -523,19 +573,31 @@
                 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("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -554,11 +616,18 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
-                log.info("开始查询小区街路巷是否存在完成");
+                log.info("查询小区街路巷是否存在完成");
 
                 log.info("开始查询房屋是否存在");
                 //先判断房屋是否存在
@@ -584,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())) {
                     //空户处理完房屋信息,直接返回
@@ -598,14 +667,14 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updatePopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updatePopulationDO(vo,populationDO,communityId,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("开始查询实有人口房屋居住信息");
                 //处理实有人口房屋居住信息
@@ -623,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());
@@ -634,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("执行数据库导入完成");
 
@@ -663,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<>();
         //需要新增的人口集合
@@ -672,6 +797,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationDrugMistakeExcelVO> mistakes = new ArrayList<>();
@@ -726,19 +855,32 @@
                 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 (ComMngPopulationDrugExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -757,9 +899,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -801,11 +950,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateDrugPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateDrugPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveDrugPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveDrugPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -827,6 +976,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationDrugMistakeExcelVO mistake = new ComMngPopulationDrugMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setDrugMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -855,6 +1050,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -866,7 +1071,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<>();
         //需要新增的人口集合
@@ -875,6 +1080,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationCorrectMistakeExcelVO> mistakes = new ArrayList<>();
@@ -929,19 +1138,32 @@
                 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 (ComMngPopulationCorrectExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -960,9 +1182,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -1004,11 +1233,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateCorrectPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateCorrectPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveCorrectPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveCorrectPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -1030,6 +1259,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationCorrectMistakeExcelVO mistake = new ComMngPopulationCorrectMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setCorrectMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -1058,6 +1333,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -1069,7 +1354,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<>();
         //需要新增的人口集合
@@ -1078,6 +1363,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationMajorMistakeExcelVO> mistakes = new ArrayList<>();
@@ -1132,19 +1421,32 @@
                 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 (ComMngPopulationMajorExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -1163,9 +1465,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -1207,11 +1516,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateMajorPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateMajorPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveMajorPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveMajorPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -1233,6 +1542,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationMajorMistakeExcelVO mistake = new ComMngPopulationMajorMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setMajorMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -1261,6 +1616,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -1272,7 +1637,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<>();
         //需要新增的人口集合
@@ -1281,6 +1646,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationCultMistakeExcelVO> mistakes = new ArrayList<>();
@@ -1335,19 +1704,32 @@
                 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 (ComMngPopulationCultExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -1366,9 +1748,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -1410,11 +1799,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateCultPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateCultPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveCultPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveCultPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -1436,6 +1825,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setCultMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -1464,6 +1899,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -1475,7 +1920,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<>();
         //需要新增的人口集合
@@ -1484,6 +1929,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationRehabilitationMistakeExcelVO> mistakes = new ArrayList<>();
@@ -1538,19 +1987,32 @@
                 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 (ComMngPopulationRehabilitationExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -1569,9 +2031,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -1613,11 +2082,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateRehabilitationPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateRehabilitationPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveRehabilitationPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveRehabilitationPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -1639,6 +2108,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setRehabilitationMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -1667,6 +2182,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -1678,7 +2203,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<>();
         //需要新增的人口集合
@@ -1687,6 +2212,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationKeyMistakeExcelVO> mistakes = new ArrayList<>();
@@ -1741,19 +2270,32 @@
                 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 (ComMngPopulationKeyExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -1772,9 +2314,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -1816,11 +2365,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateKeyPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateKeyPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveKeyPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveKeyPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -1842,6 +2391,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setKeyMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -1870,6 +2465,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -1881,7 +2486,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<>();
         //需要新增的人口集合
@@ -1890,6 +2495,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationSentenceMistakeExcelVO> mistakes = new ArrayList<>();
@@ -1944,19 +2553,32 @@
                 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 (ComMngPopulationSentenceExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -1975,9 +2597,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -2019,11 +2648,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateSentencePopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateSentencePopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveSentencePopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveSentencePopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -2045,6 +2674,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setSentenceMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -2073,6 +2748,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -2084,7 +2769,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<>();
         //需要新增的人口集合
@@ -2093,6 +2778,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationVeteransMistakeExcelVO> mistakes = new ArrayList<>();
@@ -2147,19 +2836,32 @@
                 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 (ComMngPopulationVeteransExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -2178,9 +2880,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -2222,11 +2931,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateVeteransPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateVeteransPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveVeteransPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveVeteransPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -2248,6 +2957,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setVeteransMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -2276,6 +3031,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -2287,7 +3052,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<>();
         //需要新增的人口集合
@@ -2296,6 +3061,10 @@
         List<ComMngPopulationDO> updateList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationDisabilityMistakeExcelVO> mistakes = new ArrayList<>();
@@ -2350,19 +3119,32 @@
                 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 (ComMngPopulationDisabilityExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -2381,9 +3163,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -2425,11 +3214,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateDisabilityPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateDisabilityPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveDisabilityPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveDisabilityPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -2451,6 +3240,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setDisabilityMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -2479,6 +3314,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -2490,7 +3335,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<>();
         //需要新增的人口集合
@@ -2503,6 +3348,10 @@
         List<ComDrugPopulationDO> updateDrugList = new ArrayList<>();
         //需要新增的人口与房屋关系集合
         List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> savePopulationCommunityList = new ArrayList<>();
+        //需要新增的人口与社区关系集合
+        List<ComMngPopulationCommunityTagsDO> updatePopulationCommunityList = new ArrayList<>();
 
         log.info("开始处理导入数据");
         List<ComMngPopulationLowSecurityMistakeExcelVO> mistakes = new ArrayList<>();
@@ -2557,19 +3406,32 @@
                 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 (ComMngPopulationLowSecurityExcelVO vo : list) {
                 if (vo.getDoorNo().contains("号")) {
                     vo.setDoorNo(vo.getDoorNo().replace("号",""));
                 }
-                if(vo.getFloor().contains("栋")){
-                    vo.setFloor(vo.getFloor().replace("栋",""));
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    if(vo.getFloor().contains("栋")){
+                        vo.setFloor(vo.getFloor().replace("栋",""));
+                    }
                 }
-                if(vo.getUnitNo().contains("单元")){
-                    vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    if(vo.getUnitNo().contains("单元")){
+                        vo.setUnitNo(vo.getUnitNo().replace("单元",""));
+                    }
                 }
-                if(vo.getHouseNo().contains("号")){
-                    vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    if(vo.getHouseNo().contains("号")){
+                        vo.setHouseNo(vo.getHouseNo().replace("号",""));
+                    }
                 }
                 log.info("开始查询小区街路巷是否存在");
                 //查询小区街路巷是否存在
@@ -2588,9 +3450,16 @@
                 }
                 StringBuilder address = new StringBuilder();
                 address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName())
-                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋")
-                        .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号");
-
+                        .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号");
+                if (StringUtils.isNotEmpty(vo.getFloor())) {
+                    address.append(vo.getFloor()).append("栋");
+                }
+                if (StringUtils.isNotEmpty(vo.getUnitNo())) {
+                    address.append(vo.getUnitNo()).append("单元");
+                }
+                if (StringUtils.isNotEmpty(vo.getHouseNo())) {
+                    address.append(vo.getHouseNo()).append("号");
+                }
                 vo.setAddress(address.toString());
                 log.info("开始查询小区街路巷是否存在完成");
 
@@ -2632,11 +3501,11 @@
                 if(!isOnly(populationKey,populationMap)){
                     //存在实有人口信息,则更新
                     populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
-                    ComMngPopulationDO updatePopulationDO = updateLowSecurityPopulationDO(vo,populationDO,labelList);
+                    ComMngPopulationDO updatePopulationDO = updateLowSecurityPopulationDO(vo,populationDO,communityId,userId);
                     updateList.add(updatePopulationDO);
                 }else{
                     //不存在实有人口,则新增
-                    populationDO = saveLowSecurityPopulationDO(vo, populationActVO, comMngVillageDO,labelList);
+                    populationDO = saveLowSecurityPopulationDO(vo, populationActVO, comMngVillageDO,userId);
                     saveList.add(populationDO);
                 }
                 log.info("开始查询实有人口是否已存在完成");
@@ -2658,6 +3527,52 @@
                     }
                 }
                 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);
+
+                    ComMngPopulationLowSecurityMistakeExcelVO mistake = new ComMngPopulationLowSecurityMistakeExcelVO();
+                    BeanUtils.copyProperties(vo,mistake);
+                    setLowSecurityMistake(mistake, vo);
+                    mistake.setMistake("该实有人口已存在于该社区,执行更新");
+                    mistakes.add(mistake);
+                }
+                log.info("查询实有人口存在社区信息完成");
             }
         }catch (Exception e){
             log.info("出现错误,错误原因:" + e.getMessage());
@@ -2686,6 +3601,16 @@
             comMngPopulationHouseUserService.saveBatch(houseUserList);
             log.info("执行数据库导入人口房屋关系完成");
         }
+        if(!savePopulationCommunityList.isEmpty()){
+            log.info("执行数据库导入人口社区关系");
+            comMngPopulationCommunityTagsService.saveBatch(savePopulationCommunityList);
+            log.info("数据库导入人口社区关系完成");
+        }
+        if(!updatePopulationCommunityList.isEmpty()){
+            log.info("执行数据库更新人口社区关系");
+            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
+            log.info("数据库更新人口社区关系完成");
+        }
         log.info("执行数据库导入完成");
 
         if (!mistakes.isEmpty()) {
@@ -2696,303 +3621,427 @@
     }
 
 
-    private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO, Long communityId, 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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
+        populationDO.setUpdateBy(userId);
         return populationDO;
     }
 
-    private ComMngPopulationDO updateDrugPopulationDO(ComMngPopulationDrugExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateDrugPopulationDO(ComMngPopulationDrugExcelVO vo, ComMngPopulationDO populationDO, Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comDrugPopulationDO.setCardNo(cardNoAES);
-        comDrugPopulationDAO.updateById(comDrugPopulationDO);
+        populationDO.setUpdateBy(userId);
+
+        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;
     }
 
-    private ComMngPopulationDO updateCorrectPopulationDO(ComMngPopulationCorrectExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateCorrectPopulationDO(ComMngPopulationCorrectExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comCorrectPopulationDO.setCardNo(cardNoAES);
-        comCorrectPopulationDAO.updateById(comCorrectPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateMajorPopulationDO(ComMngPopulationMajorExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateMajorPopulationDO(ComMngPopulationMajorExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comMajorPopulationDO.setCardNo(cardNoAES);
-        comMajorPopulationDAO.updateById(comMajorPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateCultPopulationDO(ComMngPopulationCultExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateCultPopulationDO(ComMngPopulationCultExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comCultPopulationDO.setCardNo(cardNoAES);
-        comCultPopulationDAO.updateById(comCultPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comRehabilitationPopulationDO.setCardNo(cardNoAES);
-        comRehabilitationPopulationDAO.updateById(comRehabilitationPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comKeyPopulationDO.setCardNo(cardNoAES);
-        comKeyPopulationDAO.updateById(comKeyPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comSentencePopulationDO.setCardNo(cardNoAES);
-        comSentencePopulationDAO.updateById(comSentencePopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comVeteransPopulationDO.setCardNo(cardNoAES);
-        comVeteransPopulationDAO.updateById(comVeteransPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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){
+    private ComMngPopulationDO updateDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comDisabilityPopulationDO.setCardNo(cardNoAES);
-        comDisabilityPopulationDAO.updateById(comDisabilityPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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;
     }
 
-    private ComMngPopulationDO updateLowSecurityPopulationDO(ComMngPopulationLowSecurityExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){
+    private ComMngPopulationDO updateLowSecurityPopulationDO(ComMngPopulationLowSecurityExcelVO vo, ComMngPopulationDO populationDO,Long communityId, Long userId){
         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();
-        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.setActId(communityId);
         populationDO.setCardNo(cardNoAES);
-        comLowSecurityPopulationDO.setCardNo(cardNoAES);
-        comLowSecurityPopulationDAO.updateById(comLowSecurityPopulationDO);
+        populationDO.setUpdateBy(userId);
+        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());
@@ -3004,6 +4053,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)) {
@@ -3016,7 +4066,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveDrugPopulationDO(ComMngPopulationDrugExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveDrugPopulationDO(ComMngPopulationDrugExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComDrugPopulationDO comDrugPopulationDO = new ComDrugPopulationDO();
@@ -3024,22 +4074,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comDrugPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3056,7 +4115,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveCorrectPopulationDO(ComMngPopulationCorrectExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveCorrectPopulationDO(ComMngPopulationCorrectExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComCorrectPopulationDO comCorrectPopulationDO = new ComCorrectPopulationDO();
@@ -3064,22 +4123,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comCorrectPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3096,7 +4164,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveMajorPopulationDO(ComMngPopulationMajorExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveMajorPopulationDO(ComMngPopulationMajorExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComMajorPopulationDO comMajorPopulationDO = new ComMajorPopulationDO();
@@ -3104,22 +4172,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comMajorPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3136,7 +4213,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveCultPopulationDO(ComMngPopulationCultExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveCultPopulationDO(ComMngPopulationCultExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComCultPopulationDO comCultPopulationDO = new ComCultPopulationDO();
@@ -3144,22 +4221,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comCultPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3176,7 +4262,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComRehabilitationPopulationDO comRehabilitationPopulationDO = new ComRehabilitationPopulationDO();
@@ -3184,22 +4270,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comRehabilitationPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3216,7 +4311,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComKeyPopulationDO comKeyPopulationDO = new ComKeyPopulationDO();
@@ -3224,22 +4319,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comKeyPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3256,7 +4360,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComSentencePopulationDO comSentencePopulationDO = new ComSentencePopulationDO();
@@ -3264,22 +4368,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comSentencePopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3296,7 +4409,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComVeteransPopulationDO comVeteransPopulationDO = new ComVeteransPopulationDO();
@@ -3304,22 +4417,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comVeteransPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3336,7 +4458,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         ComDisabilityPopulationDO comDisabilityPopulationDO = new ComDisabilityPopulationDO();
@@ -3344,22 +4466,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comDisabilityPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -3376,7 +4507,7 @@
         return populationDO;
     }
 
-    private ComMngPopulationDO saveLowSecurityPopulationDO(ComMngPopulationLowSecurityExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) {
+    private ComMngPopulationDO saveLowSecurityPopulationDO(ComMngPopulationLowSecurityExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,Long userId) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         ComLowSecurityPopulationDO comLowSecurityPopulationDO = new ComLowSecurityPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
@@ -3384,22 +4515,31 @@
         Long populationId = Snowflake.getId();
         populationDO.setId(populationId);
         comLowSecurityPopulationDO.setPopulationId(populationId);
-        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());
+
+        String cardNoAES = populationDO.getCardNo();
+        try {
+            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
+        }catch (Exception e){
+            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)) {
@@ -4204,7 +5344,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("该标签已存在,标签名称重复");
             }
@@ -4743,9 +5884,9 @@
         }
         comActPopulationScreenVO.setSpecialNum(specialNum.longValue());
         //统计已使用社区通人数
-//        Long count = populationDAO.countUsedCommunityPopulation(communityId);
-//        comActPopulationScreenVO.setUsedCommunityNum(count == null ? 0 : count);
-        comActPopulationScreenVO.setUsedCommunityNum(1183L);
+        Long count = populationDAO.countUsedCommunityPopulation(communityId);
+        comActPopulationScreenVO.setUsedCommunityNum(count == null ? 0 : count);
+//        comActPopulationScreenVO.setUsedCommunityNum(1183L);
 
         //统计性别
         Map<String, Long> sexMap = populationDAO.countBySex(communityId);

--
Gitblit v1.7.1