From 9fdd4862e4f28b1068ed02fedbec71038a637f1f Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期四, 24 六月 2021 18:23:14 +0800
Subject: [PATCH] 修改bug

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java |  175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 165 insertions(+), 10 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 f0cb7a4..c385ad5 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
@@ -1,5 +1,6 @@
 package com.panzhihua.service_community.service.impl;
 
+import cn.hutool.core.util.IdcardUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -11,9 +12,11 @@
 import com.panzhihua.common.enums.PopulCultureLevelEnum;
 import com.panzhihua.common.enums.PopulHouseUseEnum;
 import com.panzhihua.common.enums.PopulIsOksEnum;
+import com.panzhihua.common.enums.PopulMarriageEnum;
 import com.panzhihua.common.exceptions.ServiceException;
 import com.panzhihua.common.model.dtos.community.*;
 import com.panzhihua.common.model.dtos.community.bigscreen.BigScreenEventDetailDTO;
+import com.panzhihua.common.model.dtos.grid.PagePopulationListDTO;
 import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
 import com.panzhihua.common.model.helper.AESUtil;
 import com.panzhihua.common.model.vos.R;
@@ -27,6 +30,8 @@
 import com.panzhihua.common.model.vos.community.screen.index.*;
 import com.panzhihua.common.model.vos.grid.EventGridDataVO;
 import com.panzhihua.common.model.vos.grid.EventResourceVO;
+import com.panzhihua.common.model.vos.grid.PopulationDetailVO;
+import com.panzhihua.common.model.vos.grid.PopulationListVO;
 import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO;
 import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO;
 import com.panzhihua.common.model.vos.screen.ComMngPopulationAgeVO;
@@ -371,11 +376,11 @@
                     .eq(ComMngPopulationDO::getCardNo, cardNoAES));
             if (populationDO == null) {
                 //不存在实有人口,则新增
-                populationDO = savePopulationDO(vo, comActDO, comMngVillageDO, cardNoAES);
+                populationDO = savePopulationDO(vo, comActDO, comMngVillageDO);
             } else {
                 //如果存在人口信息,且是自用房,则更新人口默认的房屋信息
                 if (vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) {
-                    populationDO = updatePopulationHouseUse(vo, populationDO, cardNoAES);
+                    populationDO = updatePopulationHouseUse(vo, populationDO);
                 }
             }
 
@@ -408,22 +413,23 @@
         return R.ok();
     }
 
-    private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO, String cardNoAES) throws Exception {
+    private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO) throws Exception {
         populationDO.setRoad(vo.getRoad());
         populationDO.setDoorNo(vo.getDoorNo());
         populationDO.setFloor(vo.getFloor());
         populationDO.setUnitNo(vo.getUnitNo());
         populationDO.setHouseNo(vo.getHouseNo());
-        populationDO.setCardNo(cardNoAES);
+        populationDO.setCardNo(vo.getCardNo());
         populationDO.setCardNoStr(vo.getCardNo());
         if (StringUtils.isNotEmpty(populationDO.getPhone())) {
-            populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
+//            populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
+            populationDO.setPhone(populationDO.getPhone());
         }
         this.baseMapper.updateById(populationDO);
         return populationDO;
     }
 
