From 7638faeffc85815dcd89c4e99553635d91396fdd Mon Sep 17 00:00:00 2001 From: manailin <261030956@qq.com> Date: 星期三, 16 六月 2021 19:00:19 +0800 Subject: [PATCH] [新增]新增导入残疾人excel --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 136 ++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 126 insertions(+), 10 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 03a3485..4615f92 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 @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.base.Joiner; import com.google.common.collect.Lists; +import com.panzhihua.common.enums.PopulHouseUseEnum; import com.panzhihua.common.enums.PopulIsOksEnum; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.dtos.community.*; @@ -17,9 +18,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,13 +30,13 @@ 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; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.*; @@ -198,6 +197,56 @@ } 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 -> { @@ -276,8 +325,12 @@ 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); @@ -303,11 +356,22 @@ //查询该房屋未建立,执行建立房屋信息 populationHouseDO = new ComMngPopulationHouseDO(); populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setCode(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); populationHouseDO.setCommunityId(communityId); populationHouseDO.setFloor(vo.getFloor()); populationHouseDO.setUnitNo(vo.getUnitNo()); populationHouseDO.setHouseNo(vo.getHouseNo()); populationHouseDO.setAddress(address); + populationHouseDO.setUpdateAt(new Date()); + populationHouseDO.setConstructPurpose(vo.getBuildPurpose()); + try { + populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); + }catch (Exception e){ + } + if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){ populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); } @@ -369,6 +433,7 @@ populationDO.setVillageName(comMngVillageDO.getGroupAt()); populationDO.setHouseAddress(address); populationDO.setHouseId(populationHouseDO.getId()); + populationDO.setUpdateAt(new Date()); this.baseMapper.insert(populationDO); savePopulList.add(populationDO); index++; @@ -385,13 +450,14 @@ populationDO.setVillageName(comMngVillageDO.getGroupAt()); populationDO.setHouseAddress(address); populationDO.setHouseId(populationHouseDO.getId()); + populationDO.setUpdateAt(new Date()); this.baseMapper.insert(populationDO); savePopulList.add(populationDO); index++; } }else { //实有人口已存在,判断录入的这个房屋信息是否是用户的居住地 - if(vo.getIsResidence() != null && vo.getIsResidence().equals(PopulIsOksEnum.YES.getCode())){ + if(vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())){ populationDO.setRoad(vo.getRoad()); populationDO.setDoorNo(vo.getDoorNo()); populationDO.setFloor(vo.getFloor()); @@ -399,7 +465,10 @@ populationDO.setHouseNo(vo.getHouseNo()); populationDO.setHouseAddress(address); populationDO.setCardNo(AESUtil.encrypt128(populationDO.getCardNo(), aesKey)); - populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey)); + if(StringUtils.isNotEmpty(populationDO.getPhone())){ + populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey)); + } + populationDO.setHouseId(populationHouseDO.getId()); this.baseMapper.updateById(populationDO); } @@ -415,6 +484,7 @@ populationHouseUserDO.setHouseId(populationHouseDO.getId()); populationHouseUserDO.setPopulId(populationDO.getId()); populationHouseUserDO.setRelation(populationDO.getRelation()); + populationHouseUserDO.setRelationStr(populationDO.getRelationStr()); comMngPopulationHouseUserDAO.insert(populationHouseUserDO); } } @@ -527,7 +597,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(); @@ -580,6 +657,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)); @@ -719,8 +802,41 @@ return R.ok(this.baseMapper.getPopulationTotalByAdmin(communityId)); } - - public static void main(String[] args) { -// List<ComMngPopulationHouseUserDO> distinctClass = populationHouseUserDOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getPopulId() + ";" + o.getHouseId() + ";" + o.getId() + ";" + o.getRelation()))), ArrayList::new)); + @Override + public R editTagPopulationByCardNo(ComMngPopulationTagCardNoDTO comMngPopulationTagCardNoDTO) { + ComMngPopulationDO comMngPopulationDO = getPopulationByCardNo(comMngPopulationTagCardNoDTO.getCardNo()); + if (comMngPopulationDO == null) { + return R.fail("未查询到人口记录"); + } + ComMngPopulationDO comMngPopulation = new ComMngPopulationDO(); + if(comMngPopulationDO.getLabel()!=null) { + if(!comMngPopulationDO.getLabel().contains(comMngPopulationTagCardNoDTO.getLabel())) { + comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel().concat(",").concat(comMngPopulationDO.getLabel())); + } + }else{ + comMngPopulation.setLabel(comMngPopulationTagCardNoDTO.getLabel()); + } + comMngPopulation.setCardNo(null); + comMngPopulation.setId(comMngPopulationDO.getId()); + int nub = populationDAO.updateById(comMngPopulation); + if (nub < 1) { + return R.fail(); + } + return R.ok(); } + + @Override + public ComMngPopulationDO getPopulationByCardNo(String cardNo) { + try { + String aesCardNo = AESUtil.encrypt128(cardNo, aesKey); + return baseMapper.selectOne( + new QueryWrapper<ComMngPopulationDO>() + .eq("card_no",aesCardNo) + ); + } catch (Exception e) { + log.error("根据身份证查询业务-加密证件信息出错"); + } + return null; + } + } -- Gitblit v1.7.1