huanghongfa
2021-06-21 28c53bd6511a4434a7f830ffca3f3f81feee8e21
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -14,6 +14,7 @@
import com.panzhihua.common.enums.PopulIsOksEnum;
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.user.PageInputUserDTO;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.common.model.vos.R;
@@ -801,9 +802,7 @@
        List<IndexPopulationSexStatisticsVO> sexPopulationList = comMngPopulationDAO.getScreenIndexByPopulationSex(communityId);
        populationStatisticsVO.setSexPopulationList(sexPopulationList);
        //查询实有人口年龄统计
        List<ComMngPopulationDO> populationDOList = comMngPopulationDAO.selectList(new QueryWrapper<ComMngPopulationDO>().lambda()
                .eq(ComMngPopulationDO::getActId,communityId));
        List<IndexPopulationAgeStatisticsVO> agePopulationList = statisticsAge(populationDOList);
        List<IndexPopulationAgeStatisticsVO> agePopulationList = statisticsAge(communityId);
        populationStatisticsVO.setAgePopulationList(agePopulationList);
        statisticsVO.setPopulationStatisticsVO(populationStatisticsVO);
@@ -858,11 +857,40 @@
                        Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
                        otherSpecialVO.setSum(otherSpecialVO.getSum() + count);
                    }else{
                        IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
                        specialStatisticsVO.setTitle(userTag.getTagName());
                        Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
                        specialStatisticsVO.setSum(count);
                        specialStatisticsVOList.add(specialStatisticsVO);
                        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);
                            }
                        }
                    }
                }
            });
@@ -872,7 +900,8 @@
        return R.ok(statisticsVO);
    }
    private List<IndexPopulationAgeStatisticsVO> statisticsAge(List<ComMngPopulationDO> populationDOList){
    private List<IndexPopulationAgeStatisticsVO> statisticsAge(Long communityId){
        Map<String,Long> ageMap = populationDAO.indexCountByAge(communityId);
        List<IndexPopulationAgeStatisticsVO> agePopulationList = new ArrayList<>();
        IndexPopulationAgeStatisticsVO ageStatisticsVO1 = new IndexPopulationAgeStatisticsVO();
        IndexPopulationAgeStatisticsVO ageStatisticsVO2 = new IndexPopulationAgeStatisticsVO();
@@ -887,7 +916,7 @@
        ageStatisticsVO5.setType(5);
        ageStatisticsVO6.setType(6);
        if(populationDOList.isEmpty()){
        if(ageMap.isEmpty()){
            ageStatisticsVO1.setSum(0);
            ageStatisticsVO2.setSum(0);
            ageStatisticsVO3.setSum(0);
@@ -895,23 +924,14 @@
            ageStatisticsVO5.setSum(0);
            ageStatisticsVO6.setSum(0);
        }else{
            populationDOList.forEach(population -> {
                Integer age = IdcardUtil.getAgeByIdCard(population.getCardNoStr());
                if(age >= 0 && age < 16){
                    ageStatisticsVO1.setSum(ageStatisticsVO1.getSum() + 1);
                }else if(age >= 16 && age < 27){
                    ageStatisticsVO2.setSum(ageStatisticsVO2.getSum() + 1);
                }else if(age >= 27 && age < 35){
                    ageStatisticsVO3.setSum(ageStatisticsVO3.getSum() + 1);
                }else if(age >= 35 && age < 45){
                    ageStatisticsVO4.setSum(ageStatisticsVO4.getSum() + 1);
                }else if(age >= 45 && age < 55){
                    ageStatisticsVO5.setSum(ageStatisticsVO5.getSum() + 1);
                }else if(age >= 55){
                    ageStatisticsVO6.setSum(ageStatisticsVO6.getSum() + 1);
                }
            });
            ageStatisticsVO1.setSum(ageMap.get("age16").intValue());
            ageStatisticsVO2.setSum(ageMap.get("age27").intValue());
            ageStatisticsVO3.setSum(ageMap.get("age35").intValue());
            ageStatisticsVO4.setSum(ageMap.get("age45").intValue());
            ageStatisticsVO5.setSum(ageMap.get("age55").intValue());
            ageStatisticsVO6.setSum(ageMap.get("age55over").intValue());
        }
        agePopulationList.add(ageStatisticsVO1);
        agePopulationList.add(ageStatisticsVO2);
        agePopulationList.add(ageStatisticsVO3);
@@ -978,6 +998,10 @@
            newStatisticsVO.setAudios(audioList);
            newStatisticsVO.setPics(picList);
            newStatisticsVO.setVideos(videoList);
            //查询事件流转记录
            List<EventTransferRecordVO> transferRecordList = this.baseMapper.getEventScreenEventTransList(newStatisticsVO.getId());
            newStatisticsVO.setTransferRecordList(transferRecordList);
        }
        statisticsVO.setNewStatisticsVO(newStatisticsVO);
@@ -1017,11 +1041,40 @@
                        Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
                        otherSpecialVO.setSum(otherSpecialVO.getSum() + count);
                    }else{
                        IndexSpecialStatisticsVO specialStatisticsVO = new IndexSpecialStatisticsVO();
                        specialStatisticsVO.setTitle(userTag.getTagName());
                        Integer count = comMngPopulationDAO.getSpecialStatisticsByLabel(userTag.getTagName());
                        specialStatisticsVO.setSum(count);
                        specialStatisticsVOList.add(specialStatisticsVO);
                        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);
                            }
                        }
                    }
                }
            });
