|
@@ -7,8 +7,10 @@ import cn.com.qmth.examcloud.core.oe.admin.api.SyncExamDataCloudService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordDataBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.SyncExamDataReq;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
|
+import cn.com.qmth.examcloud.support.Constants;
|
|
|
import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
+import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -31,25 +33,30 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
|
|
|
@Override
|
|
|
public List<KeyValuePair<Long, ExamRecordData>> execute(Long key, ExamRecordData examRecordData, TaskContext context) throws Exception {
|
|
|
+ String sequenceLockKey = Constants.EXAM_CONTROL_LOCK_PREFIX + examRecordData.getStudentId();
|
|
|
|
|
|
- List<KeyValuePair<Long, ExamRecordData>> resultList = new ArrayList<>();
|
|
|
- KeyValuePair<Long, ExamRecordData> keyValuePair = new KeyValuePair<>(key, examRecordData);
|
|
|
+ try {
|
|
|
+ //添加考试控制全局锁
|
|
|
+ SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
|
|
|
- //处理上一节点中,指定时间内仍未处理完成的数据
|
|
|
- if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_HAND_IN ||
|
|
|
- examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_AUTO_HAND_IN) {
|
|
|
- examRecordDataService.processAfterHandInExam(examRecordData.getId());
|
|
|
- }
|
|
|
+ //处理上一节点中,指定时间内仍未处理完成的数据
|
|
|
+ if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_HAND_IN ||
|
|
|
+ examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_AUTO_HAND_IN) {
|
|
|
+ examRecordDataService.processAfterHandInExam(examRecordData.getId());
|
|
|
+ }
|
|
|
|
|
|
- //同步数据
|
|
|
- SyncExamDataReq syncReq = new SyncExamDataReq();
|
|
|
- syncReq.setExamRecordData(copyExamRecordDataFrom(examRecordData));
|
|
|
- syncExamDataCloudService.syncExamData(syncReq);
|
|
|
+ //同步数据
|
|
|
+ SyncExamDataReq syncReq = new SyncExamDataReq();
|
|
|
+ syncReq.setExamRecordData(copyExamRecordDataFrom(examRecordData));
|
|
|
+ syncExamDataCloudService.syncExamData(syncReq);
|
|
|
|
|
|
- return null;
|
|
|
+ return null;
|
|
|
+ } finally {
|
|
|
+ SequenceLockHelper.releaseLock(sequenceLockKey);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private ExamRecordDataBean copyExamRecordDataFrom(ExamRecordData examRecordData){
|
|
|
+ private ExamRecordDataBean copyExamRecordDataFrom(ExamRecordData examRecordData) {
|
|
|
ExamRecordDataBean data = new ExamRecordDataBean();
|
|
|
data.setId(examRecordData.getId());
|
|
|
data.setExamId(examRecordData.getExamId());
|