huanghongfa
2021-12-09 9576bebcacea938771f6f5b51d958e6a4ac59df6
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -9,6 +9,7 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.panzhihua.common.model.vos.community.screen.civil.*;
import com.panzhihua.common.utlis.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -41,9 +42,6 @@
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.community.bigscreen.BigScreenStatisticPartyBuild;
import com.panzhihua.common.model.vos.community.screen.civil.CivilPopulationStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.civil.CivilStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.civil.CivilVillageStatisticsVO;
import com.panzhihua.common.model.vos.community.screen.event.*;
import com.panzhihua.common.model.vos.community.screen.event.EventTransferRecordVO;
import com.panzhihua.common.model.vos.community.screen.index.*;
@@ -7043,66 +7041,66 @@
        // 查询特殊人群统计
        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(),communityId);
//                        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(),communityId);
//                                specialStatisticsVO.setSum(count);
//                                specialStatisticsVOList.add(specialStatisticsVO);
//                            }
//                        }
//                    }
//                }
//            });
//        }
//        // 计算特殊人群总数
//        specialStatisticsVOList.add(otherSpecialVO);
//        Integer specialNum = 0;
//        if (!specialStatisticsVOList.isEmpty()) {
//            for (IndexSpecialStatisticsVO special : specialStatisticsVOList) {
//                specialNum += special.getSum();
//            }
//        }
//        civilStatisticsVO.setSpecialNum(specialNum);
//        civilStatisticsVO.setSpecialStatisticsList(specialStatisticsVOList);
        //查询特殊人群标签列表
        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(),communityId);
                        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(),communityId);
                                specialStatisticsVO.setSum(count);
                                specialStatisticsVOList.add(specialStatisticsVO);
                            }
                        }
                    }
                }
            });
        }
        // 计算特殊人群总数
        specialStatisticsVOList.add(otherSpecialVO);
        Integer specialNum = 0;
        if (!specialStatisticsVOList.isEmpty()) {
            for (IndexSpecialStatisticsVO special : specialStatisticsVOList) {
                specialNum += special.getSum();
            }
        }
        civilStatisticsVO.setSpecialNum(specialNum);
        civilStatisticsVO.setSpecialStatisticsList(specialStatisticsVOList);
        // 计算环比上月增长率
        BigDecimal rate = BigDecimal.ZERO;
@@ -7127,29 +7125,46 @@
        // 查询小区列表
        List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(communityId);
        villageStatisticsList.forEach(civilVillageStatisticsVO -> {
            civilVillageStatisticsVO.setUserSum(comMngPopulationDAO.selectCount(new QueryWrapper<ComMngPopulationDO>().lambda().eq(ComMngPopulationDO::getVillageId,civilVillageStatisticsVO.getVillageId())));
            List<IndexSpecialStatisticsVO> specialStatisticsVOS = new ArrayList<>();
            IndexSpecialStatisticsVO otherSpecial = new IndexSpecialStatisticsVO();
            otherSpecial.setTitle("其他");
            otherSpecial.setSum(0);
            // 查询特殊人群标签列表
            List<ComMngUserTagVO> userTagVOS = comMngPopulationDAO.getUserTagListByCommunityId(communityId);
            userTagVOS.forEach(comMngUserTagVO -> {
              Integer count=comMngPopulationDAO.selectCountByVillageId(civilVillageStatisticsVO.getVillageId(),comMngUserTagVO.getTagName());
              IndexSpecialStatisticsVO indexSpecialStatisticsVO=new IndexSpecialStatisticsVO();
              indexSpecialStatisticsVO.setTitle(comMngUserTagVO.getTagName());
              indexSpecialStatisticsVO.setSum(count);
              otherSpecial.setSum(otherSpecial.getSum()+count);
              specialStatisticsVOS.add(indexSpecialStatisticsVO);
            });
            otherSpecial.setSum(civilVillageStatisticsVO.getUserSum()-otherSpecial.getSum());
            specialStatisticsVOS.add(otherSpecial);
            civilVillageStatisticsVO.setSpecialStatisticsList(specialStatisticsVOS);
        });
//        villageStatisticsList.forEach(civilVillageStatisticsVO -> {
//            civilVillageStatisticsVO.setUserSum(comMngPopulationDAO.selectCount(new QueryWrapper<ComMngPopulationDO>().lambda().eq(ComMngPopulationDO::getVillageId,civilVillageStatisticsVO.getVillageId())));
//            List<IndexSpecialStatisticsVO> specialStatisticsVOS = new ArrayList<>();
//            IndexSpecialStatisticsVO otherSpecial = new IndexSpecialStatisticsVO();
//            otherSpecial.setTitle("其他");
//            otherSpecial.setSum(0);
//            // 查询特殊人群标签列表
//            List<ComMngUserTagVO> userTagVOS = comMngPopulationDAO.getUserTagListByCommunityId(communityId);
//
//            userTagVOS.forEach(comMngUserTagVO -> {
//              Integer count=comMngPopulationDAO.selectCountByVillageId(civilVillageStatisticsVO.getVillageId(),comMngUserTagVO.getTagName());
//              IndexSpecialStatisticsVO indexSpecialStatisticsVO=new IndexSpecialStatisticsVO();
//              indexSpecialStatisticsVO.setTitle(comMngUserTagVO.getTagName());
//              indexSpecialStatisticsVO.setSum(count);
//              otherSpecial.setSum(otherSpecial.getSum()+count);
//              specialStatisticsVOS.add(indexSpecialStatisticsVO);
//            });
//            otherSpecial.setSum(civilVillageStatisticsVO.getUserSum()-otherSpecial.getSum());
//            specialStatisticsVOS.add(otherSpecial);
//            civilVillageStatisticsVO.setSpecialStatisticsList(specialStatisticsVOS);
//        });
        civilStatisticsVO.setVillageStatisticsList(villageStatisticsList);
        //查询党建引领数据
        CivilPartyStatisticsVO civilParty = this.baseMapper.getCivilParty(communityId);
        if(civilParty != null){
            civilStatisticsVO.setCivilPartyStatisticsVO(civilParty);
        }
        //查询社区治理数据
        CivilGovernmentStatisticsVO civilGovernment = this.baseMapper.getCivilGovernment(communityId);
        if(civilGovernment != null){
            civilStatisticsVO.setCivilGovernmentStatisticsVO(civilGovernment);
        }
        //查询网格管理数据
        CivilGridStatisticsVO civilGrid = this.baseMapper.getCivilGrid(communityId);
        if(civilGrid != null){
            civilStatisticsVO.setCivilGridStatisticsVO(civilGrid);
        }
        //查询便民服务数据
        return R.ok(civilStatisticsVO);
    }