|
@@ -3,6 +3,8 @@ package cn.com.qmth.examcloud.core.oe.task.service.pipeline;
|
|
import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
|
|
import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.NodeExecuter;
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.NodeExecuter;
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.TaskContext;
|
|
import cn.com.qmth.examcloud.commons.helpers.pipeline.TaskContext;
|
|
|
|
+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.SyncExamDataCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.*;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.SyncExamDataReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.SyncExamDataReq;
|
|
@@ -56,7 +58,7 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
private ExamRecordDataCloudService examRecordDataCloudService;
|
|
private ExamRecordDataCloudService examRecordDataCloudService;
|
|
@Autowired
|
|
@Autowired
|
|
private ExamBossService examBossService;
|
|
private ExamBossService examBossService;
|
|
-
|
|
|
|
|
|
+ private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(SyncExamDataExecutor.class);
|
|
|
|
|
|
/**
|
|
/**
|
|
* 执行
|
|
* 执行
|
|
@@ -78,13 +80,20 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + studentId;
|
|
String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + studentId;
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ debugLog("enter executor...",examRecordData.getId());
|
|
|
|
+
|
|
//添加考试控制全局锁
|
|
//添加考试控制全局锁
|
|
SequenceLockHelper.getLockSimple(sequenceLockKey);
|
|
SequenceLockHelper.getLockSimple(sequenceLockKey);
|
|
|
|
|
|
|
|
+ debugLog("get locker success...",examRecordData.getId());
|
|
|
|
+
|
|
//如果已同步,直接交给下一节点
|
|
//如果已同步,直接交给下一节点
|
|
if (SyncStatus.SYNCED == examRecordData.getSyncStatus()) {
|
|
if (SyncStatus.SYNCED == examRecordData.getSyncStatus()) {
|
|
|
|
+
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
|
|
|
|
|
|
+ this.debugLog("already synced,will go to next node...",examRecordData.getId());
|
|
|
|
+
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -92,13 +101,19 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
Long examRecordDataId = examRecordData.getId();
|
|
Long examRecordDataId = examRecordData.getId();
|
|
if (ExamRecordStatus.EXAM_HAND_IN == examRecordData.getExamRecordStatus() ||
|
|
if (ExamRecordStatus.EXAM_HAND_IN == examRecordData.getExamRecordStatus() ||
|
|
ExamRecordStatus.EXAM_AUTO_HAND_IN == examRecordData.getExamRecordStatus()) {
|
|
ExamRecordStatus.EXAM_AUTO_HAND_IN == examRecordData.getExamRecordStatus()) {
|
|
|
|
+ this.debugLog("prepare to execute last node's hand in data...",examRecordDataId);
|
|
|
|
+
|
|
examRecordDataService.processAfterHandInExam(examRecordDataId);
|
|
examRecordDataService.processAfterHandInExam(examRecordDataId);
|
|
|
|
+
|
|
|
|
+ this.debugLog("execute last node's hand in data success...",examRecordDataId);
|
|
}
|
|
}
|
|
|
|
|
|
//如果考试记录状态为完结状态,则开始同步数据到正式库
|
|
//如果考试记录状态为完结状态,则开始同步数据到正式库
|
|
if (ExamRecordStatus.EXAM_END == examRecordData.getExamRecordStatus() ||
|
|
if (ExamRecordStatus.EXAM_END == examRecordData.getExamRecordStatus() ||
|
|
ExamRecordStatus.EXAM_OVERDUE == examRecordData.getExamRecordStatus()) {
|
|
ExamRecordStatus.EXAM_OVERDUE == examRecordData.getExamRecordStatus()) {
|
|
|
|
|
|
|
|
+ this.debugLog("prepare to sync data...",examRecordDataId);
|
|
|
|
+
|
|
//同步数据
|
|
//同步数据
|
|
SyncExamDataReq syncReq = new SyncExamDataReq();
|
|
SyncExamDataReq syncReq = new SyncExamDataReq();
|
|
syncReq.setExamRecordData(copyExamRecordDataFrom(examRecordData));
|
|
syncReq.setExamRecordData(copyExamRecordDataFrom(examRecordData));
|
|
@@ -120,6 +135,8 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
|
|
|
syncExamDataCloudService.syncExamData(syncReq);
|
|
syncExamDataCloudService.syncExamData(syncReq);
|
|
|
|
|
|
|
|
+ this.debugLog("sync data success,and to be change status...",examRecordDataId);
|
|
|
|
+
|
|
//考试完结次数加1
|
|
//考试完结次数加1
|
|
ExamBoss examBoss = examBossService.getExamBoss(examRecordData.getExamStudentId());
|
|
ExamBoss examBoss = examBossService.getExamBoss(examRecordData.getExamStudentId());
|
|
if (null != examBoss) {
|
|
if (null != examBoss) {
|
|
@@ -132,12 +149,16 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
|
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
|
|
|
|
|
|
+ this.debugLog("sync data and change status success...",examRecordDataId);
|
|
|
|
+
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//其它状态的数据,直接交给下一个节点处理
|
|
//其它状态的数据,直接交给下一个节点处理
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
outList.add(new KeyValuePair<>(key, examRecordData));
|
|
|
|
|
|
|
|
+ this.debugLog("current status is '" + examRecordData.getExamRecordStatus().name() +
|
|
|
|
+ "'.do nothing and go to the next node...", examRecordData.getId());
|
|
} finally {
|
|
} finally {
|
|
SequenceLockHelper.releaseLockSimple(sequenceLockKey);
|
|
SequenceLockHelper.releaseLockSimple(sequenceLockKey);
|
|
}
|
|
}
|
|
@@ -385,4 +406,10 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
examRecordData.setSyncStatus(SyncStatus.SYNCED);
|
|
examRecordData.setSyncStatus(SyncStatus.SYNCED);
|
|
examRecordDataService.saveExamRecordDataCache(examRecordDataId, examRecordData);
|
|
examRecordDataService.saveExamRecordDataCache(examRecordDataId, examRecordData);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void debugLog(String msg,Long examRecordDataId) {
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("[SYNC-EXAM-DATA-EXECUTOR-" + examRecordDataId + "]:"+msg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|