xiaof 3 жил өмнө
parent
commit
e50d047efb
12 өөрчлөгдсөн 131 нэмэгдсэн , 289 устгасан
  1. 4 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/DataSyncService.java
  2. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPaperStructureService.java
  3. 38 223
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java
  4. 13 22
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java
  5. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SsoServiceImpl.java
  6. 31 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCloudMarkingTaskService.java
  7. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PushLogicServiceImpl.java
  8. 19 21
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamPaperStructureController.java
  9. 2 2
      distributed-print/src/test/java/com/qmth/distributed/print/SyncHelpTest.java
  10. 6 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/PushTypeEnum.java
  11. 2 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java
  12. 11 5
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/CloudMarkingTaskUtils.java

+ 4 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/DataSyncService.java

@@ -1,13 +1,10 @@
 package com.qmth.distributed.print.business.service;
 
-import com.qmth.distributed.print.business.bean.marking.EvaluationParameters;
 import com.qmth.distributed.print.business.bean.params.SyncDataParam;
 import com.qmth.distributed.print.business.entity.ExamPaperStructure;
 
 /**
  * 同步数据到云阅卷 服务类
- *
- * @Date: 2021/5/20.
  */
 public interface DataSyncService {
     void syncToCloudReview();
@@ -16,7 +13,9 @@ public interface DataSyncService {
 
     void syncDataMerge(SyncDataParam syncDataParam);
 
-    void syncPaperStructure(ExamPaperStructure examPaperStructure);
-
     void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure);
+
+    void syncPaperAndAnswer(ExamPaperStructure examPaperStructure);
+
+    void syncObjectiveStructure(ExamPaperStructure examPaperStructure);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPaperStructureService.java

@@ -24,7 +24,7 @@ public interface ExamPaperStructureService extends IService<ExamPaperStructure>
 
     ExamPaperStructure upload(String examPaperStructure, String md5, String keys, MultipartFile[] files);
 
-    ExamPaperStructure uploadAnswer(String examPaperStructure, String md5, MultipartFile file);
+    ExamPaperStructure uploadAnswer(Long id, String md5, MultipartFile file);
 
     void updateStatusById(Long id, ExamPaperStructureStatusEnum startSync);
 

+ 38 - 223
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java

@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.distributed.print.business.bean.dto.ExamPaperObjectiveStructureDto;
-import com.qmth.distributed.print.business.bean.dto.ExamPaperSubjectiveStructureDto;
 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;
@@ -31,11 +29,12 @@ import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.common.service.BasicAttachmentService;
 import com.qmth.teachcloud.common.service.SysConfigService;
 import com.qmth.teachcloud.common.service.TeachcloudCommonService;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
@@ -88,7 +87,7 @@ public class DataSyncServiceImpl implements DataSyncService {
     private ExamPaperGroupMarkerService examPaperGroupMarkerService;
 
     @Resource
-    StmmsUtils stmmsUtils;
+    private CloudMarkingTaskUtils cloudMarkingTaskUtils;
 
     ExecutorService executorService = Executors.newFixedThreadPool(5);
 
@@ -154,7 +153,7 @@ public class DataSyncServiceImpl implements DataSyncService {
             List<ExamPrintPlan> examPrintPlans = examPrintPlanService.list(printPlanQueryWrapper);
             ExamPrintPlan examPrintPlan = examPrintPlans.stream().max(Comparator.comparingLong(ExamPrintPlan::getExamEndTime)).get();
             String examTime = DateUtil.format(new Date(examPrintPlan.getExamEndTime()), DATE_FORMAT);
-            syncDataParam.setThirdRelateId(stmmsUtils.syncExam(examPrintPlan.getSchoolId(), time, syncDataParam.getThirdRelateName(), examTime));
+            syncDataParam.setThirdRelateId(cloudMarkingTaskUtils.syncExam(examPrintPlan.getSchoolId(), time, syncDataParam.getThirdRelateName(), examTime));
         }
 
         for (Long printPlanId : printPlans) {
@@ -163,16 +162,6 @@ public class DataSyncServiceImpl implements DataSyncService {
         }
     }
 
-    @Override
-    public void syncPaperStructure(ExamPaperStructure examPaperStructure) {
-        executorService.execute(syncStructure(examPaperStructure));
-    }
-
-    @Override
-    public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure) {
-        executorService.execute(syncPaperStructureAndGroup1(examPaperStructure));
-    }
-
     /**
      * 同步基础信息
      *
@@ -194,157 +183,9 @@ public class DataSyncServiceImpl implements DataSyncService {
         };
     }
 
-    /**
-     * 同步试卷结构信息
-     *
-     * @param examPaperStructure
-     * @return
-     */
-    private TimerTask syncStructure(ExamPaperStructure examPaperStructure) {
-        return new TimerTask() {
-            @Override
-            public void run() {
-                SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
-                if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
-                    doSyncStructure(examPaperStructure);
-                }
-            }
-        };
-    }
-
-    /**
-     * 同步试卷结构信息
-     *
-     * @param evaluationParameters
-     * @return
-     */
-    private TimerTask syncPaperStructureAndGroup1(ExamPaperStructure examPaperStructure) {
-        return new TimerTask() {
-            @Override
-            public void run() {
-                SysConfig sysConfig = sysConfigService.getByKey("sys.sync.enable");
-                if (sysConfig != null && "true".equals(sysConfig.getConfigValue())) {
-                    doSyncStructureAndGroup(examPaperStructure);
-                }
-            }
-        };
-    }
-
-    public void doSyncStructure(ExamPaperStructure examPaperStructure) {
-        // 开始同步
-        examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
-        ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
-        try {
-            String paperTypes = examPaperStructure.getPaperType();
-            if (StringUtils.isBlank(paperTypes)) {
-                throw ExceptionResultEnum.ERROR.exception("没有可同步的试卷类型");
-            }
-
-            // 同步试卷
-            String paperAnswer = examPaperStructure.getPaperAnswer();
-            if (StringUtils.isNotBlank(paperAnswer)) {
-                List<JSONObject> paperAnswerJsons = JSONObject.parseArray(paperAnswer, JSONObject.class);
-                for (JSONObject paperAnswerJson : paperAnswerJsons) {
-                    if (paperAnswerJson.containsKey("paperType") && paperAnswerJson.containsKey("paper")) {
-                        String paperType = paperAnswerJson.getString("paperType");
-                        String paper = paperAnswerJson.getString("paper");
-                        if (StringUtils.isAnyBlank(paperType, paper)) {
-                            continue;
-                        }
-
-                        // 同步试卷文件
-                        File paperFile = downFileFromFss(paper, paperType, SyncFileTypeEnum.PAPER);
-                        String syncPaperFileUrl = stmmsUtils.syncFile(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + paperType, SyncFileTypeEnum.PAPER, paperFile);
-                        // 试卷文件保存url
-                        paperAnswerJson.put("paperUrl", syncPaperFileUrl);
-                    }
-                }
-                status = ExamPaperStructureStatusEnum.PAPER_FINISH;
-                examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
-            }
-
-            // 同步标答
-            if (StringUtils.isNotBlank(paperAnswer)) {
-                List<JSONObject> paperAnswerJsons = JSONObject.parseArray(paperAnswer, JSONObject.class);
-                for (JSONObject paperAnswerJson : paperAnswerJsons) {
-                    if (paperAnswerJson.containsKey("paperType") && paperAnswerJson.containsKey("answer")) {
-                        String paperType = paperAnswerJson.getString("paperType");
-                        String answer = paperAnswerJson.getString("answer");
-                        if (StringUtils.isAnyBlank(paperType, answer)) {
-                            continue;
-                        }
-                        // 同步标答文件
-                        File answerFile = downFileFromFss(answer, paperType, SyncFileTypeEnum.ANSWER);
-                        String syncAnswerFileUrl = stmmsUtils.syncFile(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + paperType, SyncFileTypeEnum.ANSWER, answerFile);
-                        // 标答文件保存url
-                        paperAnswerJson.put("answerUrl", syncAnswerFileUrl);
-                    }
-                }
-                examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
-            }
-            status = ExamPaperStructureStatusEnum.ANSWER_FINISH;
-
-            // 同步客观题
-            String objectiveStructure = examPaperStructure.getObjectiveStructure();
-            if (StringUtils.isNotBlank(objectiveStructure)) {
-                List<JSONObject> objectiveJsons = JSONObject.parseArray(objectiveStructure, JSONObject.class);
-                for (JSONObject objectiveJson : objectiveJsons) {
-                    if (objectiveJson.containsKey("paperType") && objectiveJson.containsKey("content")) {
-                        String objectivePaperType = objectiveJson.getString("paperType");
-                        String objectiveContent = objectiveJson.getString("content");
-                        if (StringUtils.isAnyBlank(objectivePaperType, objectiveContent)) {
-                            continue;
-                        }
-                        List<ExamPaperObjectiveStructureDto> objectiveStructureDtos = JSONObject.parseArray(objectiveContent, ExamPaperObjectiveStructureDto.class);
-                        List<QuestionDTO> syncObjectiveStructureDatas = objectiveStructureDtos.stream().map(m -> {
-                            QuestionDTO syncStructureData = new QuestionDTO();
-                            syncStructureData.setMainNumber(Integer.valueOf(m.getMainNumber()));
-                            syncStructureData.setSubNumber(m.getSubNumber());
-                            syncStructureData.setMainTitle(m.getMainName());
-                            syncStructureData.setTotalScore(Double.valueOf(m.getScore()));
-                            syncStructureData.setAnswer(m.getAnswer());
-                            return syncStructureData;
-                        }).collect(Collectors.toList());
-                        stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + objectivePaperType, true, null, syncObjectiveStructureDatas);
-                    }
-                }
-            }
-            status = ExamPaperStructureStatusEnum.OBJECTIVE_FINISH;
-
-            // 同步主观题
-            String subjectiveStructure = examPaperStructure.getSubjectiveStructure();
-            if (StringUtils.isNotBlank(subjectiveStructure)) {
-                List<JSONObject> subjectiveJsons = JSONObject.parseArray(subjectiveStructure, JSONObject.class);
-                for (JSONObject subjectiveJson : subjectiveJsons) {
-                    if (subjectiveJson.containsKey("paperType") && subjectiveJson.containsKey("content")) {
-                        String subjectivePaperType = subjectiveJson.getString("paperType");
-                        String subjectiveContent = subjectiveJson.getString("content");
-                        if (StringUtils.isAnyBlank(subjectivePaperType, subjectiveContent)) {
-                            continue;
-                        }
-                        List<ExamPaperSubjectiveStructureDto> subjectiveStructureDtos = JSONObject.parseArray(subjectiveContent, ExamPaperSubjectiveStructureDto.class);
-                        List<QuestionDTO> syncSubjectiveStructureDatas = subjectiveStructureDtos.stream().map(m -> {
-                            QuestionDTO syncStructureData = new QuestionDTO();
-                            syncStructureData.setMainNumber(Integer.valueOf(m.getMainNumber()));
-                            syncStructureData.setSubNumber(m.getSubNumber());
-                            syncStructureData.setMainTitle(m.getMainName());
-                            syncStructureData.setTotalScore(Double.valueOf(m.getScore()));
-                            return syncStructureData;
-                        }).collect(Collectors.toList());
-                        stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + subjectivePaperType, false, null, syncSubjectiveStructureDatas);
-                    }
-                }
-            }
-            status = ExamPaperStructureStatusEnum.FINISH;
-        } catch (ApiException e) {
-            throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
-        } finally {
-            examPaperStructure.setStatus(status);
-            examPaperStructureService.updateById(examPaperStructure);
-        }
-    }
-
-    public void doSyncStructureAndGroup(ExamPaperStructure examPaperStructure) {
+    @Async
+    @Override
+    public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure) {
         // 开始同步
         examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
         ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
@@ -373,15 +214,15 @@ public class DataSyncServiceImpl implements DataSyncService {
                     return syncStructureData;
                 }).collect(Collectors.toList());
 
