| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | | private ComActVillageDAO comActVillageDAO; |
| | | @Value("${domain.aesKey:}") |
| | | private String aesKey; |
| | | |
| | | |
| | | /** |
| | |
| | | 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)); |