|
@@ -125,62 +125,71 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
// 按学院code进行分组,并按学院进行循环同步
|
|
|
Map<String, List<SyncExamTaskDto>> byCollegeCodeMap = params.stream().collect(Collectors.groupingBy(SyncExamTaskDto::getCollegeCode));
|
|
|
for (Map.Entry<String, List<SyncExamTaskDto>> entry : byCollegeCodeMap.entrySet()) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //按课程做同步
|
|
|
- for (SyncExamTaskDto param : params) {
|
|
|
- // 前置方法已经校验过各课程下是否有学院代码
|
|
|
// 本行为,若为按学校同步,则后续方法都传null,方便校验
|
|
|
- String orgCode = cloudMarkingTaskUtils.isCollegeMode(schoolId) ? param.getCollegeCode() : null;
|
|
|
- // 同步机构
|
|
|
- thirdRelateOrgId = saveSchool(schoolId, thirdRelateOrgId, orgCode, param.getCollegeName());
|
|
|
- // 同步考试
|
|
|
- thirdRelateId = saveExam(schoolId, objectId, orgCode, thirdRelateId, thirdRelateName, examTime);
|
|
|
-
|
|
|
- Long examTaskId = Long.valueOf(param.getExamTaskId());
|
|
|
- ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
- ExamTaskSync examTaskSync = examTaskSyncService.getBySchoolIdAndOrgCodeAndPaperNumber(schoolId, examTask.getExamId(), orgCode, examTask.getPaperNumber());
|
|
|
- if (examTaskSync != null && ExamTaskSyncStatusEnum.STARTING.equals(examTaskSync.getSyncStatus())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("其它任务中该课程正在同步中,请刷新列表查看最新状态");
|
|
|
+ String orgCode = cloudMarkingTaskUtils.isCollegeMode(schoolId) ? entry.getKey() : null;
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(orgCode)) {
|
|
|
+ SysOrg byCode = sysOrgService.findByCode(orgCode);
|
|
|
+ // 同步机构
|
|
|
+ thirdRelateOrgId = saveSchool(schoolId, thirdRelateOrgId, orgCode, byCode.getName());
|
|
|
}
|
|
|
- ExamTaskSyncStatusEnum syncStatus = ExamTaskSyncStatusEnum.STARTING;
|
|
|
-
|
|
|
- if (examTaskSync == null) {
|
|
|
- examTaskSync = new ExamTaskSync(schoolId, examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber(), orgCode, Math.toIntExact(thirdRelateId), syncStatus, sysUser.getId(), System.currentTimeMillis(), null);
|
|
|
- } else {
|
|
|
- examTaskSync.setSyncStatus(syncStatus);
|
|
|
- examTaskSync.setSyncStartTime(System.currentTimeMillis());
|
|
|
- examTaskSync.setSyncUserId(sysUser.getId());
|
|
|
- examTaskSync.setErrorMsg(null);
|
|
|
+ // 查询本地库中云阅卷考试Id是否存在
|
|
|
+ TSyncStmmsExam tSyncStmmsExam = tSyncStmmsExamService.getBySchoolIdAndOrgCodeAndExamName(schoolId, orgCode, thirdRelateName);
|
|
|
+ if (tSyncStmmsExam != null) {
|
|
|
+ thirdRelateId = Long.valueOf(tSyncStmmsExam.getExamId());
|
|
|
}
|
|
|
- examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
|
|
|
|
- try {
|
|
|
- List<Long> printPlanIds = Arrays.asList(param.getPrintPlanIds().split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
|
|
|
- List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
|
|
|
- // 同步考生
|
|
|
- List<SyncExamStudentDto> syncExamStudentDtoList = examStudentService.listStudentByExamDetailCourseId(examDetailCourseList);
|
|
|
-
|
|
|
- long count = syncExamStudentDtoList.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
|
|
|
- if (count > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
|
|
|
+ //按课程做同步
|
|
|
+ for (SyncExamTaskDto param : params) {
|
|
|
+ // 前置方法已经校验过各课程下是否有学院代码
|
|
|
+ // 同步考试
|
|
|
+ thirdRelateId = saveExam(schoolId, objectId, orgCode, thirdRelateId, thirdRelateName, examTime);
|
|
|
+
|
|
|
+ Long examTaskId = Long.valueOf(param.getExamTaskId());
|
|
|
+ ExamTask examTask = examTaskService.getById(examTaskId);
|
|
|
+ ExamTaskSync examTaskSync = examTaskSyncService.getBySchoolIdAndOrgCodeAndPaperNumber(schoolId, examTask.getExamId(), orgCode, examTask.getPaperNumber());
|
|
|
+ if (examTaskSync != null && ExamTaskSyncStatusEnum.STARTING.equals(examTaskSync.getSyncStatus())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("其它任务中该课程正在同步中,请刷新列表查看最新状态");
|
|
|
}
|
|
|
- // 同步考生
|
|
|
- saveStudent(schoolId, thirdRelateId, syncExamStudentDtoList);
|
|
|
+ ExamTaskSyncStatusEnum syncStatus = ExamTaskSyncStatusEnum.STARTING;
|
|
|
+
|
|
|
+ if (examTaskSync == null) {
|
|
|
+ examTaskSync = new ExamTaskSync(schoolId, examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber(), orgCode, Math.toIntExact(thirdRelateId), syncStatus, sysUser.getId(), System.currentTimeMillis(), null);
|
|
|
+ } else {
|
|
|
+ examTaskSync.setSyncStatus(syncStatus);
|
|
|
+ examTaskSync.setSyncStartTime(System.currentTimeMillis());
|
|
|
+ examTaskSync.setSyncUserId(sysUser.getId());
|
|
|
+ examTaskSync.setErrorMsg(null);
|
|
|
+ }
|
|
|
+ examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<Long> printPlanIds = Arrays.asList(param.getPrintPlanIds().split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
|
|
|
+ List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
|
|
|
+ // 同步考生
|
|
|
+ List<SyncExamStudentDto> syncExamStudentDtoList = examStudentService.listStudentByExamDetailCourseId(examDetailCourseList);
|
|
|
+
|
|
|
+ long count = syncExamStudentDtoList.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
|
|
|
+ }
|
|
|
+ // 同步考生
|
|
|
+ saveStudent(schoolId, thirdRelateId, syncExamStudentDtoList);
|
|
|
|
|
|
- // 同步题卡
|
|
|
- for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
|
|
|
// 同步题卡
|
|
|
- cardUpload(schoolId, thirdRelateId, examTask, examDetailCourseDto.getPaperType());
|
|
|
+ for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
|
|
|
+ // 同步题卡
|
|
|
+ cardUpload(schoolId, thirdRelateId, examTask, examDetailCourseDto.getPaperType());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ examTaskSync.setErrorMsg(e.getMessage());
|
|
|
+ examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FAIL);
|
|
|
+ } finally {
|
|
|
+ examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FINISH);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- examTaskSync.setErrorMsg(e.getMessage());
|
|
|
- examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FAIL);
|
|
|
- } finally {
|
|
|
- examTaskSync.setSyncStatus(ExamTaskSyncStatusEnum.FINISH);
|
|
|
+ examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
|
}
|
|
|
- examTaskSyncService.saveOrUpdate(examTaskSync);
|
|
|
+
|
|
|
}
|
|
|
// 任务结果
|
|
|
result = TaskResultEnum.SUCCESS;
|
|
@@ -542,33 +551,33 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
/**
|
|
|
* 创建考试
|
|
|
*
|
|
|
- * @param schoolId 学校ID
|
|
|
- * @param thirdRelateId 学院ID
|
|
|
- * @param orgCode 学院代码
|
|
|
- * @param orgName 学院名称
|
|
|
+ * @param schoolId 学校ID
|
|
|
+ * @param thirdRelateOrgId 学院ID
|
|
|
+ * @param orgCode 学院代码
|
|
|
+ * @param orgName 学院名称
|
|
|
*/
|
|
|
@Override
|
|
|
- public Integer saveSchool(Long schoolId, Integer thirdRelateId, String orgCode, String orgName) {
|
|
|
+ public Integer saveSchool(Long schoolId, Integer thirdRelateOrgId, String orgCode, String orgName) {
|
|
|
if (StringUtils.isBlank(orgCode)) {
|
|
|
return null;
|
|
|
}
|
|
|
try {
|
|
|
- if (Objects.isNull(thirdRelateId)) {
|
|
|
- thirdRelateId = cloudMarkingTaskUtils.syncSchool(schoolId, orgCode, orgName);
|
|
|
+ if (Objects.isNull(thirdRelateOrgId)) {
|
|
|
+ thirdRelateOrgId = cloudMarkingTaskUtils.syncSchool(schoolId, orgCode, orgName);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
}
|
|
|
try {
|
|
|
UpdateWrapper<SysOrg> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().set(SysOrg::getThirdRelateId, thirdRelateId)
|
|
|
+ updateWrapper.lambda().set(SysOrg::getThirdRelateId, thirdRelateOrgId)
|
|
|
.eq(SysOrg::getSchoolId, schoolId)
|
|
|
.eq(SysOrg::getCode, orgCode)
|
|
|
.isNull(SysOrg::getThirdRelateId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("保存云阅卷机构数据失败。");
|
|
|
}
|
|
|
- return thirdRelateId;
|
|
|
+ return thirdRelateOrgId;
|
|
|
}
|
|
|
|
|
|
/**
|