瀏覽代碼

3.1.0-同步教研分析

xiaof 3 年之前
父節點
當前提交
c97877116a

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java

@@ -275,4 +275,13 @@ public interface PrintCommonService {
      * @return
      */
     String createCourseSequence(Long schoolId, String courseCode);
+
+    /**
+     * 提交初始化数据后更新批次状态
+     *
+     * @param schoolId    学校ID
+     * @param paperNumber 试卷编号
+     * @param paperType   试卷类型
+     */
+    public void updateGradeBatchStatus(Long schoolId, String paperNumber, String paperType);
 }

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

@@ -83,13 +83,26 @@ public class DataSyncReportServiceImpl implements DataSyncReportService {
             List<GradeBatchPaper> gradeBatchPaperList = gradeBatchPaperService.list(queryWrapper);
             for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
                 String courseCode = gradeBatchPaper.getPaperNumber() + gradeBatchPaper.getPaperType();
-                teachCloudReportTaskUtils.syncCourse(schoolId, String.valueOf(examId), courseCode, gradeBatchPaper.getPaperName(), gradeBatchPaper.getPaperType(), gradeBatchPaper.getTeachCollegeName(), gradeBatchPaper.getEnable());
+                boolean syncCourse = teachCloudReportTaskUtils.syncCourse(schoolId, String.valueOf(examId), courseCode, gradeBatchPaper.getPaperName(), gradeBatchPaper.getPaperType(), gradeBatchPaper.getTeachCollegeName(), gradeBatchPaper.getEnable());
+                if (syncCourse) {
+                    //
+                    QueryWrapper<GradeBatchPaper> gradeBatchPaperQueryWrapper = new QueryWrapper<>();
+                    gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getSchoolId, schoolId).eq(GradeBatchPaper::getPaperNumber, gradeBatchPaper.getPaperNumber()).eq(GradeBatchPaper::getPaperType, gradeBatchPaper.getPaperType());
+                    List<GradeBatchPaper> gradeBatchPapers = gradeBatchPaperService.list(gradeBatchPaperQueryWrapper);
+                    long count = gradeBatchPapers.stream().filter(m -> GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE.equals(m.getStatus()) || GradeAnalyzePaperStatusEnum.CALCULATING.equals(m.getStatus()) || GradeAnalyzePaperStatusEnum.FINISH_CALCULATE.equals(m.getStatus())).count();
+
+                    // 更新批次课程状态
+                    gradeBatchPaper.setStatus(count > 0 ? GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE : GradeAnalyzePaperStatusEnum.SETTING_GRADE_PAPER_PARAM);
+                    gradeBatchPaperService.updateById(gradeBatchPaper);
+                }
             }
 
+            long batchCount = gradeBatchPaperList.stream().filter(m -> GradeAnalyzePaperStatusEnum.SETTING_GRADE_PAPER_PARAM.equals(m.getStatus())).count();
+
             // 更新批次表考试ID、状态
             UpdateWrapper<GradeBatch> updateWrapper = new UpdateWrapper<>();
             updateWrapper.lambda().set(GradeBatch::getThirdExamId, examId)
-                    .set(GradeBatch::getStatus, GradeAnalyzePaperStatusEnum.SETTING_GRADE_PAPER_PARAM)
+                    .set(GradeBatch::getStatus, batchCount > 0 ? GradeAnalyzePaperStatusEnum.SETTING_GRADE_PAPER_PARAM : GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE)
                     .eq(GradeBatch::getId, gradeBatch.getId());
             gradeBatchService.update(updateWrapper);
             // 任务结果

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

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -104,6 +106,8 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
         Long schoolId = requestUser.getSchoolId();
         List<AbleAnalyzePaperParam> ableAnalyzePaperParamList = gradeBatchPaperParam.getAbleAnalyzePaperList();
 
