Explorar o código

add: 查看报告分析计算串通(部分验证需要补全)

caozixuan %!s(int64=3) %!d(string=hai) anos
pai
achega
451fbdb840
Modificáronse 13 ficheiros con 233 adicións e 78 borrados
  1. 4 3
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/printOpen/PaperDimension.java
  2. 4 3
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/printOpen/PaperStructure.java
  3. 2 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataCalculateService.java
  4. 6 0
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataCheckService.java
  5. 8 0
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataGetAndEditService.java
  6. 57 35
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataCalculateServiceImpl.java
  7. 35 7
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataCheckServiceImpl.java
  8. 16 5
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataGetAndEditServiceImpl.java
  9. 4 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseServiceImpl.java
  10. 3 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CalculateTaskTemplate.java
  11. 24 16
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CourseCodeSyncTaskService.java
  12. 18 4
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/OpenApiController.java
  13. 52 0
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/TestCallPrintOpenApiController.java

+ 4 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/printOpen/PaperDimension.java

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.report.business.bean.dto.printOpen;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.enums.DimensionEnum;
 
 /**
  * @Description: 分布式印刷开放接口 - 试卷维度配置
@@ -16,7 +17,7 @@ public class PaperDimension {
 
     private String paperName;
 
-    private String dimensionType;
+    private DimensionEnum dimensionType;
 
     private String codePrimary;
 
@@ -52,11 +53,11 @@ public class PaperDimension {
         this.paperName = paperName;
     }
 
-    public String getDimensionType() {
+    public DimensionEnum getDimensionType() {
         return dimensionType;
     }
 
-    public void setDimensionType(String dimensionType) {
+    public void setDimensionType(DimensionEnum dimensionType) {
         this.dimensionType = dimensionType;
     }
 

+ 4 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/printOpen/PaperStructure.java

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.report.business.bean.dto.printOpen;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.enums.QuestionType;
 
 import java.math.BigDecimal;
 
@@ -16,7 +17,7 @@ public class PaperStructure {
 
     private String questionName;
 
-    private String numberType;
+    private QuestionType numberType;
 
     private String bigQuestionNumber;
 
@@ -48,11 +49,11 @@ public class PaperStructure {
         this.questionName = questionName;
     }
 
-    public String getNumberType() {
+    public QuestionType getNumberType() {
         return numberType;
     }
 
-    public void setNumberType(String numberType) {
+    public void setNumberType(QuestionType numberType) {
         this.numberType = numberType;
     }
 

+ 2 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataCalculateService.java

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.report.business.service;
 
 import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
 
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 
 /**
@@ -10,5 +11,5 @@ import java.lang.reflect.InvocationTargetException;
  * @Date: 2022-06-10
  */
 public interface AnalyzeDataCalculateService {
-    void dataCalculateStart(CalculateParams calculateParams) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException;
+    void dataCalculateStart(CalculateParams calculateParams) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, IOException;
 }

+ 6 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataCheckService.java

@@ -1,5 +1,9 @@
 package com.qmth.teachcloud.report.business.service;
 
+import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
+
+import java.io.IOException;
+
 /**
  * @Description: 基础分析数据校验服务类
  * @Author: CaoZixuan
@@ -56,4 +60,6 @@ public interface AnalyzeDataCheckService {
      * @param courseCode 课程编号
      */
     void triggerAssign(Long schoolId, Long examId, String courseCode);
+
+    void analyzeDataCheck(CalculateParams calculateParams) throws IOException;
 }

+ 8 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeDataGetAndEditService.java

@@ -50,4 +50,12 @@ public interface AnalyzeDataGetAndEditService {
     void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException;
 
     void tbExamStudentScoreDatasourceDispose(Long examId, String courseCode, Long schoolId) throws IOException;
+
+    /**
+     * 基础数据获取和新增总控
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @param schoolId 学校id
+     */
+    void dataGetAndEdit(Long examId,String courseCode,Long schoolId) throws IOException;
 }

+ 57 - 35
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataCalculateServiceImpl.java

@@ -4,15 +4,21 @@ import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
 import com.qmth.teachcloud.report.business.entity.TBSyncTask;
 import com.qmth.teachcloud.report.business.enums.DataCalculateSequenceEnum;