-                stmmsUtils.syncPaperStructure(schoolId, examId, subjectCode, false, null, syncSubjectiveStructureDatas);
+                cloudMarkingTaskUtils.syncPaperStructure(schoolId, examId, subjectCode, false, null, syncSubjectiveStructureDatas);
             }
 //            status = ExamPaperStructureStatusEnum.FINISH;
 
             // 同步分组
-            int countGroup = stmmsUtils.countGroup(schoolId, examId, subjectCode);
+            int countGroup = cloudMarkingTaskUtils.countGroup(schoolId, examId, subjectCode);
             // 如果存在分组,先删掉
             if (countGroup > 0) {
-                stmmsUtils.deleteGroup(schoolId, examId, subjectCode);
+                cloudMarkingTaskUtils.deleteGroup(schoolId, examId, subjectCode);
             }
             List<ExamPaperGroup> examPaperGroups = examPaperGroupService.listByExamPaperStructureId(examPaperStructure.getId());
             if (!CollectionUtils.isEmpty(examPaperGroups)) {
@@ -412,14 +253,14 @@ public class DataSyncServiceImpl implements DataSyncService {
                     }
                     groupDetailDTOS.add(groupDetailDTO);
                 }
-                stmmsUtils.saveMarkerGroup(schoolId, examId, subjectCode, 0, groupDetailDTOS);
+                cloudMarkingTaskUtils.saveMarkerGroup(schoolId, examId, subjectCode, 0, groupDetailDTOS);
             }
 
             // 同步绑定评卷员
             for (ExamPaperGroup examPaperGroup : examPaperGroups) {
                 List<ExamPaperGroupMarker> examPaperGroupMarkers = examPaperGroupMarkerService.listByGroupId(examPaperGroup.getId());
                 for (ExamPaperGroupMarker examPaperGroupMarker : examPaperGroupMarkers) {
-                    stmmsUtils.saveMarker(schoolId, examId, subjectCode, examPaperGroup.getGroupNumber(), examPaperGroupMarker.getLoginName());
+                    cloudMarkingTaskUtils.saveMarker(schoolId, examId, subjectCode, examPaperGroup.getGroupNumber(), examPaperGroupMarker.getLoginName());
                 }
             }
 
