huanghongfa
2021-12-14 d7ea73196c8eb7df71c20b4fdccbc1ef9eff96fe
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -9,6 +9,8 @@
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;
import org.springframework.context.annotation.Bean;
@@ -40,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.*;
@@ -54,10 +53,6 @@
import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO;
import com.panzhihua.common.model.vos.screen.ComMngPopulationAgeVO;
import com.panzhihua.common.model.vos.user.*;
import com.panzhihua.common.utlis.AgeUtils;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.Snowflake;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.*;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.*;
@@ -472,25 +467,27 @@
                        break;
                    case 2:
                        comMngPopulationVO.setRoad(houseDO.getAlley());
                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
//                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
                        break;
                    case 3:
                        comMngPopulationVO.setRoad(houseDO.getAlley());
                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
                        comMngPopulationVO.setFloor(houseDO.getFloor());
//                        comMngPopulationVO.setFloor(houseDO.getFloor());
                        break;
                    case 4:
                        comMngPopulationVO.setRoad(houseDO.getAlley());
                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
                        comMngPopulationVO.setFloor(houseDO.getFloor());
                        comMngPopulationVO.setUnitNo(houseDO.getUnitNo());
//                        comMngPopulationVO.setUnitNo(houseDO.getUnitNo());
                        break;
                    case 5:
                        comMngPopulationVO.setRoad(houseDO.getAlley());
                        comMngPopulationVO.setDoorNo(houseDO.getHouseNum());
                        comMngPopulationVO.setFloor(houseDO.getFloor());
                        comMngPopulationVO.setUnitNo(houseDO.getUnitNo());
                        comMngPopulationVO.setHouseNo(houseDO.getHouseNo());
                        if(comMngPopulationVO.getLevelIsAll() == null){
                            comMngPopulationVO.setHouseNo(houseDO.getHouseNo());
                        }
                        break;
                    default:
                        break;
@@ -4885,15 +4882,6 @@
        ComElderAuthElderliesDO comElderAuthElderliesDO =
                comElderAuthElderliesDAO.selectOne(new QueryWrapper<ComElderAuthElderliesDO>().lambda()
                        .eq(ComElderAuthElderliesDO::getPopulationId, populationDO.getId()).eq(ComElderAuthElderliesDO::getCommunityId, 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();
        // }
        String cardNoAES = populationDO.getCardNo();
        try {
            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
@@ -4918,19 +4906,6 @@
                    comElderAuthElderliesDO.setPersonnelCategory(ComElderAuthElderliesDO.personnelCategory.above100);
                }
            }
//            if (!comElderAuthElderliesDO.getIsAlive().equals(1) || !comElderAuthElderliesDO.getIsRegister().equals(1)) {
//                if (vo.getIsRegister().equals(1) && vo.getIsAlive().equals(1)) {
//                    Date nowDate = new Date();
//                    // 获取当前年
//                    int year = DateUtils.getYear(nowDate);
//                    // 获取当前月
//                    int month = DateUtils.getMonth(nowDate) + 1;
//                    ComEldersAuthStatisticsDO comEldersAuthStatisticsDO = comEldersAuthStatisticsMapper.selectOne(new QueryWrapper<ComEldersAuthStatisticsDO>()
//                            .lambda().eq(ComEldersAuthStatisticsDO::getCommunityId, communityId).eq(ComEldersAuthStatisticsDO::getYear, year).eq(ComEldersAuthStatisticsDO::getMonth, month));
//                    comEldersAuthStatisticsDO.setSum(comEldersAuthStatisticsDO.getSum() + 1);
//                    comEldersAuthStatisticsMapper.updateById(comEldersAuthStatisticsDO);
//                }
//            }
            comElderAuthElderliesDAO.updateById(comElderAuthElderliesDO);
        } else {
            comElderAuthElderliesDO = new ComElderAuthElderliesDO();
@@ -4951,19 +4926,11 @@
                    comElderAuthElderliesDO.setPersonnelCategory(ComElderAuthElderliesDO.personnelCategory.above100);
                }
            }