+import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
 import com.qmth.teachcloud.report.business.service.AnalyzeDataCalculateService;
 import com.qmth.teachcloud.report.business.service.AnalyzeForReportService;
 import com.qmth.teachcloud.report.business.service.TBExamCourseService;
+import com.qmth.teachcloud.report.business.templete.strategy.CalculateTaskTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -21,17 +27,25 @@ import java.util.concurrent.atomic.AtomicInteger;
  * @Author: CaoZixuan
  * @Date: 2022-06-10
  */
+@Service
 public class AnalyzeDataCalculateServiceImpl implements AnalyzeDataCalculateService {
     @Resource
     private TBExamCourseService tbExamCourseService;
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
-    public void dataCalculateStart(CalculateParams calculateParams) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+    public void dataCalculateStart(CalculateParams calculateParams) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, IOException {
+        AnalyzeForReportService analyzeForReportService = SpringContextHolder.getBean(AnalyzeForReportService.class);
+        CalculateTaskTemplate calculateTaskTemplate = SpringContextHolder.getBean(CalculateTaskTemplate.class);
+
+        TBSyncTask tbSyncTask = calculateParams.getTbSyncTask();
         Long examId = calculateParams.getExamId();
         Long schoolId = calculateParams.getSchoolId();
         List<String> courseCodeList = calculateParams.getCourseCode();
-        TBSyncTask tbSyncTask = calculateParams.getTbSyncTask();
         List<String> needRepeatCourseCodeList = calculateParams.getRepeatCalculateCourseCodeList();
+        if (needRepeatCourseCodeList == null){
+            needRepeatCourseCodeList = new ArrayList<>();
+        }
 
         // 上次计算失败的课程和表
         String errorCourseCode = tbSyncTask.getObj();
@@ -51,45 +65,53 @@ public class AnalyzeDataCalculateServiceImpl implements AnalyzeDataCalculateServ
                     continue;
                 }
             }
+            // 准备计算
+            analyzeForReportService.realityForCalculate(examId,courseCode);
             // 上次计算异常且不需要重算的 - 断点续算
