From 63932c08a4ec3bc2e6bde7cf8aa2864bc3ddc89e Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 22 四月 2021 16:33:03 +0800 Subject: [PATCH] 新增确认导入实有人口接口 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 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 6a879ca..d0478ee 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 @@ -11,6 +11,7 @@ import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO; import com.panzhihua.common.model.dtos.community.ComMngPopulationTagDTO; import com.panzhihua.common.model.dtos.community.PageComActDTO; +import com.panzhihua.common.model.helper.AESUtil; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.user.ComHouseMemberVo; @@ -25,6 +26,7 @@ import com.panzhihua.service_community.model.dos.ComMngVillageDO; import com.panzhihua.service_community.service.ComMngPopulationService; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; @@ -46,6 +48,8 @@ private ComActDAO comActDAO; @Resource private ComActVillageDAO comActVillageDAO; + @Value("${domain.aesKey:}") + private String aesKey; /** @@ -223,6 +227,64 @@ return R.ok("共计导入实有人口数量:" + populationDOList.size()); } + /** + * 确认导入实有人口(有则更新,无则新建) + * @param list 用户信息 + * @param communityId 社区id + * @return 导入结果 + */ + @Override + public R listSavePopulationConfirm(List<ComMngPopulationServeExcelVO> list, Long communityId) { + if (list.size() == 0) { + return R.fail("数据为空!"); + } + List<ComMngPopulationDO> comMngPopulationDOS = populationDAO.selectList(new QueryWrapper<ComMngPopulationDO>().lambda().eq(ComMngPopulationDO::getActId, communityId)); + //查询该社区所有(实有房屋)小区 +// List<ComMngVillageDO> villageDOList = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId)); + ComActDO comActDO = comActDAO.selectById(communityId); + ArrayList<ComMngPopulationDO> populationDOList = Lists.newArrayList(); + list.forEach(vo -> { + ComMngPopulationDO comMngPopulationDO = new ComMngPopulationDO(); + //查询街路巷是否存在 + ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getRoad()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId)); +// ComMngVillageDO comMngVillageDO = villageDOList.stream().filter(village -> village.getAlley().equals(vo.getRoad()) && village.getHouseNum().equals(Integer.valueOf(vo.getDoorNo()))).findFirst().orElse(null); + BeanUtils.copyProperties(vo, comMngPopulationDO); + if (comMngVillageDO == null) { + throw new ServiceException("街道巷:" + vo.getRoad() + "不存在!"); + } + comMngPopulationDO.setVillageId(comMngVillageDO.getVillageId()); + comMngPopulationDO.setActId(comActDO.getCommunityId()); + comMngPopulationDO.setStreetId(comActDO.getStreetId()); + comMngPopulationDO.setLabel(Joiner.on(",").join(vo.getUserTagStr())); + comMngPopulationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDOList.add(comMngPopulationDO); + }); + + if(!populationDOList.isEmpty()){ + //循环遍历待导入人员信息,如果数据库存在则更新,如果不存在则新建 + populationDOList.forEach(population -> { + try { + //加密身份证号码 + String cardNo = AESUtil.encrypt128(population.getCardNo(), aesKey); + population.setCardNo(cardNo); + //查询这个用户是否存在 + ComMngPopulationDO comMngPopulationDO = this.populationDAO.selectOne(new QueryWrapper<ComMngPopulationDO>().lambda() + .eq(ComMngPopulationDO::getCardNo, population.getCardNo())); + if(comMngPopulationDO != null){ + population.setId(comMngPopulationDO.getId()); + BeanUtils.copyProperties(population,comMngPopulationDO); + this.populationDAO.updateById(population); + }else{ + this.populationDAO.insert(population); + } + }catch (Exception e){ + log.error("导入实有人口失败"); + } + }); + } + return R.ok("共计导入实有人口数量:" + populationDOList.size()); + } + public boolean isNumeric(String str) { for (int i = 0; i < str.length(); i++) { System.out.println(str.charAt(i)); -- Gitblit v1.7.1