springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -2531,6 +2531,17 @@ R pagePopulation(ComMngPopulationDTO comMngPopulationVO); /** * 导出老人 * * @param comMngPopulationVO * 查询参数 * @return 分页集合 */ @PostMapping("/common/data/population/exportOld") R exportOld(ComMngPopulationDTO comMngPopulationVO); /** * 根据身份证查询实有人口信息 */ @GetMapping("/common/data/population/selectByIdCard") springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java
@@ -2756,6 +2756,90 @@ } } @ApiOperation(value = "老人-数据导出") @PostMapping("/data/exportOld") public R dataExportPopulationOld(@RequestBody ComMngPopulationDTO comMngPopulationVO) { // 获取登陆用户 LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); // 获取登陆用户绑定社区id Long communityId = loginUserInfo.getCommunityId(); // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 String ftpUrl = "/mnt/data/web/excel/"; String name = "实有人口数据.xlsx"; try { SFTPUtil sftp = new SFTPUtil(userName, password, host, port); sftp.login(); boolean existDir = sftp.isExistDir(ftpUrl + name); if (!existDir) { String property = System.getProperty("user.dir"); String fileName = property + File.separator + name; // 这里 需要指定写用哪个class去写 ExcelWriter excelWriter = null; InputStream inputStream = null; try { List<ComMngPopulationVO> populList = null; populList = JSON.parseArray( JSON.toJSONString(communityService.exportOld(comMngPopulationVO).getData()), ComMngPopulationVO.class); List<ComMngPopulationExcelVo> populationExcelVoList = new ArrayList<>(); if (populList != null && populList.size() > 0) { for (ComMngPopulationVO popul : populList) { ComMngPopulationExcelVo populationExcelVo = new ComMngPopulationExcelVo(); BeanUtils.copyProperties(popul, populationExcelVo); // 设置性别 populationExcelVo.setSex(PopulSexEnum.getCnDescByName(popul.getSex())); // 设置政治面貌 populationExcelVo.setPoliticalOutlook( PopulPoliticalOutlookEnum.getCnDescByName(popul.getPoliticalOutlook())); // 设置是否租住 // populationExcelVo.setIsRent(PopulIsOkEnum.getCnDescByName(popul.getIsRent())); // 设置本地或外地 populationExcelVo.setOutOrLacal(PopulOutOrLocalEnum.getCnDescByName(popul.getOutOrLocal())); // 设置婚姻状况 populationExcelVo.setMarriage(PopulMarriageEnum.getCnDescByName(popul.getMarriage())); // 设置文化程度 populationExcelVo .setCultureLevel(PopulCultureLevelEnum.getCnDescByName(popul.getCultureLevel())); // 设置年龄 if (StringUtils.isNotEmpty(popul.getBirthday())) { populationExcelVo.setAge(AgeUtils.getAgeFromBirthTimes(popul.getBirthday())); } populationExcelVoList.add(populationExcelVo); } } excelWriter = EasyExcel.write(fileName, ComMngPopulationExcelVo.class) .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) .registerWriteHandler(new CustomSheetWriteHandler()).build(); WriteSheet writeSheet = EasyExcel.writerSheet("老人导出数据").build(); excelWriter.write(populationExcelVoList, writeSheet); excelWriter.finish(); File file = new File(fileName); inputStream = new FileInputStream(file); sftp.uploadMore(ftpUrl, name, inputStream); sftp.logout(); inputStream.close(); String absolutePath = file.getAbsolutePath(); boolean delete = file.delete(); log.info("删除excel【{}】结果【{}】", absolutePath, delete); } finally { // 千万别忘记finish 会帮忙关闭流 if (inputStream != null) { inputStream.close(); } if (excelWriter != null) { excelWriter.finish(); } } } return R.ok(excelUrl + name); } catch (Exception e) { e.printStackTrace(); log.error("文件传输失败【{}】", e.getMessage()); return R.fail(); } } @ApiOperation(value = "编辑实有人口_电子档案") @PostMapping("/edit/electronicArchives") public R editPopulation(@RequestBody UserElectronicFileVO userElectronicFileVO) { springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java
@@ -334,6 +334,17 @@ public R pagePopulation(@RequestBody ComMngPopulationDTO comMngPopulationVO) { return comMngPopulationService.pagePopulation(comMngPopulationVO); } /** * 社区后台老人导出管理列表 * * @param comMngPopulationVO * 查询参数 * @return 实有人口分页查询结果 */ @PostMapping("/population/exportOld") public R exportOld(@RequestBody ComMngPopulationDTO comMngPopulationVO) { return comMngPopulationService.exportOld(comMngPopulationVO); } /** * 根据身份证查询实有人口信息 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -152,6 +152,13 @@ @Param("comMngPopulationVO") ComMngPopulationDTO comMngPopulationVO); /** * 导出老人列表 * @param comMngPopulationVO * @return */ List<ComMngPopulationVO> exportOld(@Param("comMngPopulationVO") ComMngPopulationDTO comMngPopulationVO); /** * 分页查询特殊群体列表 * @param page 分页参数 * @param pageInputUserDTO 请求参数 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java
@@ -74,6 +74,15 @@ R pagePopulation(ComMngPopulationDTO comMngPopulationVO); /** * 老人导出 * * @param comMngPopulationVO * 查询参数 * @return 分页集合 */ R exportOld(ComMngPopulationDTO comMngPopulationVO); /** * 查询平台所有的实有人口 * * @return 实有人口集合 按照创建顺序倒序排列 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); } /** * 删除实有人口 * springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComMngPopulationDOMapper.xml
@@ -346,6 +346,68 @@ order by cmp.create_at desc </select> <select id="exportOld" resultType="com.panzhihua.common.model.vos.community.ComMngPopulationVO"> SELECT cmp.`name`, cmp.id, cmp.street_id, cmp.act_id, cmp.village_id, cmp.sex, cmp.card_no, cmp.road, cmp.door_no, cmp.floor, cmp.unit_no, cmp.house_no, cmp.political_outlook, cmp.work_company, cmp.special_situation, cmp.phone, cmp.remark, cmp.native_place, cmp.nation, cmpct.label, cmp.marriage, cmp.culture_level, cmp.profession, cmp.out_or_local, cmp.census_register, cmp.healthy, cmp.birthday, cmp.update_at, cmp.address, cmp.is_rent FROM com_mng_population_community_tags as cmpct LEFT JOIN com_mng_population AS cmp ON cmp.id = cmpct.population_id <where> <if test='comMngPopulationVO.name != null and comMngPopulationVO.name != ""'> AND cmp.`name` LIKE concat(#{comMngPopulationVO.name},'%') </if> <if test='comMngPopulationVO.label != null and comMngPopulationVO.label != ""'> AND cmpct.label LIKE concat('%',#{comMngPopulationVO.label},'%') </if> <if test='comMngPopulationVO.actId != null'> and cmpct.community_id = ${comMngPopulationVO.actId} </if> <if test='comMngPopulationVO.outOrLocal != null'> and cmp.out_or_local = #{comMngPopulationVO.outOrLocal} </if> <if test='comMngPopulationVO.villageId != null and comMngPopulationVO.villageId != ""'> and cmp.village_id = #{comMngPopulationVO.villageId} </if> <if test='comMngPopulationVO.road != null and comMngPopulationVO.road != ""'> AND cmp.road = #{comMngPopulationVO.road} </if> <if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo != ""'> AND cmp.door_no = #{comMngPopulationVO.doorNo} </if> <if test='comMngPopulationVO.floor != null and comMngPopulationVO.floor != ""'> AND cmp.floor = #{comMngPopulationVO.floor} </if> <if test='comMngPopulationVO.isDeath != null'> AND cmp.death = #{comMngPopulationVO.isDeath} </if> <if test='comMngPopulationVO.unitNo != null and comMngPopulationVO.unitNo != ""'> AND cmp.unit_no = #{comMngPopulationVO.unitNo} </if> <if test='comMngPopulationVO.houseNo != null and comMngPopulationVO.houseNo != ""'> AND cmp.house_no = #{comMngPopulationVO.houseNo} </if> <if test='comMngPopulationVO.sex != null and comMngPopulationVO.sex != ""'> AND cmp.sex = #{comMngPopulationVO.sex} </if> <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageStartTime != "" and comMngPopulationVO.ageEndTime == null'> AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ <= ]]> #{comMngPopulationVO.ageStartTime} </if> <if test='comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageEndTime != "" and comMngPopulationVO.ageStartTime == null'> AND date_format(cmp.birthday,'%Y-%m-%d') <![CDATA[ >= ]]> #{comMngPopulationVO.ageEndTime} </if> <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime == comMngPopulationVO.ageEndTime'> AND cmp.birthday BETWEEN #{comMngPopulationVO.ageStartTimeEnd} and #{comMngPopulationVO.ageEndTime} </if> <if test='comMngPopulationVO.ageStartTime != null and comMngPopulationVO.ageEndTime != null and comMngPopulationVO.ageStartTime != comMngPopulationVO.ageEndTime'> AND cmp.birthday BETWEEN #{comMngPopulationVO.ageEndTimeEnd} and #{comMngPopulationVO.ageStartTime} </if> <if test='comMngPopulationVO.nativePlace != null and comMngPopulationVO.nativePlace != ""'> AND cmp.native_place LIKE concat(#{comMngPopulationVO.nativePlace},'%') </if> <if test='comMngPopulationVO.nation != null and comMngPopulationVO.nation != ""'> AND cmp.nation = #{comMngPopulationVO.nation} </if> <if test='comMngPopulationVO.politicalOutlook != null and comMngPopulationVO.politicalOutlook != ""'> AND cmp.political_outlook = #{comMngPopulationVO.politicalOutlook} </if> <if test='comMngPopulationVO.cardNo != null and comMngPopulationVO.cardNo != ""'> AND cmp.card_no = #{comMngPopulationVO.cardNo} </if> <if test='comMngPopulationVO.remark != null and comMngPopulationVO.remark != ""'> AND cmp.remark = #{comMngPopulationVO.remark} </if> <if test='comMngPopulationVO.keyWord != null and comMngPopulationVO.keyWord != ""'> AND (cmp.`name` like concat (#{comMngPopulationVO.keyWord},'%') or cmp.card_no_str = #{comMngPopulationVO.keyWord} or cmpct.label like concat ('%',#{comMngPopulationVO.keyWord},'%') or cmp.phone like concat ('%',#{comMngPopulationVO.keyWord},'%') ) </if> </where> order by cmp.create_at desc </select> <select id="specialInputUser" resultType="com.panzhihua.common.model.vos.user.InputUserInfoVO"> SELECT cmp.id,