-            if (courseCode.equals(errorCourseCode) && needRepeatCourseCodeList.contains(courseCode)){
-                // 上次计算异常的课程,且不需要重算
-                String errorMethod = tbSyncTask.getRemark();
-                DataCalculateSequenceEnum error = DataCalculateSequenceEnum.valueOf(errorMethod);
-                int errorIndex = error.getIndex();
+            try {
+                if (courseCode.equals(errorCourseCode) && !needRepeatCourseCodeList.contains(courseCode)){
+                    // 上次计算异常的课程,且不需要重算
+                    String errorMethod = tbSyncTask.getRemark();
+                    DataCalculateSequenceEnum error = DataCalculateSequenceEnum.valueOf(errorMethod);
+                    int errorIndex = error.getIndex();
+
+                    for (DataCalculateSequenceEnum dataCalculateSequenceEnum : DataCalculateSequenceEnum.values()) {
+                        int currentIndex = dataCalculateSequenceEnum.getIndex();
+                        if (currentIndex < errorIndex){
+                            // 已经计算过的方法,不用重算,但进度需要累加
+                            currentTask.addAndGet(dataCalculateSequenceEnum.getWeight());
+                            continue;
+                        }
+                        // 没有计算的方法和断点的方法都需要重新计算
+                        tbSyncTask.setRemark(dataCalculateSequenceEnum.name());
+                        String currentMethodName = dataCalculateSequenceEnum.getMethodName();
 
-                for (DataCalculateSequenceEnum dataCalculateSequenceEnum : DataCalculateSequenceEnum.values()) {
-                    int currentIndex = dataCalculateSequenceEnum.getIndex();
-                    if (currentIndex < errorIndex){
-                        // 已经计算过的方法,不用重算,但进度需要累加
+                        Method currenMethod = analyzeForReportService.getClass().getDeclaredMethod(currentMethodName,Long.class,String.class);
+                        currenMethod.invoke(analyzeForReportService,examId,courseCode); // 实例化对象,参数
                         currentTask.addAndGet(dataCalculateSequenceEnum.getWeight());
-                        continue;
+                        tbSyncTask.setProgress(BigDecimal.valueOf(currentTask.get()).divide(BigDecimal.valueOf(totalTask.get()),2, RoundingMode.HALF_UP));
+                        calculateTaskTemplate.updateProgress(calculateParams);
+                    }
+                } else {
+                    // 正常计算和重算
+                    for (DataCalculateSequenceEnum dataCalculateSequenceEnum : DataCalculateSequenceEnum.values()) {
+                        // 没有计算的方法和断点的方法都需要重新计算
+                        tbSyncTask.setRemark(dataCalculateSequenceEnum.name());
+                        String currentMethodName = dataCalculateSequenceEnum.getMethodName();
+                        Method currenMethod = analyzeForReportService.getClass().getDeclaredMethod(currentMethodName,Long.class,String.class);
+                        currenMethod.invoke(analyzeForReportService,examId,courseCode); // 实例化对象,参数
+                        currentTask.addAndGet(dataCalculateSequenceEnum.getWeight());
+                        tbSyncTask.setProgress(BigDecimal.valueOf(currentTask.get()).divide(BigDecimal.valueOf(totalTask.get()),2, RoundingMode.HALF_UP));
+                        calculateTaskTemplate.updateProgress(calculateParams);
                     }
-                    // 没有计算的方法和断点的方法都需要重新计算
-                    tbSyncTask.setRemark(dataCalculateSequenceEnum.name());
-                    String currentMethodName = dataCalculateSequenceEnum.getMethodName();
-                    AnalyzeForReportService analyzeForReportService = SpringContextHolder.getBean(AnalyzeForReportService.class);
-                    Method currenMethod = analyzeForReportService.getClass().getDeclaredMethod(currentMethodName,Long.class,String.class);
-                    currenMethod.invoke(analyzeForReportService,examId,courseCode); // 实例化对象,参数
-                    currentTask.addAndGet(dataCalculateSequenceEnum.getWeight());
-                    tbSyncTask.setProgress(BigDecimal.valueOf(currentTask.get()).divide(BigDecimal.valueOf(totalTask.get()),2, RoundingMode.HALF_UP));
-                    // TODO: 2022/6/10 回调 ↓
-                }
-            } else {
-                // 正常计算和重算
-                for (DataCalculateSequenceEnum dataCalculateSequenceEnum : DataCalculateSequenceEnum.values()) {
-                    // 没有计算的方法和断点的方法都需要重新计算
-                    tbSyncTask.setRemark(dataCalculateSequenceEnum.name());
-                    String currentMethodName = dataCalculateSequenceEnum.getMethodName();
-                    AnalyzeForReportService analyzeForReportService = SpringContextHolder.getBean(AnalyzeForReportService.class);
-                    Method currenMethod = analyzeForReportService.getClass().getDeclaredMethod(currentMethodName,Long.class,String.class);
-                    currenMethod.invoke(analyzeForReportService,examId,courseCode); // 实例化对象,参数
-                    currentTask.addAndGet(dataCalculateSequenceEnum.getWeight());
-                    tbSyncTask.setProgress(BigDecimal.valueOf(currentTask.get()).divide(BigDecimal.valueOf(totalTask.get()),2, RoundingMode.HALF_UP));
-                    // TODO: 2022/6/10 回调 ↓
                 }
+                // 计算完成
+                analyzeForReportService.updateCoursePublishStatus(examId,courseCode, PublishStatusEnum.UN_PUBLISH);
+            }catch (Exception e){
+                // 教研分析计算部分出错时,需要回归t_b_exam_course表状态为未计算 再向外抛出异常
+                analyzeForReportService.updateCoursePublishStatus(examId,courseCode, PublishStatusEnum.UN_COMPUTE);
+                throw e;
             }
         }
-
     }
 }

+ 35 - 7
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataCheckServiceImpl.java

@@ -2,6 +2,8 @@ package com.qmth.teachcloud.report.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.service.BasicCourseService;
+import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
 import com.qmth.teachcloud.report.business.entity.TBPaper;
 import com.qmth.teachcloud.report.business.entity.TBPaperStruct;
 import com.qmth.teachcloud.report.business.service.*;