//            if (vo.getIsRegister().equals(1) && vo.getIsAlive().equals(1)) {
//                Date nowDate = new Date();
//                // 获取当前年
//                int year = DateUtils.getYear(nowDate);
//                // 获取当前月
//                int month = DateUtils.getMonth(nowDate) + 1;
//                ComEldersAuthStatisticsDO comEldersAuthStatisticsDO = comEldersAuthStatisticsMapper.selectOne(new QueryWrapper<ComEldersAuthStatisticsDO>()
//                        .lambda().eq(ComEldersAuthStatisticsDO::getCommunityId, communityId).eq(ComEldersAuthStatisticsDO::getYear, year).eq(ComEldersAuthStatisticsDO::getMonth, month));
//                comEldersAuthStatisticsDO.setSum(comEldersAuthStatisticsDO.getSum() + 1);
//                comEldersAuthStatisticsMapper.updateById(comEldersAuthStatisticsDO);
//            }
            comElderAuthElderliesDAO.insert(comElderAuthElderliesDO);
        }
        //维护养老认证健在状态
        comPensionAuthPensionerDAO.editPensionIsAlive(populationDO.getId(),vo.getIsAlive());
        return populationDO;
    }
@@ -4974,15 +4941,6 @@
                comPensionAuthPensionerDAO.selectOne(new QueryWrapper<ComPensionAuthPensionerDO>().lambda()
                        .eq(ComPensionAuthPensionerDO::getPopulationId, populationDO.getId())
                        .eq(ComPensionAuthPensionerDO::getCommunityId, 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();
        // }
        String cardNoAES = populationDO.getCardNo();
        try {
            cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey);
@@ -4997,23 +4955,6 @@
            BeanUtils.copyProperties(vo, comPensionAuthPensionerDO);
            comPensionAuthPensionerDO.setIdCard(cardNoAES);
            comPensionAuthPensionerDO.setAddress(vo.getNowAddress());
//            if (!comPensionAuthPensionerDO.getIsAlive().equals(1) || !comPensionAuthPensionerDO.getIsRegister().equals(1)) {
//                if (vo.getIsRegister().equals(1) && vo.getIsAlive().equals(1)) {
//                    Date nowDate = new Date();
//                    // 获取当前年
//                    int year = (DateUtils.getYear(nowDate));
//                    ComPensionAuthStatisticsDO comPensionAuthStatisticsDO = comPensionAuthStatisticsDAO.selectOne(new QueryWrapper<ComPensionAuthStatisticsDO>()
//                            .lambda().eq(ComPensionAuthStatisticsDO::getCommunityId, communityId)
//                            .eq(ComPensionAuthStatisticsDO::getYear, year));
//                    if(null == comPensionAuthStatisticsDO){
//                        comPensionAuthStatisticsDO = comPensionAuthStatisticsDAO.selectOne(new QueryWrapper<ComPensionAuthStatisticsDO>()
//                                .lambda().eq(ComPensionAuthStatisticsDO::getCommunityId, communityId)
//                                .eq(ComPensionAuthStatisticsDO::getYear, year - 1));
//                    }
//                    comPensionAuthStatisticsDO.setSum(comPensionAuthStatisticsDO.getSum() + 1);
//                    comPensionAuthStatisticsDAO.updateById(comPensionAuthStatisticsDO);
//                }
//            }
            comPensionAuthPensionerDAO.updateById(comPensionAuthPensionerDO);
        } else {
            comPensionAuthPensionerDO = new ComPensionAuthPensionerDO();
@@ -5025,17 +4966,9 @@
            comPensionAuthPensionerDO.setIdCard(vo.getCardNo());
            comPensionAuthPensionerDO.setAddress(vo.getNowAddress());
            comPensionAuthPensionerDAO.insert(comPensionAuthPensionerDO);
//            if (vo.getIsRegister().equals(1) && vo.getIsAlive().equals(1)) {
//                Date nowDate = new Date();
//                // 获取当前年
//                int year = (DateUtils.getYear(nowDate));
//                ComPensionAuthStatisticsDO comPensionAuthStatisticsDO = comPensionAuthStatisticsDAO.selectOne(new QueryWrapper<ComPensionAuthStatisticsDO>()
//                        .lambda().eq(ComPensionAuthStatisticsDO::getCommunityId, communityId)
//                        .eq(ComPensionAuthStatisticsDO::getYear, year));
//                comPensionAuthStatisticsDO.setSum(comPensionAuthStatisticsDO.getSum() + 1);
//                comPensionAuthStatisticsDAO.updateById(comPensionAuthStatisticsDO);
//            }
        }
        //维护高龄老人健在状态
        comElderAuthElderliesDAO.editEditIsAlive(populationDO.getId(),vo.getIsAlive());
        return populationDO;
    }
