|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.task.service.pipeline;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
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.TaskContext;
|
|
@@ -20,9 +21,12 @@ import cn.com.qmth.examcloud.core.oe.task.dao.ExamCaptureRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.dao.ExamSyncCaptureRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.dao.entity.ExamCaptureEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.task.dao.entity.ExamSyncCaptureEntity;
|
|
|
+import cn.com.qmth.examcloud.core.oe.task.service.ExamBossService;
|
|
|
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.enums.SyncStatus;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamBoss;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -50,6 +54,8 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
private ExamSyncCaptureRepo examSyncCaptureRepo;
|
|
|
@Autowired
|
|
|
private ExamRecordDataCloudService examRecordDataCloudService;
|
|
|
+ @Autowired
|
|
|
+ private ExamBossService examBossService;
|
|
|
|
|
|
@Override
|
|
|
public List<KeyValuePair<Long, ExamRecordData>> execute(Long key, ExamRecordData examRecordData, TaskContext context) throws Exception {
|
|
@@ -59,6 +65,11 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
//添加考试控制全局锁
|
|
|
SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
|
|
|
+ //如果已同步,直接返回
|
|
|
+ if (SyncStatus.SYNCED == examRecordData.getSyncStatus()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
//处理上一节点中,指定时间内仍未处理完成的数据
|
|
|
Long examRecordDataId = examRecordData.getId();
|
|
|
if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_HAND_IN ||
|
|
@@ -66,6 +77,9 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
examRecordDataService.processAfterHandInExam(examRecordDataId);
|
|
|
}
|
|
|
|
|
|
+ List<KeyValuePair<Long, ExamRecordData>> resultList = new ArrayList<>();
|
|
|
+ KeyValuePair<Long, ExamRecordData> keyValuePair = new KeyValuePair<>(key, examRecordData);
|
|
|
+
|
|
|
//同步数据
|
|
|
SyncExamDataReq syncReq = new SyncExamDataReq();
|
|
|
syncReq.setExamRecordData(copyExamRecordDataFrom(examRecordData));
|
|
@@ -77,7 +91,20 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
syncReq.setFaceBiopsy(getFaceBiopsy(examRecordDataId));
|
|
|
syncExamDataCloudService.syncExamData(syncReq);
|
|
|
|
|
|
- return null;
|
|
|
+ //考试完结次数加1
|
|
|
+ ExamBoss examBoss = examBossService.getExamBoss(examRecordData.getExamId());
|
|
|
+ if (null != examBoss) {
|
|
|
+ examBoss.setEndCount(examBoss.getEndCount() + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置并保存考试记录的同步状态
|
|
|
+ examRecordData.setSyncStatus(SyncStatus.SYNCED);
|
|
|
+ setAndSaveExamRecordDataSyncStatus(examRecordDataId);
|
|
|
+
|
|
|
+ keyValuePair.setValue(examRecordData);
|
|
|
+ resultList.add(keyValuePair);
|
|
|
+
|
|
|
+ return resultList;
|
|
|
} finally {
|
|
|
SequenceLockHelper.releaseLock(sequenceLockKey);
|
|
|
}
|
|
@@ -310,4 +337,19 @@ public class SyncExamDataExecutor implements NodeExecuter<Long, ExamRecordData,
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置并保存考试记录的同步状态
|
|
|
+ *
|
|
|
+ * @param examRecordDataId
|
|
|
+ */
|
|
|
+ private void setAndSaveExamRecordDataSyncStatus(Long examRecordDataId) {
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(examRecordDataId);
|
|
|
+
|
|
|
+ if (SyncStatus.SYNCED == examRecordData.getSyncStatus()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ examRecordData.setSyncStatus(SyncStatus.SYNCED);
|
|
|
+ examRecordDataService.saveExamRecordDataCache(examRecordDataId, examRecordData);
|
|
|
+ }
|
|
|
}
|