From 14317726aca669284ddf4e6b65a03091d3826cd2 Mon Sep 17 00:00:00 2001 From: tangxiaobao <303826152@qq.com> Date: 星期四, 19 八月 2021 18:13:41 +0800 Subject: [PATCH] 实有人口和社区关系以及对应标签修改 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java | 68 ++------------------------------- 1 files changed, 5 insertions(+), 63 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java index bfca2d3..f1c9cfe 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java @@ -47,31 +47,18 @@ private Long communityId; + private Long userId; + private static int headSize = 0; private Map<Integer, String> headData; - private String userName; - // FTP 登录密码 - private String password; - // FTP 服务器地址IP地址 - private String host; - // FTP 端口 - private int port; - private String excelUrl; - private StringRedisTemplate stringRedisTemplate; - public static String loadUrl; - - public ComMngPopulationKeyExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + public ComMngPopulationKeyExcelListen(CommunityService communityService, Long communityId, Long userId, StringRedisTemplate stringRedisTemplate) { this.communityService = communityService; this.communityId = communityId; - this.userName = userName; - this.password = password; - this.host = host; - this.port = port; - this.excelUrl = excelUrl; + this.userId = userId; this.stringRedisTemplate = stringRedisTemplate; } @@ -348,7 +335,7 @@ //根据list中的IdCard城市来去重 List<ComMngPopulationKeyExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationKeyExcelVO::getDistinctPass)).collect(Collectors.toList()); log.info("开始进入业务层处理逻辑"); - R r = communityService.listSavePopulationKeyExcelVO(newVoList, communityId); + R r = communityService.listSavePopulationKeyExcelVO(newVoList, communityId, userId); log.info("业务层处理逻辑完成"); if (!R.isOk(r)) { log.info("业务层处理成功"); @@ -405,51 +392,6 @@ vo.setCensusRegister(map.get(16)); vo.setRemark(map.get(17)); } - - private R mistakeExportPopulation(List<ComMngPopulationMistakeExcelVO> vo) { - //生成动态模板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 { - excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); - WriteSheet writeSheet = EasyExcel.writerSheet("实有人口错误数据").build(); - excelWriter.write(vo, 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(); - } - } private String convertMarriage(String ma) { -- Gitblit v1.7.1