|
@@ -18,6 +18,9 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.sun.jna.Native;
|
|
|
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
|
|
|
import org.apache.tomcat.util.http.fileupload.FileUtils;
|
|
@@ -315,11 +318,22 @@ public class AcsService {
|
|
|
// AdminUserDO user = userService.findUserByUserNumber(importUser.getEmployeeNo());
|
|
|
// CompletableFuture<Void> addUserFuture = CompletableFuture.runAsync(() -> {
|
|
|
try {
|
|
|
- //用户名称与那users表里的相同
|
|
|
-// if (user.getNickname().equals(importUser.getName())) {
|
|
|
- UserManage.addUserInfo(lUserID, importUser.getEmployeeNo(), importUser.getName());
|
|
|
- System.out.println("添加用户成功");
|
|
|
-// }
|
|
|
+ String result = getUser(importUser.getEmployeeNo());
|
|
|
+ if ( result==null) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
|
|
|
+ JsonArray userInfoArray = jsonObject
|
|
|
+ .getAsJsonObject("UserInfoSearch")
|
|
|
+ .getAsJsonArray("UserInfo");
|
|
|
+ if (userInfoArray!=null) {
|
|
|
+ JsonObject userInfo = userInfoArray.get(0).getAsJsonObject();
|
|
|
+ String empNo = userInfo.get("employeeNo").getAsString();
|
|
|
+ if (empNo != null) {
|
|
|
+ UserManage.addUserInfo(lUserID, importUser.getEmployeeNo(), importUser.getName());
|
|
|
+ respVO.getCreateUsernames().add(importUser.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (UnsupportedEncodingException | InterruptedException | JSONException e) {
|
|
|
throw new RuntimeException("添加用户信息失败: " + e.getMessage(), e);
|
|
|
}
|
|
@@ -414,6 +428,7 @@ public class AcsService {
|
|
|
File tempDir = Files.createTempDirectory("users_images").toFile();
|
|
|
List<String> successUsers =new LinkedList<>();
|
|
|
List<String> failUsers =new LinkedList<>();
|
|
|
+ List<String> nullUsers =new LinkedList<>();
|
|
|
try (InputStream inputStream = file.getInputStream();
|
|
|
ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(inputStream)) {
|
|
|
ZipEntry entry;
|
|
@@ -437,15 +452,31 @@ public class AcsService {
|
|
|
bos.write(buffer, 0, len);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- String photoUrl = fileApi.createFile(Files.readAllBytes(newFile.toPath()));
|
|
|
- //给对应学号的人的照片添加
|
|
|
- String msg =addFaceByUrl( userNumber, photoUrl);
|
|
|
- //System.out.println("数据"+msg);
|
|
|
- if (msg.contains("下发人脸成功")&&msg.contains("但是有异常情况")){
|
|
|
- failUsers.add(studentName);
|
|
|
+ String result =getUser(userNumber);
|
|
|
+ if (result!=null){
|
|
|
+ Gson gson = new Gson();
|
|
|
+ JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
|
|
|
+
|
|
|
+ JsonArray userInfoArray = jsonObject
|
|
|
+ .getAsJsonObject("UserInfoSearch")
|
|
|
+ .getAsJsonArray("UserInfo");
|
|
|
+ if (userInfoArray!=null) {
|
|
|
+ JsonObject userInfo = userInfoArray.get(0).getAsJsonObject();
|
|
|
+ String empNo = userInfo.get("employeeNo").getAsString();
|
|
|
+ if (empNo != null) {
|
|
|
+ String photoUrl = fileApi.createFile(Files.readAllBytes(newFile.toPath()));
|
|
|
+ //给对应学号的人的照片添加
|
|
|
+ String msg = addFaceByUrl(userNumber, photoUrl);
|
|
|
+ //System.out.println("数据"+msg);
|
|
|
+ if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
+ failUsers.add(studentName);
|
|
|
+ } else {
|
|
|
+ successUsers.add(studentName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
- successUsers.add(studentName);
|
|
|
+ nullUsers.add(studentName);
|
|
|
}
|
|
|
continue;
|
|
|
// }else{
|
|
@@ -464,7 +495,10 @@ public class AcsService {
|
|
|
"}"+
|
|
|
"添加照片失败的用户{"
|
|
|
+failUsers+
|
|
|
- "}";
|
|
|
+ "}"+
|
|
|
+ "不存在的用户{"+
|
|
|
+ nullUsers+"}";
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 检查多个图片名称格式
|