浏览代码

试卷结构大部分调整

caozixuan 2 年之前
父节点
当前提交
434a8c6c88

+ 30 - 29
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchPaperServiceImpl.java

@@ -155,6 +155,7 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
                     updateBatchStatus.set(true);
                 }
                 gradeBatchPaper.setId(dbBatchPaper.getId());
+                gradeBatchPaper.setEnable(true);
                 gradeBatchPaper.setStatus(dbBatchPaper.getStatus());
                 gradeBatchPaper.setPublishStatus(dbBatchPaper.getPublishStatus());
                 gradeBatchPaper.updateInfo(requestUser.getId());
@@ -222,35 +223,35 @@ public class GradeBatchPaperServiceImpl extends ServiceImpl<GradeBatchPaperMappe
             }
         }
 
-        // 更新批次科目状态
-        for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
-            gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE);
-            this.updateById(gradeBatchPaper);
-
-            // 更新批次状态
-            GradeBatch gradeBatch = gradeBatchService.getById(gradeBatchPaper.getBatchId());
-            // 批次未推送成功,不更新状态
-            if(GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH.equals(gradeBatch.getStatus())){
-                continue;
-            }
-            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());
-                        gradeBatchService.update(updateWrapper);
-                    }
-                }
-            }
-        }
+//        // 更新批次科目状态
+//        for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
+//            gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE);
+//            this.updateById(gradeBatchPaper);
+//
+//            // 更新批次状态
+//            GradeBatch gradeBatch = gradeBatchService.getById(gradeBatchPaper.getBatchId());
+//            // 批次未推送成功,不更新状态
+//            if(GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH.equals(gradeBatch.getStatus())){
+//                continue;
+//            }
+//            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());
+//                        gradeBatchService.update(updateWrapper);
+//                    }
+//                }
+//            }
+//        }
     }
 
     /**

+ 35 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -1198,15 +1198,41 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         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());
+//                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());
+//                    }
+//                }
+                gradeBatchPaper.setStatus(GradeAnalyzePaperStatusEnum.READY_TO_CALCULATE);
+                gradeBatchPaperService.updateById(gradeBatchPaper);
+
+                // 更新批次状态
+                GradeBatch gradeBatch = gradeBatchService.getById(gradeBatchPaper.getBatchId());
+                // 批次未推送成功,不更新状态
+                if(GradeAnalyzePaperStatusEnum.PUSH_GRADE_BATCH.equals(gradeBatch.getStatus())){
+                    continue;
+                }
+                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 = 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());
+                            gradeBatchService.update(updateWrapper);
+                        }
                     }
                 }
             }

+ 1 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/params/CourseParam.java

@@ -10,8 +10,6 @@ import java.util.Optional;
 
 /**
  * @Description: 课程参数
- * @Param:
- * @return:
  * @Author: wangliang
  * @Date: 2022/5/27
  */