+        // 是否需要更新批次状态
+        AtomicBoolean updateBatchStatus = new AtomicBoolean(false);
         List<GradeBatchPaper> gradeBatchPaperList = ableAnalyzePaperParamList.stream().flatMap(e -> {
             String paperNumber = e.getPaperNumber();
             String paperType = e.getPaperType();
@@ -129,6 +133,7 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
                 // 新增
                 gradeBatchPaper.insertInfo(requestUser.getId());
                 gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH);
+                updateBatchStatus.set(true);
             } else {
                 // 编辑(计算中的不允许被编辑,其他状态下的只要开课学院和试卷名称有变化,状态就更新为需要重新推送)
                 GradeAnalyzePaperStatusEnum dbStatus = dbBatchPaper.getStatus();
@@ -137,6 +142,7 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
                 }
                 if (!teachCollegeId.equals(dbBatchPaper.getTeachCollegeId()) || !teachCollegeName.equals(dbBatchPaper.getTeachCollegeName()) || !paperName.equals(dbBatchPaper.getPaperName())) {
                     gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH);
+                    updateBatchStatus.set(true);
                 }
                 gradeBatchPaper.setId(dbBatchPaper.getId());
                 gradeBatchPaper.setStatus(dbBatchPaper.getStatus());
@@ -146,6 +152,13 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
         }).collect(Collectors.toList());
 
         this.saveOrUpdateBatch(gradeBatchPaperList);
+
+        // 更新批次状态
+        if (updateBatchStatus.get()) {
+            UpdateWrapper<GradeBatch> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.lambda().set(GradeBatch::getStatus, GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH).eq(GradeBatch::getId, batchId);
+            gradeBatchService.update(updateWrapper);
+        }
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -166,6 +179,7 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
         return this.baseMapper.findByThirdExamIdAndGradeCourseCode(schoolId, thirdExamId, gradeCourseCode);
     }
 
