101captain
2022-01-24 ae491ab1663209a21322be073e5f9104dd46bbb3
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -578,6 +578,66 @@
        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);
    }
    /**
     * 删除实有人口
     *