@@ -9,6 +11,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Objects;
@@ -32,6 +35,10 @@ public class AnalyzeDataCheckServiceImpl implements AnalyzeDataCheckService {
     private TBPaperService tbPaperService;
     @Resource
     private TBPaperStructService tbPaperStructService;
+    @Resource
+    private BasicCourseService basicCourseService;
+    @Resource
+    private AnalyzeDataGetAndEditService analyzeDataGetAndEditService;
 
     @Transactional(rollbackFor = Exception.class)
     @Override
@@ -42,19 +49,19 @@ public class AnalyzeDataCheckServiceImpl implements AnalyzeDataCheckService {
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void checkPaperTotal(Long schoolId, Long examId, String courseCode) {
-        TBPaper tbPaper = tbPaperService.getOne(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
-        if (Objects.isNull(tbPaper)){
+        TBPaper tbPaper = tbPaperService.getOne(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode));
+        if (Objects.isNull(tbPaper)) {
             throw ExceptionResultEnum.ERROR.exception("未找到试卷");
         }
         Long paperId = tbPaper.getId();
         BigDecimal totalScore = tbPaper.getTotalScore();
 
-        List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId,paperId));
+        List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId, paperId));
         BigDecimal sum = BigDecimal.ZERO;
         for (TBPaperStruct tbPaperStruct : tbPaperStructList) {
             sum = sum.add(tbPaperStruct.getFullScore());
         }
-        if (totalScore.compareTo(sum) != 0){
+        if (totalScore.compareTo(sum) != 0) {
             throw ExceptionResultEnum.ERROR.exception("试卷总分和试卷结构中各个题目分数之和不一致");
         }
     }
@@ -71,12 +78,33 @@ public class AnalyzeDataCheckServiceImpl implements AnalyzeDataCheckService {
         if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
             throw ExceptionResultEnum.ERROR.exception("课程编号[" + courseCode + "]的课程分析数据已测试或发布,不能变更基础数据");
         }
-        tbCommonLevelConfigService.importLevelConfig(examId, courseCode, null);
-        tbCommonRankLevelConfigService.importRankLevelConfig(examId, courseCode, null);
+        String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
+        tbCommonLevelConfigService.importLevelConfig(examId, courseCode, courseName);
+        tbCommonRankLevelConfigService.importRankLevelConfig(examId, courseCode, courseName);
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void triggerAssign(Long schoolId, Long examId, String courseCode) {
-        analyzeForReportService.normalAssignScore(examId,schoolId,courseCode);
+        analyzeForReportService.normalAssignScore(examId, schoolId, courseCode);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void analyzeDataCheck(CalculateParams calculateParams) throws IOException {
+        Long examId = calculateParams.getExamId();
+        Long schoolId = calculateParams.getSchoolId();
+        List<String> courseCodeList = calculateParams.getCourseCode();
+        for (String courseCode : courseCodeList) {
+            // 新增
+            analyzeDataGetAndEditService.dataGetAndEdit(examId, courseCode, schoolId);
+            // 检查
+            this.checkPaperTotal(schoolId, examId, courseCode);
+            this.checkExamStudentAnswer(schoolId, examId, courseCode);
+
+            // 触发分析的前置操作
+            this.importConfigData(schoolId, examId, courseCode);
+            this.triggerAssign(schoolId, examId, courseCode);
+        }
     }
 }

+ 16 - 5
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeDataGetAndEditServiceImpl.java

@@ -103,6 +103,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
         }
 
         TBPaper tbPaper = new TBPaper();
+        tbPaper.setExamId(examId);
         tbPaper.setCourseCode(courseCode);
         tbPaper.setCourseName(courseName);
         tbPaper.setPaperType(paperConfig.getPaperType());
@@ -135,7 +136,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
             tbDimension.setExamId(examId);
             tbDimension.setCourseCode(courseCode);
             tbDimension.setCourseName(courseName);
-            tbDimension.setDimensionType(e.getDimensionType());
+            tbDimension.setDimensionType(e.getDimensionType().getDesc());
             tbDimension.setCodePrimary(e.getCodePrimary());
             tbDimension.setNamePrimary(e.getNamePrimary());
             tbDimension.setCodeSecond(e.getCodeSecond());
