浏览代码

update calcFaceBiopsyResult

deason 3 年之前
父节点
当前提交
97a57bfce2

+ 2 - 0
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/ExamFaceLiveVerifyRepo.java

@@ -13,4 +13,6 @@ public interface ExamFaceLiveVerifyRepo extends JpaRepository<ExamFaceLiveVerify
 
     List<ExamFaceLiveVerifyEntity> findByExamRecordDataIdAndFinished(Long examRecordDataId, boolean finished);
 
+    List<ExamFaceLiveVerifyEntity> findByExamRecordDataId(Long examRecordDataId);
+
 }

+ 26 - 7
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java

@@ -9,12 +9,15 @@ import cn.com.qmth.examcloud.core.oe.student.api.response.CalcExamScoreResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CalcFaceBiopsyResultResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CheckPaperInExamResp;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.QuestionTypeUtil;
+import cn.com.qmth.examcloud.core.oe.student.dao.ExamFaceLiveVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamFaceLivenessVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.FaceBiopsyRepo;
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamFaceLiveVerifyEntity;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamFaceLivenessVerifyEntity;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.FaceBiopsyEntity;
+import cn.com.qmth.examcloud.core.oe.student.dao.enums.FaceLiveVerifyStatus;
 import cn.com.qmth.examcloud.core.oe.student.dao.enums.FaceVerifyResult;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordQuestionsService;
@@ -39,6 +42,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -68,6 +72,9 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     @Autowired
     private ExamFaceLivenessVerifyRepo examFaceLivenessVerifyRepo;
 
+    @Autowired
+    private ExamFaceLiveVerifyRepo examFaceLiveVerifyRepo;
+
     @Autowired
     private ExamRecordQuestionsService examRecordQuestionsService;
 
@@ -263,8 +270,21 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
             //是否进行活体检测
             if (FaceBiopsyHelper.isFaceVerify(rootOrgId, examId, studentId)) {
                 FaceBiopsyScheme faceBiopsyScheme = FaceBiopsyHelper.getFaceBiopsyScheme(rootOrgId);
-                //新活体检测方案
-                if (faceBiopsyScheme == FaceBiopsyScheme.FACE_MOTION) {
+
+                if (FaceBiopsyScheme.FACE_CLIENT == faceBiopsyScheme) {
+                    // C端活体检测方案
+                    List<ExamFaceLiveVerifyEntity> entities = examFaceLiveVerifyRepo.findByExamRecordDataId(examRecordData.getId());
+                    if (CollectionUtils.isEmpty(entities)) {
+                        return new CalcFaceBiopsyResultResp(true, true, IsSuccess.FAILED);
+                    }
+
+                    for (ExamFaceLiveVerifyEntity entity : entities) {
+                        if (FaceLiveVerifyStatus.SUCCESS == entity.getStatus()) {
+                            return new CalcFaceBiopsyResultResp(IsSuccess.SUCCESS);
+                        }
+                    }
+                } else if (faceBiopsyScheme == FaceBiopsyScheme.FACE_MOTION) {
+                    // Electron Client 自研活体检测方案
                     FaceBiopsyEntity faceBiopsy = faceBiopsyRepo.findByExamRecordDataId(examRecordData.getId());
 
                     //如果活检结果最终为true,只需要更新活检状态即可
@@ -273,11 +293,9 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
                     }
 
                     return new CalcFaceBiopsyResultResp(true, true, IsSuccess.FAILED);
-                }
-                //旧活体检测方案
-                else {
-                    List<ExamFaceLivenessVerifyEntity> faceVerifies =
-                            examFaceLivenessVerifyRepo.findByExamRecordDataIdOrderById(examRecordData.getId());
+                } else {
+                    // FaceID活体检测方案
+                    List<ExamFaceLivenessVerifyEntity> faceVerifies = examFaceLivenessVerifyRepo.findByExamRecordDataIdOrderById(examRecordData.getId());
 
                     if (null != faceVerifies && faceVerifies.size() > 0) {
                         ExamFaceLivenessVerifyEntity latestFaceVerify = faceVerifies.get(faceVerifies.size() - 1);
@@ -292,6 +310,7 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
                     return new CalcFaceBiopsyResultResp(true, true, IsSuccess.FAILED);
                 }
             }
+
             return new CalcFaceBiopsyResultResp();
         }
     }