From d48af7fd7d54dc71fd3553f3e36a3787db4edce8 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Tue, 20 Aug 2024 12:30:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=B5=8B=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/common/core/utils/ImportExcelUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/utils/ImportExcelUtils.java b/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/utils/ImportExcelUtils.java index 0a0a8d6..57d8b55 100644 --- a/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/utils/ImportExcelUtils.java +++ b/bonus-common/bonus-common-core/src/main/java/com/bonus/common/core/utils/ImportExcelUtils.java @@ -238,6 +238,7 @@ public class ImportExcelUtils { * @throws IOException */ public static Map getPicturesXlsx(XSSFSheet sheet, String className) throws IOException { + List keyNameList = new ArrayList<>(); Map map = new HashMap<>(16); List list = sheet.getRelations(); for (POIXMLDocumentPart part : list) { @@ -267,12 +268,17 @@ public class ImportExcelUtils { keyName = ""; } map.put(keyName, picture.getPictureData()); + keyNameList.add(keyName); } catch (Exception e) { throw new RuntimeException("模版中包含非图片(jpeg、jpg、png)的文件,请仔细检查"); } } } } + Set setList = new HashSet<>(keyNameList); + if(setList.size()!=keyNameList.size()){ + throw new RuntimeException("模版中人脸照片单元格存在多张图片,请仔细检查"); + } return map; } @@ -284,6 +290,7 @@ public class ImportExcelUtils { * @throws IOException */ public static Map getPicturesXls(HSSFSheet sheet, String className) throws IOException { + List keyNameList = new ArrayList<>(); int i = 0; Map map = new HashMap(16); if (sheet.getDrawingPatriarch() != null) { @@ -307,10 +314,15 @@ public class ImportExcelUtils { keyName = "file" + "_" + cAnchor.getRow1() + "_1"; } map.put(keyName, picture.getPictureData()); + keyNameList.add(keyName); } } } } + Set setList = new HashSet<>(keyNameList); + if(setList.size()!=keyNameList.size()){ + throw new RuntimeException("模版中人脸照片单元格存在多张图片,请仔细检查"); + } return map; }