From bb0875bb4f0193d6cdc7774f7367821e38dee1fe Mon Sep 17 00:00:00 2001 From: caihaohan Date: Mon, 6 Nov 2023 18:15:21 +0800 Subject: [PATCH] fix: 78190 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 企标--导入--导入文件夹内的excel文件与下载模板的名称不一样提示语不对 --- .../service/impl/LawsCommonServiceImpl.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java index 90bb9031..91f956e7 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java @@ -1452,7 +1452,28 @@ public class LawsCommonServiceImpl implements ILawsCommonService { FileUnZip.deleteDir(saveDirectory); throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR)); } - + String excelName = excelfilelist.get(0).getName(); + if (tableName.equals(TableNameEnum.ENTERPRISE_STANDARDS.getTableName())) { + // 检查Excel的文件名 + if (!excelName.equals("企业标准导入模板.xlsx")) { + FileUnZip.deleteDir(saveDirectory); + throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR)); + } + } + if (tableName.equals(TableNameEnum.DOMESTIC_REGULATIONS.getTableName())) { + // 检查Excel的文件名 + if (!excelName.equals("国内标准导入模板.xlsx")) { + FileUnZip.deleteDir(saveDirectory); + throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR)); + } + } + if (tableName.equals(TableNameEnum.FOREIGN_REGULATIONS.getTableName())) { + // 检查Excel的文件名 + if (!excelName.equals("海外标准导入模板.xlsx")) { + FileUnZip.deleteDir(saveDirectory); + throw new JeroBootException(MessageUtils.getMessage(ResultCommon.IMPORT_TEMPLATE_ERROR)); + } + } // 数据内容格式校验 Map fileMap = new HashMap<>(); try (Workbook workbook = new XSSFWorkbook(Files.newInputStream(excelfilelist.get(0).toPath()))) { @@ -1967,7 +1988,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService { ByteArrayOutputStream baosZip = new ByteArrayOutputStream(); try (ZipOutputStream zos = new ZipOutputStream(baosZip)) { // 添加第一个文件到ZIP中 - ZipEntry entry1 = new ZipEntry("企标导入模板.xlsx"); + ZipEntry entry1 = new ZipEntry("企标标准导入模板.xlsx"); zos.putNextEntry(entry1); zos.write(mainWorkbookBytes); zos.closeEntry();