deason 3 tahun lalu
induk
melakukan
8ee857b89f

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

@@ -10,6 +10,12 @@ public class FaceLiveVerifyInfo implements JsonSerializable {
     @ApiModelProperty(value = "当前活检记录ID")
     private Long faceLiveVerifyId;
 
+    @ApiModelProperty(value = "当前活检开始时间")
+    private Integer startMinute;
+
+    @ApiModelProperty(value = "当前第几次活检")
+    private Integer times;
+
     public Long getFaceLiveVerifyId() {
         return faceLiveVerifyId;
     }
@@ -18,4 +24,20 @@ public class FaceLiveVerifyInfo implements JsonSerializable {
         this.faceLiveVerifyId = faceLiveVerifyId;
     }
 
+    public Integer getStartMinute() {
+        return startMinute;
+    }
+
+    public void setStartMinute(Integer startMinute) {
+        this.startMinute = startMinute;
+    }
+
+    public Integer getTimes() {
+        return times;
+    }
+
+    public void setTimes(Integer times) {
+        this.times = times;
+    }
+
 }

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

@@ -28,8 +28,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Optional;
 
 @Service
@@ -64,17 +66,38 @@ public class ExamFaceLiveVerifyServiceImpl implements ExamFaceLiveVerifyService
             throw new StatusException("考试会话已过期");
         }
 
-        ExamFaceLiveVerifyEntity entity = new ExamFaceLiveVerifyEntity();
-        entity.setExamRecordDataId(examRecordDataId);
-        entity.setFinished(false);
-        entity.setStatus(FaceLiveVerifyStatus.ERROR);
-        examFaceLiveVerifyRepo.save(entity);
+        int times = 1;
+        Long faceLiveVerifyId = null;
+        List<ExamFaceLiveVerifyEntity> entities = examFaceLiveVerifyRepo.findByExamRecordDataId(examRecordData.getId());
+        if (!CollectionUtils.isEmpty(entities)) {
+            for (ExamFaceLiveVerifyEntity entity : entities) {
+                if (entity.getFinished()) {
+                    times++;
+                } else {
+                    faceLiveVerifyId = entity.getId();
+                }
+            }
+        }
 
-        FaceLiveVerifyInfo info = new FaceLiveVerifyInfo();
-        info.setFaceLiveVerifyId(entity.getId());
+        if (times > 2) {
+            throw new StatusException("活检次数不能超过2次");
+        }
 
-        // todo 第几次活检、活检开始时间
+        if (faceLiveVerifyId == null) {
+            ExamFaceLiveVerifyEntity entity = new ExamFaceLiveVerifyEntity();
+            entity.setExamRecordDataId(examRecordDataId);
+            entity.setFinished(false);
+            entity.setStatus(FaceLiveVerifyStatus.ERROR);
+            examFaceLiveVerifyRepo.save(entity);
+            faceLiveVerifyId = entity.getId();
+        }
+
+        Integer startMinute = this.calculateStartFaceVerifyMinute(examRecordDataId);
 
+        FaceLiveVerifyInfo info = new FaceLiveVerifyInfo();
+        info.setFaceLiveVerifyId(faceLiveVerifyId);
+        info.setStartMinute(startMinute);
+        info.setTimes(times);
         return info;
     }