-    private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO, String cardNoAES) {
+    private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO) {
         ComMngPopulationDO populationDO = new ComMngPopulationDO();
         BeanUtils.copyProperties(vo, populationDO);
         populationDO.setId(Snowflake.getId());
@@ -433,7 +439,7 @@
         populationDO.setStreetId(comActDO.getStreetId());
         populationDO.setLabel(Joiner.on(",").join(userTag));
         populationDO.setVillageName(comMngVillageDO.getGroupAt());
-        populationDO.setCardNo(cardNoAES);
+        populationDO.setCardNo(vo.getCardNo());
         populationDO.setCardNoStr(vo.getCardNo());
         populationDO.setUpdateAt(new Date());
         this.baseMapper.insert(populationDO);
@@ -923,7 +929,12 @@
                                 specialStatisticsVO.setTitle(userTag.getTagName());
                                 specialStatisticsVO.setSum(264);
                                 specialStatisticsVOList.add(specialStatisticsVO);
-                            } else {
+                            }else if(userTag.getTagName().equals("高龄老人")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(comMngPopulationDAO.getStatisticsCount(communityId));
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else{
                                 IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
                                 specialStatisticsVO.setTitle(userTag.getTagName());
                                 Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
@@ -1039,6 +1050,10 @@
             newStatisticsVO.setAudios(audioList);
             newStatisticsVO.setPics(picList);
             newStatisticsVO.setVideos(videoList);
+
+            //查询事件流转记录
+            List<EventTransferRecordVO> transferRecordList = this.baseMapper.getEventScreenEventTransList(newStatisticsVO.getId());
+            newStatisticsVO.setTransferRecordList(transferRecordList);
         }
         statisticsVO.setNewStatisticsVO(newStatisticsVO);
 
@@ -1049,6 +1064,22 @@
         //查询社区事件列表
         List<EventGridIncidentStatisticsVO> gridIncidentList = this.baseMapper.getEventScreenEventList(communityId);
         statisticsVO.setGridIncidentList(gridIncidentList);
+
+        //查询小区列表
+        List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(communityId);
+        if(!villageStatisticsList.isEmpty()){
+            villageStatisticsList.forEach(village -> {
+                CivilVillageStatisticsVO villageStatisticsVO = this.baseMapper.getCivilScreenVillageStatistics(village.getVillageId());
+                if(villageStatisticsVO != null){
+                    BeanUtils.copyProperties(villageStatisticsVO,village);
+                }
+            });
+        }
+        statisticsVO.setVillageStatisticsList(villageStatisticsList);
+
+        //查询统计人口数据
+        ComMngPopulationTotalVO populationTotalVO = populationDAO.getPopulationTotalByAdmin(communityId);
+        statisticsVO.setPopulationTotalVO(populationTotalVO);
 
         return R.ok(statisticsVO);
     }
@@ -1100,7 +1131,12 @@
                                 specialStatisticsVO.setTitle(userTag.getTagName());
                                 specialStatisticsVO.setSum(264);
                                 specialStatisticsVOList.add(specialStatisticsVO);
