|
@@ -13,9 +13,11 @@ import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.repository.FaceBiopsyItemRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.repository.FaceBiopsyItemStepRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.*;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.service.ExamFaceLivenessVerifyService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.ExamSessionInfoService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.FaceBiopsyService;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
@@ -47,7 +49,62 @@ public class FaceBiopsyController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
|
|
- @ApiOperation(value = "获取人脸活体检测基本信息")
|
|
|
+ @Autowired
|
|
|
+ private ExamFaceLivenessVerifyService examFaceLivenessVerifyService;
|
|
|
+
|
|
|
+ private final String NEW_FACE_BIOPSY_SCHEME = "S2";
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取活体检测基本信息")
|
|
|
+ @GetMapping("/getFaceBiopsyBaseInfo")
|
|
|
+ public FaceBiopsyBaseInfo getFaceBiopsyBaseInfo(@RequestParam Long examRecordDataId) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ Long studentId = user.getUserId();
|
|
|
+ String sequenceLockKey = Constants.GET_FACE_BIOPSY_INFO_PREFIX + studentId;
|
|
|
+ //系统在请求结束后会,自动释放锁,无需手动解锁
|
|
|
+ SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
+
|
|
|
+ //判断考试记录id是否有效
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
|
|
|
+ ExamRecordDataEntity.class);
|
|
|
+ if (examRecordData == null) {
|
|
|
+ throw new StatusException("200101", "无效的考试记录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取考试会话,判断考生是否已结束考试
|
|
|
+ ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(studentId);
|
|
|
+ if (examSessionInfo == null) {
|
|
|
+ throw new StatusException("200102", "考试会话已过期");
|
|
|
+ }
|
|
|
+
|
|
|
+ //考试未开启人脸活体检测,不允许获取活检信息
|
|
|
+ String isFaceVerifyStr = ExamCacheTransferHelper.getCachedExamProperty(examRecordData.getExamId(),
|
|
|
+ examRecordData.getOrgId(), examRecordData.getStudentId(),
|
|
|
+ ExamProperties.IS_FACE_VERIFY.name()).getValue();
|
|
|
+ if (!Constants.isTrue.equals(isFaceVerifyStr)) {
|
|
|
+ throw new StatusException("200103", "本场考试未开启人脸活体检测");
|
|
|
+ }
|
|
|
+
|
|
|
+ FaceBiopsyBaseInfo faceBiopsyBaseInfo = new FaceBiopsyBaseInfo();
|
|
|
+ OrgPropertyCacheBean orgProperty = CacheHelper.getOrgProperty(user.getRootOrgId(),
|
|
|
+ Constants.IDENTIFICATION_OF_LIVING_BODY_SCHEME_KEY);
|
|
|
+ faceBiopsyBaseInfo.setIdentificationOfLivingBodyScheme(orgProperty.getValue());
|
|
|
+ Integer faceVerifyMinute = null;
|
|
|
+ // 如果是新活体检测方案,则使用新的计算方案计算活检开始时间
|
|
|
+ if (NEW_FACE_BIOPSY_SCHEME.equals(orgProperty.getValue())) {
|
|
|
+ faceVerifyMinute = faceBiopsyService.getFaceBiopsyStartMinute(examRecordDataId);
|
|
|
+ }
|
|
|
+ // 非新活检,默认使用旧的活检计算方式
|
|
|
+ else {
|
|
|
+ faceVerifyMinute = examFaceLivenessVerifyService.getFaceLivenessVerifyMinute(
|
|
|
+ examRecordData.getOrgId(), examRecordData.getExamId(), studentId,
|
|
|
+ examRecordData.getId(), examSessionInfo.getHeartbeat());
|
|
|
+ }
|
|
|
+
|
|
|
+ faceBiopsyBaseInfo.setFaceVerifyMinute(faceVerifyMinute);
|
|
|
+ return faceBiopsyBaseInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取人脸活体检测详细步骤")
|
|
|
@GetMapping("/getFaceBiopsyInfo")
|
|
|
public FaceBiopsyInfo getFaceBiopsyInfo(@RequestParam Long examRecordDataId) {
|
|
|
User user = getAccessUser();
|