@@ -5061,6 +4994,7 @@
        populationDO.setVillageName(comMngVillageDO.getGroupAt());
        populationDO.setCardNoStr(vo.getCardNo());
        populationDO.setUpdateAt(new Date());
        populationDO.setDeath(vo.getDeath().toString());
        String cardNoAES = populationDO.getCardNo();
        try {
@@ -5601,16 +5535,6 @@
        Long populationId = Snowflake.getId();
        populationDO.setId(populationId);
        comElderAuthElderliesDO.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();
        // }
        populationDO.setVillageId(comMngVillageDO.getVillageId());
        populationDO.setActId(comActDO.getCommunityId());
        populationDO.setStreetId(comActDO.getStreetId());
@@ -5651,17 +5575,6 @@
                comElderAuthElderliesDO.setPersonnelCategory(ComElderAuthElderliesDO.personnelCategory.above100);
            }
        }
//        if (vo.getIsRegister().equals(1) && vo.getIsAlive().equals(1)) {
//            Calendar calendar = Calendar.getInstance();
//            // 获取当前年
//            int year = calendar.get(Calendar.YEAR);
//            // 获取当前月
//            int month = calendar.get(Calendar.MONTH) + 1;
//            ComEldersAuthStatisticsDO comEldersAuthStatisticsDO = comEldersAuthStatisticsMapper.selectOne(new QueryWrapper<ComEldersAuthStatisticsDO>()
//                    .lambda().eq(ComEldersAuthStatisticsDO::getCommunityId, communityId).eq(ComEldersAuthStatisticsDO::getYear, year).eq(ComEldersAuthStatisticsDO::getMonth, month));
//            comEldersAuthStatisticsDO.setSum(comEldersAuthStatisticsDO.getSum() + 1);
//            comEldersAuthStatisticsMapper.updateById(comEldersAuthStatisticsDO);
//        }
        comElderAuthElderliesDAO.insert(comElderAuthElderliesDO);
        return populationDO;
    }
