From 8788a78ad30c1bb9d50d91b10e76d3ae47ed8da2 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期一, 07 六月 2021 09:28:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test_future_wangge' into test_future_wangge --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 157 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 129 insertions(+), 28 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java index 102a8e4..62a9965 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java @@ -17,9 +17,7 @@ import com.panzhihua.common.model.vos.area.AreaAddressVO; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.user.*; -import com.panzhihua.common.utlis.AgeUtils; -import com.panzhihua.common.utlis.IdCard; -import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.*; import com.panzhihua.service_community.dao.*; import com.panzhihua.service_community.model.dos.*; import com.panzhihua.service_community.service.ComMngPopulationHouseUserService; @@ -31,7 +29,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; -import com.panzhihua.common.utlis.StringUtils; import javax.annotation.Resource; import javax.crypto.BadPaddingException; @@ -137,7 +134,7 @@ return R.fail("用户信息不存在"); } if(StringUtils.isNotEmpty(comMngPopulationDO.getBirthday())){//计算年龄 - comMngPopulationDO.setAge(AgeUtils.getAgeFromBirthTime(comMngPopulationDO.getBirthday())); + comMngPopulationDO.setAge(AgeUtils.getAgeFromBirthTimes(comMngPopulationDO.getBirthday())); } ComMngPopulationVO comMngPopulationVO = new ComMngPopulationVO(); @@ -165,6 +162,9 @@ //查询当前用户房屋信息 List<ComMngHouseVo> houseList = comMngPopulationHouseDAO.getPopulHouseListByPopulId(populationId); if(!houseList.isEmpty()){ + houseList.forEach(house ->{ + + }); comMngPopulationVO.setHouseList(houseList); } @@ -195,11 +195,61 @@ } page.setSize(pageSize); page.setCurrent(pageNum); + + if(comMngPopulationVO.getHouseId() != null){ + ComMngPopulationHouseDO houseDO = comMngPopulationHouseDAO.selectById(comMngPopulationVO.getHouseId()); + if(houseDO != null){ + switch (comMngPopulationVO.getLevel()){ + case 1: + comMngPopulationVO.setRoad(houseDO.getAlley()); + break; + case 2: + comMngPopulationVO.setRoad(houseDO.getAlley()); + comMngPopulationVO.setDoorNo(houseDO.getHouseNum()); + break; + case 3: + comMngPopulationVO.setRoad(houseDO.getAlley()); + comMngPopulationVO.setDoorNo(houseDO.getHouseNum()); + comMngPopulationVO.setFloor(houseDO.getFloor()); + break; + case 4: + comMngPopulationVO.setRoad(houseDO.getAlley()); + comMngPopulationVO.setDoorNo(houseDO.getHouseNum()); + comMngPopulationVO.setFloor(houseDO.getFloor()); + 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()); + break; + default: + break; + } + } + } + + if(StringUtils.isNotEmpty(comMngPopulationVO.getAgeStart())){ + String ageStartTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(new Date(),-(Integer.parseInt(comMngPopulationVO.getAgeStart()) + 1)),"yyyy-MM-dd"); + if(StringUtils.isNotEmpty(ageStartTime)){ + comMngPopulationVO.setAgeStartTime(ageStartTime); + } + } + + if(StringUtils.isNotEmpty(comMngPopulationVO.getAgeEnd())){ + String ageEndTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(new Date(),-(Integer.parseInt(comMngPopulationVO.getAgeEnd()) + 1)),"yyyy-MM-dd"); + if(StringUtils.isNotEmpty(ageEndTime)){ + comMngPopulationVO.setAgeEndTime(ageEndTime); + } + } + IPage<ComMngPopulationVO> iPage = populationDAO.pagePopulation(page, comMngPopulationVO); if(!iPage.getRecords().isEmpty()){ iPage.getRecords().forEach(populDO -> { if(StringUtils.isNotEmpty(populDO.getBirthday())){ - populDO.setAge(AgeUtils.getAgeFromBirthTime(populDO.getBirthday())); + populDO.setAge(AgeUtils.getAgeFromBirthTimes(populDO.getBirthday())); } }); } @@ -259,6 +309,7 @@ int index = 2; //处理实有人口信息 List<ComMngPopulationDO> savePopulList = new ArrayList<>(); + List<ComMngPopulationHouseDO> saveHouseList = new ArrayList<>(); for (ComMngPopulationServeExcelVO vo : list) { String address = ""; //查询街路巷是否存在 @@ -272,39 +323,58 @@ continue; } + if(!comMngVillageDO.getHouseNum().contains("号")){ + comMngVillageDO.setHouseNum(comMngVillageDO.getHouseNum() + "号"); + } + address = areaAddressVO.getProvince() + areaAddressVO.getCity() - + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum() + "号" + + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); vo.setAddress(address); //先判断房屋是否存在 ComMngPopulationHouseDO populationHouseDO = comMngPopulationHouseDAO.selectOne(new QueryWrapper<ComMngPopulationHouseDO>().lambda() - .eq(ComMngPopulationHouseDO::getCommunityId,communityId).eq(ComMngPopulationHouseDO::getAlley,vo.getRoad()).eq(ComMngPopulationHouseDO::getHouseNum,vo.getDoorNo()) + .eq(ComMngPopulationHouseDO::getCommunityId,communityId).eq(ComMngPopulationHouseDO::getVillageId,comMngVillageDO.getVillageId()) .eq(ComMngPopulationHouseDO::getFloor,vo.getFloor()).eq(ComMngPopulationHouseDO::getUnitNo,vo.getUnitNo()) .eq(ComMngPopulationHouseDO::getHouseNo,vo.getHouseNo())); if(populationHouseDO == null){ - //查询该房屋未建立,执行建立房屋信息 - populationHouseDO = new ComMngPopulationHouseDO(); - populationHouseDO.setAlley(vo.getRoad()); - populationHouseDO.setHouseNum(vo.getDoorNo()); - populationHouseDO.setCommunityId(communityId); - populationHouseDO.setFloor(vo.getFloor()); - populationHouseDO.setUnitNo(vo.getUnitNo()); - populationHouseDO.setHouseNo(vo.getHouseNo()); - populationHouseDO.setAddress(address); - if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){ - populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + boolean isExits = true; + if(!saveHouseList.isEmpty()){ + for (ComMngPopulationHouseDO saveHouse:saveHouseList){ + if(saveHouse.getVillageId().equals(comMngVillageDO.getVillageId()) + && saveHouse.getFloor().equals(vo.getFloor()) && saveHouse.getUnitNo().equals(vo.getUnitNo()) + && saveHouse.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = saveHouse; + isExits = false; + break; + } + } } - if(vo.getHouseStatus() != null){ - populationHouseDO.setStatus(vo.getHouseStatus()); + if(isExits){ + //查询该房屋未建立,执行建立房屋信息 + populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setAddress(address); + populationHouseDO.setUpdateAt(new Date()); + if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){ + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if(vo.getHouseStatus() != null){ + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if(vo.getHousePurpose() != null){ + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if(vo.getControlStatus() != null){ + populationHouseDO.setControlStatus(vo.getControlStatus()); + } + comMngPopulationHouseDAO.insert(populationHouseDO); + saveHouseList.add(populationHouseDO); } - if(vo.getHousePurpose() != null){ - populationHouseDO.setPurpose(vo.getHousePurpose()); - } - if(vo.getControlStatus() != null){ - populationHouseDO.setControlStatus(vo.getControlStatus()); - } - comMngPopulationHouseDAO.insert(populationHouseDO); } if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){ @@ -351,6 +421,7 @@ populationDO.setVillageName(comMngVillageDO.getGroupAt()); populationDO.setHouseAddress(address); populationDO.setHouseId(populationHouseDO.getId()); + populationDO.setUpdateAt(new Date()); this.baseMapper.insert(populationDO); savePopulList.add(populationDO); index++; @@ -367,6 +438,7 @@ populationDO.setVillageName(comMngVillageDO.getGroupAt()); populationDO.setHouseAddress(address); populationDO.setHouseId(populationHouseDO.getId()); + populationDO.setUpdateAt(new Date()); this.baseMapper.insert(populationDO); savePopulList.add(populationDO); index++; @@ -509,7 +581,14 @@ * @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(); @@ -562,6 +641,12 @@ return R.fail(); } BeanUtils.copyProperties(vo,populationDO); + if(StringUtils.isEmpty(vo.getLabel())){ + populationDO.setLabel(null); + } + if(StringUtils.isEmpty(vo.getRemark())){ + populationDO.setRemark(null); + } populationDO.setCardNo(null); populationDO.setPhone(AESUtil.encrypt128(vo.getPhone(), aesKey)); @@ -571,8 +656,21 @@ populationDO.setStreetId(comActDO.getStreetId()); } + //查询当前用户所有房屋id + List<Long> houseIds = comMngPopulationHouseUserDAO.getPopulationHouseIdByUserId(vo.getId()); //清除用户房屋居住信息 comMngPopulationHouseUserDAO.deletePopulationHouseByUserId(vo.getId()); + if(!houseIds.isEmpty()){ + houseIds.forEach(houseId -> { + //查询当前房屋下是否有人口信息,如果没有则将房屋设置为空户 + List<Long> oldHouseIds = comMngPopulationHouseUserDAO.getPopulationHouseIdByhHosueId(houseId); + if(oldHouseIds.isEmpty()){ + //修改房屋信息为空户 + comMngPopulationHouseDAO.updateHouseByIsEmpty(houseId,1); + } + }); + } + //更新用户的房屋信息 Long houseId = null; @@ -586,6 +684,9 @@ houseId = houseEditDto.getId();//居住地 } populationHouseUserDOList.add(populationHouseUserDO); + + //修改房屋信息不为空户 + comMngPopulationHouseDAO.updateHouseByIsEmpty(houseEditDto.getId(),2); } } comMngPopulationHouseUserService.saveBatch(populationHouseUserDOList); -- Gitblit v1.7.1