From 9176a251e4053adbd3dfd0032170c92073a0ed34 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 14 Jun 2022 17:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E4=B8=8B=E5=BC=80=E5=8F=91=E8=AF=95?= =?UTF-8?q?=E8=AF=95=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/utils/ExcelPoiUtils.java | 2 +- ...cCommunitySelfOrganizationServiceImpl.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java index 43f5bb5a88..199fe6dcdb 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java @@ -238,7 +238,7 @@ public class ExcelPoiUtils { params.setTitleRows(titleRows); params.setHeadRows(headerRows); params.setSaveUrl("/tmp/excel/"); - params.setNeedSave(false); + params.setNeedSave(true); try { // return ExcelImportUtil.importExcel(inputStream, pojoClass, params); return (new ExcelImportService()).importExcelByIs(inputStream, pojoClass, params, false); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index aadefc5244..702125cd3d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -510,16 +510,18 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); CommunitySelfOrgImportExcel excel = null; //1.读取Excel数据 - ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcelMore(inputStream,0,2,ImportCommunitySelfOrganization.class); + ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcel1(inputStream,0,2,ImportCommunitySelfOrganization.class); //2.存在错误行数据时存入错误数据集合中 - for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { - //打印失败的行 和失败的信息 - log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); - excel = new CommunitySelfOrgImportExcel(); - //excel.setAgencyName(entity.getOrganizationName()); - excel.setSocietyName(entity.getOrganizationName()); - excel.setErrorInfo(entity.getErrorMsg()); - fileList.add(excel); + if(CollectionUtils.isNotEmpty(testExcelImportResult.getFailList())){ + for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { + //打印失败的行 和失败的信息 + log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); + excel = new CommunitySelfOrgImportExcel(); + //excel.setAgencyName(entity.getOrganizationName()); + excel.setSocietyName(entity.getOrganizationName()); + excel.setErrorInfo(entity.getErrorMsg()); + fileList.add(excel); + } } //正确行数据集合 List list = testExcelImportResult.getList();