-                            } else {
+                            }else if(userTag.getTagName().equals("高龄老人")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(comMngPopulationDAO.getStatisticsCount(communityId));
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else{
                                 IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
                                 specialStatisticsVO.setTitle(userTag.getTagName());
                                 Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
@@ -1153,7 +1189,69 @@
         comActPopulationScreenVO.setTotalNum(vo.getPopulationTotal() == null ? 0 : vo.getPopulationTotal());
         comActPopulationScreenVO.setLocalNum(vo.getLocalTotal() == null ? 0 : vo.getLocalTotal().longValue());
         comActPopulationScreenVO.setOutNum(vo.getOutTotal() == null ? 0 : vo.getOutTotal().longValue());
-        comActPopulationScreenVO.setSpecialNum(vo.getSpecialTotal() == null ? 0 : vo.getSpecialTotal().longValue());
+
+        //查询特殊人群统计
+        List<IndexSpecialStatisticsVO> specialStatisticsVOList = new ArrayList<>();
+
+        //查询特殊人群标签列表
+        List<ComMngUserTagVO> userTagList = comMngPopulationDAO.getUserTagListByCommunityId(communityId);
+        IndexSpecialStatisticsVO otherSpecialVO = new IndexSpecialStatisticsVO();
+        otherSpecialVO.setTitle("其他");
+        otherSpecialVO.setSum(0);
+        if(!userTagList.isEmpty()){
+            userTagList.forEach(userTag -> {
+                if(userTag != null){
+                    if(userTag.getSysFlag().equals(0)){
+                        Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
+                        otherSpecialVO.setSum(otherSpecialVO.getSum() + count);
+                    }else{
+                        if(StringUtils.isNotEmpty(userTag.getTagName())){
+                            if(userTag.getTagName().equals("特扶家庭")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(22);
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else if(userTag.getTagName().equals("低保户")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(94);
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else if(userTag.getTagName().equals("低收入人群")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(2);
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else if(userTag.getTagName().equals("退役军人")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(264);
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else if(userTag.getTagName().equals("高龄老人")){
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                specialStatisticsVO.setSum(comMngPopulationDAO.getStatisticsCount(communityId));
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }else{
+                                IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
+                                specialStatisticsVO.setTitle(userTag.getTagName());
+                                Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
+                                specialStatisticsVO.setSum(count);
+                                specialStatisticsVOList.add(specialStatisticsVO);
+                            }
+                        }
+                    }
+                }
+            });
+        }
+        //计算特殊人群总数
+        specialStatisticsVOList.add(otherSpecialVO);
+        Integer specialNum = 0;
+        if(!specialStatisticsVOList.isEmpty()){
+            for (IndexSpecialStatisticsVO special:specialStatisticsVOList) {
+                specialNum += special.getSum();
+            }
+        }
+        comActPopulationScreenVO.setSpecialNum(specialNum.longValue());
         //统计已使用社区通人数
         Long count = populationDAO.countUsedCommunityPopulation(communityId);
         comActPopulationScreenVO.setUsedCommunityNum(count == null ? 0 : count);
@@ -1320,10 +1418,67 @@
                 statisticsVO.setAudios(audioList);
                 statisticsVO.setPics(picList);
                 statisticsVO.setVideos(videoList);
+
+                //查询事件流转记录
+                List<EventTransferRecordVO> transferRecordList = this.baseMapper.getEventScreenEventTransList(eventDetailDTO.getEventId());
+                if(!transferRecordList.isEmpty()){
+                    transferRecordList.forEach(transfer -> {
+                        if(transfer.getFromType().equals(EventTransferRecordVO.fromType.wgy)){
+                            //查询上级网格信息
+                            EventTransferRecordDetailVO transferRecordDetailVO = this.baseMapper.getEventScreenEventTransDetail(transfer.getEventId());
+                            transfer.setSuperiorRelationship(transferRecordDetailVO.getStreetName() + "-"
+                                    + transferRecordDetailVO.getCommunityName() + "-" + transferRecordDetailVO.getGridName());
+                        }else if(transfer.getFromType().equals(EventTransferRecordVO.fromType.sq)){
+                            //查询上级社区信息
+                            EventTransferRecordDetailVO transferRecordDetailVO = this.baseMapper.getEventScreenEventTransDetailByCommunityId(transfer.getFromId());
+                            transfer.setSuperiorRelationship(transferRecordDetailVO.getStreetName() + "-"
+                                    + transferRecordDetailVO.getCommunityName());
+                        }
+                    });
+                }
+                statisticsVO.setTransferRecordList(transferRecordList);
             }
         }
         return R.ok(statisticsVO);
     }
 
+    @Override
+    public R pagePopulationListApp(PagePopulationListDTO populationListDTO){
+        IPage<PopulationListVO> pagePopulationList = this.baseMapper.pagePopulationListApp(new Page(populationListDTO.getPageNum(),populationListDTO.getPageSize()),populationListDTO);
+        if(!pagePopulationList.getRecords().isEmpty()){
+            pagePopulationList.getRecords().forEach(population -> {
+                population.setAge(IdcardUtil.getAgeByIdCard(population.getCardNo()));
+            });
+        }
+        return R.ok(pagePopulationList);
+    }
+
+    @Override
+    public R getPopulationDetailApp(Long populationId){
+        PopulationDetailVO detail = this.baseMapper.getPopulationDetailApp(populationId);
+        if(detail != null){
+            detail.setAge(IdcardUtil.getAgeByIdCard(detail.getCardNo()));
+            if(StringUtils.isNotEmpty(detail.getCultureLevel())){
+                detail.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(Integer.parseInt(detail.getCultureLevel())));
+            }
+            if(StringUtils.isNotEmpty(detail.getMarriage())){
+                detail.setMarriage(PopulMarriageEnum.getCnDescByName(Integer.parseInt(detail.getMarriage())));
+            }
+        }
+        return R.ok(detail);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R getPopulationRepairByApp(){
+        List<ComMngPopulationDO> populationDOList = this.baseMapper.selectList(new QueryWrapper<ComMngPopulationDO>());
+        if(!populationDOList.isEmpty()){
+            populationDOList.forEach(population -> {
+                this.baseMapper.updateById(population);
+            });
+        }
+        return R.ok();
+    }
+
 
 }
\ No newline at end of file

--
Gitblit v1.7.1