|
@@ -33,6 +33,7 @@ import javax.annotation.PreDestroy;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
import java.nio.file.Files;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.zip.ZipEntry;
|
|
@@ -288,47 +289,56 @@ public class AcsService {
|
|
|
JsonArray userInfoArray = jsonObject
|
|
|
.getAsJsonObject("UserInfoSearch")
|
|
|
.getAsJsonArray("UserInfo");
|
|
|
-
|
|
|
- if (userInfoArray != null) {//考勤机里有用户
|
|
|
- String msg = addFaceByUrl(userNumber,photoUrl);
|
|
|
- if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
- return "更新人脸失败";
|
|
|
- } else {
|
|
|
- if (user!=null) {
|
|
|
- user.setPhotoUrl(photoUrl);
|
|
|
- userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
- }
|
|
|
- return "更新人脸成功";
|
|
|
- }
|
|
|
- } else {//考勤及里面没用户
|
|
|
- //确保在执行完增加用户后执行增加人脸
|
|
|
- CompletableFuture<Void> userFuture = CompletableFuture.runAsync(() -> {
|
|
|
- try {
|
|
|
- addUser(userNumber, user.getNickname());
|
|
|
- } catch (JSONException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- });
|
|
|
- userFuture.thenRun(() -> {
|
|
|
- try {
|
|
|
- String msg = addFaceByUrl(userNumber, photoUrl);
|
|
|
- if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
- } else {
|
|
|
- if (user!=null) {
|
|
|
- user.setPhotoUrl(photoUrl);
|
|
|
- userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- });
|
|
|
- return "添加考勤用户并且增加照片成功";
|
|
|
- }
|
|
|
+ if (photoUrl.trim().isEmpty()&&user.getPhotoUrl()!=null){//去除空格后为空,删除人脸
|
|
|
+ deleteFace(userNumber);//考勤机里的
|
|
|
+ user.setPhotoUrl(photoUrl.trim());//同步更新user表里的
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
+ userService.updateUser(BeanUtils.toBean(user, UserSaveReqVO.class));
|
|
|
+ return "删除照片成功";
|
|
|
+ }else {
|
|
|
+ if (userInfoArray != null) {//考勤机里有用户
|
|
|
+ String msg = addFaceByUrl(userNumber, photoUrl);
|
|
|
+ if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
+ return "更新人脸失败";
|
|
|
+ } else {
|
|
|
+ if (user != null) {
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
+ user.setPhotoUrl(photoUrl);
|
|
|
+ userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
+ }
|
|
|
+ return "更新人脸成功";
|
|
|
+ }
|
|
|
+ } else {//考勤及里面没用户
|
|
|
+ //确保在执行完增加用户后执行增加人脸
|
|
|
+ CompletableFuture<Void> userFuture = CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ addUser(userNumber, user.getNickname());
|
|
|
+ } catch (JSONException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ userFuture.thenRun(() -> {
|
|
|
+ try {
|
|
|
+ String msg = addFaceByUrl(userNumber, photoUrl);
|
|
|
+ if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
+ } else {
|
|
|
+ if (user != null) {
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
+ user.setPhotoUrl(photoUrl);
|
|
|
+ userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return "添加考勤用户并且增加照片成功";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -343,9 +353,10 @@ public class AcsService {
|
|
|
.getAsJsonObject("UserInfoSearch")
|
|
|
.getAsJsonArray("UserInfo");
|
|
|
|
|
|
- if (photoUrl.trim().isEmpty()){//去除空格后为空,删除人脸
|
|
|
+ if (photoUrl.trim().isEmpty()&&user.getPhotoUrl()!=null){//去除空格后为空,删除人脸
|
|
|
deleteFace(employeeNo);//考勤机里的
|
|
|
user.setPhotoUrl(photoUrl.trim());//同步更新user表里的
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
userService.updateUser(BeanUtils.toBean(user, UserSaveReqVO.class));
|
|
|
return "删除照片成功";
|
|
|
}else {
|
|
@@ -356,6 +367,7 @@ public class AcsService {
|
|
|
} else {
|
|
|
if (user != null) {
|
|
|
user.setPhotoUrl(photoUrl);
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
}
|
|
|
return "更新照片成功";
|
|
@@ -379,6 +391,7 @@ public class AcsService {
|
|
|
if (msg.contains("下发人脸成功") && msg.contains("但是有异常情况")) {
|
|
|
} else {
|
|
|
if (user!=null) {
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
user.setPhotoUrl(photoUrl);
|
|
|
userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
}
|
|
@@ -473,6 +486,7 @@ public class AcsService {
|
|
|
} else {
|
|
|
respVO.getCreateImages().add(studentName);//添加成功
|
|
|
if (user!=null) {
|
|
|
+ user.setPhotoUpdateTime(LocalDateTime.now());
|
|
|
user.setPhotoUrl(photoUrl);
|
|
|
userService.updateUser((BeanUtils.toBean(user, UserSaveReqVO.class)));
|
|
|
}
|