@@ -169,7 +170,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
             tbPaperStruct.setId(SystemConstant.getDbUuid());
             tbPaperStruct.setPaperId(paperId);
             tbPaperStruct.setQuestionName(e.getQuestionName());
-            tbPaperStruct.setNumberType(e.getNumberType());
+            tbPaperStruct.setNumberType(e.getNumberType().getDesc());
             tbPaperStruct.setBigQuestionNumber(e.getBigQuestionNumber());
             tbPaperStruct.setSmallQuestionNumber(e.getSmallQuestionNumber());
             tbPaperStruct.setQuestionType(e.getBigTopicName());
@@ -225,7 +226,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
                 tbModuleProficiency.setModuleType(moduleType.getDesc());
                 tbModuleProficiency.setInterpret(interpret);
                 tbModuleProficiency.setRemark(remark);
-                tbModuleProficiency.setDefine(e.getDefine().trim());
+                tbModuleProficiency.setDefine(SystemConstant.strNotNull(e.getDefine())?e.getDefine().trim():null);
                 tbModuleProficiency.setLevel(e.getLevel());
                 tbModuleProficiency.setMin(e.getMin());
                 tbModuleProficiency.setMax(e.getMax());
@@ -289,6 +290,16 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
         this.saveExamStudentScore(examStudentScoreList, examId, courseCode, courseName, schoolId);
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void dataGetAndEdit(Long examId, String courseCode, Long schoolId) throws IOException {
+        this.tbPaperDispose(examId, courseCode, schoolId);
+        this.tbPaperDimensionDispose(examId, courseCode, schoolId);
+        this.tbPaperStructDispose(examId, courseCode, schoolId);
+        this.tbPaperModuleDispose(examId, courseCode, schoolId);
+        this.tbExamStudentScoreDatasourceDispose(examId, courseCode, schoolId);
+    }
+
     /**
      * 创建基础班级数据
      *
@@ -351,7 +362,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
             throw ExceptionResultEnum.ERROR.exception("缺少课程数据");
         }
         Long teachCollegeId = tbExamCourse.getTeachCollegeId();
-        if (SystemConstant.longNotNull(teachCollegeId)) {
+        if (!SystemConstant.longNotNull(teachCollegeId)) {
             throw ExceptionResultEnum.ERROR.exception("课程数据缺少开课学院异常");
         }
 
@@ -510,7 +521,7 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
                 throw ExceptionResultEnum.ERROR.exception("缺少课程数据");
             }
             Long teachCollegeId = tbExamCourse.getTeachCollegeId();
-            if (SystemConstant.longNotNull(teachCollegeId)) {
+            if (!SystemConstant.longNotNull(teachCollegeId)) {
                 throw ExceptionResultEnum.ERROR.exception("课程数据缺少开课学院异常");
             }
 

+ 4 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseServiceImpl.java

@@ -69,8 +69,10 @@ public class TBExamCourseServiceImpl extends ServiceImpl<TBExamCourseMapper, TBE
         QueryWrapper<TBExamCourse> examCourseQuery = new QueryWrapper<>();
         examCourseQuery.lambda()
                 .eq(TBExamCourse::getExamId, examId)
-                .eq(TBExamCourse::getCourseCode, courseCode)
-                .eq(TBExamCourse::getCourseName, courseName);
+                .eq(TBExamCourse::getCourseCode, courseCode);
+        if (SystemConstant.strNotNull(courseName)){
+            examCourseQuery.lambda().eq(TBExamCourse::getCourseName, courseName);
+        }
         List<TBExamCourse> tbExamCourseList = this.list(examCourseQuery);
         if (tbExamCourseList.size() != 1) {
             throw ExceptionResultEnum.ERROR.exception("考试课程基础数据异常");

+ 3 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CalculateTaskTemplate.java

@@ -19,6 +19,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URLEncoder;
 import java.util.Objects;
 
@@ -69,7 +70,7 @@ public abstract class CalculateTaskTemplate {
      * @param calculateParams
      * @throws IOException
      */
-    public abstract void calculate(CalculateParams calculateParams) throws IOException;
+    public abstract void calculate(CalculateParams calculateParams) throws IOException, InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException;
 
     /**
      * 更新任务进度方法
@@ -77,7 +78,7 @@ public abstract class CalculateTaskTemplate {
      * @param calculateParams
      * @throws IOException
      */
