| | |
| | | public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId) throws Exception { |
| | | List<ComMngPopulationMistakeExcelVO> mistakes = new ArrayList<>(); |
| | | // List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); |
| | | //查询该社区 |
| | | ComActDO comActDO = comActDAO.selectById(communityId); |
| | | //查询该社区的省市区地址 |
| | | AreaAddressVO areaAddressVO = populationDAO.getAreaAddress(comActDO.getProvinceCode(), comActDO.getCityCode(), comActDO.getAreaCode()); |
| | | //查询社区上街道信息 |
| | | String streetName = ""; |
| | | if (comActDO.getStreetId() != null) { |
| | | ComStreetDO streetDO = comStreetDAO.selectById(comActDO.getStreetId()); |
| | | if (streetDO != null) { |
| | | streetName = streetDO.getName(); |
| | | } |
| | | //查询社区信息 |
| | | ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); |
| | | if(populationActVO == null){ |
| | | log.error("未查询到社区信息"); |
| | | return R.fail("未查询到社区信息"); |
| | | } |
| | | //查询该社区 |
| | | // ComActDO comActDO = comActDAO.selectById(communityId); |
| | | //查询该社区的省市区地址 |
| | | // AreaAddressVO areaAddressVO = populationDAO.getAreaAddress(comActDO.getProvinceCode(), comActDO.getCityCode(), comActDO.getAreaCode()); |
| | | //查询社区上街道信息 |
| | | String streetName = populationActVO.getStreetName(); |
| | | // if (comActDO.getStreetId() != null) { |
| | | // ComStreetDO streetDO = comStreetDAO.selectById(comActDO.getStreetId()); |
| | | // if (streetDO != null) { |
| | | // streetName = streetDO.getName(); |
| | | // } |
| | | // } |
| | | StringBuilder areaPath = new StringBuilder(); |
| | | areaPath.append(areaAddressVO.getProvince()).append(">").append(areaAddressVO.getCity()).append(">").append(areaAddressVO.getDistrict()).append(">"); |
| | | areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); |
| | | //处理实有人口信息 |
| | | for (ComMngPopulationServeExcelVO vo : list) { |
| | | if (vo.getDoorNo().contains("号")) { |
| | |
| | | } |
| | | |
| | | StringBuilder address = new StringBuilder(); |
| | | address.append(areaAddressVO.getProvince()).append(areaAddressVO.getCity()).append(areaAddressVO.getDistrict()) |
| | | address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) |
| | | .append(streetName).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") |
| | | .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); |
| | | |
| | |
| | | .eq(ComMngPopulationHouseDO::getHouseNo, vo.getHouseNo())); |
| | | if (populationHouseDO == null) { |
| | | //房屋信息不存在建立房屋信息 |
| | | populationHouseDO = savePopulationHouse(vo, comMngVillageDO, communityId, areaPath, comActDO.getName()); |
| | | populationHouseDO = savePopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); |
| | | vo.setHouseId(populationHouseDO.getId()); |
| | | } |
| | | |
| | |
| | | |
| | | if (populationDOList.isEmpty()) { |
| | | //不存在实有人口,则新增 |
| | | populationDO = savePopulationDO(vo, comActDO, comMngVillageDO); |
| | | populationDO = savePopulationDO(vo, populationActVO, comMngVillageDO); |
| | | // ComMngPopulationHouseUserDO comMngPopulationHouseUserDO = savePopulationHouseUser(vo, populationDO, populationHouseDO); |
| | | } else { |
| | | //如果存在人口信息,且是自用房,则更新人口默认的房屋信息 |
| | | // if (vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) { |
| | | // populationDO = updatePopulationDO(vo, populationDO); |
| | | // } |
| | | populationDO = updatePopulationDO(vo, comActDO, populationDOList.get(0)); |
| | | populationDO = updatePopulationDO(vo, populationActVO, populationDOList.get(0)); |
| | | } |
| | | |
| | | //处理实有人口房屋居住信息 |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngPopulationDO populationDO) throws Exception { |
| | | private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComPopulationActVO comActDO, ComMngPopulationDO populationDO) throws Exception { |
| | | UpdateWrapper<ComMngPopulationDO> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id",populationDO.getId()); |
| | | ComMngPopulationDO update = new ComMngPopulationDO(); |
| | |
| | | return populationDO; |
| | | } |
| | | |
| | | private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComActDO comActDO, ComMngVillageDO comMngVillageDO) { |
| | | private ComMngPopulationDO savePopulationDO(ComMngPopulationServeExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO) { |
| | | ComMngPopulationDO populationDO = new ComMngPopulationDO(); |
| | | BeanUtils.copyProperties(vo, populationDO); |
| | | populationDO.setId(Snowflake.getId()); |