@@ -34,7 +32,7 @@ public class CourseParam implements Serializable {
     private String teachCollegeName;
 
     @ApiModelProperty(value = "启用/禁用,ture:启用,false:禁用,默认启用")
-    Boolean enable = true;
+    private Boolean enable;
 
     /**
      * 参数校验

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

@@ -35,7 +35,7 @@ public interface TBExamCourseService extends IService<TBExamCourse> {
      * @param courseCode 课程编号
      * @return true:不能删除 || false:可以删除
      */
-    boolean verifyExamCourseCantDelete(Long examId, Long schoolId, String courseCode);
+    boolean verifyExamCourseCantDelete(Long schoolId, Long examId, String courseCode);
 
     List<String> findEffectiveByExamId(Long examId, String courseCode);
 

+ 87 - 70
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseDeleteServiceImpl.java

@@ -82,14 +82,16 @@ public class TBExamCourseDeleteServiceImpl implements TBExamCourseDeleteService
     TAExamCourseTeacherDioService taExamCourseTeacherDioService;
     @Resource
     TAExamCourseTeacherPaperStructService taExamCourseTeacherPaperStructService;
+    @Resource
+    TAPaperStructService taPaperStructService;
 
+    // 重算
+    @Resource
+    AnalyzeForReportService analyzeForReportService;
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void deleteBasicTableData(Long schoolId, Long examId, String courseCode) {
-        if (tbExamCourseService.verifyExamCourseCantDelete(schoolId, examId, courseCode)) {
-            throw ExceptionResultEnum.ERROR.exception("考试id为【" + examId + "】,课程编号为【" + courseCode + "】的分析课程当前不能被删除");
-        }
         // 基础且无关联表删除
         tbCommonLevelConfigService.remove(new QueryWrapper<TBCommonLevelConfig>()
                 .lambda()
@@ -127,24 +129,24 @@ public class TBExamCourseDeleteServiceImpl implements TBExamCourseDeleteService
                 .lambda()
                 .eq(TBPaper::getExamId, examId)
                 .eq(TBPaper::getCourseCode, courseCode));
-        if (tbPaperList != null && tbPaperList.size() > 0){
-            if (tbPaperList.size() > 1){
+        if (tbPaperList != null && tbPaperList.size() > 0) {
+            if (tbPaperList.size() > 1) {
                 throw ExceptionResultEnum.ERROR.exception("考试id为【" + examId + "】,分析课程编号为【" + courseCode + "】存在多个试卷t_b_paper");
             }
             TBPaper tbPaper = tbPaperList.get(0);
             Long paperId = tbPaper.getId();
             List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>()
                     .lambda()
-                    .eq(TBPaperStruct::getPaperId,paperId));
+                    .eq(TBPaperStruct::getPaperId, paperId));
             List<TBExamRecord> tbExamRecordList = tbExamRecordService.list(new QueryWrapper<TBExamRecord>()
                     .lambda()
-                    .eq(TBExamRecord::getExamId,examId)
-                    .eq(TBExamRecord::getPaperId,paperId));
+                    .eq(TBExamRecord::getExamId, examId)
+                    .eq(TBExamRecord::getPaperId, paperId));
             List<Long> tbExamRecordIdList = tbExamRecordList.stream().map(TBExamRecord::getId).collect(Collectors.toList());
-            if (tbExamRecordIdList.size() > 0){
+            if (tbExamRecordIdList.size() > 0) {
                 List<TBAnswer> tbAnswerList = tbAnswerService.list(new QueryWrapper<TBAnswer>()
                         .lambda()
-                        .in(TBAnswer::getExamRecordId,tbExamRecordIdList));
+                        .in(TBAnswer::getExamRecordId, tbExamRecordIdList));
                 // 删除't_b_answer'表
                 tbAnswerService.removeByIds(tbAnswerList.stream().map(TBAnswer::getId).collect(Collectors.toList()));
             }
@@ -166,127 +168,142 @@ public class TBExamCourseDeleteServiceImpl implements TBExamCourseDeleteService
                 .lambda()
                 .eq(TBPaper::getExamId, examId)
                 .eq(TBPaper::getCourseCode, courseCode));
-        if (tbPaperList != null && tbPaperList.size() > 0){
-            if (tbPaperList.size() > 1){
+        if (tbPaperList != null && tbPaperList.size() > 0) {
+            if (tbPaperList.size() > 1) {
                 throw ExceptionResultEnum.ERROR.exception("考试id为【" + examId + "】,分析课程编号为【" + courseCode + "】存在多个试卷t_b_paper");
             }
             TBPaper tbPaper = tbPaperList.get(0);
             Long paperId = tbPaper.getId();
             List<TBExamRecord> tbExamRecordList = tbExamRecordService.list(new QueryWrapper<TBExamRecord>()
                     .lambda()
-                    .eq(TBExamRecord::getExamId,examId)
-                    .eq(TBExamRecord::getPaperId,paperId));
+                    .eq(TBExamRecord::getExamId, examId)
+                    .eq(TBExamRecord::getPaperId, paperId));
             List<Long> tbExamRecordIdList = tbExamRecordList.stream().map(TBExamRecord::getId).collect(Collectors.toList());
-            if (tbExamRecordIdList.size() > 0){
+            if (tbExamRecordIdList.size() > 0) {
                 taExamCourseRecordService.remove(new QueryWrapper<TAExamCourseRecord>()
                         .lambda()
-                        .in(TAExamCourseRecord::getExamRecordId,tbExamRecordIdList));
+                        .in(TAExamCourseRecord::getExamRecordId, tbExamRecordIdList));
             }
         }
         // 独立的分析表↓
         // 删除't_a_exam_course'
         taExamCourseService.remove(new QueryWrapper<TAExamCourse>().lambda()
-                .eq(TAExamCourse::getSchoolId,schoolId)
-                .eq(TAExamCourse::getExamId,examId)
-                .eq(TAExamCourse::getCourseCode,courseCode));
+                .eq(TAExamCourse::getSchoolId, schoolId)
+                .eq(TAExamCourse::getExamId, examId)
+                .eq(TAExamCourse::getCourseCode, courseCode));
         // 删除't_a_exam_course_clazz'
         taExamCourseClazzService.remove(new QueryWrapper<TAExamCourseClazz>()
                 .lambda()
-                .eq(TAExamCourseClazz::getSchoolId,schoolId)
-                .eq(TAExamCourseClazz::getExamId,examId)
-                .eq(TAExamCourseClazz::getCourseCode,courseCode));
+                .eq(TAExamCourseClazz::getSchoolId, schoolId)
+                .eq(TAExamCourseClazz::getExamId, examId)
+                .eq(TAExamCourseClazz::getCourseCode, courseCode));
         // 删除't_a_exam_course_college_inspect'
         taExamCourseCollegeInspectService.remove(new QueryWrapper<TAExamCourseCollegeInspect>()
                 .lambda()
-                .eq(TAExamCourseCollegeInspect::getSchoolId,schoolId)
-                .eq(TAExamCourseCollegeInspect::getExamId,examId)
-                .eq(TAExamCourseCollegeInspect::getCourseCode,courseCode));
+                .eq(TAExamCourseCollegeInspect::getSchoolId, schoolId)
+                .eq(TAExamCourseCollegeInspect::getExamId, examId)
+                .eq(TAExamCourseCollegeInspect::getCourseCode, courseCode));
         // 删除't_a_exam_course_college_inspect_dio'
         taExamCourseCollegeInspectDioService.remove(new QueryWrapper<TAExamCourseCollegeInspectDio>()
                 .lambda()
-                .eq(TAExamCourseCollegeInspectDio::getSchoolId,schoolId)
-                .eq(TAExamCourseCollegeInspectDio::getExamId,examId)
-                .eq(TAExamCourseCollegeInspectDio::getCourseCode,courseCode));
+                .eq(TAExamCourseCollegeInspectDio::getSchoolId, schoolId)
+                .eq(TAExamCourseCollegeInspectDio::getExamId, examId)
+                .eq(TAExamCourseCollegeInspectDio::getCourseCode, courseCode));
         // 删除't_a_exam_course_college_paper_struct'
         taExamCourseCollegePaperStructService.remove(new QueryWrapper<TAExamCourseCollegePaperStruct>()
                 .lambda()
-                .eq(TAExamCourseCollegePaperStruct::getSchoolId,schoolId)
-                .eq(TAExamCourseCollegePaperStruct::getExamId,examId)
-                .eq(TAExamCourseCollegePaperStruct::getCourseCode,courseCode));
+                .eq(TAExamCourseCollegePaperStruct::getSchoolId, schoolId)
+                .eq(TAExamCourseCollegePaperStruct::getExamId, examId)
+                .eq(TAExamCourseCollegePaperStruct::getCourseCode, courseCode));
         // 删除't_a_exam_course_college_teacher'
         taExamCourseCollegeTeacherService.remove(new QueryWrapper<TAExamCourseCollegeTeacher>()
                 .lambda()
-                .eq(TAExamCourseCollegeTeacher::getSchoolId,schoolId)
-                .eq(TAExamCourseCollegeTeacher::getExamId,examId)
-                .eq(TAExamCourseCollegeTeacher::getCourseCode,courseCode));
+                .eq(TAExamCourseCollegeTeacher::getSchoolId, schoolId)
+                .eq(TAExamCourseCollegeTeacher::getExamId, examId)
+                .eq(TAExamCourseCollegeTeacher::getCourseCode, courseCode));
         // 删除't_a_exam_course_difficult'
         taExamCourseDifficultService.remove(new QueryWrapper<TAExamCourseDifficult>()
                 .lambda()
-                .eq(TAExamCourseDifficult::getSchoolId,schoolId)
-                .eq(TAExamCourseDifficult::getExamId,examId)
-                .eq(TAExamCourseDifficult::getCourseCode,courseCode));
+                .eq(TAExamCourseDifficult::getSchoolId, schoolId)
+                .eq(TAExamCourseDifficult::getExamId, examId)
+                .eq(TAExamCourseDifficult::getCourseCode, courseCode));
         // 删除't_a_exam_course_dio'
         taExamCourseDioService.remove(new QueryWrapper<TAExamCourseDio>().lambda()
-                .eq(TAExamCourseDio::getSchoolId,schoolId)
-                .eq(TAExamCourseDio::getExamId,examId)
-                .eq(TAExamCourseDio::getCourseCode,courseCode));
+                .eq(TAExamCourseDio::getSchoolId, schoolId)
+                .eq(TAExamCourseDio::getExamId, examId)
+                .eq(TAExamCourseDio::getCourseCode, courseCode));
         // 删除't_a_exam_course_record_dio'
         taExamCourseRecordDioService.remove(new QueryWrapper<TAExamCourseRecordDio>().lambda()
-                .eq(TAExamCourseRecordDio::getSchoolId,schoolId)
-                .eq(TAExamCourseRecordDio::getExamId,examId)
-                .eq(TAExamCourseRecordDio::getCourseCode,courseCode));
+                .eq(TAExamCourseRecordDio::getSchoolId, schoolId)
+                .eq(TAExamCourseRecordDio::getExamId, examId)
+                .eq(TAExamCourseRecordDio::getCourseCode, courseCode));
         // 删除't_a_exam_course_record_mod'
         taExamCourseRecordModService.remove(new QueryWrapper<TAExamCourseRecordMod>().lambda()
-                .eq(TAExamCourseRecordMod::getSchoolId,schoolId)
-                .eq(TAExamCourseRecordMod::getExamId,examId)
-                .eq(TAExamCourseRecordMod::getCourseCode,courseCode));
+                .eq(TAExamCourseRecordMod::getSchoolId, schoolId)
+                .eq(TAExamCourseRecordMod::getExamId, examId)
+                .eq(TAExamCourseRecordMod::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher'
         taExamCourseTeacherService.remove(new QueryWrapper<TAExamCourseTeacher>().lambda()
-                .eq(TAExamCourseTeacher::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacher::getExamId,examId)
-                .eq(TAExamCourseTeacher::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacher::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacher::getExamId, examId)
+                .eq(TAExamCourseTeacher::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_college_difficult'
         taExamCourseTeacherCollegeDifficultService.remove(new QueryWrapper<TAExamCourseTeacherCollegeDifficult>().lambda()
-                .eq(TAExamCourseTeacherCollegeDifficult::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherCollegeDifficult::getExamId,examId)
-                .eq(TAExamCourseTeacherCollegeDifficult::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacherCollegeDifficult::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherCollegeDifficult::getExamId, examId)
+                .eq(TAExamCourseTeacherCollegeDifficult::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_college_dio'
         taExamCourseTeacherCollegeDioService.remove(new QueryWrapper<TAExamCourseTeacherCollegeDio>().lambda()
-                .eq(TAExamCourseTeacherCollegeDio::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherCollegeDio::getExamId,examId)
-                .eq(TAExamCourseTeacherCollegeDio::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacherCollegeDio::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherCollegeDio::getExamId, examId)
+                .eq(TAExamCourseTeacherCollegeDio::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_college_paper_struct'
         taExamCourseTeacherCollegePaperStructService.remove(new QueryWrapper<TAExamCourseTeacherCollegePaperStruct>().lambda()
-                .eq(TAExamCourseTeacherCollegePaperStruct::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherCollegePaperStruct::getExamId,examId)
-                .eq(TAExamCourseTeacherCollegePaperStruct::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacherCollegePaperStruct::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherCollegePaperStruct::getExamId, examId)
+                .eq(TAExamCourseTeacherCollegePaperStruct::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_difficult'
         taExamCourseTeacherDifficultService.remove(new QueryWrapper<TAExamCourseTeacherDifficult>().lambda()
-                .eq(TAExamCourseTeacherDifficult::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherDifficult::getExamId,examId)
-                .eq(TAExamCourseTeacherDifficult::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacherDifficult::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherDifficult::getExamId, examId)
+                .eq(TAExamCourseTeacherDifficult::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_dio'
         taExamCourseTeacherDioService.remove(new QueryWrapper<TAExamCourseTeacherDio>().lambda()
-                .eq(TAExamCourseTeacherDio::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherDio::getExamId,examId)
-                .eq(TAExamCourseTeacherDio::getCourseCode,courseCode));
+                .eq(TAExamCourseTeacherDio::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherDio::getExamId, examId)
+                .eq(TAExamCourseTeacherDio::getCourseCode, courseCode));
         // 删除't_a_exam_course_teacher_paper_struct'
         taExamCourseTeacherPaperStructService.remove(new QueryWrapper<TAExamCourseTeacherPaperStruct>().lambda()
-                .eq(TAExamCourseTeacherPaperStruct::getSchoolId,schoolId)
-                .eq(TAExamCourseTeacherPaperStruct::getExamId,examId)
-                .eq(TAExamCourseTeacherPaperStruct::getCourseCode,courseCode));
-        // 删除''
+                .eq(TAExamCourseTeacherPaperStruct::getSchoolId, schoolId)
+                .eq(TAExamCourseTeacherPaperStruct::getExamId, examId)
+                .eq(TAExamCourseTeacherPaperStruct::getCourseCode, courseCode));
+        // 删除't_a_paper_struct'
+        taPaperStructService.remove(new QueryWrapper<TAPaperStruct>().lambda()
+                .eq(TAPaperStruct::getSchoolId, schoolId)
+                .eq(TAPaperStruct::getExamId, examId)
+                .eq(TAPaperStruct::getCourseCode, courseCode));
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void repeatCalculateTotalTableData(Long schoolId, Long examId, String courseCode) {
-
+        analyzeForReportService.buildAnalyzeExamTotal(examId, courseCode);
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void deleteTBExamCourse(List<TBExamCourseDeleteParams> tbExamCourseDeleteParamsList) {
+    public synchronized void deleteTBExamCourse(List<TBExamCourseDeleteParams> tbExamCourseDeleteParamsList) {
+        for (TBExamCourseDeleteParams tbExamCourseDeleteParams : tbExamCourseDeleteParamsList) {
+            Long schoolId = tbExamCourseDeleteParams.getSchoolId();
+            Long examId = tbExamCourseDeleteParams.getExamId();
+            String courseCode = tbExamCourseDeleteParams.getCourseCode();
 
+            if (tbExamCourseService.verifyExamCourseCantDelete(schoolId, examId, courseCode)) {
+                throw ExceptionResultEnum.ERROR.exception("考试id为【" + examId + "】,课程编号为【" + courseCode + "】的分析课程当前不能被删除");
+            }
+            this.deleteBasicTableData(schoolId, examId, courseCode);
+            this.deleteAnalyzeTableData(schoolId, examId, courseCode);
+            this.repeatCalculateTotalTableData(schoolId, examId, courseCode);
+        }
     }
 }

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

@@ -85,7 +85,7 @@ public class TBExamCourseServiceImpl extends ServiceImpl<TBExamCourseMapper, TBE
     }
 
     @Override
-    public boolean verifyExamCourseCantDelete(Long examId, Long schoolId, String courseCode) {
+    public boolean verifyExamCourseCantDelete(Long schoolId, Long examId, String courseCode) {
         QueryWrapper<BasicCourse> schoolCourseQuery = new QueryWrapper<>();
         schoolCourseQuery.lambda()
                 .eq(BasicCourse::getSchoolId, schoolId)

+ 26 - 6
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/OpenApiController.java

@@ -4,6 +4,7 @@ import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.teachcloud.common.bean.params.BasicSemesterParams;
+import com.qmth.teachcloud.common.bean.params.TBExamCourseDeleteParams;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
@@ -20,6 +21,7 @@ import com.qmth.teachcloud.report.business.bean.params.PublishParams;
 import com.qmth.teachcloud.report.business.bean.params.TBExamParam;
 import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
 import com.qmth.teachcloud.report.business.service.AnalyzeForReportService;
+import com.qmth.teachcloud.report.business.service.TBExamCourseDeleteService;
 import com.qmth.teachcloud.report.business.service.TBExamCourseService;
 import com.qmth.teachcloud.report.business.service.TBExamService;
 import com.qmth.teachcloud.report.business.templete.strategy.CourseCodeSyncTaskService;
@@ -36,6 +38,8 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Optional;
 
 /**
@@ -74,11 +78,14 @@ public class OpenApiController {
     @Resource
     AnalyzeForReportService analyzeForReportService;
 
+    @Resource
+    TBExamCourseDeleteService tbExamCourseDeleteService;
+
     @ApiOperation(value = "学期创建/更新接口")
     @ApiResponses({@ApiResponse(code = 200, message = "学期创建/更新接口", response = Object.class)})
     @RequestMapping(value = "/semester_edit", method = RequestMethod.POST)
     @Aac(auth = BOOL.FALSE)
-    public Result semesterEdit(@ApiParam(value = "接收学期数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException, IllegalAccessException {
+    public Result semesterEdit(@ApiParam(value = "接收学期数据信息", required = true) @RequestBody String result) throws IOException, IllegalAccessException {
         Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
         String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
         log.info("semesterEdit进来了,result:{}", decodeJson);
@@ -93,7 +100,7 @@ public class OpenApiController {
     @ApiResponses({@ApiResponse(code = 200, message = "考试创建/更新接口", response = Object.class)})
     @RequestMapping(value = "/exam_edit", method = RequestMethod.POST)
     @Aac(auth = BOOL.FALSE)
-    public Result examEdit(@ApiParam(value = "接收考试数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
+    public Result examEdit(@ApiParam(value = "接收考试数据信息", required = true) @RequestBody String result) throws IOException {
         Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
         String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
         log.info("examEdit进来了,result:{}", decodeJson);
@@ -110,15 +117,28 @@ public class OpenApiController {
     @RequestMapping(value = "/course_edit", method = RequestMethod.POST)
     @Aac(auth = BOOL.FALSE)
     @Transactional
-    public Result courseEdit(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
+    public Result courseEdit(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException {
         Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
         String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
         log.info("courseEdit进来了进来了,result:{}", decodeJson);
         CourseParam courseParam = JacksonUtil.readJson(decodeJson, CourseParam.class);
         courseParam.validParams();
         BasicSchool basicSchool = AuthThirdUtil.hasPermission();
-        basicCourseService.createCourse(basicSchool.getId(), courseParam.getCourseCode(), courseParam.getCourseName());
-        tbExamCourseService.createCourse(basicSchool.getId(), courseParam.getExamId(), courseParam.getCourseCode(), courseParam.getCourseName(), courseParam.getPaperType(), courseParam.getTeachCollegeName());
+        Boolean enable = courseParam.getEnable();
+        if (enable != null && enable) {
+            // 新增或编辑分析课程
+            basicCourseService.createCourse(basicSchool.getId(), courseParam.getCourseCode(), courseParam.getCourseName());
+            tbExamCourseService.createCourse(basicSchool.getId(), courseParam.getExamId(), courseParam.getCourseCode(), courseParam.getCourseName(), courseParam.getPaperType(), courseParam.getTeachCollegeName());
+        } else {
+            // 删除分析课程
+            List<TBExamCourseDeleteParams> tbExamCourseDeleteParamsList = new ArrayList<>();
+            TBExamCourseDeleteParams tbExamCourseDeleteParams = new TBExamCourseDeleteParams();
+            tbExamCourseDeleteParams.setSchoolId(basicSchool.getId());
+            tbExamCourseDeleteParams.setExamId(courseParam.getExamId());
+            tbExamCourseDeleteParams.setCourseCode(courseParam.getCourseCode());
+            tbExamCourseDeleteParamsList.add(tbExamCourseDeleteParams);
+            tbExamCourseDeleteService.deleteTBExamCourse(tbExamCourseDeleteParamsList);
+        }
         return ResultUtil.ok(true);
     }
 
@@ -126,7 +146,7 @@ public class OpenApiController {
     @ApiResponses({@ApiResponse(code = 200, message = "生成课程(试卷)分析报告接口", response = Object.class)})
     @RequestMapping(value = "/calculate", method = RequestMethod.POST)
     @Aac(auth = BOOL.FALSE)
-    public Result calculate(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
+    public Result calculate(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException {
         Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
         String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
         log.info("calculate进来了,result:{}", decodeJson);