|
@@ -18,12 +18,14 @@ import cn.com.qmth.examcloud.support.enums.SyncStatus;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamBoss;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
+import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
|
|
|
import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Example;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -95,47 +97,63 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public SyncExamDataResp syncExamData(@RequestBody SyncExamDataReq req) {
|
|
|
- String sequenceLockKey = Constants.EXAM_SYNC_CONTROL_LOCK_PREFIX + req.getExamRecordData().getStudentId();
|
|
|
-
|
|
|
- //添加考试同步控制全局锁,自动解锁
|
|
|
- SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
+// String sequenceLockKey = Constants.EXAM_SYNC_CONTROL_LOCK_PREFIX + req.getExamRecordData().getStudentId();
|
|
|
+//
|
|
|
+// //添加考试同步控制全局锁,自动解锁
|
|
|
+// SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
|
|
|
//校验考试记录是否已同步,如果已同步,则直接返回
|
|
|
if (hasSynced(req.getExamRecordData().getId())) {
|
|
|
return new SyncExamDataResp();
|
|
|
}
|
|
|
|
|
|
- //同步考试记录
|
|
|
- ExamRecordDataBean examRecordData = req.getExamRecordData();
|
|
|
- Long examRecordDataId = syncExamRecordData(examRecordData);
|
|
|
+ //临时考试记录
|
|
|
+ ExamRecordDataBean transitionExamRecordData = req.getExamRecordData();
|
|
|
+
|
|
|
+ //同步考试记录,并返回真实的考试记录id
|
|
|
+ Long realExamRecordDataId = syncExamRecordData(transitionExamRecordData);
|
|
|
|
|
|
//添加同步记录
|
|
|
- addExamRecordDataSync(examRecordData.getId(), examRecordDataId);
|
|
|
+ addExamRecordDataSync(transitionExamRecordData.getId(), realExamRecordDataId);
|
|
|
|
|
|
//同步抓拍照片结果(同步抓拍的数据)
|
|
|
- syncExamSyncCapture(req.getExamSyncCapture(), examRecordDataId);
|
|
|
+ if (null != req.getExamSyncCapture()) {
|
|
|
+ syncExamSyncCapture(req.getExamSyncCapture(), realExamRecordDataId);
|
|
|
+ }
|
|
|
|
|
|
//同步抓拍照片结果(异步抓拍的数据)
|
|
|
- syncExamCapture(req.getExamCaptures(), examRecordDataId);
|
|
|
+ if (null != req.getExamCaptures()) {
|
|
|
+
|
|
|
+ syncExamCapture(req.getExamCaptures(), realExamRecordDataId);
|
|
|
+ }
|
|
|
|
|
|
//同步face id活体检测数据
|
|
|
- syncExamFaceLivenessVerify(req.getExamFaceLivenessVerifies(), examRecordDataId);
|
|
|
+ if (null != req.getExamFaceLivenessVerifies()) {
|
|
|
+
|
|
|
+ syncExamFaceLivenessVerify(req.getExamFaceLivenessVerifies(), realExamRecordDataId);
|
|
|
+ }
|
|
|
|
|
|
//同步新活检
|
|
|
- syncFaceBiopsy(req.getFaceBiopsy(), examRecordDataId);
|
|
|
+ if (null != req.getFaceBiopsy()) {
|
|
|
+
|
|
|
+ syncFaceBiopsy(req.getFaceBiopsy(), realExamRecordDataId);
|
|
|
+ }
|
|
|
|
|
|
//同步考试记录对应的试卷结构
|
|
|
- syncExamRecordPaperStruct(req.getExamRecordPaperStruct(), examRecordDataId);
|
|
|
+ syncExamRecordPaperStruct(req.getExamRecordPaperStruct(), realExamRecordDataId);
|
|
|
|
|
|
//同步作答记录
|
|
|
- syncExamRecordQuestions(req.getExamRecordQuestions(), examRecordDataId);
|
|
|
+ syncExamRecordQuestions(req.getExamRecordQuestions(), realExamRecordDataId);
|
|
|
|
|
|
- //计算违纪自动审核结果(无人脸或活检失败)
|
|
|
- boolean isNoPhotoAndIllegality = (null == req.getExamCaptures() || req.getExamCaptures().isEmpty());//是否无照片
|
|
|
- saveAutoAudit(examRecordData, isNoPhotoAndIllegality);
|
|
|
+ //如果开启了活检
|
|
|
+ if (FaceBiopsyHelper.isFaceEnable(transitionExamRecordData.getRootOrgId(), transitionExamRecordData.getExamId(), transitionExamRecordData.getStudentId())) {
|
|
|
+ //计算违纪自动审核结果(无人脸或活检失败)
|
|
|
+ boolean isNoPhotoAndIllegality = (null == req.getExamCaptures() || req.getExamCaptures().isEmpty());//是否无照片
|
|
|
+ saveAutoAudit(transitionExamRecordData, isNoPhotoAndIllegality,realExamRecordDataId);
|
|
|
+ }
|
|
|
|
|
|
//同步后续处理
|
|
|
- processAfterSyncExamData(examRecordDataId, examRecordData.getExamId());
|
|
|
+ processAfterSyncExamData(realExamRecordDataId, transitionExamRecordData.getExamId());
|
|
|
|
|
|
return new SyncExamDataResp();
|
|
|
}
|
|
@@ -151,7 +169,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
entity.setCacheId(cacheId);
|
|
|
entity.setDbId(dbId);
|
|
|
|
|
|
- examRecordDataSyncRepo.save(entity);
|
|
|
+ examRecordDataSyncRepo.saveAndFlush(entity);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -226,7 +244,11 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
result.setFaceStrangerCount(examRecordData.getFaceStrangerCount());
|
|
|
result.setFaceTotalCount(examRecordData.getFaceTotalCount());
|
|
|
result.setFaceSuccessPercent(examRecordData.getFaceSuccessPercent());
|
|
|
- result.setFaceVerifyResult(IsSuccess.valueOf(examRecordData.getFaceVerifyResult()));
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(examRecordData.getFaceVerifyResult())) {
|
|
|
+ result.setFaceVerifyResult(IsSuccess.valueOf(examRecordData.getFaceVerifyResult()));
|
|
|
+ }
|
|
|
+
|
|
|
result.setFaceLandmarkVal(examRecordData.getFaceLandmarkVal());
|
|
|
result.setIsAllObjectivePaper(examRecordData.getAllObjectivePaper());
|
|
|
result.setBaiduFaceLivenessSuccessPercent(examRecordData.getBaiduFaceLivenessSuccessPercent());
|
|
@@ -283,41 +305,41 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void saveAutoAudit(ExamRecordDataBean examRecordData, boolean isNoPhotoAndIllegality) {
|
|
|
+ private void saveAutoAudit(ExamRecordDataBean examRecordData, boolean isNoPhotoAndIllegality,Long realExamRecordDataId) {
|
|
|
//无照片违纪自动审核
|
|
|
if (isNoPhotoAndIllegality) {
|
|
|
- examAuditService.saveExamAuditByNoPhoto(examRecordData.getId());
|
|
|
+ examAuditService.saveExamAuditByNoPhoto(realExamRecordDataId);
|
|
|
} else {
|
|
|
//活体检测失败违纪自动审核
|
|
|
if (null != examRecordData.getFaceVerifyResult()
|
|
|
&& IsSuccess.FAILED.name().equals(examRecordData.getFaceVerifyResult())
|
|
|
&& examRecordData.getIllegality()) {
|
|
|
- examAuditService.saveExamAuditByFaceVerifyFailed(examRecordData.getId(), examRecordData.getRootOrgId());
|
|
|
+ examAuditService.saveExamAuditByFaceVerifyFailed(realExamRecordDataId, examRecordData.getRootOrgId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void syncExamRecordQuestions(ExamRecordQuestionsBean examRecordQuestions, Long examRecordDataId) {
|
|
|
- ExamRecordQuestionsEntity entity = copyExamRecordQuestionsFrom(examRecordQuestions, examRecordDataId);
|
|
|
+ private void syncExamRecordQuestions(ExamRecordQuestionsBean examRecordQuestions, Long realExamRecordDataId) {
|
|
|
+ ExamRecordQuestionsEntity entity = copyExamRecordQuestionsFrom(examRecordQuestions, realExamRecordDataId);
|
|
|
examRecordQuestionsRepo.save(entity);
|
|
|
|
|
|
//更新考试记录表中的作答记录id
|
|
|
ExamRecordDataEntity examRecordData =
|
|
|
- GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
+ GlobalHelper.getEntity(examRecordDataRepo, realExamRecordDataId, ExamRecordDataEntity.class);
|
|
|
examRecordData.setExamRecordQuestionsId(entity.getId());
|
|
|
examRecordDataRepo.save(examRecordData);
|
|
|
}
|
|
|
|
|
|
- private ExamRecordQuestionsEntity copyExamRecordQuestionsFrom(ExamRecordQuestionsBean bean, Long examRecordDataId) {
|
|
|
+ private ExamRecordQuestionsEntity copyExamRecordQuestionsFrom(ExamRecordQuestionsBean bean, Long realExamRecordDataId) {
|
|
|
ExamRecordQuestionsEntity entity = new ExamRecordQuestionsEntity();
|
|
|
- entity.setExamRecordDataId(examRecordDataId);
|
|
|
+ entity.setExamRecordDataId(realExamRecordDataId);
|
|
|
|
|
|
List<ExamQuestionEntity> examQuestionEntityList = new ArrayList<>();
|
|
|
|
|
|
for (ExamQuestionBean questionBean : bean.getExamQuestionBeans()) {
|
|
|
ExamQuestionEntity questionEntity = new ExamQuestionEntity();
|
|
|
|
|
|
- questionEntity.setExamRecordDataId(questionBean.getExamRecordDataId());
|
|
|
+ questionEntity.setExamRecordDataId(realExamRecordDataId);
|
|
|
questionEntity.setMainNumber(questionBean.getMainNumber());
|
|
|
questionEntity.setQuestionId(questionBean.getQuestionId());
|
|
|
questionEntity.setOrder(questionBean.getOrder());
|
|
@@ -330,7 +352,11 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
questionEntity.setCorrectAnswer(questionBean.getCorrectAnswer());
|
|
|
questionEntity.setOptionPermutation(questionBean.getOptionPermutation());
|
|
|
questionEntity.setAudioPlayTimes(questionBean.getAudioPlayTimes());
|
|
|
- questionEntity.setAnswerType(AnswerType.valueOf(questionBean.getAnswerType()));
|
|
|
+
|
|
|
+ if (null != questionBean.getAnswerType()) {
|
|
|
+
|
|
|
+ questionEntity.setAnswerType(AnswerType.valueOf(questionBean.getAnswerType()));
|
|
|
+ }
|
|
|
|
|
|
examQuestionEntityList.add(questionEntity);
|
|
|
}
|
|
@@ -364,7 +390,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
FaceBiopsyEntity faceBiopsyEntity = copyFaceBiopsyFrom(faceBiopsy, examRecordDataId);
|
|
|
faceBiopsyRepo.save(faceBiopsyEntity);
|
|
|
|
|
|
- for (FaceBiopsyItemBean itemBean:faceBiopsy.getFaceBiopsyItems()) {
|
|
|
+ for (FaceBiopsyItemBean itemBean : faceBiopsy.getFaceBiopsyItems()) {
|
|
|
FaceBiopsyItemEntity faceBiopsyItemEntity = copyFaceBiopsyItemFrom(
|
|
|
itemBean, faceBiopsyEntity.getId(), examRecordDataId);
|
|
|
faceBiopsyItemRepo.save(faceBiopsyItemEntity);
|
|
@@ -440,7 +466,11 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
entity.setStartTime(bean.getStartTime());
|
|
|
entity.setUsedTime(bean.getUsedTime());
|
|
|
entity.setResultJson(bean.getResultJson());
|
|
|
- entity.setVerifyResult(FaceVerifyResult.valueOf(bean.getVerifyResult()));
|
|
|
+
|
|
|
+ if (null != bean.getVerifyResult()) {
|
|
|
+ entity.setVerifyResult(FaceVerifyResult.valueOf(bean.getVerifyResult()));
|
|
|
+ }
|
|
|
+
|
|
|
entity.setBizId(bean.getBizId());
|
|
|
entity.setIsError(bean.getError());
|
|
|
entity.setErrorMsg(bean.getErrorMsg());
|
|
@@ -503,18 +533,18 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
/**
|
|
|
* 同步后的后续操作
|
|
|
*
|
|
|
- * @param examRecordDataId
|
|
|
+ * @param realExamRecordDataId
|
|
|
* @param examId
|
|
|
*/
|
|
|
- private void processAfterSyncExamData(Long examRecordDataId, Long examId) {
|
|
|
+ private void processAfterSyncExamData(Long realExamRecordDataId, Long examId) {
|
|
|
// 保存阅卷相关数据
|
|
|
- examRecordForMarkingService.saveExamRecordForMarking(examRecordDataId);
|
|
|
+ examRecordForMarkingService.saveExamRecordForMarking(realExamRecordDataId);
|
|
|
|
|
|
// 保存考试分数数据到推分队列
|
|
|
- examScorePushQueueService.saveScoreDataInfoToQueue(examRecordDataId);
|
|
|
+ examScorePushQueueService.saveScoreDataInfoToQueue(realExamRecordDataId);
|
|
|
|
|
|
// 保存考试分数数据到分数获取队列
|
|
|
- examScoreObtainQueueService.saveExamScoreObtainQueue(examRecordDataId);
|
|
|
+ examScoreObtainQueueService.saveExamScoreObtainQueue(realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
}
|