huanghongfa
2021-04-26 231e22e6372433c833fbcef05b6f9ea48910fb15
修改bug
7个文件已修改
154 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java
@@ -180,7 +180,7 @@
                }
                for (int i = 18; i < headSize; i++) {
                    if (oneData.get(i) != null && oneData.get(i).equals("是")) {
                        vo.getUserTagStr().add(headData.get(i));
                        vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("(")));
                    }
                }
                voList.add(vo);
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java
@@ -2171,4 +2171,12 @@
     */
    @PostMapping("common/data/special/page")
    R specialInputUser(@RequestBody PageInputUserDTO pageInputUserDTO);
    /**
     * 删除特殊群体人员
     * @param id    特殊群体id
     * @return  删除结果
     */
    @PostMapping("common/data/special/delete")
    R deleteSpecialInputUser(@RequestParam(value = "id") Long id);
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java
@@ -345,18 +345,71 @@
        return userService.deleteSpecialInputUser(id);
    }
    @ApiOperation(value = "特殊群体 导出特殊群体Excel")
//    @ApiOperation(value = "特殊群体 导出特殊群体Excel")
//    @PostMapping("/special/export")
//    public R exportSpecial(@RequestBody ExportSpecialUserDTO exportSpecialUserDTO) {
//        exportSpecialUserDTO.setCommunityId(this.getCommunityId());
//        String url = excelUrl;
//        String uuid = UUID.randomUUID().toString().replace("-", "");
//        String name = uuid + ".xlsx";
//        String ftpUrl = "/mnt/data/web/excel/";
////        用户搜索了就下载搜索的用户否则下载所有用户
//        R r = userService.specialUserExport(exportSpecialUserDTO);
//        if (R.isOk(r)) {
//            List<EexcelUserDTO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), EexcelUserDTO.class);
//            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 {
//                        excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
//                        WriteSheet writeSheet = EasyExcel.writerSheet("模板").build();
//                        excelWriter.write(eexcelUserDTOS, 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(url + name);
//            } catch (Exception e) {
//                e.printStackTrace();
//                log.error("文件传输失败【{}】", e.getMessage());
//                return R.fail();
//            }
//        }
//        return R.fail("未查询到用户");
//    }
    @ApiOperation(value = "特殊群体-数据导出")
    @PostMapping("/special/export")
    public R exportSpecial(@RequestBody ExportSpecialUserDTO exportSpecialUserDTO) {
        exportSpecialUserDTO.setCommunityId(this.getCommunityId());
        String url = excelUrl;
        String uuid = UUID.randomUUID().toString().replace("-", "");
        String name = uuid + ".xlsx";
    public R dataExportSpecilPopulation() {
        //获取登陆用户
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        //获取登陆用户绑定社区id
        Long communityId = loginUserInfo.getCommunityId();
        //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
        String ftpUrl = "/mnt/data/web/excel/";
//        用户搜索了就下载搜索的用户否则下载所有用户
        R r = userService.specialUserExport(exportSpecialUserDTO);
        if (R.isOk(r)) {
            List<EexcelUserDTO> eexcelUserDTOS = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), EexcelUserDTO.class);
        String name = "特殊群体导出数据.xlsx";
            try {
                SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
                sftp.login();
@@ -368,9 +421,28 @@
                    ExcelWriter excelWriter = null;
                    InputStream inputStream = null;
                    try {
                        excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet("模板").build();
                        excelWriter.write(eexcelUserDTOS, writeSheet);
                    List<ComMngPopulationVO> populList = JSON.parseArray(JSON.toJSONString(communityService.getPopulationListByCommunityId(communityId).getData()),ComMngPopulationVO.class);
                    List<ComMngPopulationExcelVo> populationExcelVoList = new ArrayList<>();
                    if(populList != null && populList.size() > 0){
                        for (ComMngPopulationVO popul:populList){
                            if(popul.getLabel() == null){
                                continue;
                            }
                            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()));
                            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);
@@ -390,14 +462,12 @@
                        }
                    }
                }
                return R.ok(url + name);
            return R.ok(excelUrl + name);
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }
        return R.fail("未查询到用户");
    }
    @ApiOperation(value = "特殊群体/分页查询标签列表", response = ComMngTagVO.class)
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java
@@ -361,4 +361,14 @@
    public R specialInputUser(@RequestBody PageInputUserDTO pageInputUserDTO) {
        return comMngPopulationService.specialInputUser(pageInputUserDTO);
    }
    /**
     * 删除特殊群体人员
     * @param id    特殊群体id
     * @return  删除结果
     */
    @PostMapping("/special/delete")
    public R deleteSpecialInputUser(@RequestParam(value = "id") Long id){
        return comMngPopulationService.deleteSpecialInputUser(id);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -172,7 +172,7 @@
    @Select("<script> " +
            "select cmp.id,cmv.`alley` as areaName,cmp.`name`,cmp.phone,cmp.label as tags,cmp.create_at from com_mng_population as cmp " +
            "left join com_mng_village as cmv on cmv.village_id = cmp.village_id where cmp.act_id = #{pageInputUserDTO.communityId} " +
            "left join com_mng_village as cmv on cmv.village_id = cmp.village_id where cmp.act_id = #{pageInputUserDTO.communityId} and cmp.label is not null " +
            "<if test='pageInputUserDTO.name != null and pageInputUserDTO.name != &quot;&quot;'>" +
            " AND cmp.`name` LIKE concat(#{pageInputUserDTO.name},'%') " +
            " </if> " +
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java
@@ -114,4 +114,11 @@
     * @return  特殊群体列表
     */
    R specialInputUser(PageInputUserDTO pageInputUserDTO);
    /**
     * 删除特殊群体人员
     * @param id    特殊群体id
     * @return  删除结果
     */
    R deleteSpecialInputUser(Long id);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -234,9 +234,6 @@
            comMngPopulationDO.setActId(comActDO.getCommunityId());
            comMngPopulationDO.setStreetId(comActDO.getStreetId());
            comMngPopulationDO.setLabel(Joiner.on(",").join(userTag));
            if(!userTag.isEmpty()){
                //特殊群体插入
            }
            comMngPopulationDO.setVillageName(comMngVillageDO.getGroupAt());
            populationDOList.add(comMngPopulationDO);
            index++;
@@ -436,4 +433,24 @@
                ,pageInputUserDTO.getPageSize()), pageInputUserDTO);
        return R.ok(iPage);
    }
    /**
     * 删除特殊群体人员
     * @param id    特殊群体id
     * @return  删除结果
     */
    @Override
    public R deleteSpecialInputUser(Long id){
        //查询特殊群体人员
        ComMngPopulationDO populationDO = this.baseMapper.selectById(id);
        if(populationDO == null){
            return R.fail("未查询到该记录");
        }
        populationDO.setLabel(null);
        if(this.baseMapper.updateById(populationDO) > 0){
            return R.ok();
        }else{
            return R.fail();
        }
    }
}