|
@@ -1,6 +1,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.core.oe.common.base.Constants;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
|
|
|
import cn.com.qmth.examcloud.core.oe.common.base.utils.CommonUtil;
|
|
@@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description 人脸活体检测接口实现类
|
|
@@ -82,7 +84,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
if (unCompletedFaceBiopsyItemList != null && !unCompletedFaceBiopsyItemList.isEmpty()) {
|
|
|
FaceBiopsyItemEntity faceBiopsyItemEntity = unCompletedFaceBiopsyItemList.get(0);
|
|
|
result.setFaceBiopsyItemId(faceBiopsyItemEntity.getId());
|
|
|
- result.setFaceVerifyMinute(calculateFaceBiopsyStartMinute(examRecordDataId, faceBiopsyEntity.getVerifiedTimes()));
|
|
|
+ result.setFaceVerifyMinute(getFaceBiopsyStartMinute(examRecordDataId));
|
|
|
|
|
|
List<FaceBiopsyItemStepEntity> faceBiopsyItemStepEntityList =
|
|
|
faceBiopsyItemStepRepo.findByFaceBiopsyItemId(faceBiopsyItemEntity.getId());
|
|
@@ -140,15 +142,17 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
|
|
|
ExamRecordDataEntity.class);
|
|
|
|
|
|
- //如果冻结时间外不添加活体检测,则已活检测次数为>=2次,超过两次,则返回null
|
|
|
+ //如果冻结时间外不添加活体检测
|
|
|
if (!addFaceVerifyOutFreezeTime(examRecordData.getExamId(), examRecordData.getOrgId(),
|
|
|
examRecordData.getStudentId())) {
|
|
|
+ //如果已活检测次数为>=2次,超过两次,则返回null
|
|
|
if (faceBiopsyEntity.getVerifiedTimes() >= 2) {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
- //如果冻结时间外添加新活检,则已最大活检次数>=3次,则返回null
|
|
|
+ //如果冻结时间外添加新活检
|
|
|
else {
|
|
|
+ //如果已最大活检次数>=3次,则返回null
|
|
|
if (faceBiopsyEntity.getVerifiedTimes() >= 3) {
|
|
|
return null;
|
|
|
}
|
|
@@ -171,7 +175,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
String errorMsg = null;
|
|
|
/**
|
|
|
* 是否结束考试
|
|
|
- * case1:人脸比对失败(即活检第1步,action==FACE_COMPARE)时,结束考试
|
|
|
+ * case1:人脸比对失败(即活检第1步,action==FACE_COMPARE,照片非本人或检测中多人脸)时,结束考试
|
|
|
* case2:冻结时间内,第2次人脸活检整体失败,结束考试
|
|
|
* case3:冻结时间外,人脸活检失败,结束考试
|
|
|
*/
|
|
@@ -195,19 +199,39 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
errorMsg = stepInfo.getErrorMsg();
|
|
|
}
|
|
|
|
|
|
- //整个检测步骤中只要有一次失败,则认为整个活检失败
|
|
|
+ //如果当前步骤为超时,则直接跳出循环
|
|
|
+ if ((stepInfo.getReadTimeout() != null && stepInfo.getReadTimeout())) {
|
|
|
+ errorMsg = "未在指定时间内完成指令";
|
|
|
+ finalIsSuccess = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //整个检测步骤中只要有一次失败或超时,则认为整个活检失败
|
|
|
if (!stepInfo.getResult()) {
|
|
|
finalIsSuccess = false;
|
|
|
}
|
|
|
|
|
|
switch (stepInfo.getAction()) {
|
|
|
case FACE_COMPARE:
|
|
|
- //如果第一步检测(即人脸比对)失败,则结束考试
|
|
|
- if (!stepInfo.getResult()) {
|
|
|
+ //如果第一步检测部分失败(照片非本人或检测中多人脸),需要结束考试
|
|
|
+ Map faceCompareResult = JsonUtil.fromJson(stepInfo.getResultJson(), Map.class);
|
|
|
+ //TODO 取照片检测结果
|
|
|
+ Boolean isStranger = Boolean.valueOf(faceCompareResult.get("isStranger").toString());
|
|
|
+ Boolean isPass = Boolean.valueOf(faceCompareResult.get("isPass").toString());
|
|
|
+ Boolean existsSystemError = Boolean.valueOf(faceCompareResult.get("existsSystemError").toString());
|
|
|
+ //case1.1.有陌生人(即多人脸),不管是否比对成功,直接结束考试
|
|
|
+ if (isStranger) {
|
|
|
isEndExam = true;
|
|
|
}
|
|
|
+ //case1.2.无陌生人且检测失败且不是系统错误(即照片非本人),也直接结束考试
|
|
|
+ else {
|
|
|
+ if (!isPass && !existsSystemError) {
|
|
|
+ isEndExam = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case HAPPY:
|
|
|
+ case SERIOUS:
|
|
|
//如果此前步骤已判断为需要结束考试则不作任何处理
|
|
|
if (!isEndExam) {
|
|
|
if (isInFreezeTime) {
|
|
@@ -354,7 +378,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
addFaceBiopsyItemStepList(examRecordDataId, faceBiopsyItemId);
|
|
|
|
|
|
//构建业务实体
|
|
|
- return buildFaceBiopsyInfo(examRecordDataId, faceBiopsyItemId, 1, faceBiopsyItemStepEntityList);
|
|
|
+ return buildFaceBiopsyInfo(examRecordDataId, faceBiopsyItemId, faceBiopsyItemStepEntityList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -379,7 +403,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
List<FaceBiopsyItemStepEntity> faceBiopsyItemStepEntityList =
|
|
|
addFaceBiopsyItemStepList(examRecordDataId, faceBiopsyItemId);
|
|
|
|
|
|
- return buildFaceBiopsyInfo(examRecordDataId, faceBiopsyItemId, verifiedTimes, faceBiopsyItemStepEntityList);
|
|
|
+ return buildFaceBiopsyInfo(examRecordDataId, faceBiopsyItemId, faceBiopsyItemStepEntityList);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -391,12 +415,12 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
* @param faceBiopsyItemStepEntityList
|
|
|
* @return
|
|
|
*/
|
|
|
- private FaceBiopsyInfo buildFaceBiopsyInfo(Long examRecordDataId, Long faceBiopsyItemId, Integer verifyTimes,
|
|
|
+ private FaceBiopsyInfo buildFaceBiopsyInfo(Long examRecordDataId, Long faceBiopsyItemId,
|
|
|
List<FaceBiopsyItemStepEntity> faceBiopsyItemStepEntityList) {
|
|
|
//构建业务实体
|
|
|
FaceBiopsyInfo faceBiopsyInfo = new FaceBiopsyInfo();
|
|
|
faceBiopsyInfo.setFaceBiopsyItemId(faceBiopsyItemId);
|
|
|
- faceBiopsyInfo.setFaceVerifyMinute(calculateFaceBiopsyStartMinute(examRecordDataId, verifyTimes));
|
|
|
+ faceBiopsyInfo.setFaceVerifyMinute(getFaceBiopsyStartMinute(examRecordDataId));
|
|
|
faceBiopsyInfo.setVerifySteps(copyFaceBiopsyStepDomainListFrom(faceBiopsyItemStepEntityList));
|
|
|
return faceBiopsyInfo;
|
|
|
}
|