-    protected void updateProgress(CalculateParams calculateParams) throws IOException {
+    public void updateProgress(CalculateParams calculateParams) throws IOException {
         log.info("updateProgress come in");
         TBSyncTaskService tbSyncTaskService = SpringContextHolder.getBean(TBSyncTaskService.class);
         TBSyncTask tbSyncTask = calculateParams.getTbSyncTask();

+ 24 - 16
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/strategy/CourseCodeSyncTaskService.java

@@ -1,14 +1,29 @@
 package com.qmth.teachcloud.report.business.templete.strategy;
 
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
+import com.qmth.teachcloud.report.business.entity.TBExamCourse;
 import com.qmth.teachcloud.report.business.entity.TBSyncTask;
+import com.qmth.teachcloud.report.business.enums.DataCalculateSequenceEnum;
+import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
+import com.qmth.teachcloud.report.business.service.AnalyzeDataCalculateService;
+import com.qmth.teachcloud.report.business.service.AnalyzeDataCheckService;
+import com.qmth.teachcloud.report.business.service.AnalyzeForReportService;
+import com.qmth.teachcloud.report.business.service.TBExamCourseService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @Description: 科目(试卷)计算service
@@ -19,6 +34,11 @@ import java.util.List;
  */
 @Service
 public class CourseCodeSyncTaskService extends CalculateTaskTemplate {
+    @Resource
+    private AnalyzeDataCheckService analyzeDataCheckService;
+    @Resource
+    private AnalyzeDataCalculateService analyzeDataCalculateService;
+
     private final static Logger log = LoggerFactory.getLogger(CourseCodeSyncTaskService.class);
 
     /**
@@ -35,11 +55,7 @@ public class CourseCodeSyncTaskService extends CalculateTaskTemplate {
         updateProgress(calculateParams);
 
         //TODO 此处加校验数据具体逻辑方法,推荐service方法然后加@Transactional注解
-//        List<String> courseCodeLIst = calculateParams.getCourseCode();
-//        for (String s : courseCodeLIst) {
-//            --- ---
-//
-//        }
+        analyzeDataCheckService.analyzeDataCheck(calculateParams);
     }
 
     /**
@@ -49,22 +65,14 @@ public class CourseCodeSyncTaskService extends CalculateTaskTemplate {
      * @throws IOException
      */
     @Override
-    public void calculate(CalculateParams calculateParams) throws IOException {
+    public void calculate(CalculateParams calculateParams) throws IOException, InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
         log.info("CourseCodeSyncTaskService calculate come in");
+        AnalyzeForReportService analyzeForReportService = SpringContextHolder.getBean(AnalyzeForReportService.class);
         TBSyncTask tbSyncTask = calculateParams.getTbSyncTask();
         tbSyncTask.setStatus(TaskStatusEnum.RUNNING);
         updateProgress(calculateParams);
 
-//        for (String s : courseCodeLIst) {
-//            --- ---
-//                    -- --  ----  -
-//        }
-//        tbSyncTask.setProgress();
-//        updateProgress(calculateParams);
-
-//        tbSyncTask.setObj(calculateParams.getCourseCode().get(0));//科目名称
-//        tbSyncTask.setRemark("tableName");//表名称
-
         //TODO 此处加计算数据具体逻辑方法,推荐service方法然后加@Transactional注解
+        analyzeDataCalculateService.dataCalculateStart(calculateParams);
     }
 }

+ 18 - 4
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/OpenApiController.java

@@ -25,14 +25,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.net.URLDecoder;
+import java.util.List;
 import java.util.Optional;
 
 /**
@@ -135,4 +133,20 @@ public class OpenApiController {
         courseCodeSyncTaskService.start(calculateParams);
         return ResultUtil.ok(true);
     }
+
+
+    @ApiOperation(value = "生成课程(试卷)分析报告接口测试")
+    @ApiResponses({@ApiResponse(code = 200, message = "生成课程(试卷)分析报告接口", response = Object.class)})
+    @RequestMapping(value = "/calculate_test", method = RequestMethod.POST)
+    @Aac(auth = BOOL.FALSE)
+    public Result calculateTest(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                            @ApiParam(value = "科目编号", required = true) @RequestParam List<String> courseCode,
+                            @ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) throws IOException {
+        CalculateParams calculateParams = new CalculateParams();
+        calculateParams.setSchoolId(schoolId);
+        calculateParams.setCourseCode(courseCode);
+        calculateParams.setExamId(examId);
+        courseCodeSyncTaskService.start(calculateParams);
+        return ResultUtil.ok(true);
+    }
 }

+ 52 - 0
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/TestCallPrintOpenApiController.java

@@ -7,6 +7,10 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.report.business.bean.dto.printOpen.*;
+import com.qmth.teachcloud.report.business.bean.params.CalculateParams;
+import com.qmth.teachcloud.report.business.service.AnalyzeDataCalculateService;
+import com.qmth.teachcloud.report.business.service.AnalyzeDataCheckService;
+import com.qmth.teachcloud.report.business.service.AnalyzeDataGetAndEditService;
 import com.qmth.teachcloud.report.business.service.CallPrintOpenApiService;
 import io.swagger.annotations.*;
 import org.springframework.validation.annotation.Validated;
@@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
 /**
@@ -31,6 +36,12 @@ import java.util.List;
 public class TestCallPrintOpenApiController {
     @Resource
     CallPrintOpenApiService callPrintOpenApiService;
+    @Resource
+    AnalyzeDataCalculateService analyzeDataCalculateService;
+    @Resource
+    AnalyzeDataCheckService analyzeDataCheckService;
+    @Resource
+    AnalyzeDataGetAndEditService analyzeDataGetAndEditService;
 
     @ApiOperation(value = "试卷配置")
     @ApiResponses({@ApiResponse(code = 200, message = "试卷配置", response = Object.class)})
@@ -86,4 +97,45 @@ public class TestCallPrintOpenApiController {
         System.out.println(JSON.toJSONString(examStudentScoreList));
         return ResultUtil.ok();
     }
+
+    @ApiOperation(value = "获取和新增数据")
+    @ApiResponses({@ApiResponse(code = 200, message = "获取和新增数据", response = Object.class)})
+    @RequestMapping(value = "/insert_analyze_data", method = RequestMethod.POST)
+    @Aac(auth = BOOL.FALSE)
+    public Result insertAnalyzeData(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                                    @ApiParam(value = "科目编号", required = true) @RequestParam String courseCode,
+                                    @ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) throws IOException {
+        analyzeDataGetAndEditService.dataGetAndEdit(examId, courseCode, schoolId);
+        return ResultUtil.ok();
+    }
+
+    @ApiOperation(value = "数据检验和分析触发器")
+    @ApiResponses({@ApiResponse(code = 200, message = "数据检验和分析触发器", response = Object.class)})
+    @RequestMapping(value = "/check_and_trigger", method = RequestMethod.POST)
+    @Aac(auth = BOOL.FALSE)
+    public Result checkAndTrigger(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                                  @ApiParam(value = "科目编号", required = true) @RequestParam List<String> courseCode,
+                                  @ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) throws IOException {
+        CalculateParams calculateParams = new CalculateParams();
+        calculateParams.setSchoolId(schoolId);
+        calculateParams.setCourseCode(courseCode);
+        calculateParams.setExamId(examId);
+        analyzeDataCheckService.analyzeDataCheck(calculateParams);
+        return ResultUtil.ok();
+    }
+
+    @ApiOperation(value = "数据计算")
+    @ApiResponses({@ApiResponse(code = 200, message = "数据计算", response = Object.class)})
+    @RequestMapping(value = "/calculate", method = RequestMethod.POST)
+    @Aac(auth = BOOL.FALSE)
+    public Result calculate(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                            @ApiParam(value = "科目编号", required = true) @RequestParam List<String> courseCode,
+                            @ApiParam(value = "学校id", required = true) @RequestParam Long schoolId) throws IOException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
+        CalculateParams calculateParams = new CalculateParams();
+        calculateParams.setSchoolId(schoolId);
+        calculateParams.setCourseCode(courseCode);
+        calculateParams.setExamId(examId);
+        analyzeDataCalculateService.dataCalculateStart(calculateParams);
+        return ResultUtil.ok();
+    }
 }