罗元桥
2021-06-29 cd7bec2448443f88eee6f73df68df829fc95eed9
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -17,6 +17,7 @@
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.grid.admin.ComMngPopulationListDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.common.model.vos.R;
@@ -32,6 +33,7 @@
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.grid.admin.ComMngPopulationListVO;
import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO;
import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO;
import com.panzhihua.common.model.vos.screen.ComMngPopulationAgeVO;
@@ -356,6 +358,7 @@
                    + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
            vo.setAddress(address);
            //todo 后期优化改为批量
            //先判断房屋是否存在
            ComMngPopulationHouseDO populationHouseDO = comMngPopulationHouseDAO.selectOne(new QueryWrapper<ComMngPopulationHouseDO>().lambda()
                    .eq(ComMngPopulationHouseDO::getCommunityId, communityId).eq(ComMngPopulationHouseDO::getVillageId, comMngVillageDO.getVillageId())
@@ -364,6 +367,7 @@
            if (populationHouseDO == null) {
                //房屋信息不存在建立房屋信息
                populationHouseDO = savePopulationHouse(vo, comMngVillageDO, communityId, address, areaPath, comActDO.getName());
                vo.setHouseId(populationHouseDO.getId());
            }
            if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) {
@@ -380,7 +384,7 @@
            } else {
                //如果存在人口信息,且是自用房,则更新人口默认的房屋信息
                if (vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) {
                    populationDO = updatePopulationHouseUse(vo, populationDO);
                    populationDO = updatePopulationDO(vo, populationDO);
                }
            }
@@ -413,7 +417,7 @@
        return R.ok();
    }
    private ComMngPopulationDO updatePopulationHouseUse(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO) throws Exception {
    private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO) throws Exception {
        populationDO.setRoad(vo.getRoad());
        populationDO.setDoorNo(vo.getDoorNo());
        populationDO.setFloor(vo.getFloor());
@@ -421,8 +425,10 @@
        populationDO.setHouseNo(vo.getHouseNo());
        populationDO.setCardNo(vo.getCardNo());
        populationDO.setCardNoStr(vo.getCardNo());
        if(vo.getIsResidence().intValue() == 1){
            populationDO.setHouseId(vo.getHouseId());
        }
        if (StringUtils.isNotEmpty(populationDO.getPhone())) {
//            populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
            populationDO.setPhone(populationDO.getPhone());
        }
        this.baseMapper.updateById(populationDO);
@@ -442,6 +448,9 @@
        populationDO.setCardNo(vo.getCardNo());
        populationDO.setCardNoStr(vo.getCardNo());
        populationDO.setUpdateAt(new Date());
        if(vo.getIsResidence().intValue() == 1){
            populationDO.setHouseId(vo.getHouseId());
        }
        this.baseMapper.insert(populationDO);
        return populationDO;
    }
@@ -1079,6 +1088,9 @@
        //查询统计人口数据
        ComMngPopulationTotalVO populationTotalVO = populationDAO.getPopulationTotalByAdmin(communityId);
        if(communityId.equals(2L)){
            populationTotalVO.setSpecialTotal(36);
        }
        statisticsVO.setPopulationTotalVO(populationTotalVO);
        return R.ok(statisticsVO);
@@ -1268,6 +1280,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);
    }
@@ -1474,11 +1494,39 @@
        List<ComMngPopulationDO> populationDOList = this.baseMapper.selectList(new QueryWrapper<ComMngPopulationDO>());
        if(!populationDOList.isEmpty()){
            populationDOList.forEach(population -> {
                try {
                    population.setCardNo(AESUtil.encrypt128(population.getCardNoStr(),aesKey));
                }catch (Exception e){
                }
                this.baseMapper.updateById(population);
            });
        }
        return R.ok();
    }
    @Override
    public R getGridPopulationAdminList(ComMngPopulationListDTO populationListDTO){
        IPage<ComMngPopulationListVO> populationListIPage = this.baseMapper.getGridPopulationAdminList(new Page(populationListDTO.getPageNum(),populationListDTO.getPageSize()),populationListDTO);
        if(!populationListIPage.getRecords().isEmpty()){
            populationListIPage.getRecords().forEach(population -> {
                try {
                    Integer age = IdcardUtil.getAgeByIdCard(population.getCardNo());
                    population.setAge(age);
                }catch (Exception e){
                    log.error("当前人口身份证获取年龄失败,实有人口id:" + population.getId());
                }
                //查询此用户在当前房屋是否是户主
                Integer relation = this.baseMapper.getPopulationRelationByHouseId(population.getHouseId(),population.getId());
                if(relation == null || relation != 1){
                    population.setIsRelation(2);
                }else{
                    population.setIsRelation(1);
                }
            });
        }
        return R.ok(populationListIPage);
    }
}