|
@@ -9,9 +9,9 @@ import com.qmth.distributed.print.business.bean.dto.SyncExamCardDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.SyncDataParam;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
-import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.ExamPrintPlanSyncStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.GroupDetailDTO;
|
|
|
import com.qmth.teachcloud.common.bean.dto.stmms.PicConfig;
|
|
@@ -22,10 +22,7 @@ import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
import com.qmth.teachcloud.common.entity.SysConfig;
|
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.SyncFileTypeEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.TaskResultEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.TaskStatusEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.*;
|
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
|
import com.qmth.teachcloud.common.service.SysConfigService;
|
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
@@ -176,7 +173,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
public void run() {
|
|
|
SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
|
|
|
if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
|
|
|
- TBSyncTask syncTask = tbSyncTaskService.saveTask(examPrintPlan);
|
|
|
+ TBSyncTask syncTask = tbSyncTaskService.saveTask(examPrintPlan.getSchoolId(), examPrintPlan.getId(), PushTypeEnum.EXAM_PUSH);
|
|
|
doSyncBaseData(examPrintPlan, thirdRelateId, thirdRelateName, syncTask, sysUser);
|
|
|
}
|
|
|
}
|
|
@@ -185,10 +182,12 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure) {
|
|
|
+ public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure, TBSyncTask tbSyncTask) {
|
|
|
// 开始同步
|
|
|
- examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
|
|
|
- ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
|
|
|
+ ExamPaperStructureStatusEnum structureStatus = ExamPaperStructureStatusEnum.INIT;
|
|
|
+ // 同步初始参数
|
|
|
+ TaskResultEnum result = null;
|
|
|
+ String errorMessage = null;
|
|
|
try {
|
|
|
String paperTypes = examPaperStructure.getPaperType();
|
|
|
if (StringUtils.isBlank(paperTypes)) {
|
|
@@ -201,6 +200,9 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
// 科目代码(课程代码+卷型+课程序号)
|
|
|
String subjectCode = examPaperStructure.getCourseCode().concat(examPaperStructure.getPaperType()).concat(examPaperStructure.getSequence());
|
|
|
|
|
|
+ // 同步中
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), TaskStatusEnum.RUNNING, null, null);
|
|
|
+
|
|
|
// 同步主观题
|
|
|
String subjectiveStructure = examPaperStructure.getSubjectiveStructure();
|
|
|
if (StringUtils.isNotBlank(subjectiveStructure)) {
|
|
@@ -216,7 +218,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
|
|
|
cloudMarkingTaskUtils.syncPaperStructure(schoolId, examId, subjectCode, false, null, syncSubjectiveStructureDatas);
|
|
|
}
|
|
|
-// status = ExamPaperStructureStatusEnum.FINISH;
|
|
|
+ structureStatus = ExamPaperStructureStatusEnum.SUBJECTIVE_FINISH;
|
|
|
|
|
|
// 同步分组
|
|
|
int countGroup = cloudMarkingTaskUtils.countGroup(schoolId, examId, subjectCode);
|
|
@@ -255,6 +257,7 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
cloudMarkingTaskUtils.saveMarkerGroup(schoolId, examId, subjectCode, 0, groupDetailDTOS);
|
|
|
}
|
|
|
+ structureStatus = ExamPaperStructureStatusEnum.GROUP_FINISH;
|
|
|
|
|
|
// 同步绑定评卷员
|
|
|
for (ExamPaperGroup examPaperGroup : examPaperGroups) {
|
|
@@ -263,18 +266,25 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
cloudMarkingTaskUtils.saveMarker(schoolId, examId, subjectCode, examPaperGroup.getGroupNumber(), examPaperGroupMarker.getLoginName());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ structureStatus = ExamPaperStructureStatusEnum.FINISH;
|
|
|
+ result = TaskResultEnum.SUCCESS;
|
|
|
} catch (ApiException e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
|
|
|
+ result = TaskResultEnum.ERROR;
|
|
|
+ errorMessage = e.getMessage();
|
|
|
} finally {
|
|
|
- examPaperStructure.setStatus(status);
|
|
|
+ examPaperStructure.setStatus(structureStatus);
|
|
|
examPaperStructureService.updateById(examPaperStructure);
|
|
|
+
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), TaskStatusEnum.FINISH, result, errorMessage);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void syncPaperAndAnswer(ExamPaperStructure examPaperStructure) {
|
|
|
+ public void syncPaperAndAnswer(ExamPaperStructure examPaperStructure, TBSyncTask tbSyncTask) {
|
|
|
+ // 同步初始参数
|
|
|
+ TaskResultEnum result = null;
|
|
|
+ String errorMessage = null;
|
|
|
try {
|
|
|
Long schoolId = examPaperStructure.getSchoolId();
|
|
|
// 云阅卷考试ID
|
|
@@ -282,6 +292,8 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
// 科目代码(课程代码+卷型+课程序号)
|
|
|
String subjectCode = examPaperStructure.getCourseCode().concat(examPaperStructure.getPaperType()).concat(examPaperStructure.getSequence());
|
|
|
|
|
|
+ // 同步中
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), TaskStatusEnum.RUNNING, null, null);
|
|
|
// 同步试卷
|
|
|
String paperAnswer = examPaperStructure.getPaperAnswer();
|
|
|
if (StringUtils.isNotBlank(paperAnswer)) {
|
|
@@ -322,15 +334,21 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
|
|
|
}
|
|
|
+ result = TaskResultEnum.SUCCESS;
|
|
|
} catch (ApiException e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
|
|
|
+ result = TaskResultEnum.ERROR;
|
|
|
+ errorMessage = e.getMessage();
|
|
|
} finally {
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), TaskStatusEnum.FINISH, result, errorMessage);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void syncObjectiveStructure(ExamPaperStructure examPaperStructure) {
|
|
|
+ public void syncObjectiveStructure(ExamPaperStructure examPaperStructure, TBSyncTask tbSyncTask) {
|
|
|
+ // 同步初始参数
|
|
|
+ TaskResultEnum result = null;
|
|
|
+ String errorMessage = null;
|
|
|
try {
|
|
|
Long schoolId = examPaperStructure.getSchoolId();
|
|
|
// 云阅卷考试ID
|
|
@@ -352,53 +370,67 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}).collect(Collectors.toList());
|
|
|
cloudMarkingTaskUtils.syncPaperStructure(schoolId, examId, subjectCode, true, null, syncObjectiveStructureDatas);
|
|
|
}
|
|
|
+
|
|
|
+ result = TaskResultEnum.SUCCESS;
|
|
|
} catch (ApiException e) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
|
|
|
+ result = TaskResultEnum.ERROR;
|
|
|
+ errorMessage = e.getMessage();
|
|
|
} finally {
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), TaskStatusEnum.FINISH, result, errorMessage);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 同步核心方法
|
|
|
+ * 同步考试、考生、科目、题卡
|
|
|
*
|
|
|
- * @param thirdRelateName
|
|
|
- * @param syncTask
|
|
|
+ * @param examPrintPlan 计划
|
|
|
+ * @param thirdRelateId 云阅卷考试ID
|
|
|
+ * @param thirdRelateName 云阅卷考试名称
|
|
|
+ * @param syncTask 同步任务对象
|
|
|
+ * @param sysUser 登录用户
|
|
|
*/
|
|
|
public void doSyncBaseData(ExamPrintPlan examPrintPlan, Long thirdRelateId, String thirdRelateName, TBSyncTask syncTask, SysUser sysUser) {
|
|
|
UpdateWrapper<ExamPrintPlan> updateWrapper = new UpdateWrapper<>();
|
|
|
ExamPrintPlanSyncStatusEnum syncStatus = ExamPrintPlanSyncStatusEnum.INIT;
|
|
|
+
|
|
|
+ // 同步初始参数
|
|
|
+ TaskResultEnum result = null;
|
|
|
+ TaskStatusEnum status;
|
|
|
+ String errorMessage = null;
|
|
|
try {
|
|
|
if (!PrintPlanStatusEnum.END.equals(examPrintPlan.getStatus()) && !PrintPlanStatusEnum.PRINT_FINISH.equals(examPrintPlan.getStatus())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印刷计划未打印完成或者未结束,不能同步数据");
|
|
|
}
|
|
|
- UpdateWrapper<TBSyncTask> tbSyncTaskUpdateWrapper = new UpdateWrapper<>();
|
|
|
- tbSyncTaskUpdateWrapper.lambda().set(TBSyncTask::getStatus, TaskStatusEnum.RUNNING).eq(TBSyncTask::getId, syncTask.getId());
|
|
|
- tbSyncTaskService.update(tbSyncTaskUpdateWrapper);
|
|
|
+ // 同步中
|
|
|
+ status = TaskStatusEnum.RUNNING;
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(syncTask.getId(), status, null, null);
|
|
|
|
|
|
- // 同步计划 -> 对应云阅卷考试
|
|
|
+ // 同步计划 -> 同步到云阅卷考试
|
|
|
thirdRelateId = saveExam(examPrintPlan, thirdRelateId);
|
|
|
syncStatus = ExamPrintPlanSyncStatusEnum.EXAM_FINISH;
|
|
|
syncTask.setThirdRelateId(thirdRelateId);
|
|
|
// 考试同步成功,才能同步考生和题卡
|
|
|
if (Objects.nonNull(thirdRelateId)) {
|
|
|
updateWrapper.lambda().set(ExamPrintPlan::getThirdRelateId, thirdRelateId).set(ExamPrintPlan::getThirdRelateName, thirdRelateName);
|
|
|
+ // 同步考生
|
|
|
saveStudent(examPrintPlan.getSchoolId(), examPrintPlan.getId(), thirdRelateId);
|
|
|
syncStatus = ExamPrintPlanSyncStatusEnum.STUDENT_FINISH;
|
|
|
+ // 同步题卡
|
|
|
cardUpload(examPrintPlan.getSchoolId(), examPrintPlan.getId(), thirdRelateId);
|
|
|
syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
|
|
|
} else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试,同步数据失败");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试ID,同步数据失败");
|
|
|
}
|
|
|
-
|
|
|
- // 更新日志表
|
|
|
- syncTask.setResult(TaskResultEnum.SUCCESS);
|
|
|
- syncTask.setErrorMessage(null);
|
|
|
+ // 任务结果
|
|
|
+ result = TaskResultEnum.SUCCESS;
|
|
|
} catch (Exception e) {
|
|
|
- syncTask.setResult(TaskResultEnum.ERROR);
|
|
|
- syncTask.setErrorMessage(e.getMessage());
|
|
|
+ result = TaskResultEnum.ERROR;
|
|
|
+ errorMessage = e.getMessage();
|
|
|
} finally {
|
|
|
- syncTask.setStatus(TaskStatusEnum.FINISH);
|
|
|
- tbSyncTaskService.saveOrUpdate(syncTask);
|
|
|
+ // 同步结束
|
|
|
+ status = TaskStatusEnum.FINISH;
|
|
|
+ tbSyncTaskService.updateStatusAndResultById(syncTask.getId(), status, result, errorMessage);
|
|
|
+
|
|
|
updateWrapper.lambda().set(ExamPrintPlan::getSyncStatus, syncStatus).eq(ExamPrintPlan::getId, examPrintPlan.getId());
|
|
|
examPrintPlanService.update(updateWrapper);
|
|
|
// 同步成功,发送短信
|