deason 3 lat temu
rodzic
commit
9eeb48200d

+ 14 - 0
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamFaceLiveVerifyServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.qmth.examcloud.core.oe.student.service.ExamFaceLiveVerifyService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
 import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
+import cn.com.qmth.examcloud.support.enums.IsSuccess;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import org.slf4j.Logger;
@@ -70,6 +71,7 @@ public class ExamFaceLiveVerifyServiceImpl implements ExamFaceLiveVerifyService
         Check.isNull(req.getFaceLiveVerifyId(), "当前活检记录ID不能为空");
         Check.isNull(req.getExamRecordDataId(), "考试记录ID不能为空");
         Check.isNull(req.getStatus(), "人脸活体验证状态不能为空");
+        Check.isEmpty(req.getActions(), "动作验证列表不能为空");
 
         ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
         if (examRecordData == null || ExamRecordStatus.EXAM_ING != examRecordData.getExamRecordStatus()) {
@@ -90,6 +92,11 @@ public class ExamFaceLiveVerifyServiceImpl implements ExamFaceLiveVerifyService
         }
 
         ExamFaceLiveVerifyEntity entity = optional.get();
+        if (entity.getFinished()) {
+            log.warn("当前活检记录已完成!faceLiveVerifyId = {}", req.getFaceLiveVerifyId());
+            return;
+        }
+
         entity.setFinished(true);
         entity.setStatus(req.getStatus());
         entity.setFaceCount(req.getFaceCount());
@@ -100,6 +107,13 @@ public class ExamFaceLiveVerifyServiceImpl implements ExamFaceLiveVerifyService
         entity.setActions(new JsonMapper().toJson(req.getActions()));
         entity.setUpdateTime(new Date());
         examFaceLiveVerifyRepo.save(entity);
+
+        examRecordData.setFaceVerifyResult(FaceLiveVerifyStatus.SUCCESS == req.getStatus() ? IsSuccess.SUCCESS : IsSuccess.FAILED);
+        if (FaceLiveVerifyStatus.SUCCESS != req.getStatus()) {
+            // 活检失败,则认为违纪
+            examRecordData.setIsIllegality(true);
+        }
+        examRecordDataService.saveExamRecordDataCache(req.getExamRecordDataId(), examRecordData);
     }
 
 }

+ 11 - 0
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/FaceProcessServiceImpl.java

@@ -8,10 +8,12 @@ import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceCompareResult;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamCaptureRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureEntity;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
+import cn.com.qmth.examcloud.core.oe.student.service.ExamingSessionService;
 import cn.com.qmth.examcloud.core.oe.student.service.FaceProcessService;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
+import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONArray;
@@ -32,6 +34,9 @@ public class FaceProcessServiceImpl implements FaceProcessService {
     @Autowired
     private ExamRecordDataService examRecordDataService;
 
+    @Autowired
+    private ExamingSessionService examingSessionService;
+
     @Autowired
     private ExamCaptureRepo examCaptureRepo;
 
@@ -69,6 +74,12 @@ public class FaceProcessServiceImpl implements FaceProcessService {
             return;
         }
 
+        ExamingSession examingSession = examingSessionService.getExamingSession(req.getStudentId());
+        if (examingSession == null) {
+            log.warn("考试会话已过期!examRecordDataId = {}, studentId = {}", req.getExamRecordDataId(), req.getStudentId());
+            return;
+        }
+
         ExamCaptureEntity entity = new ExamCaptureEntity();
         entity.setExamRecordDataId(req.getExamRecordDataId());
         entity.setIsPass(req.getPass());