deason 3 years ago
parent
commit
792515360b

+ 1 - 27
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/entity/ExamFaceLiveVerifyEntity.java

@@ -35,7 +35,7 @@ public class ExamFaceLiveVerifyEntity extends JpaEntity {
     private FaceLiveVerifyStatus status;
 
     /**
-     * 动作验证列表
+     * 动作验证列表,JSON格式
      */
     @Column(length = 2000)
     private String actions;
@@ -60,16 +60,6 @@ public class ExamFaceLiveVerifyEntity extends JpaEntity {
      */
     private Long processTime;
 
-    /**
-     * 验证次数
-     */
-    private Integer verifyTimes;
-
-    /**
-     * 是否错误
-     */
-    private Boolean hasError;
-
     /**
      * 错误信息
      */
@@ -140,22 +130,6 @@ public class ExamFaceLiveVerifyEntity extends JpaEntity {
         this.processTime = processTime;
     }
 
-    public Integer getVerifyTimes() {
-        return verifyTimes;
-    }
-
-    public void setVerifyTimes(Integer verifyTimes) {
-        this.verifyTimes = verifyTimes;
-    }
-
-    public Boolean getHasError() {
-        return hasError;
-    }
-
-    public void setHasError(Boolean hasError) {
-        this.hasError = hasError;
-    }
-
     public String getErrorMsg() {
         return errorMsg;
     }

+ 5 - 5
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/enums/FaceLiveVerifyStatus.java

@@ -5,15 +5,15 @@ package cn.com.qmth.examcloud.core.oe.student.dao.enums;
  */
 public enum FaceLiveVerifyStatus {
 
-    none("验证成功"),// 无异常
+    SUCCESS("验证成功"),
 
-    liveness_action_error("活检动作错误"),
+    ACTION_FAILED("动作有误,验证失败"),
 
-    face_count_error("人脸数量异常"),
+    NOT_ONESELF("不是本人"),
 
-    face_compare_error("人脸比对异常"),
+    TIME_OUT("超时未完成"),
 
-    unknown("未知");
+    ERROR("验证异常");
 
     private String description;
 

+ 18 - 7
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/bean/client/FaceLiveVerifyAction.java

@@ -16,15 +16,18 @@ public class FaceLiveVerifyAction implements JsonSerializable {
     @ApiModelProperty(value = "是否通过")
     private Boolean pass;
 
-    @ApiModelProperty(value = "图片地址")
+    @ApiModelProperty(value = "动作文件地址")
     private String fileUrl;
 
-    @ApiModelProperty(value = "操作次数")
-    private Integer operateNum;
+    @ApiModelProperty(value = "尝试操作次数")
+    private Integer retry;
 
     @ApiModelProperty(value = "处理耗时(毫秒)")
     private Long processTime;
 
+    @ApiModelProperty(value = "错误信息")
+    private String errorMsg;
+
     public String getType() {
         return type;
     }
@@ -49,12 +52,12 @@ public class FaceLiveVerifyAction implements JsonSerializable {
         this.fileUrl = fileUrl;
     }
 
-    public Integer getOperateNum() {
-        return operateNum;
+    public Integer getRetry() {
+        return retry;
     }
 
-    public void setOperateNum(Integer operateNum) {
-        this.operateNum = operateNum;
+    public void setRetry(Integer retry) {
+        this.retry = retry;
     }
 
     public Long getProcessTime() {
@@ -65,4 +68,12 @@ public class FaceLiveVerifyAction implements JsonSerializable {
         this.processTime = processTime;
     }
 
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+
 }

+ 0 - 22
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/bean/client/FaceLiveVerifyResult.java

@@ -37,12 +37,6 @@ public class FaceLiveVerifyResult implements JsonSerializable {
     @ApiModelProperty(value = "处理耗时(毫秒)")
     private Long processTime;
 
-    @ApiModelProperty(value = "验证次数")
-    private Integer verifyTimes;
-
-    @ApiModelProperty(value = "是否错误")
-    private Boolean hasError;
-
     @ApiModelProperty(value = "错误信息")
     private String errorMsg;
 
@@ -110,22 +104,6 @@ public class FaceLiveVerifyResult implements JsonSerializable {
         this.processTime = processTime;
     }
 
-    public Integer getVerifyTimes() {
-        return verifyTimes;
-    }
-
-    public void setVerifyTimes(Integer verifyTimes) {
-        this.verifyTimes = verifyTimes;
-    }
-
-    public Boolean getHasError() {
-        return hasError;
-    }
-
-    public void setHasError(Boolean hasError) {
-        this.hasError = hasError;
-    }
-
     public String getErrorMsg() {
         return errorMsg;
     }

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

@@ -1,13 +1,16 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import cn.com.qmth.examcloud.commons.util.FileUtil;
+import cn.com.qmth.examcloud.commons.util.JsonMapper;
 import cn.com.qmth.examcloud.core.oe.student.base.bean.CompareFaceSyncInfo;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
 import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceCaptureResult;
 import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceCompareResult;
 import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceLiveVerifyResult;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamCaptureRepo;
+import cn.com.qmth.examcloud.core.oe.student.dao.ExamFaceLiveVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureEntity;
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamFaceLiveVerifyEntity;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.core.oe.student.service.FaceProcessService;
 import cn.com.qmth.examcloud.support.Constants;
@@ -36,6 +39,9 @@ public class FaceProcessServiceImpl implements FaceProcessService {
     @Autowired
     private ExamCaptureRepo examCaptureRepo;
 
+    @Autowired
+    private ExamFaceLiveVerifyRepo examFaceLiveVerifyRepo;
+
     @Autowired
     private RedisClient redisClient;
 
@@ -109,7 +115,27 @@ public class FaceProcessServiceImpl implements FaceProcessService {
 
     @Override
     public void saveFaceLiveVerifyResult(FaceLiveVerifyResult req) {
-        //todo
+        Check.isNull(req.getStudentId(), "学生ID不能为空");
+        Check.isNull(req.getExamRecordDataId(), "考试记录ID不能为空");
+        Check.isNull(req.getStatus(), "人脸活体验证状态不能为空");
+
+        ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
+        if (examRecordData == null || ExamRecordStatus.EXAM_ING != examRecordData.getExamRecordStatus()) {
+            // 考试记录无效
+            log.warn("Skip saveFaceLiveVerifyResult... examRecordDataId = {}", req.getExamRecordDataId());
+            return;
+        }
+
+        ExamFaceLiveVerifyEntity entity = new ExamFaceLiveVerifyEntity();
+        entity.setExamRecordDataId(req.getExamRecordDataId());
+        entity.setStatus(req.getStatus());
+        entity.setFaceCount(req.getFaceCount());
+        entity.setSimilarity(req.getSimilarity());
+        entity.setRealness(req.getRealness());
+        entity.setErrorMsg(req.getErrorMsg());
+        entity.setProcessTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
+        entity.setActions(new JsonMapper().toJson(req.getActions()));
+        examFaceLiveVerifyRepo.save(entity);
     }
 
 }