@@ -6396,23 +6309,14 @@
    /**
     * 批量删除实有人口
     *
     * @param Ids
     * @return
     * @param ids 实有人口id集合
     * @return  删除结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R deletePopulations(List<Long> Ids) {
        if (!Ids.isEmpty()) {
            Ids.forEach(id -> {
                // 清除用户房屋居住信息
                comMngPopulationHouseUserDAO.deletePopulationHouseByUserId(id);
            });
        }
        int delete = populationDAO.deleteBatchIds(Ids);
        if (delete > 0) {
            return R.ok();
        }
        return R.fail();
    public R deletePopulations(List<Long> ids, Long communityId) {
        comMngPopulationCommunityTagsDAO.deletePopulationRelation(ids,communityId);
        return R.ok();
    }
    /**
@@ -6494,6 +6398,16 @@
            populationDO.setActId(comActDO.getCommunityId());
            populationDO.setStreetId(comActDO.getStreetId());
        }
        //修改人员标签
        List<ComMngPopulationCommunityTagsDO> communityTagsDOList = comMngPopulationCommunityTagsDAO
                .selectList(new QueryWrapper<ComMngPopulationCommunityTagsDO>().lambda()
                .eq(ComMngPopulationCommunityTagsDO::getCommunityId,communityId)
                .eq(ComMngPopulationCommunityTagsDO::getPopulationId,vo.getId()));
        communityTagsDOList.forEach(communityTags -> {
            communityTags.setLabel(vo.getLabel());
            comMngPopulationCommunityTagsDAO.updateById(communityTags);
        });
        // 查询当前用户所有房屋id
        List<Long> houseIds = comMngPopulationHouseUserDAO.getPopulationHouseIdByUserId(vo.getId());
@@ -6657,6 +6571,19 @@
    public R specialInputUser(PageInputUserDTO pageInputUserDTO) {
        IPage<InputUserInfoVO> iPage = populationDAO.specialInputUser(
            new Page<>(pageInputUserDTO.getPageNum(), pageInputUserDTO.getPageSize()), pageInputUserDTO);
        if(iPage!=null){
            iPage.getRecords().forEach(page -> {
                if(page.getAreaName() == null || StringUtils.isEmpty(page.getAreaName())){
                    StringBuilder sb = new StringBuilder();
                    sb.append(page.getAlley());
                    if(!page.getHouseNum().contains("号")){
                        sb.append(page.getHouseNum() + "号");
                    }
                    page.setAreaName(sb.toString());
                }
            });
        }
        return R.ok(iPage);
    }
@@ -6668,13 +6595,24 @@
     * @return 删除结果
     */
    @Override
    public R deleteSpecialInputUser(Long id) {
    public R deleteSpecialInputUser(Long id,Long communityId) {
        // 查询特殊群体人员
        ComMngPopulationDO populationDO = this.baseMapper.selectById(id);
        if (populationDO == null) {
            return R.fail("未查询到该记录");
        }
        populationDO.setLabel(null);
        //  清理社区与人口关联信息的label信息
        List<ComMngPopulationCommunityTagsDO> communityTagsDOList = comMngPopulationCommunityTagsDAO.selectList(new QueryWrapper<ComMngPopulationCommunityTagsDO>()
                .lambda().eq(ComMngPopulationCommunityTagsDO::getPopulationId,id).eq(ComMngPopulationCommunityTagsDO::getCommunityId,communityId));
        if(communityTagsDOList != null && communityTagsDOList.size() > 0){
            communityTagsDOList.forEach(communityTags -> {
                communityTags.setLabel(null);
                comMngPopulationCommunityTagsDAO.updateById(communityTags);
            });
        }
        if (this.baseMapper.updateById(populationDO) > 0) {
            return R.ok();
        } else {
@@ -7103,7 +7041,7 @@
        // 查询特殊人群统计
        List<IndexSpecialStatisticsVO> specialStatisticsVOList = new ArrayList<>();
        // 查询特殊人群标签列表
        //查询特殊人群标签列表
        List<ComMngUserTagVO> userTagList = comMngPopulationDAO.getUserTagListByCommunityId(communityId);
        IndexSpecialStatisticsVO otherSpecialVO = new IndexSpecialStatisticsVO();
        otherSpecialVO.setTitle("其他");
@@ -7187,8 +7125,49 @@
        // 查询小区列表
        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);
//        });
        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);
        }
        //查询便民服务数据
        CivilConvenienceStatisticsVO civilConvenience = this.baseMapper.getCivilConvenience(communityId);
        if(civilConvenience != null){
            civilStatisticsVO.setCivilConvenienceStatisticsVO(civilConvenience);
        }
        return R.ok(civilStatisticsVO);
    }