@@ -1059,9 +1112,6 @@
        return R.ok(civilStatisticsVO);
    }
   @Override
    public R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO)  {
@@ -1107,7 +1157,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);
@@ -1124,6 +1236,14 @@
        setAgeGroup(comActPopulationScreenVO,communityId);
        //统计学历
        setCultureGroup(comActPopulationScreenVO,communityId);
        //查询网格数据
        List<EventGridStatisticsVO> gridStatisticsList = this.baseMapper.getEventScreenGridData(communityId);
        comActPopulationScreenVO.setGridStatisticsList(gridStatisticsList);
        //查询小区列表
        List<CivilVillageStatisticsVO> villageStatisticsList = this.baseMapper.getCivilScreenVillageList(communityId);
        comActPopulationScreenVO.setVillageStatisticsList(villageStatisticsList);
        return R.ok(comActPopulationScreenVO);
    }
@@ -1211,6 +1331,78 @@
        comActPopulationScreenVO.setAgeGroup(ageList);
    }
    @Override
    public R getScreenGirds(Long communityId){
        return R.ok(this.baseMapper.getEventScreenGridData(communityId));
    }
    @Override
    public R getScreenEventDetail(BigScreenEventDetailDTO eventDetailDTO){
        EventNewStatisticsVO statisticsVO = new EventNewStatisticsVO();
        if(eventDetailDTO.getType().equals(7)){//随手拍详情
            statisticsVO = this.baseMapper.getEventScreenSSPDateil(eventDetailDTO.getEventId());
            if(statisticsVO != null && StringUtils.isNotEmpty(statisticsVO.getPhotoPathList())){
                statisticsVO.setDangerLevel("0");
                statisticsVO.setMajor(false);
                statisticsVO.setUrgent(false);
                if(statisticsVO.getEventDealStatus().equals(2)){
                    statisticsVO.setEventDealStatus(4);
                }
                List<EventResourceVO> picList = new ArrayList<>();
                String [] pics = statisticsVO.getPhotoPathList().split(",");
                if(pics.length > 0){
                    for (int i = 0; i < pics.length; i++) {
                        EventResourceVO resourceVO = new EventResourceVO();
                        resourceVO.setType(1);
                        resourceVO.setUrl(pics[i]);
                        picList.add(resourceVO);
                    }
                }
                statisticsVO.setPics(picList);
            }
        }else{//事件详情
            statisticsVO = this.baseMapper.getEventScreenEventDetail(eventDetailDTO.getEventId());
            if(statisticsVO != null){
                //查询事件资源文件
                List<EventResourceDO> eventResourceDOList =
                        eventResourceService.getBaseMapper().selectList(new LambdaQueryWrapper<EventResourceDO>()
                                .eq(EventResourceDO::getClassification, 1)
                                .eq(EventResourceDO::getRefId, statisticsVO.getId())
                        );
                List<EventResourceVO> picList = new ArrayList<>();
                List<EventResourceVO> audioList = new ArrayList<>();
                List<EventResourceVO> videoList = new ArrayList<>();
                eventResourceDOList.forEach(eventResourceDO -> {
                    switch (eventResourceDO.getType()) {
                        case 1:
                            EventResourceVO picEventResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, picEventResourceVO);
                            picList.add(picEventResourceVO);
                            break;
                        case 2:
                            EventResourceVO audioResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, audioResourceVO);
                            audioList.add(audioResourceVO);
                            break;
                        case 3:
                            EventResourceVO videoResourceVO = new EventResourceVO();
                            BeanUtils.copyProperties(eventResourceDO, videoResourceVO);
                            videoList.add(videoResourceVO);
                            break;
                    }
                });
                statisticsVO.setAudios(audioList);
                statisticsVO.setPics(picList);
                statisticsVO.setVideos(videoList);
                //查询事件流转记录
                List<EventTransferRecordVO> transferRecordList = this.baseMapper.getEventScreenEventTransList(eventDetailDTO.getEventId());
                statisticsVO.setTransferRecordList(transferRecordList);
            }
        }
        return R.ok(statisticsVO);
    }
    public static void main(String[] args) {
//        List<ComMngPopulationHouseUserDO> distinctClass = populationHouseUserDOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getPopulId() + ";" + o.getHouseId() + ";" + o.getId() + ";" + o.getRelation()))), ArrayList::new));
    }