|
@@ -2,6 +2,8 @@ package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.SyncExamDataCloudService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.SyncExamDataReq;
|
|
@@ -46,6 +48,8 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
|
|
|
private static final long serialVersionUID = -25466948667789119L;
|
|
|
|
|
|
+ private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(SyncExamDataCloudServiceProvider.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamRecordForMarkingService examRecordForMarkingService;
|
|
|
@Autowired
|
|
@@ -53,10 +57,6 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
@Autowired
|
|
|
private ExamScoreObtainQueueService examScoreObtainQueueService;
|
|
|
@Autowired
|
|
|
- private ExamBossService examBossService;
|
|
|
- @Autowired
|
|
|
- private ExamRecordDataCacheService examRecordDataCacheService;
|
|
|
- @Autowired
|
|
|
private ExamRecordDataRepo examRecordDataRepo;
|
|
|
@Autowired
|
|
|
private ExamStudentRepo examStudentRepo;
|
|
@@ -100,11 +100,19 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
@Override
|
|
|
public SyncExamDataResp syncExamData(@RequestBody SyncExamDataReq req) {
|
|
|
|
|
|
+ long st = System.currentTimeMillis();
|
|
|
+
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+
|
|
|
+ Long transitionExamRecordDataId = req.getExamRecordData().getId();
|
|
|
+
|
|
|
//校验考试记录是否已同步,如果已同步,则直接返回
|
|
|
- if (hasSynced(req.getExamRecordData().getId())) {
|
|
|
+ if (hasSynced(transitionExamRecordDataId)) {
|
|
|
return new SyncExamDataResp();
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("1 校验考试记录是否已同步", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//临时考试记录
|
|
|
ExamRecordDataBean transitionExamRecordData = req.getExamRecordData();
|
|
|
|
|
@@ -112,50 +120,72 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
Long examStudentId = transitionExamRecordData.getExamStudentId();
|
|
|
updateExamStudent(examStudentId);
|
|
|
|
|
|
+ startTime = this.debugCost("2 更新考生考试次数", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步考试记录,并返回真实的考试记录id
|
|
|
Long realExamRecordDataId = syncExamRecordData(transitionExamRecordData);
|
|
|
|
|
|
+ startTime = this.debugCost("3 同步考试记录表", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//添加同步记录
|
|
|
addExamRecordDataSync(transitionExamRecordData.getId(), realExamRecordDataId);
|
|
|
|
|
|
+ startTime = this.debugCost("4 添加同步关系表", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步考试分数表
|
|
|
Long examScoreId = syncExamScore(transitionExamRecordData, realExamRecordDataId);
|
|
|
|
|
|
+ startTime = this.debugCost("5 同步考试分数表", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//计算最终分数
|
|
|
String examType = ExamCacheTransferHelper.getDefaultCachedExam(transitionExamRecordData.getExamId()).getExamType();
|
|
|
if (ExamType.ONLINE.name().equals(examType) || ExamType.OFFLINE.name().equals(examType)) {
|
|
|
examStudentFinalScoreService.calcAndSaveFinalScore(examStudentId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("6 计算最终考试分数", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步抓拍照片结果(同步抓拍的数据)
|
|
|
if (null != req.getExamSyncCapture()) {
|
|
|
syncExamSyncCapture(req.getExamSyncCapture(), realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("7 同步抓拍照片结果(同步抓拍的数据)", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步抓拍照片结果(异步抓拍的数据)
|
|
|
if (null != req.getExamCaptures()) {
|
|
|
|
|
|
syncExamCapture(req.getExamCaptures(), realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("8 同步抓拍照片结果(异步抓拍的数据)", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步face id活体检测数据
|
|
|
if (null != req.getExamFaceLivenessVerifies()) {
|
|
|
|
|
|
syncExamFaceLivenessVerify(req.getExamFaceLivenessVerifies(), realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("9 同步face id活体检测数据", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步新活检
|
|
|
if (null != req.getFaceBiopsy()) {
|
|
|
|
|
|
syncFaceBiopsy(req.getFaceBiopsy(), realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("10 同步face id活体检测数据", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步考试记录对应的试卷结构
|
|
|
syncExamRecordPaperStruct(req.getExamRecordPaperStruct(), realExamRecordDataId);
|
|
|
|
|
|
+ startTime = this.debugCost("11 同步考试记录对应的试卷结构", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步作答记录
|
|
|
syncExamRecordQuestions(req.getExamRecordQuestions(), realExamRecordDataId);
|
|
|
|
|
|
+ startTime = this.debugCost("12 同步作答记录", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//如果开启了活检
|
|
|
if (FaceBiopsyHelper.isFaceEnable(transitionExamRecordData.getRootOrgId(), transitionExamRecordData.getExamId(), transitionExamRecordData.getStudentId())) {
|
|
|
//计算违纪自动审核结果(无人脸或活检失败)
|
|
@@ -163,9 +193,15 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
saveAutoAudit(transitionExamRecordData, isNoPhotoAndIllegality, realExamRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ startTime = this.debugCost("13 如果开启了活检,计算违纪自动审核结果", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//同步后续处理
|
|
|
processAfterSyncExamData(realExamRecordDataId, examScoreId, transitionExamRecordData.getObjectiveScore(),
|
|
|
- examStudentId);
|
|
|
+ examStudentId, transitionExamRecordDataId);
|
|
|
+
|
|
|
+ this.debugCost("14 同步后续处理 - 共计", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
+ this.debugCost("100 同步考试记录相关数据 - 共计", transitionExamRecordDataId, st);
|
|
|
|
|
|
return new SyncExamDataResp();
|
|
|
}
|
|
@@ -588,18 +624,38 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
|
|
|
* @param examScoreId
|
|
|
*/
|
|
|
private void processAfterSyncExamData(Long realExamRecordDataId, Long examScoreId, Double objectiveScore,
|
|
|
- Long examStudentId) {
|
|
|
+ Long examStudentId, Long transitionExamRecordDataId) {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+
|
|
|
// 保存阅卷相关数据
|
|
|
examRecordForMarkingService.saveExamRecordForMarking(realExamRecordDataId, objectiveScore);
|
|
|
|
|
|
+ startTime = this.debugCost("14.1 同步后续处理 - 保存阅卷相关数据", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
// 保存考试分数数据到推分队列
|
|
|
examScorePushQueueService.saveScoreDataInfoToQueue(realExamRecordDataId, examScoreId);
|
|
|
|
|
|
+ startTime = this.debugCost("14.2 同步后续处理 - 保存考试分数数据到推分队列", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
// 保存考试分数数据到分数获取队列
|
|
|
examScoreObtainQueueService.saveExamScoreObtainQueue(realExamRecordDataId);
|
|
|
|
|
|
+ startTime = this.debugCost("14.3 同步后续处理 - 保存考试分数数据到推分队列", transitionExamRecordDataId, startTime);
|
|
|
+
|
|
|
//刷新考生的缓存
|
|
|
examStudentCache.refresh(examStudentId);
|
|
|
+
|
|
|
+ this.debugCost("14.4 同步后续处理 - 刷新考生的缓存", transitionExamRecordDataId, startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ //记录耗时
|
|
|
+ private Long debugCost(String msg, Long examRecordDataId, Long startTime) {
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("[SYNC_EXAM_DATA_CLOUD_SERVICE_PROVIDER-" + examRecordDataId + "]:" + msg +
|
|
|
+ " 耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
+ }
|
|
|
+
|
|
|
+ return System.currentTimeMillis();
|
|
|
}
|
|
|
|
|
|
}
|