@@ -7403,8 +7382,11 @@
                statisticsVO.setDangerLevel("0");
                statisticsVO.setMajor(false);
                statisticsVO.setUrgent(false);
                if (statisticsVO.getEventDealStatus().equals(2)) {
                    statisticsVO.setEventDealStatus(4);
                if (statisticsVO.getEventDealStatus().equals(2)||statisticsVO.getEventDealStatus().equals(1)) {
                    statisticsVO.setEventDealStatus(1);
                }
                else {
                    statisticsVO.setEventDealStatus(2);
                }
                List<EventResourceVO> picList = new ArrayList<>();
                String[] pics = statisticsVO.getPhotoPathList().split(",");
@@ -7524,6 +7506,10 @@
            if (StringUtils.isNotEmpty(detail.getMarriage())) {
                detail.setMarriage(PopulMarriageEnum.getCnDescByName(Integer.parseInt(detail.getMarriage())));
            }
            //查询该人口的标签
            List<ComMngPopulationCommunityTagsVo> communityTagsList = this.baseMapper.getCommunityTagList(populationId);
            String label = LabelUtils.assembleLabel(communityTagsList);
            detail.setLabel(label);
        }
        return R.ok(detail);
    }
@@ -7604,6 +7590,8 @@
            return R.fail("您选择的数据中存在被引用的,无法删除");
        }
        this.baseMapper.deleteBatchIds(ids);
        //删除人口并删除人口和社区关联关系
        this.baseMapper.deletePopulaitonRelation(ids);
        return R.ok("删除成功");
    }
@@ -7745,6 +7733,46 @@
            new Page(villagePopulationDTO.getPageNum(), villagePopulationDTO.getPageSize()), villagePopulationDTO));
    }
    @Override
    public R specialInputUserExport(PageInputUserDTO pageInputUserDTO) {
        return R.ok(this.comMngPopulationDAO.specialInputUserExport(pageInputUserDTO));
    }
    @Override
    public R westScreenStatics() {
        return R.ok(this.comMngPopulationDAO.westScreenStatics());
    }
    @Override
    public R getComprehensivePopulationStatics(Long streetId){
        EventPopulationStatisticsVO statisticsVo = new EventPopulationStatisticsVO();
        //查询人口数据
        List<EventPopulationBasicsStatisticsVO> basicsList = comMngPopulationDAO.getBasicsList(streetId);
        if(basicsList != null){
            for (EventPopulationBasicsStatisticsVO basics : basicsList) {
                statisticsVo.setPopulationNum(statisticsVo.getPopulationNum() + basics.getPopulationNum());
                statisticsVo.setVillageNum(statisticsVo.getVillageNum() + basics.getVillageNum());
                statisticsVo.setHouseNum(statisticsVo.getHouseNum() + basics.getHouseNum());
            }
            statisticsVo.setBasicsList(basicsList);
        }
        //查询特殊人群数据
        EventPopulationSpecialStatisticsVO populationSpecial = comMngPopulationDAO.getPopulationSpecial(streetId);
        if(populationSpecial != null){
            populationSpecial.setOtherTotal(populationSpecial.getZjTotal() + populationSpecial.getSfTotal()
                    + populationSpecial.getXsTotal() + populationSpecial.getXjTotal()
                    + populationSpecial.getJzTotal() + populationSpecial.getXdTotal());
            populationSpecial.setLnTotal(comMngPopulationDAO.getPopulationAge(streetId));
            statisticsVo.setSpecialStatisticsVo(populationSpecial);
        }
        return R.ok(statisticsVo);
    }
    @Override
    public R getComprehensiveStreetList(){
        return R.ok(comMngPopulationDAO.getComprehensiveStreetList());
    }
    private void setMistake(ComMngPopulationMistakeExcelVO mvo, ComMngPopulationServeExcelVO vo) {
        mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook()));
        mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent()));