自测问题修改

This commit is contained in:
cwchen 2024-08-20 12:30:21 +08:00
parent ed1564e307
commit d48af7fd7d
1 changed files with 12 additions and 0 deletions

View File

@ -238,6 +238,7 @@ public class ImportExcelUtils {
* @throws IOException
*/
public static Map<String, PictureData> getPicturesXlsx(XSSFSheet sheet, String className) throws IOException {
List<String> keyNameList = new ArrayList<>();
Map<String, PictureData> map = new HashMap<>(16);
List<POIXMLDocumentPart> 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<String> 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<String, PictureData> getPicturesXls(HSSFSheet sheet, String className) throws IOException {
List<String> keyNameList = new ArrayList<>();
int i = 0;
Map<String, PictureData> map = new HashMap<String, PictureData>(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<String> setList = new HashSet<>(keyNameList);
if(setList.size()!=keyNameList.size()){
throw new RuntimeException("模版中人脸照片单元格存在多张图片,请仔细检查");
}
return map;
}