deason 1 年之前
父節點
當前提交
3e97026107

+ 29 - 29
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/FaceBiopsyServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.JsonUtil;
+import cn.com.qmth.examcloud.commons.util.StringUtil;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.CommonUtil;
 import cn.com.qmth.examcloud.core.oe.student.bean.FaceBiopsyInfo;
 import cn.com.qmth.examcloud.core.oe.student.bean.FaceBiopsyStepInfo;
@@ -19,6 +20,8 @@ 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.FaceBiopsyService;
 import cn.com.qmth.examcloud.support.Constants;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
+import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
 import cn.com.qmth.examcloud.support.enums.ExamProperties;
 import cn.com.qmth.examcloud.support.enums.IsSuccess;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
@@ -146,27 +149,45 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
             throw new StatusException("201005", "检测结果不允许为空");
         }
 
+        ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
+        if (examRecordData == null) {
+            throw new StatusException("201010", "找不到相关考试记录数据");
+        }
+
+        // 是否考中活体不通过强制退出
+        ExamPropertyCacheBean examProperty = CacheHelper.getExamProperty(examRecordData.getExamId(), ExamProperties.FACE_VERIFY_FORCE_EXIT.name());
+        boolean isFaceVerifyForceExit = examProperty != null && StringUtil.isTrue(examProperty.getValue());
+
         //构建业务实体
-        SaveFaceBiopsyResultResp resp = buildSaveFaceBiopsyResultResp(req);
+        SaveFaceBiopsyResultResp resp = new SaveFaceBiopsyResultResp();
+
+        Boolean finalIsSuccess = calculateIsSuccess(req.getVerifySteps());
+        resp.setVerifyResult(finalIsSuccess);
+        resp.setErrorMessage(getErrorMsg(req.getVerifySteps()));
+
+        if(isFaceVerifyForceExit) {
+            Boolean isEndExam = calculateIsEndExam(req.getVerifySteps(), req.getExamRecordDataId(), finalIsSuccess);
+            resp.setEndExam(isEndExam);
+            resp.setNeedNextVerify(calculateNeedNextVerify(isEndExam, finalIsSuccess, req.getExamRecordDataId()));
+        }else {
+            // 若“考中活体不通过强制退出为false”,则首次活体不通过时,不结束考试继续作答,也不再次活体检测
+            resp.setEndExam(false);
+            resp.setNeedNextVerify(false);
+        }
 
         //更新人脸活体检测结果至数据库
         updateFaceBiopsyResult(req.getExamRecordDataId(), req.getFaceBiopsyItemId(), req.getVerifySteps(),
                 resp.getVerifyResult(), resp.getErrorMessage());
 
         //同步更新考试记录表中的活体检测结果
-        ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
-        if (examRecordData == null) {
-            throw new StatusException("201010", "找不到相关考试记录数据");
-        }
         examRecordData.setFaceVerifyResult(resp.getVerifyResult() ? IsSuccess.SUCCESS : IsSuccess.FAILED);
 
-        //活检失败,则认为违纪
-        if (!resp.getVerifyResult()) {
+        if (isFaceVerifyForceExit && !resp.getVerifyResult()) {
+            // 强制活检 且 活检失败,则认为违纪
             examRecordData.setIsIllegality(true);
         }
 
         examRecordDataService.saveExamRecordDataCache(req.getExamRecordDataId(), examRecordData);
-
         return resp;
     }
 
@@ -247,27 +268,6 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
         return generateOutFreezeTimeFaceBiopsyStartMinute(examRecordDataId);
     }
 
-    /**
-     * 构建保存人脸检测结果的业务实体
-     *
-     * @param req
-     * @return
-     */
-    private SaveFaceBiopsyResultResp buildSaveFaceBiopsyResultResp(SaveFaceBiopsyResultReq req) {
-        //构建业务实体
-        SaveFaceBiopsyResultResp resp = new SaveFaceBiopsyResultResp();
-
-        Boolean finalIsSuccess = calculateIsSuccess(req.getVerifySteps());
-        resp.setVerifyResult(finalIsSuccess);
-
-        Boolean isEndExam = calculateIsEndExam(req.getVerifySteps(), req.getExamRecordDataId(), finalIsSuccess);
-        resp.setEndExam(isEndExam);
-
-        resp.setNeedNextVerify(calculateNeedNextVerify(isEndExam, finalIsSuccess, req.getExamRecordDataId()));
-        resp.setErrorMessage(getErrorMsg(req.getVerifySteps()));
-        return resp;
-    }
-
     /**
      * 更新人脸活体检测结果至数据库
      *