+    @Transactional
     @Override
     public void checkOperateAuth(Long schoolId, String paperNumber, String paperType) {
         List<GradeBatchPaper> gradeBatchPaperList = this.list(new QueryWrapper<GradeBatchPaper>().lambda()
@@ -176,11 +190,36 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
             throw ExceptionResultEnum.ERROR.exception("选择的试卷有正在计算的分析课程");
         }
         List<Long> batchIdList = gradeBatchPaperList.stream().map(GradeBatchPaper::getBatchId).distinct().collect(Collectors.toList());
-        if (batchIdList.size() > 0){
-            if (gradeBatchService.list(new QueryWrapper<GradeBatch>().lambda().in(GradeBatch::getId, batchIdList)).stream().anyMatch(e -> GradeAnalyzePaperStatusEnum.CALCULATING.equals(e.getStatus()))){
+        if (batchIdList.size() > 0) {
+            if (gradeBatchService.list(new QueryWrapper<GradeBatch>().lambda().in(GradeBatch::getId, batchIdList)).stream().anyMatch(e -> GradeAnalyzePaperStatusEnum.CALCULATING.equals(e.getStatus()))) {
                 throw ExceptionResultEnum.ERROR.exception("所选择的试卷所属的批次正在计算中不能更改");
             }
         }
+
+        // 更新批次科目状态
+        for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
+            gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE);
+            this.updateById(gradeBatchPaper);
+
+            // 更新批次状态
+            GradeBatch gradeBatch = gradeBatchService.getById(gradeBatchPaper.getBatchId());
+            if (GradeAnalyzePaperStatusEnum.FINISH_CALCULATE.equals(gradeBatch.getStatus())) {
+                gradeBatch.setStatus(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE);
+                gradeBatchService.updateById(gradeBatch);
+            } else {
+                QueryWrapper<GradeBatchPaper> queryWrapperList = new QueryWrapper<>();
+                queryWrapperList.lambda().eq(GradeBatchPaper::getBatchId, gradeBatchPaper.getBatchId());
+                List<GradeBatchPaper> gradeBatchPaperAll = this.list(queryWrapperList);
+                if (!gradeBatchPaperAll.isEmpty()) {
+                    long count = gradeBatchPaperAll.stream().filter(m -> !GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE.equals(m.getStatus())).count();
+                    if (count == 0) {
+                        // 更新批次状态
+                        UpdateWrapper<GradeBatch> updateWrapper = new UpdateWrapper<>();
+                        updateWrapper.lambda().set(GradeBatch::getStatus, GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE).eq(GradeBatch::getId, gradeBatchPaper.getBatchId());
+                    }
+                }
+            }
+        }
     }
 
     /**

+ 32 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -16,6 +16,7 @@ import com.qmth.distributed.print.business.bean.dto.PdfDto;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
+import com.qmth.distributed.print.business.enums.GradeAnalyzePaperStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
@@ -133,6 +134,15 @@ public class PrintCommonServiceImpl implements PrintCommonService {
     @Autowired
     BasicExamService basicExamService;
 
+    @Resource
+    GradeBatchService gradeBatchService;
+
+    @Resource
+    GradeBatchPaperService gradeBatchPaperService;
+
+    @Resource
+    GradeModuleEvaluationService gradeModuleEvaluationService;
+
     /**
      * 保存附件
      *
@@ -1156,4 +1166,26 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         }
         return sequence;
     }
+
+    @Override
+    public void updateGradeBatchStatus(Long schoolId, String paperNumber, String paperType) {
+        QueryWrapper<GradeBatchPaper> gradeBatchPaperQueryWrapper = new QueryWrapper<>();
+        gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getSchoolId, schoolId).eq(GradeBatchPaper::getPaperNumber, paperNumber).eq(GradeBatchPaper::getPaperType, paperType);
+        List<GradeBatchPaper> gradeBatchPaperList = gradeBatchPaperService.list(gradeBatchPaperQueryWrapper);
+        if (!gradeBatchPaperList.isEmpty()) {
+            for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
+                QueryWrapper<GradeBatchPaper> queryWrapperList = new QueryWrapper<>();
+                queryWrapperList.lambda().eq(GradeBatchPaper::getBatchId, gradeBatchPaper.getBatchId());
+                List<GradeBatchPaper> gradeBatchPaperAll = gradeBatchPaperService.list(queryWrapperList);
+                if (!gradeBatchPaperAll.isEmpty()) {
+                    long count = gradeBatchPaperAll.stream().filter(m -> !GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE.equals(m.getStatus())).count();
+                    if (count == 0) {
+                        // 更新批次状态
+                        UpdateWrapper<GradeBatch> updateWrapper = new UpdateWrapper<>();
+                        updateWrapper.lambda().set(GradeBatch::getStatus, GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE).eq(GradeBatch::getId, gradeBatchPaper.getBatchId());
+                    }
+                }
+            }
+        }
+    }
 }

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

@@ -6,6 +6,7 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.params.analyze.GradeModuleEvaluationParam;
 import com.qmth.distributed.print.business.bean.result.analyze.GradeModuleEvaluationResult;
 import com.qmth.distributed.print.business.service.GradeModuleEvaluationService;
+import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
@@ -37,6 +38,9 @@ public class GradeModuleEvaluationController {
     @Resource
     private GradeModuleEvaluationService gradeModuleEvaluationService;
 
+    @Resource
+    PrintCommonService printCommonService;
+
     @ApiOperation(value = "成绩分析模块评价-查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = GradeModuleEvaluationResult.class)})
@@ -59,6 +63,8 @@ public class GradeModuleEvaluationController {
         }
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         gradeModuleEvaluationService.saveGradeModuleEvaluationBatch(gradeModuleEvaluationParam, requestUser);
+        // 更新批次状态
+        printCommonService.updateGradeBatchStatus(requestUser.getSchoolId(), gradeModuleEvaluationParam.getPaperNumber(), gradeModuleEvaluationParam.getPaperType());
         return ResultUtil.ok();
     }
 }