@@ -431,16 +272,10 @@ public class DataSyncServiceImpl implements DataSyncService {
         }
     }
 
-    public void doSyncAnswerFile(ExamPaperStructure examPaperStructure) {
-        // 开始同步
-        examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
-        ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
+    @Async
+    @Override
+    public void syncPaperAndAnswer(ExamPaperStructure examPaperStructure) {
         try {
-            String paperTypes = examPaperStructure.getPaperType();
-            if (StringUtils.isBlank(paperTypes)) {
-                throw ExceptionResultEnum.ERROR.exception("没有可同步的试卷类型");
-            }
-
             Long schoolId = examPaperStructure.getSchoolId();
             // 云阅卷考试ID
             String examId = String.valueOf(examPaperStructure.getThirdRelateId());
@@ -458,15 +293,13 @@ public class DataSyncServiceImpl implements DataSyncService {
                         if (StringUtils.isAnyBlank(paperType, paper)) {
                             continue;
                         }
-
                         // 同步试卷文件
                         File paperFile = downFileFromFss(paper, paperType, SyncFileTypeEnum.PAPER);
-                        String syncPaperFileUrl = stmmsUtils.syncFile(schoolId, examId, subjectCode, SyncFileTypeEnum.PAPER, paperFile);
+                        String syncPaperFileUrl = cloudMarkingTaskUtils.syncFile(schoolId, examId, subjectCode, SyncFileTypeEnum.PAPER, paperFile);
                         // 试卷文件保存url
                         paperAnswerJson.put("paperUrl", syncPaperFileUrl);
                     }
                 }
-                status = ExamPaperStructureStatusEnum.PAPER_FINISH;
                 examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
             }
 
@@ -482,64 +315,46 @@ public class DataSyncServiceImpl implements DataSyncService {
                         }
                         // 同步标答文件
                         File answerFile = downFileFromFss(answer, paperType, SyncFileTypeEnum.ANSWER);
-                        String syncAnswerFileUrl = stmmsUtils.syncFile(schoolId, examId, subjectCode, SyncFileTypeEnum.ANSWER, answerFile);
+                        String syncAnswerFileUrl = cloudMarkingTaskUtils.syncFile(schoolId, examId, subjectCode, SyncFileTypeEnum.ANSWER, answerFile);
                         // 标答文件保存url
                         paperAnswerJson.put("answerUrl", syncAnswerFileUrl);
                     }
                 }
                 examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerJsons));
             }
