101captain
2022-05-19 19f39f95190ae02a90b07c97bc9e5cb54de383a4
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -218,7 +218,7 @@
        ComMngPopulationVO comMngPopulationVO = new ComMngPopulationVO();
        BeanUtils.copyProperties(comMngPopulationDO, comMngPopulationVO);
        comMngPopulationVO.setCultureLevelName(PopulCultureLevelEnum.getCnDescByName(comMngPopulationVO.getCultureLevel()));
        // 查询户主关系信息
        // List<ComHouseMemberVo> comMngFamilyInfoVOS =
        // populationDAO.listHouseMermberByUserId(comMngPopulationDO.getHouseId(),comMngPopulationDO.getId());
@@ -240,6 +240,7 @@
        if (!comMngPopulationHouseUserDOS.isEmpty()) {
            comMngPopulationVO
                .setRelation(comMngPopulationHouseUserDOS.get(comMngPopulationHouseUserDOS.size() - 1).getRelation());
            comMngPopulationVO.setRelationName(PopulRelationEnum.getCnDescByName(comMngPopulationVO.getRelation()));
        }
        // 设置年龄
        if (StringUtils.isNotEmpty(comMngPopulationVO.getBirthday())) {
@@ -806,33 +807,45 @@
                log.info("查询小区街路巷是否存在完成");
                log.info("开始查询房屋是否存在");
                // 先判断房屋是否存在
                ComMngPopulationHouseDO populationHouseDO = null;
                String houseKey =
                    communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
                if (isOnly(houseKey, houseMap)) {
                    if (!houseList.isEmpty()) {
                        for (ComMngPopulationHouseDO house : houseList) {
                            if (house.getVillageId().equals(comMngVillageDO.getVillageId())
                                && house.getCommunityId().equals(communityId) && house.getFloor().equals(vo.getFloor())
                                && house.getUnitNo().equals(vo.getUnitNo())
                                && house.getHouseNo().equals(vo.getHouseNo())) {
                                populationHouseDO = house;
                                break;
                // 先判断房屋是否存在
                if(StringUtils.isNotEmpty(vo.getFloor())&&StringUtils.isNotEmpty(vo.getHouseNo())&&StringUtils.isNotEmpty(vo.getUnitNo())){
                    String houseKey =
                            communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
                    if (isOnly(houseKey, houseMap)) {
                        if (!houseList.isEmpty()) {
                            for (ComMngPopulationHouseDO house : houseList) {
                                if (house.getVillageId().equals(comMngVillageDO.getVillageId())
                                        && house.getCommunityId().equals(communityId) && house.getFloor().equals(vo.getFloor())
                                        && house.getUnitNo().equals(vo.getUnitNo())
                                        && house.getHouseNo().equals(vo.getHouseNo())) {
                                    populationHouseDO = house;
                                    break;
                                }
                            }
                        }
                        if (populationHouseDO == null) {
                            // 房屋信息不存在建立房屋信息
                            populationHouseDO =
                                    savePopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName());
                            houseList.add(populationHouseDO);
                        }
                    } else {
                        populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey);
                    }
                    if (populationHouseDO == null) {
                        // 房屋信息不存在建立房屋信息
                        populationHouseDO =
                            savePopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName());
                        houseList.add(populationHouseDO);
                    }
                } else {
                    populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey);
                    vo.setHouseId(populationHouseDO.getId());
                    log.info("查询房屋是否存在完成");
                }else {
                    ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO();
                    BeanUtils.copyProperties(vo, mistake);
                    setMistake(mistake, vo);
                    mistake.setMistake("房屋数据填报不完整" );
                    mistakes.add(mistake);
                    log.info("房屋数据填报不完整");
                    continue;
                }
                vo.setHouseId(populationHouseDO.getId());
                log.info("查询房屋是否存在完成");
                if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) {
                    // 空户处理完房屋信息,直接返回
@@ -842,7 +855,10 @@
                // 判断实有人口是否已存在
                log.info("开始查询实有人口是否已存在");
                ComMngPopulationDO populationDO = null;
                String populationKey = vo.getCardNo();
                String populationKey = cardNoAES;
                if(vo.getCardNo().equals("510402197505075515")){
                    System.out.println("111");
                }
                if (!isOnly(populationKey, populationMap)) {
                    // 存在实有人口信息,则更新
                    populationDO = (ComMngPopulationDO)populationMap.get(populationKey);
@@ -852,7 +868,7 @@
                    // 不存在实有人口,则新增
                    populationDO = savePopulationDO(vo, populationActVO, comMngVillageDO, userId);
                    saveList.add(populationDO);
                    populationMap.put(populationDO.getCardNo(),populationDO);
                    populationMap.put(populationKey,populationDO);
                }
                log.info("查询实有人口是否已存在完成");
@@ -896,6 +912,7 @@
                        }
                        cpopulationCommunityTagsDO.setLabel(Joiner.on(",").join(userTag));
                        cpopulationCommunityTagsDO.setCreateBy(userId);
                        populationCommunityMap.put(populationCommunityKey,cpopulationCommunityTagsDO);
                        savePopulationCommunityList.add(cpopulationCommunityTagsDO);
                    }else {
                        // 实有人口存在于当前社区,则更新
@@ -941,7 +958,7 @@
        }
        if (!updateList.isEmpty()) {
            log.info("执行数据库更新人口");
            this.baseMapper.updateAll(updateList);
            this.updateBatchById(updateList);
            // this.updateBatchById(updateList);
            log.info("数据库更新人口完成");
        }
@@ -957,7 +974,7 @@
        }
        if (!updatePopulationCommunityList.isEmpty()) {
            log.info("执行数据库更新人口社区关系");
            comMngPopulationCommunityTagsDAO.updateAll(updatePopulationCommunityList);
            comMngPopulationCommunityTagsService.updateBatchById(updatePopulationCommunityList);
            log.info("数据库更新人口社区关系完成");
        }
        log.info("执行数据库导入完成");
@@ -6417,7 +6434,11 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R deletePopulations(List<Long> ids, Long communityId) {
        comMngPopulationCommunityTagsDAO.deletePopulationRelation(ids,communityId);
        for(Long id:ids){
            comMngPopulationCommunityTagsDAO.delete(new QueryWrapper<ComMngPopulationCommunityTagsDO>().lambda().eq(ComMngPopulationCommunityTagsDO::getPopulationId,id));
            comMngPopulationDAO.deleteById(id);
            comMngPopulationHouseUserDAO.delete(new QueryWrapper<ComMngPopulationHouseUserDO>().lambda().eq(ComMngPopulationHouseUserDO::getPopulId,id));
        }
        return R.ok();
    }