Forráskód Böngészése

解决学生批量新增人脸爆粗哦问题

dzx 1 éve
szülő
commit
6d7f7ba729

+ 4 - 2
src/main/java/com/xjrsoft/common/utils/FileZipUtil.java

@@ -3,6 +3,7 @@ package com.xjrsoft.common.utils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.*;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.List;
@@ -177,10 +178,11 @@ public class FileZipUtil {
      */
     public static ZipFile convertToZipFile(MultipartFile multipartFile) throws IOException {
         // 创建临时文件
-        Path tempPath = Files.createTempFile("temp", ".zip");
+        String originalFilename = multipartFile.getOriginalFilename();
+        Path tempPath = Files.createTempFile("temp", originalFilename.substring(originalFilename.lastIndexOf('.')));
         multipartFile.transferTo(tempPath); // 将MultipartFile内容写入临时文件
 
         // 使用ZipFile读取临时文件
-        return new ZipFile(tempPath.toFile());
+        return new ZipFile(tempPath.toFile(), Charset.forName("GBK"));
     }
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/personnel/controller/StundentFaceProcessController.java

@@ -191,6 +191,9 @@ public class StundentFaceProcessController {
 
             String idNumber = filename.substring(0, 17);
             BaseStudentUser studentUser = studentMap.get(idNumber);
+            if(studentUser == null){
+                continue;
+            }
             //将照片转换成base64
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
             byte[] buffer = new byte[4096];