-            status = ExamPaperStructureStatusEnum.ANSWER_FINISH;
-
         } catch (ApiException e) {
             throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
         } finally {
-            examPaperStructure.setStatus(status);
-            examPaperStructureService.updateById(examPaperStructure);
         }
     }
 
-    public void doSyncObjectiveStructure(ExamPaperStructure examPaperStructure) {
-        // 开始同步
-        examPaperStructureService.updateStatusById(examPaperStructure.getId(), ExamPaperStructureStatusEnum.START_SYNC);
-        ExamPaperStructureStatusEnum status = ExamPaperStructureStatusEnum.UPLOAD_FINISH;
+    @Async
+    @Override
+    public void syncObjectiveStructure(ExamPaperStructure examPaperStructure) {
         try {
-            String paperTypes = examPaperStructure.getPaperType();
-            if (StringUtils.isBlank(paperTypes)) {
-                throw ExceptionResultEnum.ERROR.exception("没有可同步的试卷类型");
-            }
-
+            Long schoolId = examPaperStructure.getSchoolId();
+            // 云阅卷考试ID
+            String examId = String.valueOf(examPaperStructure.getThirdRelateId());
+            // 科目代码(课程代码+卷型+课程序号)
+            String subjectCode = examPaperStructure.getCourseCode().concat(examPaperStructure.getPaperType()).concat(examPaperStructure.getSequence());
             // 同步客观题
             String objectiveStructure = examPaperStructure.getObjectiveStructure();
             if (StringUtils.isNotBlank(objectiveStructure)) {
                 List<JSONObject> objectiveJsons = JSONObject.parseArray(objectiveStructure, JSONObject.class);
-                for (JSONObject objectiveJson : objectiveJsons) {
-                    if (objectiveJson.containsKey("paperType") && objectiveJson.containsKey("content")) {
-                        String objectivePaperType = objectiveJson.getString("paperType");
-                        String objectiveContent = objectiveJson.getString("content");
-                        if (StringUtils.isAnyBlank(objectivePaperType, objectiveContent)) {
-                            continue;
-                        }
-                        List<ExamPaperObjectiveStructureDto> objectiveStructureDtos = JSONObject.parseArray(objectiveContent, ExamPaperObjectiveStructureDto.class);
-                        List<QuestionDTO> syncObjectiveStructureDatas = objectiveStructureDtos.stream().map(m -> {
-                            QuestionDTO syncStructureData = new QuestionDTO();
-                            syncStructureData.setMainNumber(Integer.valueOf(m.getMainNumber()));
-                            syncStructureData.setSubNumber(m.getSubNumber());
-                            syncStructureData.setMainTitle(m.getMainName());
-                            syncStructureData.setTotalScore(Double.valueOf(m.getScore()));
-                            syncStructureData.setAnswer(m.getAnswer());
-                            return syncStructureData;
-                        }).collect(Collectors.toList());
-                        stmmsUtils.syncPaperStructure(examPaperStructure.getSchoolId(), String.valueOf(examPaperStructure.getThirdRelateId()), examPaperStructure.getPaperNumberId() + objectivePaperType, true, null, syncObjectiveStructureDatas);
-                    }
-                }
+                List<QuestionDTO> syncObjectiveStructureDatas = objectiveJsons.stream().map(m -> {
+                    QuestionDTO syncStructureData = new QuestionDTO();
+                    syncStructureData.setMainNumber(m.getInteger("mainNumber"));
+                    syncStructureData.setSubNumber(m.getString("subNumber"));
+                    syncStructureData.setMainTitle(m.getString("mainTitle"));
+                    syncStructureData.setTotalScore(m.getDouble("totalScore"));
+                    syncStructureData.setAnswer(m.getString("answer"));
+                    return syncStructureData;
+                }).collect(Collectors.toList());
+                cloudMarkingTaskUtils.syncPaperStructure(schoolId, examId, subjectCode, true, null, syncObjectiveStructureDatas);
             }
-            status = ExamPaperStructureStatusEnum.OBJECTIVE_FINISH;
         } catch (ApiException e) {
             throw ExceptionResultEnum.ERROR.exception("试卷结构同步失败:" + e.getMessage());
         } finally {
-            examPaperStructure.setStatus(status);
-            examPaperStructureService.updateById(examPaperStructure);
         }
     }
 
@@ -606,7 +421,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                 String code = String.valueOf(examPrintPlan.getId());
                 String name = examPrintPlan.getName();
                 String examTime = DateUtil.format(new Date(examPrintPlan.getExamEndTime()), DATE_FORMAT);
-                thirdRelateId = stmmsUtils.syncExam(examPrintPlan.getSchoolId(), code, name, examTime);
+                thirdRelateId = cloudMarkingTaskUtils.syncExam(examPrintPlan.getSchoolId(), code, name, examTime);
             }
             return thirdRelateId;
         } catch (Exception e) {
@@ -634,7 +449,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                 String teacher = "无";
                 String subjectCode = examStudent.getPaperNumberId() + examStudent.getPaperType(); // 取试卷编号
                 String subjectName = examStudent.getPaperNumber() + examStudent.getPaperType() + "-" + examStudent.getCourseName();
-                boolean syncStudent = stmmsUtils.syncStudent(schoolId, examId, examNumber, studentCode, name, college, className, teacher, subjectCode, subjectName, null, null, null, null);
+                boolean syncStudent = cloudMarkingTaskUtils.syncStudent(schoolId, examId, examNumber, studentCode, name, college, className, teacher, subjectCode, subjectName, null, null, null, null);
 
                 if (syncStudent) {
                     UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
@@ -684,7 +499,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                         String filePath = getTempDir(SyncFileTypeEnum.CARD);
                         file = createJsonFile(filePath, syncExamCardDto.getContent());
                         if (file.exists()) {
-                            String uploadCardUrl = stmmsUtils.syncFile(schoolId, String.valueOf(thirdRelateId), syncExamCardDto.getPaperNumberId() + s, SyncFileTypeEnum.CARD, file);
+                            String uploadCardUrl = cloudMarkingTaskUtils.syncFile(schoolId, String.valueOf(thirdRelateId), syncExamCardDto.getPaperNumberId() + s, SyncFileTypeEnum.CARD, file);
                             if (StringUtils.isNotBlank(uploadCardUrl)) {
                                 UpdateWrapper<ExamCard> updateWrapper = new UpdateWrapper<>();
                                 updateWrapper.lambda().set(ExamCard::getSyncStatus, true).eq(ExamCard::getId, syncExamCardDto.getId());

+ 13 - 22
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java

@@ -30,7 +30,7 @@ import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import com.qmth.teachcloud.common.service.BasicAttachmentService;
 import com.qmth.teachcloud.common.service.BasicSemesterService;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -70,7 +70,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
     BasicAttachmentService basicAttachmentService;
 
     @Resource
-    StmmsUtils stmmsUtils;
+    CloudMarkingTaskUtils stmmsUtils;
 
     @Resource
     BasicSemesterService basicSemesterService;
@@ -193,29 +193,21 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
 
     @Transactional
     @Override
-    public ExamPaperStructure uploadAnswer(String examPaperStructure, String md5, MultipartFile file) {
-
-        ExamPaperStructure examPaperStructureTemp = JSONObject.parseObject(examPaperStructure, ExamPaperStructure.class);
-        if (Objects.isNull(examPaperStructureTemp.getId())) {
-            // 保存
-            examPaperStructureTemp.setId(SystemConstant.getDbUuid());
-            this.save(examPaperStructureTemp);
-        } else {
-            examPaperStructureTemp = this.getById(examPaperStructureTemp.getId());
+    public ExamPaperStructure uploadAnswer(Long id, String md5, MultipartFile file) {
+        ExamPaperStructure examPaperStructure = this.getById(id);
+        if (examPaperStructure == null) {
+            throw ExceptionResultEnum.ERROR.exception("请先设置试卷结构和分组");
         }
-
         // 组装ExamPaperStructureDto
         List<BasicAttachment> basicAttachmentList = new ArrayList<>();
         List<Map<String, Object>> paperAnswerList = new ArrayList<>();
 
         // 试卷卷型及原卷附件ID
-        Map<String, String> paperMap = createExamTaskAttachmentIds(examPaperStructureTemp);
-
+        Map<String, String> paperMap = createExamTaskAttachmentIds(examPaperStructure);
         // 上传试卷结构、标答文件
         Map<String, Object> paperAnswerMap = new HashMap<>();
-        paperAnswerMap.put("paperType", examPaperStructureTemp.getPaperType());
+        paperAnswerMap.put("paperType", examPaperStructure.getPaperType());
         try {
-
             // 标答附件
             BasicAttachment answerBasicAttachment = printCommonService.saveAttachment(file, md5, UploadFileEnum.UPLOAD);
             if (Objects.isNull(answerBasicAttachment)) {
@@ -223,9 +215,8 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
             }
             basicAttachmentList.add(answerBasicAttachment);
             paperAnswerMap.put("answer", answerBasicAttachment.getId());
-
             // 试卷原卷
-            paperAnswerMap.put("paper", paperMap.get(examPaperStructureTemp.getPaperType()));
+            paperAnswerMap.put("paper", paperMap.get(examPaperStructure.getPaperType()));
             paperAnswerList.add(paperAnswerMap);
         } catch (Exception e) {
             for (BasicAttachment basicAttachment : basicAttachmentList) {
@@ -239,10 +230,10 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
         }
 
         // 保存
-        examPaperStructureTemp.setPaperAnswer(JSONObject.toJSONString(paperAnswerList));
-        this.updateById(examPaperStructureTemp);
+        examPaperStructure.setPaperAnswer(JSONObject.toJSONString(paperAnswerList));
+        this.updateById(examPaperStructure);
 
-        return examPaperStructureTemp;
+        return examPaperStructure;
     }
 
     @Override
@@ -352,7 +343,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
         examPaperStructure.setPaperInfoJson(paperInfoJson);
         examPaperStructure.setPropositionTeacherId(propositionTeacherId);
         examPaperStructure.setEnable(true);
-        if (SystemConstant.longNotNull(examPaperStructureId)){
+        if (SystemConstant.longNotNull(examPaperStructureId)) {
             examPaperStructure.setId(examPaperStructureId);
         }
         this.saveOrUpdate(examPaperStructure);

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SsoServiceImpl.java

@@ -5,7 +5,7 @@ import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
 import com.qmth.teachcloud.common.service.SysUserService;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,7 +26,7 @@ public class SsoServiceImpl implements SsoService {
     private SysUserService sysUserService;
 
     @Autowired
-    StmmsUtils stmmsUtils;
+    CloudMarkingTaskUtils stmmsUtils;
 
     @Override
     public Map<String, Object> markerLoginInfo() {

+ 31 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCloudMarkingTaskService.java

@@ -29,7 +29,36 @@ public class AsyncCloudMarkingTaskService {
         return sysConfig != null && "true".equals(sysConfig.getConfigValue());
     }
 
-    public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure){
-        dataSyncService.syncPaperStructureAndGroup(examPaperStructure);
+    /**
+     * 同步试卷结构、分组信息、评卷员绑定关系
+     *
+     * @param examPaperStructure 试卷结构对象
+     */
+    public void syncPaperStructureAndGroup(ExamPaperStructure examPaperStructure) {
+        if (isSync()) {
+            dataSyncService.syncPaperStructureAndGroup(examPaperStructure);
+        }
+    }
+
+    /**
+     * 同步试卷文件、标签文件
+     *
+     * @param examPaperStructure 试卷结构对象
+     */
+    public void syncPaperAndAnswer(ExamPaperStructure examPaperStructure) {
+        if (isSync()) {
+            dataSyncService.syncPaperAndAnswer(examPaperStructure);
+        }
+    }
+
+    /**
+     * 同步客观题答案
+     *
+     * @param examPaperStructure 试卷结构对象
+     */
+    public void syncObjectiveStructure(ExamPaperStructure examPaperStructure) {
+        if (isSync()) {
+            dataSyncService.syncObjectiveStructure(examPaperStructure);
+        }
     }
 }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PushLogicServiceImpl.java

@@ -17,7 +17,7 @@ import com.qmth.teachcloud.common.service.BasicClazzService;
 import com.qmth.teachcloud.common.service.BasicMajorService;
 import com.qmth.teachcloud.common.service.BasicStudentService;
 import com.qmth.teachcloud.common.service.SysUserService;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -41,7 +41,7 @@ public class PushLogicServiceImpl implements PushLogicService {
     private SysUserService sysUserService;
 
     @Resource
-    StmmsUtils stmmsUtils;
+    CloudMarkingTaskUtils stmmsUtils;
 
     @Resource
     BasicClazzService basicClazzService;

+ 19 - 21
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamPaperStructureController.java

@@ -6,16 +6,14 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.marking.EvaluationParameters;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.entity.ExamPaperStructure;
-import com.qmth.distributed.print.business.service.DataSyncService;
 import com.qmth.distributed.print.business.service.ExamPaperStructureService;
-import com.qmth.teachcloud.common.bean.params.BasicMajorParams;
+import com.qmth.distributed.print.business.templete.execute.AsyncCloudMarkingTaskService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -43,7 +41,7 @@ public class ExamPaperStructureController {
     private ExamPaperStructureService examPaperStructureService;
 
     @Resource
-    private DataSyncService dataSyncService;
+    private AsyncCloudMarkingTaskService asyncCloudMarkingTaskService;
 
     /**
      * 查询
@@ -75,8 +73,6 @@ public class ExamPaperStructureController {
                          @RequestParam("keys") String keys,
                          @RequestParam("files") MultipartFile[] files) {
         ExamPaperStructure examPaper = examPaperStructureService.upload(examPaperStructure, md5, keys, files);
-        // 推送云阅卷
-        dataSyncService.syncPaperStructure(examPaper);
         return ResultUtil.ok(String.valueOf(examPaper.getId()), null);
     }
 
@@ -88,42 +84,44 @@ public class ExamPaperStructureController {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        ExamPaperStructure examPaperStructure = examPaperStructureService.submitExamPaperParams(evaluationParameters,sysUser);
-        // 异步推送云阅卷
+        ExamPaperStructure examPaperStructure = examPaperStructureService.submitExamPaperParams(evaluationParameters, sysUser);
+        // 异步同步到云阅卷
+        asyncCloudMarkingTaskService.syncPaperStructureAndGroup(examPaperStructure);
         return ResultUtil.ok();
     }
 
     /**
      * 上传标答文件
      *
-     * @param md5   文件md5
+     * @param md5  文件md5
      * @param file 文件数组
      * @return Result
      */
     @ApiOperation(value = "上传试卷标答文件")
     @RequestMapping(value = "/upload_answer", method = RequestMethod.POST)
-    public Result uploadAnswer(@RequestParam("examPaperStructure") String examPaperStructure,
-                         @RequestParam("md5") String md5,
-                         @RequestParam("file") MultipartFile file) {
-        ExamPaperStructure examPaper = examPaperStructureService.uploadAnswer(examPaperStructure, md5, file);
-        // 推送云阅卷
-        dataSyncService.syncPaperStructure(examPaper);
-        return ResultUtil.ok(String.valueOf(examPaper.getId()), null);
+    public Result uploadAnswer(@RequestParam("id") Long id,
+                               @RequestParam("md5") String md5,
+                               @RequestParam("file") MultipartFile file) {
+        ExamPaperStructure examPaperStructure = examPaperStructureService.uploadAnswer(id, md5, file);
+        // 异步同步到云阅卷
+        asyncCloudMarkingTaskService.syncPaperAndAnswer(examPaperStructure);
+        return ResultUtil.ok(true);
     }
 
     /**
      * 保存客观题答案
-     * @param id 试卷结构表id
+     *
+     * @param id                 试卷结构表id
      * @param objectiveStructure 客观题结构json
      */
     @ApiOperation(value = "保存客观题答案")
     @RequestMapping(value = "/update_objective_answer", method = RequestMethod.POST)
     public Result uploadAnswer(@RequestParam("id") Long id,
                                @RequestParam("objectiveStructure") String objectiveStructure) {
-        ExamPaperStructure examPaper = examPaperStructureService.updateObjectiveAnswer(id, objectiveStructure);
-        // 推送云阅卷
-        dataSyncService.syncPaperStructure(examPaper);
-        return ResultUtil.ok(String.valueOf(examPaper.getId()), null);
+        ExamPaperStructure examPaperStructure = examPaperStructureService.updateObjectiveAnswer(id, objectiveStructure);
+        // 异步同步到云阅卷
+        asyncCloudMarkingTaskService.syncObjectiveStructure(examPaperStructure);
+        return ResultUtil.ok(true);
     }
 
     /**

+ 2 - 2
distributed-print/src/test/java/com/qmth/distributed/print/SyncHelpTest.java

@@ -3,7 +3,7 @@ package com.qmth.distributed.print;
 import com.qmth.teachcloud.common.bean.params.UserPushParam;
 import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
 import com.qmth.teachcloud.common.service.SysUserService;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -21,7 +21,7 @@ import javax.annotation.Resource;
 public class SyncHelpTest {
 
     @Resource
-    private StmmsUtils stmmsUtils;
+    private CloudMarkingTaskUtils stmmsUtils;
     @Resource
     private SysUserService sysUserService;
 

+ 6 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/PushTypeEnum.java

@@ -10,9 +10,13 @@ import java.util.Objects;
 public enum PushTypeEnum {
     USER_PUSH("用户推送"),
 
-    EXAM_PUSH("考试、考生、题卡推送"),
+    EXAM_PUSH("考试、考生、题卡数据推送"),
 
-    STRUCTURE_PUSH("试卷结构推送"),
+    STRUCTURE_GROUP_PUSH("试卷结构、分组、评卷员绑定关系数据推送"),
+
+    PAPER_ANSWER_FILE_PUSH("试卷、标签文件推送"),
+
+    OBJECTIVE_ANSWER_PUSH("客观题答案推送"),
 
     SCORE_PUSH("成绩推送");
 

+ 2 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -29,7 +29,7 @@ import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
 import com.qmth.teachcloud.common.enums.userPush.SyncStatusEnum;
 import com.qmth.teachcloud.common.mapper.SysUserMapper;
 import com.qmth.teachcloud.common.service.*;
-import com.qmth.teachcloud.common.sync.StmmsUtils;
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import com.qmth.teachcloud.common.util.Base64Util;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -105,7 +105,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     PushUserTrackService pushUserTrackService;
 
     @Resource
-    StmmsUtils stmmsUtils;
+    CloudMarkingTaskUtils stmmsUtils;
 
     @Resource
     SysRoleGroupMemberService sysRoleGroupMemberService;

+ 11 - 5
teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/StmmsUtils.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/CloudMarkingTaskUtils.java

@@ -35,8 +35,8 @@ import java.util.Objects;
  * Date: 2021/10/29.
  */
 @Component
-public class StmmsUtils {
-    private final static Logger log = LoggerFactory.getLogger(StmmsUtils.class);
+public class CloudMarkingTaskUtils {
+    private final static Logger log = LoggerFactory.getLogger(CloudMarkingTaskUtils.class);
 
     // 考试类型(逸教云默认是纸笔"SCAN_IMAGE")
     private static final String SAVE_EXAM_TYPE = "SCAN_IMAGE";
@@ -46,6 +46,12 @@ public class StmmsUtils {
     // 默认分页数量
     private static final int defaultPageSize = 100;
 
+    // 评卷员前缀
+    private static final String MARKER_PREFIX = "M_";
+
+    // 科组长前缀
+    private static final String MARKER_LEADER_PREFIX = "S_";
+
     @Resource
     private CommonCacheService commonCacheService;
 
@@ -403,7 +409,7 @@ public class StmmsUtils {
             map.put("examId", validParam(examId, null, true, "考试ID"));
             map.put("subjectCode", validParam(subjectCode, null, true, "科目代码"));
             map.put("groupNumber", validParam(String.valueOf(groupNumber), null, true, "分组序号"));
-            map.put("loginName", validParam(loginName, null, true, "用户名"));
+            map.put("account", MARKER_PREFIX + validParam(loginName, null, true, "用户名"));
 
             String result = HttpKit.sendPost(postUrl, getHeaders(schoolId, markerSaveUrl), map, null, null, null);
             JSONObject jsonObject = JSONObject.parseObject(result);
@@ -420,7 +426,7 @@ public class StmmsUtils {
         String markLoginUrl = dictionaryConfig.syncDataDomain().getMarkLoginUrl();
         try {
             //参数
-            return openLogin(sysUser, markLoginUrl, "M_");
+            return openLogin(sysUser, markLoginUrl, MARKER_PREFIX);
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
@@ -433,7 +439,7 @@ public class StmmsUtils {
         String markLeaderLoginUrl = dictionaryConfig.syncDataDomain().getMarkLeaderLoginUrl();
         try {
             //参数
-            return openLogin(sysUser, markLeaderLoginUrl, "S_");
+            return openLogin(sysUser, markLeaderLoginUrl, MARKER_LEADER_PREFIX);
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }