Browse Source

Merge remote-tracking branch 'origin/dev_v3.2.5' into dev_v3.2.5

wangliang 2 năm trước cách đây
mục cha
commit
f41b568d54

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TSyncStmmsExamService.java

@@ -15,4 +15,6 @@ public interface TSyncStmmsExamService extends IService<TSyncStmmsExam> {
     List<TSyncStmmsExam> syncExam(String orgCode);
 
     TSyncStmmsExam getBySchoolIdAndExamId(Long schoolId, String orgCode, Long thirdRelateId);
+
+    TSyncStmmsExam getBySchoolIdAndOrgCodeAndExamName(Long schoolId, String orgCode, String thirdRelateName);
 }

+ 65 - 56
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java

@@ -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;
     }
 
     /**

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncStmmsExamServiceImpl.java

@@ -93,4 +93,15 @@ public class TSyncStmmsExamServiceImpl extends ServiceImpl<TSyncStmmsExamMapper,
         }
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public TSyncStmmsExam getBySchoolIdAndOrgCodeAndExamName(Long schoolId, String orgCode, String thirdRelateName) {
+        QueryWrapper<TSyncStmmsExam> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(TSyncStmmsExam::getSchoolId, schoolId)
+                .eq(TSyncStmmsExam::getExamName, thirdRelateName);
+        if (StringUtils.isNotBlank(orgCode)) {
+            queryWrapper.lambda().eq(TSyncStmmsExam::getOrgCode, orgCode);
+        }
+        return this.getOne(queryWrapper);
+    }
 }

+ 4 - 12
distributed-print-business/src/main/resources/mapper/ExamPrintPlanMapper.xml

@@ -225,9 +225,7 @@
             <foreach collection="examDetailStatus" item="item" index="index" open="(" separator="," close=")">
                 #{item}
             </foreach>
-            <if test="semesterId != null">
-                and be.semester_id = #{semesterId}
-            </if>
+            and be.semester_id = #{semesterId}
             <if test="examId != null">
                 and be.id = #{examId}
             </if>
@@ -329,9 +327,7 @@
             <foreach collection="examDetailStatus" item="item" index="index" open="(" separator="," close=")">
                 #{item}
             </foreach>
-            <if test="semesterId != null">
-                and be.semester_id = #{semesterId}
-            </if>
+            and be.semester_id = #{semesterId}
             <if test="examId != null">
                 and be.id = #{examId}
             </if>
@@ -435,9 +431,7 @@
             <foreach collection="examDetailStatus" item="item" index="index" open="(" separator="," close=")">
                 #{item}
             </foreach>
-            <if test="semesterId != null">
-                and be.semester_id = #{semesterId}
-            </if>
+            and be.semester_id = #{semesterId}
             <if test="examId != null">
                 and be.id = #{examId}
             </if>
@@ -512,9 +506,7 @@
             <foreach collection="examDetailStatus" item="item" index="index" open="(" separator="," close=")">
                 #{item}
             </foreach>
-            <if test="semesterId != null">
-                and be.semester_id = #{semesterId}
-            </if>
+            and be.semester_id = #{semesterId}
             <if test="examId != null">
                 and be.id = #{examId}
             </if>

+ 1 - 3
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -698,9 +698,7 @@
             <foreach item="item" collection="examDetailStatus" separator="," open="(" close=")" index="">
                 #{item}
             </foreach>
-            <if test="semesterId != null">
-                and be.semester_id = #{semesterId}
-            </if>
+            and be.semester_id = #{semesterId}
             <if test="examId != null">
                 and be.id = #{examId}
             </if>