From 90de589a0964981f05b1571e441110130f35f4b8 Mon Sep 17 00:00:00 2001 From: 罗元桥 <2376770955@qq.com> Date: 星期五, 18 二月 2022 11:01:59 +0800 Subject: [PATCH] Merge branch 'volunteer_lyq' into 'dev' --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 149 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 149 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 32795fd..6eb960a 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 @@ -507,6 +507,19 @@ } } + if(comMngPopulationVO.getType()!=null){ + switch (comMngPopulationVO.getType()){ + case 1 : comMngPopulationVO.setAgeStart("80"); + comMngPopulationVO.setAgeEnd("89"); + break; + case 2 : comMngPopulationVO.setAgeStart("90"); + comMngPopulationVO.setAgeEnd("99"); + break; + case 3 : comMngPopulationVO.setAgeStart("100"); + break; + } + } + if (StringUtils.isNotEmpty(comMngPopulationVO.getAgeStart())) { String ageStartTime = DateUtils.getDateFormatString( DateUtils.yearAddNum(new Date(), -(Integer.parseInt(comMngPopulationVO.getAgeStart()))), "yyyy-MM-dd"); @@ -550,10 +563,79 @@ populDO.setPoliticalOutlookName( PopulPoliticalOutlookEnum.getCnDescByName(populDO.getPoliticalOutlook())); populDO.setMarriageName(PopulMarriageEnum.getCnDescByName(populDO.getMarriage())); + if(populDO.getAge()>=80&&populDO.getAge()<=89){ + populDO.setType(1); + } + if(populDO.getAge()>=90&&populDO.getAge()<=99){ + populDO.setType(2); + } + if(populDO.getAge()>=100){ + populDO.setType(3); + } } }); } return R.ok(iPage); + } + + @Override + public R exportOld(ComMngPopulationDTO comMngPopulationVO) { + if (StringUtils.isNotEmpty(comMngPopulationVO.getAgeStart())) { + String ageStartTime = DateUtils.getDateFormatString( + DateUtils.yearAddNum(new Date(), -(Integer.parseInt(comMngPopulationVO.getAgeStart()))), "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()))), "yyyy-MM-dd"); + if (StringUtils.isNotEmpty(ageEndTime)) { + comMngPopulationVO.setAgeEndTime(ageEndTime); + } + } + if (comMngPopulationVO.getAgeStartTime() != null && !"".equals(comMngPopulationVO.getAgeStartTime()) + && comMngPopulationVO.getAgeEndTime() != null && !"".equals(comMngPopulationVO.getAgeEndTime())) { + if (comMngPopulationVO.getAgeStartTime().equals(comMngPopulationVO.getAgeEndTime())) { + Date endAge = + DateUtils.stringToDate(comMngPopulationVO.getAgeEndTime(), new SimpleDateFormat("yyyy-MM-dd")); + String ageStartTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(endAge, -1), "yyyy-MM-dd"); + if (StringUtils.isNotEmpty(ageStartTime)) { + comMngPopulationVO.setAgeStartTimeEnd(ageStartTime); + } + } else { + Date endAge = + DateUtils.stringToDate(comMngPopulationVO.getAgeEndTime(), new SimpleDateFormat("yyyy-MM-dd")); + String ageStartTime = DateUtils.getDateFormatString(DateUtils.yearAddNum(endAge, -1), "yyyy-MM-dd"); + if (StringUtils.isNotEmpty(ageStartTime)) { + comMngPopulationVO.setAgeEndTimeEnd(ageStartTime); + } + } + } + List<ComMngPopulationVO> comMngPopulationVOS=this.comMngPopulationDAO.exportOld(comMngPopulationVO); + if(!comMngPopulationVOS.isEmpty()){ + comMngPopulationVOS.forEach(populDO -> { + if (StringUtils.isNotEmpty(populDO.getBirthday())) { + populDO.setAge(AgeUtils.getAgeFromBirthTimes(populDO.getBirthday())); + populDO.setRelationName(PopulRelationEnum.getCnDescByName(populDO.getRelation())); + populDO.setCultureLevelName(PopulCultureLevelEnum.getCnDescByName(populDO.getCultureLevel())); + populDO.setPoliticalOutlookName( + PopulPoliticalOutlookEnum.getCnDescByName(populDO.getPoliticalOutlook())); + populDO.setMarriageName(PopulMarriageEnum.getCnDescByName(populDO.getMarriage())); + if(populDO.getAge()>=80&&populDO.getAge()<=89){ + populDO.setType(1); + } + if(populDO.getAge()>=90&&populDO.getAge()<=99){ + populDO.setType(2); + } + if(populDO.getAge()>=100){ + populDO.setType(3); + } + } + }); + } + return R.ok(comMngPopulationVOS); } /** @@ -4457,6 +4539,10 @@ private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO, Long communityId, Long userId) { BeanUtils.copyProperties(vo, populationDO); + Integer personType = vo.getPersonType(); + if (nonNull(personType)) { + populationDO.setPersonType(personType.toString()); + } // List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> // userTagStr.split("\\(")[0]).collect(Collectors.toList()); // //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 @@ -4988,6 +5074,10 @@ ComMngVillageDO comMngVillageDO, Long userId) { ComMngPopulationDO populationDO = new ComMngPopulationDO(); BeanUtils.copyProperties(vo, populationDO); + Integer personType = vo.getPersonType(); + if (nonNull(personType)) { + populationDO.setPersonType(personType.toString()); + } populationDO.setId(Snowflake.getId()); // List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> // userTagStr.split("\\(")[0]).collect(Collectors.toList()); @@ -7953,6 +8043,65 @@ return R.ok(indexInfo); } + /** + * 历史数据人员类型填充 + * @param list + * @param communityId + * @param userId + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public R filledPopulationPersonType(List<ComMngPopulationServeExcelVO> list, Long communityId, Long userId) { + // 需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + log.info("开始处理导入数据"); + List<ComMngPopulationMistakeExcelVO> mistakes = new ArrayList<>(); + try { + // 查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String, Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key, population); + }); + for (ComMngPopulationServeExcelVO vo : list) { + // 判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if (!isOnly(populationKey, populationMap)) { + // 存在实有人口信息,则更新人员类型 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + Integer personType = vo.getPersonType(); + if (nonNull(personType)) { + populationDO.setPersonType(personType.toString()); + } + updateList.add(populationDO); + } else { + // 不存在实有人口,返回 + ComMngPopulationMistakeExcelVO mistake = new ComMngPopulationMistakeExcelVO(); + BeanUtils.copyProperties(vo, mistake); + setMistake(mistake, vo); + mistake.setMistake("人口信息不存在,请下载实有人口模板导入"); + mistakes.add(mistake); + } + } + } catch (Exception e) { + log.info("出现错误,错误原因:" + e.getMessage()); + } + if (!updateList.isEmpty()) { + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); + log.info("数据库更新人口完成"); + } + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + private void setMistake(ComMngPopulationMistakeExcelVO mvo, ComMngPopulationServeExcelVO vo) { mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); -- Gitblit v1.7.1