|
@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.core.oe.student.service.FaceBiopsyService;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
+import com.mysql.cj.util.StringUtils;
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -52,7 +53,15 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
private ExamControlService examControlService;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public FaceBiopsyInfo getFaceBiopsyInfo(Long rootOrgId, Long examRecordDataId, FaceBiopsyType faceBiopsyType) {
|
|
|
+ //如果在冻结时间外,需要判断是否开启冻结时间外添加人脸活体检测
|
|
|
+ boolean isInFreezeTime = calculateIsInFreezeTime(examRecordDataId);
|
|
|
+ if (!isInFreezeTime) {
|
|
|
+ if (!addFaceVerifyOutFreezeTime(examRecordDataId)) {
|
|
|
+ throw new StatusException("201004", "非冻结时间内不允许人脸活体检测");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//如果是第一次进行人脸活体检测,则初始化相关信息保存并返回
|
|
|
FaceBiopsyEntity faceBiopsyEntity = faceBiopsyRepo.findByExamRecordDataId(examRecordDataId);
|
|
@@ -93,6 +102,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public SaveFaceBiopsyResultResp saveFaceBiopsyResult(SaveFaceBiopsyResultReq req) {
|
|
|
//构建业务实体
|
|
|
SaveFaceBiopsyResultResp resp = buildSaveFaceBiopsyResultResp(req.getExamRecordDataId(), req.getVerifySteps());
|
|
@@ -105,6 +115,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
|
|
|
/**
|
|
|
* 获取人脸活体检测开始分钟数
|
|
|
+ *
|
|
|
* @param examRecordDataId 考试记录id
|
|
|
* @return Integer
|
|
|
*/
|
|
@@ -142,6 +153,10 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
boolean isInFreezeTime = calculateIsInFreezeTime(examRecordDataId);
|
|
|
|
|
|
for (FaceBiopsyStepInfo stepInfo : verifySteps) {
|
|
|
+ if (stepInfo.getResult() == null) {
|
|
|
+ throw new StatusException("201005", "检测结果不允许为空");
|
|
|
+ }
|
|
|
+
|
|
|
if (!stepInfo.getResult()) {
|
|
|
errorMsg = stepInfo.getErrorMsg();
|
|
|
}
|
|
@@ -196,7 +211,6 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
* @param finalIsSuccess
|
|
|
* @param errorMsg
|
|
|
*/
|
|
|
- @Transactional
|
|
|
public void updateFaceBiopsyResult(Long examRecordDataId, Long faceBiopsyItemId, List<FaceBiopsyStepInfo> verifySteps,
|
|
|
boolean finalIsSuccess, String errorMsg) {
|
|
|
List<FaceBiopsyItemStepEntity> faceBiopsyItemStepEntityList =
|
|
@@ -276,7 +290,16 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
* @return
|
|
|
*/
|
|
|
private String getRelativePath(String resourceUrl) {
|
|
|
- //TODO 待完善代码
|
|
|
+ if (!StringUtils.isNullOrEmpty(resourceUrl)) {
|
|
|
+ String domain = PropertyHolder.getString("$upyun.site.1.domain");
|
|
|
+ String backupDomain = PropertyHolder.getString("$upyun.site.1.domain.backup");
|
|
|
+ if (!StringUtils.isNullOrEmpty(domain)){
|
|
|
+ resourceUrl = resourceUrl.replace(domain, "");
|
|
|
+ }
|
|
|
+ if (!StringUtils.isNullOrEmpty(backupDomain)){
|
|
|
+ resourceUrl = resourceUrl.replace(backupDomain, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
return resourceUrl;
|
|
|
}
|
|
|
|
|
@@ -288,7 +311,6 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
* @param faceBiopsyType
|
|
|
* @return
|
|
|
*/
|
|
|
- @Transactional
|
|
|
public FaceBiopsyInfo addFirstFaceBiopsy(Long rootOrgId, Long examRecordDataId, FaceBiopsyType faceBiopsyType) {
|
|
|
//保存人脸活体检测相关信息
|
|
|
Long faceBiopsyId = addFaceBiopsyEntity(rootOrgId, examRecordDataId);
|
|
@@ -405,6 +427,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
faceBiopsyItemEntity.setExamRecordDataId(examRecordDataId);
|
|
|
faceBiopsyItemEntity.setFaceBiopsyId(faceBiopsyId);
|
|
|
faceBiopsyItemEntity.setFaceBiopsyType(faceBiopsyType);
|
|
|
+ faceBiopsyItemEntity.setCompleted(false);
|
|
|
faceBiopsyItemRepo.save(faceBiopsyItemEntity);
|
|
|
return faceBiopsyItemEntity.getId();
|
|
|
}
|
|
@@ -542,12 +565,31 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否允许冻结时间外添加人脸活体检测
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param orgId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private boolean addFaceVerifyOutFreezeTime(Long examId, Long orgId) {
|
|
|
String addFaceVerifyOutFreezeTime = CacheHelper.getExamOrgProperty(examId, orgId,
|
|
|
ExamProperties.ADD_FACE_VERIFY_OUT_FREEZE_TIME.name()).getValue();
|
|
|
return Constants.isTrue.equals(addFaceVerifyOutFreezeTime);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否允许冻结时间外添加人脸活体检测
|
|
|
+ *
|
|
|
+ * @param examRecordDataId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean addFaceVerifyOutFreezeTime(Long examRecordDataId) {
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId,
|
|
|
+ ExamRecordDataEntity.class);
|
|
|
+ return addFaceVerifyOutFreezeTime(examRecordData.getExamId(), examRecordData.getOrgId());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 当前考试是否在冻结时间内
|
|
|
*
|
|
@@ -560,7 +602,7 @@ public class FaceBiopsyServiceImpl implements FaceBiopsyService {
|
|
|
|
|
|
ExamSessionInfo examSessionInfo = examSessionInfoService.getExamSessionInfo(examRecordData.getStudentId());
|
|
|
if (examSessionInfo == null) {
|
|
|
- throw new StatusException("201002", "考试会话已过期");
|
|
|
+ throw new StatusException("201003", "考试会话已过期");
|
|
|
}
|
|
|
Long usedMilliseconds = examControlService.calculateExamUsedMilliseconds(examSessionInfo);
|
|
|
|