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; }