ソースを参照

3.2.2-推送管理联调bug

xiaof 2 年 前
コミット
5d89a7a37e
13 ファイル変更156 行追加58 行削除
  1. 44 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/SyncExamTaskDto.java
  2. 5 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/SyncDataParam.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java
  4. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailCourseService.java
  5. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TSyncStmmsExamService.java
  6. 35 24
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java
  7. 12 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java
  8. 25 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java
  9. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TBSyncTaskServiceImpl.java
  10. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TSyncStmmsExamServiceImpl.java
  11. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCloudMarkingTaskService.java
  12. 15 6
      distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml
  13. 6 6
      distributed-print/src/main/java/com/qmth/distributed/print/api/TSyncExamStudentScoreController.java

+ 44 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/SyncExamTaskDto.java

@@ -1,9 +1,13 @@
 package com.qmth.distributed.print.business.bean.dto;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.qmth.distributed.print.business.entity.ExamTask;
+import com.qmth.distributed.print.business.enums.ExamPrintPlanSyncStatusEnum;
 import com.qmth.distributed.print.business.enums.SyncCardTypeEnum;
 
+import java.util.List;
+
 /**
  * @Date: 2021/3/29.
  */
@@ -19,6 +23,14 @@ public class SyncExamTaskDto extends ExamTask {
 
     private Integer syncInitCount;
 
+    private String printPlanIds;
+
+    private Long thirdRelateId;
+
+    private String syncStatus;
+
+    private String syncUserName;
+
     public String getPaperType() {
         return paperType;
     }
@@ -66,4 +78,36 @@ public class SyncExamTaskDto extends ExamTask {
     public void setSyncInitCount(Integer syncInitCount) {
         this.syncInitCount = syncInitCount;
     }
+
+    public String getPrintPlanIds() {
+        return printPlanIds;
+    }
+
+    public void setPrintPlanIds(String printPlanIds) {
+        this.printPlanIds = printPlanIds;
+    }
+
+    public Long getThirdRelateId() {
+        return thirdRelateId;
+    }
+
+    public void setThirdRelateId(Long thirdRelateId) {
+        this.thirdRelateId = thirdRelateId;
+    }
+
+    public String getSyncStatus() {
+        return syncStatus;
+    }
+
+    public void setSyncStatus(String syncStatus) {
+        this.syncStatus = syncStatus;
+    }
+
+    public String getSyncUserName() {
+        return syncUserName;
+    }
+
+    public void setSyncUserName(String syncUserName) {
+        this.syncUserName = syncUserName;
+    }
 }

+ 5 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/SyncDataParam.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.bean.params;
 
+import com.alibaba.fastjson.JSONObject;
+
 import java.util.List;
 
 /**
@@ -30,7 +32,7 @@ public class SyncDataParam {
     /**
      * examTaskId集合
      */
-    private List<Long> list;
+    private List<JSONObject> list;
 
     public Long getPrintPlanId() {
         return printPlanId;
@@ -64,11 +66,11 @@ public class SyncDataParam {
         this.examTime = examTime;
     }
 
-    public List<Long> getList() {
+    public List<JSONObject> getList() {
         return list;
     }
 
-    public void setList(List<Long> list) {
+    public void setList(List<JSONObject> list) {
         this.list = list;
     }
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java

@@ -36,5 +36,5 @@ public interface ExamDetailCourseMapper extends BaseMapper<ExamDetailCourse> {
 
     List<SyncExamTaskDto> listSyncCourseByPrintPlanId(@Param("printPlanIds") List<Long> printPlanIds);
 
-    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanId") Long printPlanId, @Param("examTaskIds") List<Long> examTaskIds);
+    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanIds") List<Long> printPlanIds, @Param("examTaskId") Long examTaskId);
 }

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

@@ -36,5 +36,5 @@ public interface ExamDetailCourseService extends IService<ExamDetailCourse> {
 
     List<SyncExamTaskDto> listSyncCourseByPrintPlanId(List<Long> printPlanIds);
 
-    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(Long printPlanId, List<Long> examTaskIds);
+    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId);
 }

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

@@ -13,4 +13,6 @@ public interface TSyncStmmsExamService extends IService<TSyncStmmsExam> {
     List<TSyncStmmsExam> listExam();
 
     List<TSyncStmmsExam> syncExam();
+
+    TSyncStmmsExam getBySchoolIdAndExamId(Long schoolId, Long thirdRelateId);
 }

+ 35 - 24
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java

@@ -95,46 +95,50 @@ public class DataSyncServiceImpl implements DataSyncService {
     @Async
     @Override
     public void syncExamAndStudentAndCard(Long thirdRelateId, String thirdRelateName, String examTime, TBSyncTask tbSyncTask, SysUser sysUser) {
-        ExamPrintPlanSyncStatusEnum syncStatus = ExamPrintPlanSyncStatusEnum.INIT;
+        ExamPrintPlanSyncStatusEnum syncStatus;
 
         // 同步初始参数
         TaskResultEnum result = null;
         TaskStatusEnum status;
         String errorMessage = null;
         Long schoolId = tbSyncTask.getSchoolId();
-        Long printPlanId = tbSyncTask.getObjectId();
-        List<Long> examTaskIds = JSONObject.parseArray(tbSyncTask.getRemark(), Long.class);
+        Long objectId = tbSyncTask.getObjectId();
+        List<JSONObject> examTaskIds = JSONObject.parseArray(tbSyncTask.getRemark(), JSONObject.class);
         try {
             // 同步中
             status = TaskStatusEnum.RUNNING;
             tbSyncTaskService.updateStatusAndResultById(tbSyncTask.getId(), null, status, null, null);
 
             // 同步计划 -> 同步到云阅卷考试
-            thirdRelateId = saveExam(schoolId, printPlanId, thirdRelateId, thirdRelateName, examTime);
+            thirdRelateId = saveExam(schoolId, objectId, thirdRelateId, thirdRelateName, examTime);
             syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
             // 考试同步成功,才能同步考生和题卡
             if (Objects.isNull(thirdRelateId)) {
                 throw ExceptionResultEnum.ERROR.exception("无法获取云阅卷考试ID,同步数据失败");
             }
 
-            List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanId, examTaskIds);
-            for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
-                try {
-                    // 同步考生
-                    saveStudent(schoolId, thirdRelateId, examDetailCourseDto.getId());
-                    syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
-                    // 同步题卡
-                    cardUpload(schoolId, thirdRelateId, examDetailCourseDto.getExamTaskId(), examDetailCourseDto.getPaperType());
-                    syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
-                } catch (Exception e) {
-                    throw new RuntimeException("推送考生信息、题卡信息失败,试卷编号:" + examDetailCourseDto.getPaperNumber() + SystemConstant.COMMA_OF_CHINESE + e.getMessage());
-                } finally {
-                    UpdateWrapper<ExamDetailCourse> examDetailCourseUpdateWrapper = new UpdateWrapper<>();
-                    examDetailCourseUpdateWrapper.lambda().set(ExamDetailCourse::getThirdRelateId, thirdRelateId)
-                            .set(ExamDetailCourse::getSyncStatus, syncStatus)
-                            .set(ExamDetailCourse::getSyncUserId, sysUser.getId())
-                            .eq(ExamDetailCourse::getId, examDetailCourseDto.getId());
-                    examDetailCourseService.update(examDetailCourseUpdateWrapper);
+            for (JSONObject object : examTaskIds) {
+                List<Long> printPlanIds = Arrays.asList(object.getString("printPlanIds").split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
+                Long examTaskId = object.getLong("id");
+                List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
+                for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
+                    try {
+                        // 同步考生
+                        saveStudent(schoolId, thirdRelateId, examDetailCourseDto.getId());
+                        syncStatus = ExamPrintPlanSyncStatusEnum.PART_FINISH;
+                        // 同步题卡
+                        cardUpload(schoolId, thirdRelateId, examDetailCourseDto.getExamTaskId(), examDetailCourseDto.getPaperType());
+                        syncStatus = ExamPrintPlanSyncStatusEnum.FINISH;
+                    } catch (Exception e) {
+                        throw new RuntimeException("推送考生信息、题卡信息失败,试卷编号:" + examDetailCourseDto.getPaperNumber() + SystemConstant.COMMA_OF_CHINESE + e.getMessage());
+                    } finally {
+                        UpdateWrapper<ExamDetailCourse> examDetailCourseUpdateWrapper = new UpdateWrapper<>();
+                        examDetailCourseUpdateWrapper.lambda().set(ExamDetailCourse::getThirdRelateId, thirdRelateId)
+                                .set(ExamDetailCourse::getSyncStatus, syncStatus)
+                                .set(ExamDetailCourse::getSyncUserId, sysUser.getId())
+                                .eq(ExamDetailCourse::getId, examDetailCourseDto.getId());
+                        examDetailCourseService.update(examDetailCourseUpdateWrapper);
+                    }
                 }
             }
             // 任务结果
@@ -470,6 +474,10 @@ public class DataSyncServiceImpl implements DataSyncService {
      */
     public void saveStudent(Long schoolId, Long thirdRelateId, Long examDetailCourseId) {
         List<SyncExamStudentDto> examStudents = examStudentService.listStudentByExamDetailCourseId(examDetailCourseId);
+        long count = examStudents.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
+        if (count > 0) {
+            throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
+        }
         for (SyncExamStudentDto examStudent : examStudents) {
             try {
                 //参数
@@ -534,8 +542,8 @@ public class DataSyncServiceImpl implements DataSyncService {
             File file = null;
             try {
                 // 文件临时目录
-                String dirName = "upload-temp" + File.separator + SyncFileTypeEnum.CARD.name().toLowerCase() + File.separator + System.currentTimeMillis();
-                file = SystemConstant.getFileTempDirVar(dirName, SystemConstant.getNanoId() + ".json");
+                String dirName = dictionaryConfig.fssPrivateDomain().getConfig() + File.separator + "upload-temp" + File.separator + SyncFileTypeEnum.CARD.name().toLowerCase() + File.separator + System.currentTimeMillis();
+                file = new File(dirName, SystemConstant.getNanoId() + ".json");
                 file = createJsonFile(file.getPath(), cardDetail.getContent());
                 if (file.exists()) {
                     String uploadCardUrl = cloudMarkingTaskUtils.syncFile(schoolId, String.valueOf(thirdRelateId), examTask.getCourseCode() + s + examTask.getSequence(), SyncFileTypeEnum.CARD, file);
@@ -581,6 +589,9 @@ public class DataSyncServiceImpl implements DataSyncService {
         BufferedWriter out = null;
         File file = new File(url);
         try {
+            if (!file.exists()) {
+                file.getParentFile().mkdirs();
+            }
             out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
             out.write(content);
         } catch (Exception e) {

+ 12 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java

@@ -10,10 +10,7 @@ import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
 import com.qmth.distributed.print.business.entity.ExamCard;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamTaskDetail;
-import com.qmth.distributed.print.business.enums.CardTypeEnum;
-import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
-import com.qmth.distributed.print.business.enums.SyncCardTypeEnum;
+import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.mapper.ExamDetailCourseMapper;
 import com.qmth.distributed.print.business.service.ExamCardService;
 import com.qmth.distributed.print.business.service.ExamDetailCourseService;
@@ -21,11 +18,13 @@ import com.qmth.distributed.print.business.service.ExamTaskDetailService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -107,12 +106,19 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
             if (stringSet.size() > 0) {
                 examTaskDto.setSyncCardType(String.join(",", stringSet));
             }
+
+            // 解析同步状态
+            String syncStatus = examTaskDto.getSyncStatus();
+            if (StringUtils.isNotBlank(syncStatus)) {
+                List<String> collect = Stream.of(syncStatus.split(",")).map(m -> ExamPrintPlanSyncStatusEnum.valueOf(m).getDesc()).collect(Collectors.toList());
+                examTaskDto.setSyncStatus(collect.isEmpty() ? "-" : String.join(",", collect));
+            }
         }
         return examTaskDtos;
     }
 
     @Override
-    public List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(Long printPlanId, List<Long> examTaskIds) {
-        return this.baseMapper.listByPrintPlanIdAndExamTaskId(printPlanId, examTaskIds);
+    public List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId) {
+        return this.baseMapper.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
     }
 }

+ 25 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java

@@ -33,7 +33,6 @@ import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -107,11 +106,14 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
     @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
 
+    @Resource
+    TSyncStmmsExamService tSyncStmmsExamService;
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public IPage<PrintPlanResult> printPlanPage(Long schoolId, Long semesterId, Long examId, List<Long> printPlanIdList, PrintPlanStatusEnum status, Long startTime, Long endTime, int pageNumber, int pageSize) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId,requestUser.getId(),ServletUtil.getRequest().getServletPath());
+        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
         IPage<PrintPlanResult> page = examPrintPlanMapper.findPrintPlanPage(new Page<>(pageNumber, pageSize), schoolId, semesterId, examId, printPlanIdList, status, startTime, endTime, dpr);
         List<PrintPlanResult> list = page.getRecords();
         for (PrintPlanResult printPlanResult : list) {
@@ -146,11 +148,11 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
 
             List<Long> printPlanIds = Arrays.asList(new Long[]{printPlanResult.getId()});
             List<SyncExamTaskDto> syncExamTaskDtos = examDetailCourseService.listSyncCourseByPrintPlanId(printPlanIds);
-            long successCount = syncExamTaskDtos.stream().mapToInt(m->m.getSyncSuccessCount()).sum();
+            long successCount = syncExamTaskDtos.stream().mapToInt(m -> m.getSyncSuccessCount()).sum();
             printPlanResult.setSyncSuccessCount(Math.toIntExact(successCount));
-            long failCount = syncExamTaskDtos.stream().mapToInt(m->m.getSyncFailCount()).sum();
+            long failCount = syncExamTaskDtos.stream().mapToInt(m -> m.getSyncFailCount()).sum();
             printPlanResult.setSyncFailCount(Math.toIntExact(failCount));
-            long initCount = syncExamTaskDtos.stream().mapToInt(m->m.getSyncInitCount()).sum();
+            long initCount = syncExamTaskDtos.stream().mapToInt(m -> m.getSyncInitCount()).sum();
             printPlanResult.setSyncInitCount(Math.toIntExact(initCount));
         }
         return page;
@@ -453,7 +455,7 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
     @Override
     public void syncDataCloud(SyncDataParam syncDataParam) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        List<Long> examTaskIds = syncDataParam.getList();
+        List<JSONObject> examTaskIds = syncDataParam.getList();
         if (CollectionUtils.isEmpty(examTaskIds)) {
             throw ExceptionResultEnum.ERROR.exception("请选择需要推送的数据");
         }
@@ -466,13 +468,27 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
                     && Objects.isNull(syncDataParam.getExamTime())) {
                 throw ExceptionResultEnum.ERROR.exception("考试时间必填");
             }
+            String examTime = null;
             if (syncDataParam.getThirdRelateId() == null) {
                 String time = String.valueOf(System.currentTimeMillis());
-                String examTime = DateUtil.format(new Date(syncDataParam.getExamTime()), CloudMarkingTaskUtils.DATE_FORMAT);
+                examTime = DateUtil.format(new Date(syncDataParam.getExamTime()), CloudMarkingTaskUtils.DATE_FORMAT);
                 syncDataParam.setThirdRelateId(cloudMarkingTaskUtils.syncExam(schoolId, time, syncDataParam.getThirdRelateName(), examTime));
+
+                try {
+                    TSyncStmmsExam tSyncStmmsExam = tSyncStmmsExamService.getBySchoolIdAndExamId(schoolId, syncDataParam.getThirdRelateId());
+                    if (tSyncStmmsExam == null) {
+                        tSyncStmmsExam = new TSyncStmmsExam();
+                        tSyncStmmsExam.setId(SystemConstant.getDbUuid());
+                        tSyncStmmsExam.setSchoolId(schoolId);
+                        tSyncStmmsExam.setExamId(Math.toIntExact(syncDataParam.getThirdRelateId()));
+                        tSyncStmmsExam.setExamName(syncDataParam.getThirdRelateName());
+                        tSyncStmmsExamService.save(tSyncStmmsExam);
+                    }
+                } catch (Exception e) {
+                    log.error("保存云阅卷考试失败");
+                }
             }
-            Long printPlanId = syncDataParam.getPrintPlanId();
-            String examTime = DateUtil.format(new Date(syncDataParam.getExamTime()), CloudMarkingTaskUtils.DATE_FORMAT);
+            Long printPlanId = SystemConstant.getDbUuid();
             asyncCloudMarkingTaskService.syncExamAndStudentAndCard(schoolId, printPlanId, syncDataParam.getThirdRelateId(), syncDataParam.getThirdRelateName(), examTime, examTaskIds);
         }
     }

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

@@ -236,7 +236,7 @@ public class TBSyncTaskServiceImpl extends ServiceImpl<TBSyncTaskMapper, TBSyncT
         }
         switch (tbSyncTask.getType()) {
             case EXAM_PUSH:
-                asyncCloudMarkingTaskService.syncExamAndStudentAndCard(tbSyncTask.getSchoolId(), tbSyncTask.getObjectId(), tbSyncTask.getThirdRelateId(), null, null, JSON.parseArray(tbSyncTask.getRemark(), Long.class));
+                asyncCloudMarkingTaskService.syncExamAndStudentAndCard(tbSyncTask.getSchoolId(), tbSyncTask.getObjectId(), tbSyncTask.getThirdRelateId(), null, null, JSON.parseArray(tbSyncTask.getRemark(), JSONObject.class));
                 break;
             case STRUCTURE_GROUP_PUSH:
                 asyncCloudMarkingTaskService.syncPaperStructureAndGroup(examPaperStructureService.getById(tbSyncTask.getObjectId()));

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

@@ -58,4 +58,12 @@ public class TSyncStmmsExamServiceImpl extends ServiceImpl<TSyncStmmsExamMapper,
         }
         return markingExams;
     }
+
+    @Override
+    public TSyncStmmsExam getBySchoolIdAndExamId(Long schoolId, Long thirdRelateId) {
+        QueryWrapper<TSyncStmmsExam> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(TSyncStmmsExam::getSchoolId, schoolId)
+                .eq(TSyncStmmsExam::getExamId, thirdRelateId);
+        return this.getOne(queryWrapper);
+    }
 }

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

@@ -53,7 +53,7 @@ public class AsyncCloudMarkingTaskService {
      * @param objectId      同步对象ID(命题任务Id)
      * @param thirdRelateId 云阅卷考试ID
      */
-    public void syncExamAndStudentAndCard(Long schoolId, Long objectId, Long thirdRelateId, String thirdRelateName, String examTime, List<Long> examTaskIds) {
+    public void syncExamAndStudentAndCard(Long schoolId, Long objectId, Long thirdRelateId, String thirdRelateName, String examTime, List<JSONObject> examTaskIds) {
         if (isSync()) {
             TBSyncTask tbSyncTask = tbSyncTaskService.saveTask(schoolId, objectId, PushTypeEnum.EXAM_PUSH, JSONObject.toJSONString(examTaskIds));
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();

+ 15 - 6
distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml

@@ -153,7 +153,10 @@
                sum(b.total_subjects) totalSubjects,
                sum(case b.sync_status when 'FINISH' then 1 else 0 end) syncSuccessCount,
                sum(case b.sync_status when 'PART_FINISH' then 1 else 0 end) syncFailCount,
-               sum(case b.sync_status when 'INIT' then 1 else 0 end) syncInitCount
+               sum(case b.sync_status when 'INIT' then 1 else 0 end) syncInitCount,
+               group_concat(distinct b.third_relate_id) thirdRelateId,
+               group_concat(distinct b.sync_status) syncStatus,
+               group_concat(distinct su.real_name) syncUserName
         FROM exam_detail_course b
                  LEFT JOIN
              exam_detail c ON b.exam_detail_id = c.id
@@ -161,6 +164,8 @@
              exam_task et ON b.school_id = et.school_id
                  and b.course_code = et.course_code
                  and b.paper_number = et.paper_number
+                LEFT JOIN
+            sys_user su ON b.sync_user_id = su.id
         WHERE c.print_plan_id in
                 <foreach collection="printPlanIds" open="(" close=")" item="printPlanId" separator=",">
                     #{printPlanId}
@@ -184,13 +189,17 @@
              exam_task et ON b.school_id = et.school_id
                  and b.course_code = et.course_code
                  and b.paper_number = et.paper_number
-        WHERE c.print_plan_id = #{printPlanId}
-            <if test="examTaskIds != null">
-                and et.id in
-                <foreach collection="examTaskIds" open="(" close=")" item="examTaskId" separator=",">
-                    #{examTaskId}
+        <where>
+            <if test="examTaskId != null">
+                and et.id = #{examTaskId}
+            </if>
+            <if test="printPlanIds != null">
+                and c.print_plan_id in
+                <foreach collection="printPlanIds" open="(" close=")" item="printPlanId" separator=",">
+                    #{printPlanId}
                 </foreach>
             </if>
+        </where>
     </select>
 
 </mapper>

+ 6 - 6
distributed-print/src/main/java/com/qmth/distributed/print/api/TSyncExamStudentScoreController.java

@@ -40,6 +40,7 @@ import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -120,12 +121,11 @@ public class TSyncExamStudentScoreController {
             throw ExceptionResultEnum.ERROR.exception("此学期学院下未找到需要同步的考试记录");
         }
         LinkedMultiValueMap<Long, Integer> semesterExamIdMap = new LinkedMultiValueMap<>();
-        for (ExamPrintPlan examPrintPlan : examPrintPlanList) {
-            List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(examPrintPlan.getId(), null);
-            for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
-                if (examDetailCourseDto.getSyncStatus().equals(ExamPrintPlanSyncStatusEnum.FINISH)) {
-                    semesterExamIdMap.add(Long.valueOf(semesterId), Integer.parseInt(String.valueOf(examDetailCourseDto.getThirdRelateId())));
-                }
+        List<Long> printPlanIds = examPrintPlanList.stream().map(ExamPrintPlan::getId).collect(Collectors.toList());
+        List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, null);
+        for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
+            if (examDetailCourseDto.getSyncStatus().equals(ExamPrintPlanSyncStatusEnum.FINISH)) {
+                semesterExamIdMap.add(Long.valueOf(semesterId), Integer.parseInt(String.valueOf(examDetailCourseDto.getThirdRelateId())));
             }
         }
         Map<String, Object> map = printCommonService.savePush(PushTypeEnum.SCORE_PUSH, Long.valueOf(examId));