Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/dev_v2.1.0' into dev_v2.1.0

wangliang 4 rokov pred
rodič
commit
7dc2f5da9c
14 zmenil súbory, kde vykonal 402 pridanie a 334 odobranie
  1. 11 0
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/result/TBStudentReportResult.java
  2. 2 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseRecordDioMapper.java
  3. 2 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseRecordMapper.java
  4. 2 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TBStudentMapper.java
  5. 43 22
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java
  6. 1 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/TBExamStudentService.java
  7. 174 156
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java
  8. 23 17
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamStudentServiceImpl.java
  9. 1 0
      teachcloud-report-business/src/main/resources/mapper/TAExamCourseRecordDioMapper.xml
  10. 1 1
      teachcloud-report-business/src/main/resources/mapper/TAExamCourseRecordMapper.xml
  11. 19 19
      teachcloud-report-business/src/main/resources/mapper/TBExamStudentMapper.xml
  12. 94 91
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java
  13. 9 9
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/StudentReportController.java
  14. 20 13
      teachcloud-report/src/test/java/com/qmth/teachcloud/report/AnalyzeForStudentServiceTest.java

+ 11 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/result/TBStudentReportResult.java

@@ -39,6 +39,9 @@ public class TBStudentReportResult implements Serializable {
     @ApiModelProperty(value = "学生名称")
     private String studentName;
 
+    @ApiModelProperty(value = "学号")
+    private String studentCode;
+
     @ApiModelProperty(value = "班级名称")
     private String clazzName;
 
@@ -116,4 +119,12 @@ public class TBStudentReportResult implements Serializable {
     public void setAbsent(Boolean absent) {
         this.absent = absent;
     }
+
+    public String getStudentCode() {
+        return studentCode;
+    }
+
+    public void setStudentCode(String studentCode) {
+        this.studentCode = studentCode;
+    }
 }

+ 2 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseRecordDioMapper.java

@@ -18,7 +18,7 @@ import java.util.List;
  */
 public interface TAExamCourseRecordDioMapper extends BaseMapper<TAExamCourseRecordDio> {
 
-    List<ModuleDetailResult> listDiosBySchoolIdAndExamIdAndCourseCodeAndModuleName(@Param("schoolId") String schoolId, @Param("examId") String examId, @Param("courseCode") String courseCode, @Param("moduleName") String moduleName);
+    List<ModuleDetailResult> listDiosBySchoolIdAndExamIdAndCourseCodeAndModuleName(@Param("schoolId") Long schoolId, @Param("examId") String examId, @Param("courseCode") String courseCode, @Param("moduleName") String moduleName, @Param("studentCode") String studentCode);
 
-    List<DimensionDetailResult> listSubDiosBySchoolIdAndExamIdAndStudentCodeAndCourseCodeAndModuleName(@Param("schoolId") String schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode, @Param("moduleName") String moduleName);
+    List<DimensionDetailResult> listSubDiosBySchoolIdAndExamIdAndStudentCodeAndCourseCodeAndModuleName(@Param("schoolId") Long schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode, @Param("moduleName") String moduleName);
 }

+ 2 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseRecordMapper.java

@@ -22,9 +22,9 @@ public interface TAExamCourseRecordMapper extends BaseMapper<TAExamCourseRecord>
 
     List<TAExamCourseRecord> listExamCourseRecord(@Param("schoolId") Long schoolId, @Param("semester") String semester, @Param("examId") Long examId, @Param("courseCode") String courseCode);
 
-    ExamStudentResult getStudent(@Param("schoolId") String schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode);
+    ExamStudentResult getStudent(@Param("schoolId") Long schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode);
 
-    SynthesisResult getSynthesisResult(@Param("schoolId") String schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode);
+    SynthesisResult getSynthesisResult(@Param("schoolId") Long schoolId, @Param("examId") String examId, @Param("studentCode") String studentCode, @Param("courseCode") String courseCode);
 
     /**
      * 查询考生信息

+ 2 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TBStudentMapper.java

@@ -3,6 +3,7 @@ package com.qmth.teachcloud.report.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.teachcloud.report.business.bean.result.StudentInfo;
 import com.qmth.teachcloud.report.business.entity.TBStudent;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -14,5 +15,5 @@ import com.qmth.teachcloud.report.business.entity.TBStudent;
  */
 public interface TBStudentMapper extends BaseMapper<TBStudent> {
 
-    StudentInfo getStudentBySchoolIdAndStudentCode(Long schoolId, String studentCode);
+    StudentInfo getStudentBySchoolIdAndStudentCode(@Param("schoolId") Long schoolId, @Param("studentCode") String studentCode);
 }

+ 43 - 22
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForStudentService.java → teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java

@@ -5,40 +5,45 @@ package com.qmth.teachcloud.report.business.service;
  * @Author: CaoZixuan
  * @Date: 2021-06-06
  */
-public interface AnalyzeForStudentService {
+public interface AnalyzeForReportService {
 
     /**
      * 构建考试课程分析表 't_a_exam_course'
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourse(Long examId,String courseCode);
+    String buildAnalyzeExamCourse(Long examId, String courseCode);
+
     /**
      * 构建考试记录分析表数据 't_a_exam_course_record'
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseRecord(Long examId,String courseCode);
+    String buildAnalyzeExamCourseRecord(Long examId, String courseCode);
 
     /**
      * 构建以考试课程-考察学院维度的分析表 't_a_exam_course_college_inspect'
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseCollegeInspect(Long examId,String courseCode);
+    String buildAnalyzeExamCourseCollegeInspect(Long examId, String courseCode);
 
     // TODO: 2021/6/7 专业
 
     /**
      * 构建考试课程-班级维度的分析表 ’t_a_exam_course_clazz‘
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseClazz(Long examId,String courseCode);
+    String buildAnalyzeExamCourseClazz(Long examId, String courseCode);
 
     /**
      * 分析计算某科目考试的所有考察点得分率并将计算结果插入't_a_exam_course_dio'和't_a_exam_course_record_dio'和‘t_a_exam_course_record_mod’表中
@@ -52,44 +57,49 @@ public interface AnalyzeForStudentService {
      * 2.获取该科目考试的试卷结构的数据信息
      * 3.获取该科目考试所有考察点的数据源
      * 4.获取该科目考试考生每题答题记录详情数据源
-     *
+     * <p>
      * 5.计算每个考察点所对应的题目集合
      * 6.计算每个考察点在此次考试所占分数
      * 7.计算每个考生各个知识点得分率并更新't_a_exam_course_record_dio'表
      * 8.计算此次考试各个考察点得分率并插入't_a_exam_course_dio'表
      * </p>
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String AnalyzePointScoreRate(Long examId,String courseCode) throws Exception;
+    String AnalyzePointScoreRate(Long examId, String courseCode) throws Exception;
 
     /**
      * 构建考试课程考察学院维度分析表
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseCollegeInspectDio(Long examId,String courseCode);
+    String buildAnalyzeExamCourseCollegeInspectDio(Long examId, String courseCode);
 
     /**
      * 构建分析试卷结构表 't_a_paper_struct'表
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzePaperStruct(Long examId,String courseCode);
+    String buildAnalyzePaperStruct(Long examId, String courseCode);
 
     /**
      * 构建科目题目难度分类得分率表
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildExamPaperDifficult(Long examId,String courseCode);
+    String buildExamPaperDifficult(Long examId, String courseCode);
 
     /**
      * 构建表 ‘t_a_exam_total’
+     *
      * @param examId 考试id
      * @return 结果
      */
@@ -97,17 +107,28 @@ public interface AnalyzeForStudentService {
 
     /**
      * 构建表 't_a_exam_course_college_teacher'
-     * @param examId 考试id
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseCollegeTeacher(Long examId,String courseCode);
+    String buildAnalyzeExamCourseCollegeTeacher(Long examId, String courseCode);
 
     /**
      * 构建表 't_a_exam_course_teacher'
-     * @param examId 考试id
+     *
+     * @param examId     考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    String buildAnalyzeExamCourseTeacher(Long examId, String courseCode);
+
+    /**
+     * 完成计算,更新表 't_b_exam_course'表 已计算
+     *
+     * @param examId     考试id
      * @param courseCode 课程编号
      * @return 结果
      */
-    String buildAnalyzeExamCourseTeacher(Long examId,String courseCode);
+    String finishCalculate(Long examId, String courseCode);
 }

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

@@ -162,5 +162,5 @@ public interface TBExamStudentService extends IService<TBExamStudent> {
      * @param courseCode
      * @return
      */
-    PersonalReportResult reportMark(String schoolId, String studentCode, String examId, String courseCode);
+    PersonalReportResult reportMark(Long schoolId, String studentCode, String examId, String courseCode);
 }

+ 174 - 156
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForStudentServiceImpl.java → teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -12,6 +12,7 @@ import com.qmth.teachcloud.report.business.bean.dto.query.BasicAnswerDto;
 import com.qmth.teachcloud.report.business.bean.dto.query.ValidAnswerDetailDto;
 import com.qmth.teachcloud.report.business.entity.*;
 import com.qmth.teachcloud.report.business.enums.LevelRuleEnum;
+import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
 import com.qmth.teachcloud.report.business.enums.QuantileEnum;
 import com.qmth.teachcloud.report.business.enums.ValidityEnum;
 import com.qmth.teachcloud.report.business.service.*;
@@ -35,7 +36,7 @@ import java.util.stream.Collectors;
  * @Date: 2021-06-06
  */
 @Service
-public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
+public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
     @Resource
     private TAExamCourseRecordService taExamCourseRecordService;
     @Resource
@@ -95,22 +96,22 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildAnalyzeExamCourse(Long examId, String courseCode) {
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         // 考试下考生作答数据源
         List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId));
+                .eq(TAExamCourseRecord::getExamId, examId));
         List<TAExamCourse> taExamCourseList = new ArrayList<>();
         // 有效的课程
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 原数据删除
             taExamCourseService.remove(new QueryWrapper<TAExamCourse>().lambda()
-                    .eq(TAExamCourse::getExamId,examId)
-                    .eq(TAExamCourse::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourse::getExamId, examId)
+                    .eq(TAExamCourse::getCourseCode, effectiveCourseCode));
 
             // TODO: 2021/6/7 查询试卷信息AB卷的准确方式(目前AB卷规则视为一致)
             List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
-                    .eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,effectiveCourseCode));
-            if (tbPaperList.size() < 1){
+                    .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, effectiveCourseCode));
+            if (tbPaperList.size() < 1) {
                 throw ExceptionResultEnum.ERROR.exception("未找到试卷基础信息");
             }
             TBPaper tbPaper = tbPaperList.get(0);
@@ -130,7 +131,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             int totalCount = totalDatasource.size();
             long realityCount = totalDatasource.stream().filter(e -> !e.getAbsent()).count();
             long absentCount = totalDatasource.stream().filter(TAExamCourseRecord::getAbsent).count();
-            if (totalCount != realityCount + absentCount){
+            if (totalCount != realityCount + absentCount) {
                 throw ExceptionResultEnum.ERROR.exception("考试人数数据异常");
             }
             // 赋分数据集合
@@ -139,14 +140,14 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             DoubleSummaryStatistics totalStatistics = totalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double avgScore = totalStatistics.getAverage();
             long passCount = totalScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal passRate = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(realityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal passRate = BigDecimal.valueOf(passCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
             // -------------------卷面分------------------------
             List<Double> paperTotalScoreList = totalDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics paperTotalStatistics = paperTotalScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double paperAvgScore = paperTotalStatistics.getAverage();
             long paperPassCount = paperTotalScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal paperPassRate = BigDecimal.valueOf(paperPassCount).divide(BigDecimal.valueOf(realityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal paperPassRate = BigDecimal.valueOf(paperPassCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
 
 
@@ -159,10 +160,10 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             int pastTotalCount = pastDatasource.size();
             long pastRealityCount = pastDatasource.stream().filter(e -> !e.getAbsent()).count();
             long pastAbsentCount = pastDatasource.stream().filter(TAExamCourseRecord::getAbsent).count();
-            if (pastTotalCount != pastRealityCount + pastAbsentCount){
+            if (pastTotalCount != pastRealityCount + pastAbsentCount) {
                 throw ExceptionResultEnum.ERROR.exception("考试往届生人数数据异常");
             }
-            BigDecimal pastRealityRate = BigDecimal.valueOf(pastRealityCount).divide(BigDecimal.valueOf(realityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal pastRealityRate = BigDecimal.valueOf(pastRealityCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
             /*
                 该课程应届生成绩分析
@@ -174,16 +175,16 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             int currentTotalCount = currentDatasource.size();
             long currentRealityCount = currentDatasource.stream().filter(e -> !e.getAbsent()).count();
             long currentAbsentCount = currentDatasource.stream().filter(TAExamCourseRecord::getAbsent).count();
-            if (currentTotalCount != currentRealityCount + currentAbsentCount){
+            if (currentTotalCount != currentRealityCount + currentAbsentCount) {
                 throw ExceptionResultEnum.ERROR.exception("考试应届生人数数据异常");
             }
-            BigDecimal currentRealityRate = BigDecimal.valueOf(currentRealityCount).divide(BigDecimal.valueOf(realityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal currentRealityRate = BigDecimal.valueOf(currentRealityCount).divide(BigDecimal.valueOf(realityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
             // 通过率统计
             List<Double> currentScoreList = currentDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getAssignedScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics currentStatistics = currentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             long currentPassCount = currentScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal currentPassRate = BigDecimal.valueOf(currentPassCount).divide(BigDecimal.valueOf(currentRealityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal currentPassRate = BigDecimal.valueOf(currentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
             // 描述统计
             double currentMinScore = currentStatistics.getMin();
@@ -213,39 +214,39 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             BigDecimal scoreRate;
             double standardAvgScore = currentDatasource.stream().collect(Collectors.summarizingDouble(e -> e.getTotalScore().doubleValue())).getAverage();
             if (standardAvgScore != 0 && totalScore.compareTo(BigDecimal.ZERO) > 0) {
-                scoreRate = BigDecimal.valueOf(standardAvgScore).divide(totalScore,4,BigDecimal.ROUND_HALF_DOWN);
+                scoreRate = BigDecimal.valueOf(standardAvgScore).divide(totalScore, 4, BigDecimal.ROUND_HALF_DOWN);
             } else {
                 scoreRate = BigDecimal.ZERO;
             }
             // 难度系数保留1位数
-            scoreRate = scoreRate.setScale(1,BigDecimal.ROUND_HALF_DOWN); // 难度系数保留1位有效数字
-            String difficulty = this.handleLevel(examId,effectiveCourseCode,"难度等级", scoreRate.doubleValue());
+            scoreRate = scoreRate.setScale(1, BigDecimal.ROUND_HALF_DOWN); // 难度系数保留1位有效数字
+            String difficulty = this.handleLevel(examId, effectiveCourseCode, "难度等级", scoreRate.doubleValue());
             //--------------------------应届-卷面成绩-----------------------
             List<Double> paperCurrentScoreList = currentDatasource.stream().filter(e -> !e.getAbsent()).map(e -> e.getTotalScore().doubleValue()).collect(Collectors.toList());
             DoubleSummaryStatistics paperCurrentStatistics = paperCurrentScoreList.stream().collect(Collectors.summarizingDouble(e -> e));
             double paperCurrentAvgScore = paperCurrentStatistics.getAverage();
             long paperCurrentPassCount = paperCurrentScoreList.stream().filter(e -> e >= passScore.doubleValue()).count();
-            BigDecimal paperCurrentPassRate = BigDecimal.valueOf(paperCurrentPassCount).divide(BigDecimal.valueOf(currentRealityCount),4,BigDecimal.ROUND_HALF_DOWN);
+            BigDecimal paperCurrentPassRate = BigDecimal.valueOf(paperCurrentPassCount).divide(BigDecimal.valueOf(currentRealityCount), 4, BigDecimal.ROUND_HALF_DOWN);
 
             /*
                 学院信息
              */
             // TODO: 2021/6/7 考察学院数量算进去往届和缺考的吗
             List<TBExamStudent> tbExamStudentList = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
-                    .eq(TBExamStudent::getExamId,examId).eq(TBExamStudent::getCourseCode,effectiveCourseCode));
+                    .eq(TBExamStudent::getExamId, examId).eq(TBExamStudent::getCourseCode, effectiveCourseCode));
 
             List<Long> teachCollegeIdList = tbExamStudentList.stream().map(TBExamStudent::getTeachCollegeId).distinct().collect(Collectors.toList());
             List<Long> inspectCollegeIdList = tbExamStudentList.stream().map(TBExamStudent::getInspectCollegeId).distinct().collect(Collectors.toList());
-            if (teachCollegeIdList.size() != 1){
+            if (teachCollegeIdList.size() != 1) {
                 throw ExceptionResultEnum.ERROR.exception("该课程有多个开课学院异常");
             }
             Long teachCollegeId = teachCollegeIdList.get(0);
             SysOrg tbSchoolCollege = sysOrgService.getById(teachCollegeId);
             String teachCollegeName;
-            if (Objects.isNull(tbSchoolCollege)){
+            if (Objects.isNull(tbSchoolCollege)) {
                 teachCollegeName = SystemConstant.DEFAULT_SIGN;
-            }else {
-                teachCollegeName= tbSchoolCollege.getName();
+            } else {
+                teachCollegeName = tbSchoolCollege.getName();
             }
             int inspectCollegeCount = inspectCollegeIdList.size();
 
@@ -298,25 +299,25 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             taExamCourseList.add(taExamCourse);
         }
         taExamCourseService.saveBatch(taExamCourseList);
-        return " 't_a_exam_course' 表构建完毕 "  ;
+        return " 't_a_exam_course' 表构建完毕 ";
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String buildAnalyzeExamCourseRecord(Long examId,String courseCode) {
+    public String buildAnalyzeExamCourseRecord(Long examId, String courseCode) {
         // 获取本次考试所有考试记录数据源
         List<TAExamCourseRecord> taExamCourseRecordDatasource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId)
-                .eq(TAExamCourseRecord::getAbsent,false)
-                .eq(TAExamCourseRecord::getStudentCurrent,true));
+                .eq(TAExamCourseRecord::getExamId, examId)
+                .eq(TAExamCourseRecord::getAbsent, false)
+                .eq(TAExamCourseRecord::getStudentCurrent, true));
 
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
 
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             List<TAExamCourse> taExamCourseList = taExamCourseService.list(new QueryWrapper<TAExamCourse>().lambda()
-                    .eq(TAExamCourse::getExamId,examId)
-                    .eq(TAExamCourse::getCourseCode,effectiveCourseCode));
-            if (taExamCourseList.size() != 1){
+                    .eq(TAExamCourse::getExamId, examId)
+                    .eq(TAExamCourse::getCourseCode, effectiveCourseCode));
+            if (taExamCourseList.size() != 1) {
                 throw ExceptionResultEnum.ERROR.exception("考试课程分析数据获取失败");
             }
             TAExamCourse taExamCourse = taExamCourseList.get(0);
@@ -330,15 +331,15 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                 long sameCount = dataSource.stream().filter(e -> e.getTotalScore().compareTo(totalScore) == 0).count(); // 和我相同的人数
                 int totalCount = dataSource.size(); //总人数
                 // 标准回归系数
-                BigDecimal standardizedCoefficients = (taExamCourseRecord.getAssignedScore().subtract(avgScore)).divide(standardDeviation,4,BigDecimal.ROUND_HALF_DOWN);
+                BigDecimal standardizedCoefficients = (taExamCourseRecord.getAssignedScore().subtract(avgScore)).divide(standardDeviation, 4, BigDecimal.ROUND_HALF_DOWN);
 
-                int percentGrade = this.handlePercentGrade(BigDecimal.valueOf(lowCount),BigDecimal.valueOf(sameCount),BigDecimal.valueOf(totalCount));
+                int percentGrade = this.handlePercentGrade(BigDecimal.valueOf(lowCount), BigDecimal.valueOf(sameCount), BigDecimal.valueOf(totalCount));
                 taExamCourseRecord.setPercentGrade(percentGrade);
 
-                String scoreLevel = this.handleLevel(examId,effectiveCourseCode,"百分等级",percentGrade);
+                String scoreLevel = this.handleLevel(examId, effectiveCourseCode, "百分等级", percentGrade);
                 taExamCourseRecord.setScoreLevel(scoreLevel);
                 taExamCourseRecord.setStandardizedCoefficients(standardizedCoefficients);
-                this.buildColData(taExamCourseRecord,dataSource); // 总成绩在学院的排名、排名等级档位、超过学院百分比
+                this.buildColData(taExamCourseRecord, dataSource); // 总成绩在学院的排名、排名等级档位、超过学院百分比
             }
             taExamCourseRecordService.saveOrUpdateBatch(dataSource);
         }
@@ -349,15 +350,15 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzeExamCourseCollegeInspect(Long examId, String courseCode) {
         List<TAExamCourseRecord> recordDatasource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId));
+                .eq(TAExamCourseRecord::getExamId, examId));
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         List<TAExamCourseCollegeInspect> inspectCollegeList = new ArrayList<>();
 
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除原有数据
             taExamCourseCollegeInspectService.remove(new QueryWrapper<TAExamCourseCollegeInspect>().lambda()
-                    .eq(TAExamCourseCollegeInspect::getExamId,examId).eq(TAExamCourseCollegeInspect::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseCollegeInspect::getExamId, examId).eq(TAExamCourseCollegeInspect::getCourseCode, effectiveCourseCode));
 
             // 本课程下所有应届考生考生记录
             List<TAExamCourseRecord> recordCourseCurrentDatasource = recordDatasource.stream()
@@ -387,7 +388,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                 double lowerQuartile = MathUtil.calculateQuantile(assignedScoreList, QuantileEnum.LOWER_QUARTILE.getValue());
 
                 // TODO: 2021/6/7 缺考的学院信息处理
-                if (effectiveList.size() == 0){
+                if (effectiveList.size() == 0) {
                     minScore = 0;
                     maxScore = 0;
                     avgScore = 0;
@@ -438,16 +439,16 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzeExamCourseClazz(Long examId, String courseCode) {
         List<TAExamCourseRecord> recordDatasource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId));
+                .eq(TAExamCourseRecord::getExamId, examId));
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
 
         List<TAExamCourseClazz> taExamCourseClazzList = new ArrayList<>();
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除原有数据
             taExamCourseClazzService.remove(new QueryWrapper<TAExamCourseClazz>().lambda()
-                    .eq(TAExamCourseClazz::getExamId,examId)
-                    .eq(TAExamCourseClazz::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseClazz::getExamId, examId)
+                    .eq(TAExamCourseClazz::getCourseCode, effectiveCourseCode));
 
             List<TAExamCourseRecord> recordCourseCurrentDatasource = recordDatasource.stream()
                     .filter(e -> effectiveCourseCode.equals(e.getCourseCode()) && e.getStudentCurrent()).collect(Collectors.toList());
@@ -472,20 +473,20 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                 double avgScore = doubleSummaryStatistics.getAverage();
 
                 List<TBExamStudent> tbExamStudentList = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
-                        .eq(TBExamStudent::getExamId,examId)
-                        .eq(TBExamStudent::getCourseCode,effectiveCourseCode)
-                        .eq(TBExamStudent::getClazzId,clazzId));
+                        .eq(TBExamStudent::getExamId, examId)
+                        .eq(TBExamStudent::getCourseCode, effectiveCourseCode)
+                        .eq(TBExamStudent::getClazzId, clazzId));
                 List<Long> teachCollegeIdList = tbExamStudentList.stream().map(TBExamStudent::getTeachCollegeId).distinct().collect(Collectors.toList());
                 String collegeName = "";
                 for (Long collegeId : teachCollegeIdList) {
                     SysOrg tbSchoolCollege = sysOrgService.getById(collegeId);
-                    if (Objects.isNull(tbSchoolCollege)){
+                    if (Objects.isNull(tbSchoolCollege)) {
                         collegeName = collegeName + SystemConstant.DEFAULT_SIGN + ",";
                     } else {
                         collegeName = collegeName + tbSchoolCollege.getName() + ",";
                     }
                 }
-                collegeName = collegeName.substring(0,collegeName.length() - 1);
+                collegeName = collegeName.substring(0, collegeName.length() - 1);
 
                 TAExamCourseClazz taExamCourseClazz = new TAExamCourseClazz();
                 taExamCourseClazz.setId(SystemConstant.getDbUuid());
@@ -512,10 +513,10 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String AnalyzePointScoreRate(Long examId, String courseCode) throws Exception {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
 
         List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId));
+                .eq(TAExamCourseRecord::getExamId, examId));
 
         // 循环进入每次考试课程下
         for (String effectiveCourseCode : effectiveCourseCodeList) {
@@ -525,31 +526,31 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
             // 考察点数据源
             List<TBDimension> dimensionDatasource = tbDimensionService.list(new QueryWrapper<TBDimension>().lambda()
-                    .eq(TBDimension::getExamId,examId)
-                    .eq(TBDimension::getCourseCode,courseCode));
+                    .eq(TBDimension::getExamId, examId)
+                    .eq(TBDimension::getCourseCode, courseCode));
 
-            if (dimensionDatasource.size() < 1){
+            if (dimensionDatasource.size() < 1) {
                 continue;
             }
 
             // 删除原数据
             taExamCourseDioService.remove(new QueryWrapper<TAExamCourseDio>().lambda()
-                    .eq(TAExamCourseDio::getExamId,examId)
-                    .eq(TAExamCourseDio::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseDio::getExamId, examId)
+                    .eq(TAExamCourseDio::getCourseCode, effectiveCourseCode));
 
             taExamCourseRecordDioService.remove(new QueryWrapper<TAExamCourseRecordDio>().lambda()
-                    .eq(TAExamCourseRecordDio::getExamId,examId)
-                    .eq(TAExamCourseRecordDio::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseRecordDio::getExamId, examId)
+                    .eq(TAExamCourseRecordDio::getCourseCode, effectiveCourseCode));
 
             taExamCourseRecordModService.remove(new QueryWrapper<TAExamCourseRecordMod>().lambda()
-                    .eq(TAExamCourseRecordMod::getExamId,examId)
-                    .eq(TAExamCourseRecordMod::getCourseCode,courseCode));
+                    .eq(TAExamCourseRecordMod::getExamId, examId)
+                    .eq(TAExamCourseRecordMod::getCourseCode, courseCode));
 
             List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
-                    .eq(TBPaper::getExamId,examId)
-                    .eq(TBPaper::getCourseCode,courseCode));
+                    .eq(TBPaper::getExamId, examId)
+                    .eq(TBPaper::getCourseCode, courseCode));
 
-            if (tbPaperList.size() == 0){
+            if (tbPaperList.size() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("试卷基础数据查找失败");
             }
             for (TBPaper tbPaper : tbPaperList) {
@@ -557,18 +558,18 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                 Long paperId = tbPaper.getId();
                 // 试卷结构数据源
                 List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda()
-                        .eq(TBPaperStruct::getPaperId,paperId));
-                if (tbPaperStructList.size() == 0){
+                        .eq(TBPaperStruct::getPaperId, paperId));
+                if (tbPaperStructList.size() == 0) {
                     throw ExceptionResultEnum.ERROR.exception("试卷结构数据查找失败");
                 }
                 // 该试卷下所有考生作答数据
                 List<BasicAnswerDto> answerDtoList = tbAnswerService.findByPaperId(paperId);
-                if (answerDtoList.size() == 0){
+                if (answerDtoList.size() == 0) {
                     throw ExceptionResultEnum.ERROR.exception("试卷id为[" + paperId + "]的考生作答详细记录不存在");
                 }
 
                 // 5.计算每个考察点所对应的题目集合
-                Map<String, List<TBPaperStruct>> pointToPaper = this.handlePointToPaper(dimensionDatasource, tbPaperStructList, examId,courseCode);
+                Map<String, List<TBPaperStruct>> pointToPaper = this.handlePointToPaper(dimensionDatasource, tbPaperStructList, examId, courseCode);
 
                 // 计算每个模块对应的题目集合
                 Map<String, List<TBPaperStruct>> moduleToPaper = this.handleModuleToPaper(dimensionDatasource, tbPaperStructList, examId, courseCode);
@@ -589,7 +590,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                     List<BasicAnswerDto> oneStudentAnswerDetailDataSource = answerDtoList.stream()
                             .filter(e -> taExamCourseRecord.getExamRecordId().equals(e.getExamRecordId()))
                             .collect(Collectors.toList());
-                    if (oneStudentAnswerDetailDataSource.size() == 0){
+                    if (oneStudentAnswerDetailDataSource.size() == 0) {
                         continue; // 当AB卷时,examPaperTikDataSource还是整体数据,所以会匹配不到,匹配不到的说明不是本套试卷,因此匹配不到的不能处理。
                     }
                     // 考察点得分率
@@ -641,7 +642,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                         taExamCourseRecordDio.setDimensionCode(dimensionCode);
                         taExamCourseRecordDio.setStudentScore(BigDecimal.valueOf(studentScore));
                         taExamCourseRecordDio.setScoreRate(BigDecimal.valueOf(rate));
-                        taExamCourseRecordDio.setProficiency(this.handleModuleProficiency(examId,effectiveCourseCode, dimensionType, rate));
+                        taExamCourseRecordDio.setProficiency(this.handleModuleProficiency(examId, effectiveCourseCode, dimensionType, rate));
                         taExamCourseRecordDio.setInspectCollegeId(inspectCollegeId);
                         taExamCourseRecordDio.setInspectCollegeName(inspectCollegeName);
                         taExamCourseRecordDioList.add(taExamCourseRecordDio);
@@ -686,7 +687,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                         taExamCourseRecordMod.setTotalScore(BigDecimal.valueOf(studentScore));
                         taExamCourseRecordMod.setScoreRate(BigDecimal.valueOf(rate));
                         taExamCourseRecordMod.setFullScore(BigDecimal.valueOf(totalScore));
-                        taExamCourseRecordMod.setProficiency(this.handleModuleProficiency(examId,effectiveCourseCode,s,rate));
+                        taExamCourseRecordMod.setProficiency(this.handleModuleProficiency(examId, effectiveCourseCode, s, rate));
                         taExamCourseRecordMod.setInspectCollegeId(inspectCollegeId);
                         taExamCourseRecordMod.setInspectCollegeName(inspectCollegeName);
                         taExamCourseRecordMod.setStudentId(taExamCourseRecord.getStudentId());
@@ -739,11 +740,11 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
             }
 
             List<TAExamCourseRecordMod> examCourseRecordModList = taExamCourseRecordModService.list(new QueryWrapper<TAExamCourseRecordMod>().lambda()
-                    .eq(TAExamCourseRecordMod::getExamId,examId)
-                    .eq(TAExamCourseRecordMod::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseRecordMod::getExamId, examId)
+                    .eq(TAExamCourseRecordMod::getCourseCode, effectiveCourseCode));
 
             // 计算该考生在该模块得分率在该学院排名
-            List<TBModuleConfig> tbModuleConfigList = tbModuleConfigService.findDistinctModuleInfoByExamIdAndCourseCode(examId,effectiveCourseCode);
+            List<TBModuleConfig> tbModuleConfigList = tbModuleConfigService.findDistinctModuleInfoByExamIdAndCourseCode(examId, effectiveCourseCode);
             for (TAExamCourseRecordMod taExamCourseRecordMod : examCourseRecordModList) {
                 String moduleType = taExamCourseRecordMod.getModuleType();
                 Long myCollegeId = taExamCourseRecordMod.getInspectCollegeId();
@@ -754,7 +755,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
 
                 BigDecimal myScoreRate = taExamCourseRecordMod.getScoreRate();
-                double myNumber = sameColModuleList.stream().filter(e -> e.getScoreRate().compareTo(myScoreRate) > 0 ).count() + 1; //我在学院的排名
+                double myNumber = sameColModuleList.stream().filter(e -> e.getScoreRate().compareTo(myScoreRate) > 0).count() + 1; //我在学院的排名
                 taExamCourseRecordMod.setColRank((int) myNumber);
 
 
@@ -762,7 +763,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                 double lowCount = sameColModuleList.stream().filter(e -> e.getScoreRate().compareTo(myScoreRate) < 0).count(); // 在学院该模块得分低于我的人数
                 double sameCount = sameColModuleList.stream().filter(e -> e.getScoreRate().compareTo(myScoreRate) == 0).count(); // 在学院该模块得分等于我的人数
                 double totalCount = sameColModuleList.size(); // 该学院总人数
-                int percentGrade = this.handlePercentGrade(BigDecimal.valueOf(lowCount),BigDecimal.valueOf(sameCount), BigDecimal.valueOf(totalCount)); // 该学生该模块成绩在该学院的百分等级
+                int percentGrade = this.handlePercentGrade(BigDecimal.valueOf(lowCount), BigDecimal.valueOf(sameCount), BigDecimal.valueOf(totalCount)); // 该学生该模块成绩在该学院的百分等级
                 taExamCourseRecordMod.setPercentGrade(percentGrade);
 
                 // 计算模块等级
@@ -781,7 +782,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                         if (!formula.equals(LevelRuleEnum.COLLEGE_RANK.getValue())) {  // 当计算规则不为学院排名时,为了方便计算,将minNumber设置为1 使其无效
                             size = -1;
                         }
-                        taExamCourseRecordMod.setLevel(this.handleModuleRankLevel(examId,courseCode,moduleType, value, size));
+                        taExamCourseRecordMod.setLevel(this.handleModuleRankLevel(examId, courseCode, moduleType, value, size));
                     }
                 }
             }
@@ -795,14 +796,14 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzeExamCourseCollegeInspectDio(Long examId, String courseCode) {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除原有数据
             taExamCourseCollegeInspectDioService.remove(new QueryWrapper<TAExamCourseCollegeInspectDio>().lambda()
-                    .eq(TAExamCourseCollegeInspectDio::getExamId,examId)
-                    .eq(TAExamCourseCollegeInspectDio::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseCollegeInspectDio::getExamId, examId)
+                    .eq(TAExamCourseCollegeInspectDio::getCourseCode, effectiveCourseCode));
 
-            taExamCourseCollegeInspectDioService.insertByTAExamCourseRecordDio(examId,courseCode);
+            taExamCourseCollegeInspectDioService.insertByTAExamCourseRecordDio(examId, courseCode);
         }
         return "'t_a_exam_course_college_inspect_dio'表构建完成 ";
     }
@@ -811,26 +812,26 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzePaperStruct(Long examId, String courseCode) {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
-                    .eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,effectiveCourseCode));
-            if (tbPaperList.size() == 0){
+                    .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, effectiveCourseCode));
+            if (tbPaperList.size() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("基础试卷信息异常");
             }
             // 删除原有数据
             taPaperStructService.remove(new QueryWrapper<TAPaperStruct>().lambda()
-                    .eq(TAPaperStruct::getExamId,examId)
-                    .eq(TAPaperStruct::getCourseCode,effectiveCourseCode));
+                    .eq(TAPaperStruct::getExamId, examId)
+                    .eq(TAPaperStruct::getCourseCode, effectiveCourseCode));
             List<TAPaperStruct> taPaperStructList = new ArrayList<>();
             // 该课程有效试卷结构数据
-            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId,courseCode);
+            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, courseCode);
             for (TBPaper tbPaper : tbPaperList) {
                 Long paperId = tbPaper.getId();
                 String paperType = tbPaper.getPaperType();
                 List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda()
-                        .eq(TBPaperStruct::getPaperId,paperId));
-                if (tbPaperStructList.size() == 0){
+                        .eq(TBPaperStruct::getPaperId, paperId));
+                if (tbPaperStructList.size() == 0) {
                     throw ExceptionResultEnum.ERROR.exception("试卷结构数据异常");
                 }
                 for (TBPaperStruct paperStruct : tbPaperStructList) {
@@ -848,9 +849,9 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                             .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
                     BigDecimal fullScore = paperStruct.getFullScore();
                     double scoreAvg = descriptiveStatistics.getAverage();
-                    BigDecimal scoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore,4,BigDecimal.ROUND_HALF_DOWN);
-                    scoreRate = scoreRate.setScale(1,BigDecimal.ROUND_HALF_DOWN);
-                    String difficult = this.analyzeDifficult(examId,courseCode, scoreRate.doubleValue());
+                    BigDecimal scoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_DOWN);
+                    scoreRate = scoreRate.setScale(1, BigDecimal.ROUND_HALF_DOWN);
+                    String difficult = this.analyzeDifficult(examId, courseCode, scoreRate.doubleValue());
 
                     double validity = this.calculateValidity(oneQuestionAnswerDetailList, fullScore.doubleValue());
 
@@ -890,22 +891,22 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildExamPaperDifficult(Long examId, String courseCode) {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
 
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             taExamCourseDifficultService.remove(new QueryWrapper<TAExamCourseDifficult>().lambda()
-                    .eq(TAExamCourseDifficult::getExamId,examId)
-                    .eq(TAExamCourseDifficult::getCourseCode,courseCode));
+                    .eq(TAExamCourseDifficult::getExamId, examId)
+                    .eq(TAExamCourseDifficult::getCourseCode, courseCode));
 
             List<TAExamCourseDifficult> taExamCourseDifficultList = new ArrayList<>();
 
             List<TBCommonLevelConfig> configLevelDatasource = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
-                    .eq(TBCommonLevelConfig::getExamId,examId).eq(TBCommonLevelConfig::getCourseCode,effectiveCourseCode));// 该科目试题难度情况数据源
+                    .eq(TBCommonLevelConfig::getExamId, examId).eq(TBCommonLevelConfig::getCourseCode, effectiveCourseCode));// 该科目试题难度情况数据源
 
             List<TAPaperStruct> questionDatasource = taPaperStructService.list(new QueryWrapper<TAPaperStruct>().lambda()
-                    .eq(TAPaperStruct::getExamId,examId).eq(TAPaperStruct::getCourseCode,effectiveCourseCode));// 该科目试题情况数据源
+                    .eq(TAPaperStruct::getExamId, examId).eq(TAPaperStruct::getCourseCode, effectiveCourseCode));// 该科目试题情况数据源
 
-            LinkedList<AnswerDetailBean> answerDetailDatasource = tbAnswerService.findValidAnswerDetailWithPap(examId,courseCode);
+            LinkedList<AnswerDetailBean> answerDetailDatasource = tbAnswerService.findValidAnswerDetailWithPap(examId, courseCode);
             Set<Long> paperTypeList = questionDatasource.stream().map(TAPaperStruct::getPaperId).collect(Collectors.toSet());
 
             for (Long paperId : paperTypeList) {
@@ -927,11 +928,11 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
                     // 学院id集合
                     List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                            .eq(TAExamCourseRecord::getExamId,examId)
-                            .eq(TAExamCourseRecord::getCourseCode,courseCode)
-                            .eq(TAExamCourseRecord::getPaperId,paperId)
-                            .eq(TAExamCourseRecord::getAbsent,false)
-                            .eq(TAExamCourseRecord::getStudentCurrent,true))
+                            .eq(TAExamCourseRecord::getExamId, examId)
+                            .eq(TAExamCourseRecord::getCourseCode, courseCode)
+                            .eq(TAExamCourseRecord::getPaperId, paperId)
+                            .eq(TAExamCourseRecord::getAbsent, false)
+                            .eq(TAExamCourseRecord::getStudentCurrent, true))
                             .stream()
                             .map(TAExamCourseRecord::getInspectCollegeId).distinct()
                             .collect(Collectors.toList());
@@ -976,11 +977,11 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     public String buildAnalyzeExamTotal(Long examId) {
         // 删除原数据
         taExamTotalService.remove(new QueryWrapper<TAExamTotal>().lambda()
-                .eq(TAExamTotal::getExamId,examId));
+                .eq(TAExamTotal::getExamId, examId));
 
         // 数据源
         List<TAExamCourseRecord> taExamCourseRecordList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                .eq(TAExamCourseRecord::getExamId,examId));
+                .eq(TAExamCourseRecord::getExamId, examId));
 
         //考察学院
         // TODO: 2021/6/8 是否计算只有缺考的学院 是否计算只有往届的学院
@@ -989,13 +990,13 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
         // 考察学院数量
         int collegeCount = inspectCollegeInfo.size();
         String inspectCollegeNames = "";
-        if (collegeCount > 0){
+        if (collegeCount > 0) {
             for (Long inspectCollegeId : inspectCollegeInfo) {
                 SysOrg college = sysOrgService.getById(inspectCollegeId);
                 inspectCollegeNames = inspectCollegeNames + college.getName() + "、";
             }
             // 考察学院名称
-            inspectCollegeNames = inspectCollegeNames.substring(0,inspectCollegeNames.length() - 1);
+            inspectCollegeNames = inspectCollegeNames.substring(0, inspectCollegeNames.length() - 1);
         }
 
         // 课程
@@ -1049,18 +1050,18 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzeExamCourseCollegeTeacher(Long examId, String courseCode) {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             // 删除该课程原有分析
             taExamCourseCollegeTeacherService.remove(new QueryWrapper<TAExamCourseCollegeTeacher>().lambda()
-                    .eq(TAExamCourseCollegeTeacher::getExamId,examId)
-                    .eq(TAExamCourseCollegeTeacher::getCourseCode,courseCode));
+                    .eq(TAExamCourseCollegeTeacher::getExamId, examId)
+                    .eq(TAExamCourseCollegeTeacher::getCourseCode, courseCode));
 
             List<TAExamCourseCollegeTeacher> taExamCourseCollegeTeacherList = new ArrayList<>();
             // 整体该课程下数据源
             List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                    .eq(TAExamCourseRecord::getExamId,examId)
-                    .eq(TAExamCourseRecord::getCourseCode,courseCode));
+                    .eq(TAExamCourseRecord::getExamId, examId)
+                    .eq(TAExamCourseRecord::getCourseCode, courseCode));
 
             // 考察学院
             Set<Long> inspectCollegeIdSet = dataSource.stream().map(TAExamCourseRecord::getInspectCollegeId).collect(Collectors.toSet());
@@ -1087,7 +1088,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                     int totalCount = teacherRecordList.size();
                     List<TAExamCourseRecord> teacherEffectiveList = teacherRecordList.stream().filter(e -> !e.getAbsent()).collect(Collectors.toList());
                     int realityCount = teacherEffectiveList.size();
-                    if (realityCount == 0){
+                    if (realityCount == 0) {
                         continue;
                     }
                     int absentCount = totalCount - realityCount;
@@ -1126,12 +1127,12 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
                     // 开课学院数据
                     List<Long> teachCollegeIdList = teacherEffectiveList.stream().map(TAExamCourseRecord::getTeachCollegeId).distinct().collect(Collectors.toList());
-                    if (teachCollegeIdList.size() > 1){
+                    if (teachCollegeIdList.size() > 1) {
                         throw ExceptionResultEnum.ERROR.exception("有多个开课学院");
                     }
                     Long teachCollegeId = teachCollegeIdList.get(0);
                     String teachCollegeName = SystemConstant.DEFAULT_SIGN;
-                    if (teachCollegeId > 0){
+                    if (teachCollegeId > 0) {
                         teachCollegeName = sysOrgService.getById(teachCollegeId).getName();
                     }
 
@@ -1181,15 +1182,15 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     @Override
     public String buildAnalyzeExamCourseTeacher(Long examId, String courseCode) {
         // 可分析有效课程信息
-        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId,courseCode);
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             taExamCourseTeacherService.remove(new QueryWrapper<TAExamCourseTeacher>().lambda()
-                    .eq(TAExamCourseTeacher::getExamId,examId)
-                    .eq(TAExamCourseTeacher::getCourseCode,courseCode));
+                    .eq(TAExamCourseTeacher::getExamId, examId)
+                    .eq(TAExamCourseTeacher::getCourseCode, courseCode));
 
             List<TAExamCourseTeacher> taExamCourseTeacherList = new ArrayList<>();
             List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
-                    .eq(TAExamCourseRecord::getExamId,examId).eq(TAExamCourseRecord::getCourseCode,effectiveCourseCode));
+                    .eq(TAExamCourseRecord::getExamId, examId).eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode));
             List<TAExamCourseRecord> currentSource = dataSource.stream().filter(TAExamCourseRecord::getStudentCurrent).collect(Collectors.toList());
 
             Set<Long> teacherIdList = currentSource.stream().map(TAExamCourseRecord::getTeacherId).collect(Collectors.toSet());
@@ -1198,7 +1199,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
                         .filter(e -> teacherId.equals(e.getTeacherId())).collect(Collectors.toList());
                 int totalCount = teacherRecordList.size();
                 List<TAExamCourseRecord> effectiveList = teacherRecordList.stream().filter(e -> !e.getAbsent()).collect(Collectors.toList());
-                if (effectiveList.size() == 0){
+                if (effectiveList.size() == 0) {
                     continue;
                 }
                 int realityCount = effectiveList.size();
@@ -1262,6 +1263,23 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
         return " 't_a_exam_course_teacher'表构建完毕 ";
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String finishCalculate(Long examId, String courseCode) {
+        // 可分析有效课程信息
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
+        List<TBExamCourse> tbExamCourseList = new ArrayList<>();
+        for (String effectiveCourseCode : effectiveCourseCodeList) {
+            TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
+                    .eq(TBExamCourse::getExamId, examId)
+                    .eq(TBExamCourse::getCourseCode, effectiveCourseCode));
+            tbExamCourse.setPublishStatus(PublishStatusEnum.UN_PUBLISH);
+            tbExamCourseList.add(tbExamCourse);
+        }
+        tbExamCourseService.updateBatchById(tbExamCourseList);
+        return " 't_b_exam_course' 表状态更新完成";
+    }
+
     /**
      * 计算百分位等级
      *
@@ -1273,8 +1291,8 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     private int handlePercentGrade(BigDecimal lowCount, BigDecimal sameCount, BigDecimal totalCount) {
         // ((lowCount + sameCount * 0.5) / totalCount) * 100
         BigDecimal percentGrade = (lowCount.add(sameCount.multiply(new BigDecimal("0.5"))))
-                .divide(totalCount,4,BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal("100"));
-        int result = percentGrade.setScale(0,BigDecimal.ROUND_HALF_DOWN).intValue();
+                .divide(totalCount, 4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal("100"));
+        int result = percentGrade.setScale(0, BigDecimal.ROUND_HALF_DOWN).intValue();
         if (result == 100) {
             result = 99;
         }
@@ -1291,11 +1309,11 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
      * @param value 值
      * @return 档位
      */
-    private String handleLevel(Long examId,String courseCode, String type, double value) {
+    private String handleLevel(Long examId, String courseCode, String type, double value) {
         List<TBCommonLevelConfig> levelList = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
-                .eq(TBCommonLevelConfig::getExamId,examId)
-                .eq(TBCommonLevelConfig::getCourseCode,courseCode)
-                .eq(TBCommonLevelConfig::getLevelType,type));
+                .eq(TBCommonLevelConfig::getExamId, examId)
+                .eq(TBCommonLevelConfig::getCourseCode, courseCode)
+                .eq(TBCommonLevelConfig::getLevelType, type));
         String level = "";
         if ("百分等级".equals(type) || "难度等级".equals(type)) {
             for (TBCommonLevelConfig levelTemp : levelList) {
@@ -1329,7 +1347,8 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
     /**
      * 构建和学院比较的有关信息(超过学院百分比、排名、排名等级)
-     * @param taExamCourseRecord 该学生数据
+     *
+     * @param taExamCourseRecord     该学生数据
      * @param taExamCourseRecordList 该课程下学生数据
      */
     private void buildColData(TAExamCourseRecord taExamCourseRecord, List<TAExamCourseRecord> taExamCourseRecordList) {
@@ -1342,7 +1361,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
         double lowCount = examRecordSameCol.stream().filter(e -> e.getAssignedScore().compareTo(taExamCourseRecord.getAssignedScore()) < 0).count();
         BigDecimal overCollegeRate;
         if (examRecordSameCol.size() > 1) {
-            overCollegeRate = BigDecimal.valueOf(lowCount).divide(BigDecimal.valueOf(examRecordSameCol.size() - 1),4,BigDecimal.ROUND_HALF_DOWN);
+            overCollegeRate = BigDecimal.valueOf(lowCount).divide(BigDecimal.valueOf(examRecordSameCol.size() - 1), 4, BigDecimal.ROUND_HALF_DOWN);
         } else {
             overCollegeRate = BigDecimal.ONE;
         }
@@ -1356,9 +1375,8 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
         //计算在学院排名的档次
         double size = examRecordSameCol.size();
         List<TBCommonRankLevelConfig> tbCommonRankLevelConfigList = tbCommonRankLevelConfigService.list(new QueryWrapper<TBCommonRankLevelConfig>().lambda()
-                .eq(TBCommonRankLevelConfig::getExamId,taExamCourseRecord.getExamId())
-                .eq(TBCommonRankLevelConfig::getCourseCode,taExamCourseRecord.getCourseCode()));
-
+                .eq(TBCommonRankLevelConfig::getExamId, taExamCourseRecord.getExamId())
+                .eq(TBCommonRankLevelConfig::getCourseCode, taExamCourseRecord.getCourseCode()));
 
 
         if (tbCommonRankLevelConfigList.size() < 1) {
@@ -1402,8 +1420,8 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
      *
      * @param dimensionDatasource 知识点数据源
      * @param tbPaperStructList   试卷结构数据源
-     * @param examId  考试id
-     * @param courseCode  课程编号
+     * @param examId              考试id
+     * @param courseCode          课程编号
      * @return 键值对 (类型-考察点 -> 考察此考察点的题目信息集合) 例如 :”知识模块-A“,List<>
      */
     private Map<String, List<TBPaperStruct>> handlePointToPaper(List<TBDimension> dimensionDatasource, List<TBPaperStruct> tbPaperStructList, Long examId, String courseCode) throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
@@ -1411,7 +1429,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
         // 模块配置信息
         List<TBModuleConfig> tbModuleConfigList = tbModuleConfigService.findDistinctModuleInfoByExamIdAndCourseCode(examId, courseCode);
-        if (tbModuleConfigList.size() < 1){
+        if (tbModuleConfigList.size() < 1) {
             throw ExceptionResultEnum.ERROR.exception("基础模块信息异常");
         }
 
@@ -1468,8 +1486,8 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
      *
      * @param dimensionDatasource 知识点数据源
      * @param tbPaperStructList   试卷结构数据源
-     * @param examId  考试id
-     * @param courseCode  课程编号
+     * @param examId              考试id
+     * @param courseCode          课程编号
      * @return 键值对 (考察模块 -> 考察此考模块的题目信息集合) 例如 :”知识模块“,List<>
      * @throws Exception 反射异常
      */
@@ -1478,7 +1496,7 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
 
         // 模块配置信息
         List<TBModuleConfig> tbModuleConfigList = tbModuleConfigService.findDistinctModuleInfoByExamIdAndCourseCode(examId, courseCode);
-        if (tbModuleConfigList.size() < 1){
+        if (tbModuleConfigList.size() < 1) {
             throw ExceptionResultEnum.ERROR.exception("基础模块信息异常");
         }
 
@@ -1525,17 +1543,17 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     /**
      * 根据考察点得分率计算该考察点的熟练度
      *
-     * @param examId  考试id
-     * @param courseCode  课程编号
+     * @param examId        考试id
+     * @param courseCode    课程编号
      * @param dimensionType 考察点类型
-     * @param value   得分率
+     * @param value         得分率
      * @return 熟练度等级
      */
     private String handleModuleProficiency(Long examId, String courseCode, String dimensionType, double value) {
         List<TBModuleProficiency> tbModuleProficiencyList = tbModuleProficiencyService.list(new QueryWrapper<TBModuleProficiency>().lambda()
-                .eq(TBModuleProficiency::getExamId,examId)
-                .eq(TBModuleProficiency::getCourseCode,courseCode)
-                .eq(TBModuleProficiency::getModuleType,dimensionType));
+                .eq(TBModuleProficiency::getExamId, examId)
+                .eq(TBModuleProficiency::getCourseCode, courseCode)
+                .eq(TBModuleProficiency::getModuleType, dimensionType));
 
         if (tbModuleProficiencyList.size() < 1) {
             throw ExceptionResultEnum.ERROR.exception("模块二级维度熟练度配置信息不存在");
@@ -1570,18 +1588,18 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     /**
      * 处理学生在该模块成绩在该学院的排名等级
      *
-     * @param examId  考试id
-     * @param courseCode  考试编号
-     * @param module 模块类型
-     * @param value  值(排名、得分率、百分等级)
-     * @param size   该学院最低分排名(当其不为排名时,赋值-1)
+     * @param examId     考试id
+     * @param courseCode 考试编号
+     * @param module     模块类型
+     * @param value      值(排名、得分率、百分等级)
+     * @param size       该学院最低分排名(当其不为排名时,赋值-1)
      * @return 排名等级编号
      */
     private String handleModuleRankLevel(Long examId, String courseCode, String module, double value, double size) {
         List<TBModuleConfig> tbModuleConfigList = tbModuleConfigService.list(new QueryWrapper<TBModuleConfig>().lambda()
-                .eq(TBModuleConfig::getExamId,examId)
-                .eq(TBModuleConfig::getCourseCode,courseCode)
-                .eq(TBModuleConfig::getModuleType,module));
+                .eq(TBModuleConfig::getExamId, examId)
+                .eq(TBModuleConfig::getCourseCode, courseCode)
+                .eq(TBModuleConfig::getModuleType, module));
 
         String result = null;
         if (size < tbModuleConfigList.size() && size > 0) {
@@ -1623,16 +1641,16 @@ public class AnalyzeForStudentServiceImpl implements AnalyzeForStudentService {
     /**
      * 根据得分率计算每道题目的难度
      *
-     * @param examId  考试id
+     * @param examId     考试id
      * @param courseCode 课程编号
-     * @param scoreRate 题目得分率
+     * @param scoreRate  题目得分率
      * @return 难度
      */
     private String analyzeDifficult(Long examId, String courseCode, double scoreRate) {
         List<TBCommonLevelConfig> levelConfigList = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
-                .eq(TBCommonLevelConfig::getExamId,examId)
-                .eq(TBCommonLevelConfig::getCourseCode,courseCode)
-                .eq(TBCommonLevelConfig::getLevelType,"难度等级"));
+                .eq(TBCommonLevelConfig::getExamId, examId)
+                .eq(TBCommonLevelConfig::getCourseCode, courseCode)
+                .eq(TBCommonLevelConfig::getLevelType, "难度等级"));
         String difficult = "";
         for (TBCommonLevelConfig levelConfig : levelConfigList) {
             Map<String, Object> scopeMap = AnalyzeScopeUtil.analyzeScope(levelConfig.getScope());

+ 23 - 17
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamStudentServiceImpl.java

@@ -29,10 +29,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -232,6 +229,9 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
      */
     @Override
     public IPage<TBStudentReportResult> reportList(IPage<Map> iPage, Long schoolId, Long examId, Long collegeId, String courseCode, Long clazzId, Boolean absent) {
+        if(schoolId == null){
+            schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        }
         return tbExamStudentMapper.reportList(iPage, schoolId, examId, collegeId, courseCode, clazzId, absent);
     }
 
@@ -244,6 +244,9 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
      */
     @Override
     public ReportResult reportResult(Long schoolId, String studentCode) {
+        if(schoolId == null){
+            schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        }
         ReportResult reportResult = new ReportResult();
         // 考生信息
         StudentInfo studentInfo = tbStudentMapper.getStudentBySchoolIdAndStudentCode(schoolId, studentCode);
@@ -260,7 +263,10 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
     }
 
     @Override
-    public PersonalReportResult reportMark(String schoolId, String studentCode, String examId, String courseCode) {
+    public PersonalReportResult reportMark(Long schoolId, String studentCode, String examId, String courseCode) {
+        if(schoolId == null){
+            schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        }
         PersonalReportResult personalReportResult = new PersonalReportResult();
         // 考生信息
         ExamStudentResult examStudentResult = buildExamStudentResult(schoolId, examId, studentCode, courseCode);
@@ -272,7 +278,7 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
         return personalReportResult;
     }
 
-    private CollegeResult buildCollegeResult(String schoolId, String examId, String studentCode, String courseCode) {
+    private CollegeResult buildCollegeResult(Long schoolId, String examId, String studentCode, String courseCode) {
         CollegeResult collegeResult = new CollegeResult();
         // 综合信息
         SynthesisResult synthesisResult = taExamCourseRecordMapper.getSynthesisResult(schoolId, examId, studentCode, courseCode);
@@ -289,7 +295,7 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
         queryWrapper.lambda().eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode);
         List<TBPaper> papers = tbPaperMapper.selectList(queryWrapper);
 
-        if (examCourseRecords.size() != 1 || papers.size() != 1) {
+        if (examCourseRecords.size() != 1) {
             throw ExceptionResultEnum.ERROR.exception("获取数据异常,应该有且仅有一条数据");
         }
 
@@ -333,12 +339,12 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
             QueryWrapper<TBModuleProficiency> moduleProficiencyQueryWrapper = new QueryWrapper<>();
             moduleProficiencyQueryWrapper.lambda().eq(TBModuleProficiency::getExamId, examId).eq(TBModuleProficiency::getCourseCode, courseCode).eq(TBModuleProficiency::getModuleType, moduleName);
             List<TBModuleProficiency> moduleProficiencies = tbModuleProficiencyMapper.selectList(moduleProficiencyQueryWrapper);
-            List<TBModuleProficiency> moduleProficiencieTemps = moduleProficiencies.stream().flatMap(e -> {
-                TBModuleProficiency tbModuleProficiency = new TBModuleProficiency();
-                tbModuleProficiency.setExamId(e.getExamId());
-                tbModuleProficiency.setCourseCode(e.getCourseCode());
-                tbModuleProficiency.setModuleType(e.getModuleType());
-                tbModuleProficiency.setInterpret(e.getInterpret());
+            List<Map<String, String>> moduleProficiencieTemps = moduleProficiencies.stream().flatMap(e -> {
+                Map<String, String> tbModuleProficiency = new HashMap();
+                tbModuleProficiency.put("examId",e.getExamId().toString());
+                tbModuleProficiency.put("courseCode",e.getCourseCode());
+                tbModuleProficiency.put("moduleType", e.getModuleType());
+                tbModuleProficiency.put("interpret", e.getInterpret());
                 return Stream.of(tbModuleProficiency);
             }).distinct().collect(Collectors.toList());
 
@@ -346,11 +352,11 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
                 throw ExceptionResultEnum.ERROR.exception("获取数据异常,应该有且仅有一条数据");
             }
             ModuleResult moduleResult = new ModuleResult();
-            TBModuleProficiency tbModuleProficiency = moduleProficiencieTemps.get(0);
-            String info = tbModuleProficiency.getModuleType().concat(":").concat(tbModuleProficiency.getInterpret());
+            Map<String, String> tbModuleProficiency = moduleProficiencieTemps.get(0);
+            String info = tbModuleProficiency.get("moduleType").concat(":").concat(tbModuleProficiency.get("interpret"));
             moduleResult.setInfo(info);
 
-            List<ModuleDetailResult> dios = taExamCourseRecordDioMapper.listDiosBySchoolIdAndExamIdAndCourseCodeAndModuleName(schoolId, examId, courseCode, moduleName);
+            List<ModuleDetailResult> dios = taExamCourseRecordDioMapper.listDiosBySchoolIdAndExamIdAndCourseCodeAndModuleName(schoolId, examId, courseCode, moduleName, studentCode);
             moduleResult.setDios(dios);
             diagnosisDetailResult.setModules(moduleResult);
 
@@ -384,7 +390,7 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
         return collegeResult;
     }
 
-    private ExamStudentResult buildExamStudentResult(String schoolId, String examId, String studentCode, String courseCode) {
+    private ExamStudentResult buildExamStudentResult(Long schoolId, String examId, String studentCode, String courseCode) {
         ExamStudentResult examStudentResult = taExamCourseRecordMapper.getStudent(schoolId, examId, studentCode, courseCode);
         if (examStudentResult != null) {
             QueryWrapper<TBCommonRankLevelConfig> queryWrapper = new QueryWrapper<>();

+ 1 - 0
teachcloud-report-business/src/main/resources/mapper/TAExamCourseRecordDioMapper.xml

@@ -40,6 +40,7 @@
             and a.exam_id = #{examId}
             and a.course_code = #{courseCode}
             and a.dimension_type = #{moduleName}
+            and a.student_code = #{studentCode}
         </where>
     </select>
     <select id="listSubDiosBySchoolIdAndExamIdAndStudentCodeAndCourseCodeAndModuleName"

+ 1 - 1
teachcloud-report-business/src/main/resources/mapper/TAExamCourseRecordMapper.xml

@@ -7,7 +7,7 @@
         SELECT
         a.assigned_score assignedScore,
         a.student_code studentCode,
-        a.current
+        a.student_current `current`
         FROM
         t_a_exam_course_record a
         LEFT JOIN

+ 19 - 19
teachcloud-report-business/src/main/resources/mapper/TBExamStudentMapper.xml

@@ -80,16 +80,16 @@
         a.ticket_number ticketNumber,
         a.student_code studentCode,
         a.name,
-        case a.current when true then '应届' else '非应届' end as current,
+        case a.student_current when true then '应届' else '非应届' end as current,
         b.objective_score objectiveScore,
         b.subjective_score subjectiveScore,
         b.total_score totalScore,
         c.assigned_score assignedScore,
         e.clazz_code clazzCode,
         e.clazz_name clazzName,
-        f.college_name teachCollegeName,
-        g.college_name inspectCollegeName,
-        h.teacher_name teacherName
+        f.name teachCollegeName,
+        g.name inspectCollegeName,
+        h.real_name teacherName
         FROM
         t_b_exam_student a
         LEFT JOIN
@@ -101,11 +101,11 @@
         LEFT JOIN
         t_b_school_clazz e ON a.clazz_id = e.id
         LEFT JOIN
-        t_b_school_college f ON a.teach_college_id = f.id
+        sys_org f ON a.teach_college_id = f.id
         LEFT JOIN
-        t_b_school_college g ON a.inspect_college_id = g.id
+        sys_org g ON a.inspect_college_id = g.id
         LEFT JOIN
-        t_b_school_teacher h ON a.teacher_id = h.id
+        sys_user h ON a.teacher_id = h.id
         <where>
             and d.school_id = #{schoolId}
             <if test="semester != null and semester != ''">
@@ -118,7 +118,7 @@
                 and a.course_code = = #{courseCode}
             </if>
             <if test="current != null">
-                and a.current = = #{current}
+                and a.student_current = = #{current}
             </if>
             <if test="inspectCollegeId != null">
                 and a.inspect_college_id = = #{inspectCollegeId}
@@ -143,13 +143,13 @@
         a.ticket_number ticketNumber,
         a.student_code studentCode,
         a.name,
-        case a.current when true then '应届' else '非应届' end as current,
+        case a.student_current when true then '应届' else '非应届' end as current,
         c.assigned_score assignedScore,
         e.clazz_code clazzCode,
         e.clazz_name clazzName,
-        f.college_name teachCollegeName,
-        g.college_name inspectCollegeName,
-        h.teacher_name teacherName
+        f.name teachCollegeName,
+        g.name inspectCollegeName,
+        h.real_name teacherName
         FROM
         t_b_exam_student a
         LEFT JOIN
@@ -161,11 +161,11 @@
         LEFT JOIN
         t_b_school_clazz e ON a.clazz_id = e.id
         LEFT JOIN
-        t_b_school_college f ON a.teach_college_id = f.id
+        sys_org f ON a.teach_college_id = f.id
         LEFT JOIN
-        t_b_school_college g ON a.inspect_college_id = g.id
+        sys_org g ON a.inspect_college_id = g.id
         LEFT JOIN
-        t_b_school_teacher h ON a.teacher_id = h.id
+        sys_user h ON a.teacher_id = h.id
         <where>
             and d.school_id = #{schoolId}
             <if test="semester != null and semester != ''">
@@ -178,7 +178,7 @@
                 and a.course_code = = #{courseCode}
             </if>
             <if test="current != null">
-                and a.current = = #{current}
+                and a.student_current = = #{current}
             </if>
             <if test="inspectCollegeId != null">
                 and a.teach_college_id = = #{teachCollegeId}
@@ -196,7 +196,7 @@
 
     <select id="reportList" resultType="com.qmth.teachcloud.report.business.bean.result.TBStudentReportResult">
         SELECT
-            c.name inspectCollegeName,
+            c.name collegeName,
             b.exam_code examCode,
             a.course_code courseCode,
             a.student_code studentCode,
@@ -245,7 +245,7 @@
                 LEFT JOIN
             t_b_exam b ON a.exam_id = b.id
         <where>
-            and a.school_id = #{schoolId}
+            and b.school_id = #{schoolId}
             and a.student_code = #{studentCode}
         </where>
         order by b.exam_time desc
@@ -266,7 +266,7 @@
                 LEFT JOIN
             t_b_exam c ON a.exam_id = c.id
         <where>
-            and a.school_id = #{schoolId}
+            and b.school_id = #{schoolId}
             and a.exam_id = #{examId}
             and a.student_code = #{studentCode}
         </where>

+ 94 - 91
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -102,7 +102,7 @@ public class BasicDatasourceController {
         if (Objects.isNull(file)) {
             throw ExceptionResultEnum.ERROR.exception("找不到附件");
         }
-        if (examId == 0){
+        if (examId == 0) {
             throw ExceptionResultEnum.ERROR.exception("考试id为空");
         }
 
@@ -114,7 +114,7 @@ public class BasicDatasourceController {
         });
 
         //保存到数据库
-        Map<String,Long> paperMap = new HashMap<>();
+        Map<String, Long> paperMap = new HashMap<>();
         List<TBPaper> tbPaperList = new ArrayList<>();
         List<TBPaperStruct> tbPaperStructList = new ArrayList<>();
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -128,26 +128,26 @@ public class BasicDatasourceController {
 
                         String courseCode = paperConfigDto.getCourseCode();
                         String courseName = paperConfigDto.getCourseName();
-                        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                             continue;
                         }
                         BigDecimal coefficient = BigDecimal.ZERO;
-                        if (Objects.nonNull(paperConfigDto.getCoefficient()) && paperConfigDto.getCoefficient() instanceof Double){
+                        if (Objects.nonNull(paperConfigDto.getCoefficient()) && paperConfigDto.getCoefficient() instanceof Double) {
                             coefficient = BigDecimal.valueOf((Double) paperConfigDto.getCoefficient());
                         }
                         String paperType = paperConfigDto.getPaperType();
                         List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
-                                .eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode).eq(TBPaper::getPaperType,paperType));
+                                .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode).eq(TBPaper::getPaperType, paperType));
                         Long id;
-                        if (oldList.size() == 1){
+                        if (oldList.size() == 1) {
                             id = oldList.get(0).getId();
-                        }else if (oldList.size() < 1){
+                        } else if (oldList.size() < 1) {
                             id = SystemConstant.getDbUuid();
-                        }else {
+                        } else {
                             throw ExceptionResultEnum.ERROR.exception("表数据异常[t_b_paper]");
                         }
 
-                        paperMap.put(paperType,id);
+                        paperMap.put(paperType, id);
                         TBPaper tbPaper = new TBPaper();
                         tbPaper.setId(id);
                         tbPaper.setExamId(examId);
@@ -165,7 +165,7 @@ public class BasicDatasourceController {
 
                         String courseCode = paperStructDto.getCourseCode();
                         String courseName = paperStructDto.getCourseName();
-                        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                             continue;
                         }
 
@@ -174,7 +174,7 @@ public class BasicDatasourceController {
                         String mainNumber = paperStructDto.getMainNumber();
                         String subNumber = paperStructDto.getSubNumber();
                         String questionType = paperStructDto.getQuestionType();
-                        if (questionType == null){
+                        if (questionType == null) {
                             questionType = "";
                         }
                         String questionName = questionType + " " + mainNumber + SystemConstant.HYPHEN + subNumber;
@@ -201,8 +201,8 @@ public class BasicDatasourceController {
 
         List<Long> paperIdList = tbPaperStructList.stream().map(TBPaperStruct::getPaperId).collect(Collectors.toList());
         // 删除已有的试卷结构数据
-        if (paperIdList.size() > 0){
-            tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().in(TBPaperStruct::getPaperId,paperIdList));
+        if (paperIdList.size() > 0) {
+            tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().in(TBPaperStruct::getPaperId, paperIdList));
         }
 
         // 批量新增或更新试卷表
@@ -220,7 +220,7 @@ public class BasicDatasourceController {
         if (Objects.isNull(file)) {
             throw ExceptionResultEnum.ERROR.exception("附件不存在");
         }
-        if (schoolId == null || schoolId == 0){
+        if (schoolId == null || schoolId == 0) {
             throw ExceptionResultEnum.ERROR.exception("参数缺失");
         }
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(),
@@ -249,7 +249,7 @@ public class BasicDatasourceController {
                         String define = moduleProficiencyDto.getProficiency(); // define
                         String courseCode = moduleProficiencyDto.getCourseCode();
                         String courseName = moduleProficiencyDto.getCourseName();
-                        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                             continue;
                         }
                         if (proficiencyDegree != null && proficiencyDegree.length() > 0 && define != null && define.length() > 0) {
@@ -313,11 +313,11 @@ public class BasicDatasourceController {
 
                         String courseCode = moduleConfigDto.getCourseCode();
                         String courseName = basicCourseService.getOne(new QueryWrapper<BasicCourse>().lambda()
-                                .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode))
+                                .eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode))
                                 .getName();
 
 
-                        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                             continue;
                         }
                         TBModuleConfig tbModuleConfig = new TBModuleConfig();
@@ -355,18 +355,18 @@ public class BasicDatasourceController {
         for (String s : moduleProficiencyRemove) {
             String[] arr = s.split(SystemConstant.HYPHEN);
             tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
-                    .eq(TBModuleProficiency::getExamId,arr[0])
-                    .eq(TBModuleProficiency::getCourseCode,arr[1])
-                    .eq(TBModuleProficiency::getCourseName,arr[2])
-                    .eq(TBModuleProficiency::getModuleType,arr[3]));
+                    .eq(TBModuleProficiency::getExamId, arr[0])
+                    .eq(TBModuleProficiency::getCourseCode, arr[1])
+                    .eq(TBModuleProficiency::getCourseName, arr[2])
+                    .eq(TBModuleProficiency::getModuleType, arr[3]));
         }
         for (String s : moduleConfigRemove) {
             String[] arr = s.split(SystemConstant.HYPHEN);
             tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
-                    .eq(TBModuleConfig::getExamId,arr[0])
-                    .eq(TBModuleConfig::getCourseCode,arr[1])
-                    .eq(TBModuleConfig::getCourseName,arr[2])
-                    .eq(TBModuleConfig::getModuleType,arr[3]));
+                    .eq(TBModuleConfig::getExamId, arr[0])
+                    .eq(TBModuleConfig::getCourseCode, arr[1])
+                    .eq(TBModuleConfig::getCourseName, arr[2])
+                    .eq(TBModuleConfig::getModuleType, arr[3]));
         }
         tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
         tbModuleConfigService.saveBatch(tbModuleConfigList);
@@ -377,11 +377,11 @@ public class BasicDatasourceController {
     @RequestMapping(value = "/dimension/import", method = RequestMethod.POST)
     @Transactional(rollbackFor = Exception.class)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result dimensionImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long schoolId,@RequestParam Long examId) throws IOException, NoSuchFieldException {
+    public Result dimensionImport(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long schoolId, @RequestParam Long examId) throws IOException, NoSuchFieldException {
         if (Objects.isNull(file)) {
             throw ExceptionResultEnum.ERROR.exception("附件不存在");
         }
-        if (Objects.isNull(schoolId) || schoolId == 0){
+        if (Objects.isNull(schoolId) || schoolId == 0) {
             throw ExceptionResultEnum.ERROR.exception("参数缺失");
         }
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(DimensionDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
@@ -402,10 +402,10 @@ public class BasicDatasourceController {
 
                         String courseCode = dimensionDto.getCourseCode();
                         String courseName = basicCourseService.getOne(new QueryWrapper<BasicCourse>().lambda()
-                                .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode))
+                                .eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode))
                                 .getName();
 
-                        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                             continue;
                         }
                         TBDimension tbDimension = new TBDimension();
@@ -429,8 +429,8 @@ public class BasicDatasourceController {
         for (String s : tbDimensionRemove) {
             String[] arr = s.split(SystemConstant.HYPHEN);
             tbDimensionService.remove(new QueryWrapper<TBDimension>().lambda()
-                    .eq(TBDimension::getExamId,arr[0])
-                    .eq(TBDimension::getCourseCode,arr[1]));
+                    .eq(TBDimension::getExamId, arr[0])
+                    .eq(TBDimension::getCourseCode, arr[1]));
         }
         tbDimensionService.saveBatch(tbDimensionList);
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
@@ -443,15 +443,15 @@ public class BasicDatasourceController {
     public Result examAnswerImport(@ApiParam(value = "云阅卷考试id", required = true) @RequestParam Long id, @ApiParam(value = "云阅卷考试编号", required = false)
     @RequestParam(required = false) String cloudExamCode,
                                    @ApiParam(value = "教研分析将AB卷分开分析时自定义科目和卷形的连接符(连接符必须和’t_e_course‘表中的科目名称中连接符对应)")
-                                   @RequestParam(required = false) String linkSign ,@RequestParam Long schoolId) throws IOException {
-        if (schoolId == null || schoolId == 0){
+                                   @RequestParam(required = false) String linkSign, @RequestParam Long schoolId) throws IOException {
+        if (schoolId == null || schoolId == 0) {
             throw ExceptionResultEnum.ERROR.exception("参数缺失");
         }
         TBExam tbExam = tbExamService.findByCloudExamId(id);
         Long examId = tbExam.getId();
 
         // 该考试要考察的所有课程
-        List<TBExamCourse> tbExamCourseList = tbExamCourseService.list(new QueryWrapper<TBExamCourse>().lambda().eq(TBExamCourse::getExamId,examId));
+        List<TBExamCourse> tbExamCourseList = tbExamCourseService.list(new QueryWrapper<TBExamCourse>().lambda().eq(TBExamCourse::getExamId, examId));
 
         List<Map> finalList = newCallApiService.callStudentScore(id, cloudExamCode);
 //        System.out.println("------------------map : --------------------- \n" + JacksonUtil.parseJson(finalList));
@@ -540,13 +540,13 @@ public class BasicDatasourceController {
                 组建学生基础信息 student
              */
             TBStudent studentTemp = tbStudentService.getOne(new QueryWrapper<TBStudent>().lambda()
-                    .eq(TBStudent::getSchoolId,schoolId)
-                    .eq(TBStudent::getName,name)
-                    .eq(TBStudent::getStudentCode,studentCode));
+                    .eq(TBStudent::getSchoolId, schoolId)
+                    .eq(TBStudent::getName, name)
+                    .eq(TBStudent::getStudentCode, studentCode));
             Long studentId;
-            if (Objects.nonNull(studentTemp)){
+            if (Objects.nonNull(studentTemp)) {
                 studentId = studentTemp.getId();
-            }else {
+            } else {
                 studentId = SystemConstant.getDbUuid();
             }
             TBStudent tbStudent = new TBStudent();
@@ -571,15 +571,15 @@ public class BasicDatasourceController {
                 TBExamCourse tbExamCourse = needDisposeList.get(0);
                 String courseCode = tbExamCourse.getCourseCode();
                 String courseName = tbExamCourse.getCourseName();
-                if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+                if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
                     continue;
                 }
 
                 // TODO: 2021/6/2 创建学生-考试关系表(全批次删除并新增)
                 // 获取关联的基础表主键
-                SysOrg tbSchoolCollege = sysOrgService.findByForeignKey(schoolId,college,college);
-                TBSchoolClazz tbSchoolClazz = tbSchoolClazzService.findByForeignKey(schoolId,className,className);
-                SysUser tbSchoolTeacher = sysUserService.findByForeignKey(schoolId,teacher,teacher);
+                SysOrg tbSchoolCollege = sysOrgService.findByForeignKey(schoolId, college, college);
+                TBSchoolClazz tbSchoolClazz = tbSchoolClazzService.findByForeignKey(schoolId, className, className);
+                SysUser tbSchoolTeacher = sysUserService.findByForeignKey(schoolId, teacher, teacher);
 
                 TBExamStudent tbExamStudent = new TBExamStudent();
                 Long examStudentId = SystemConstant.getDbUuid();
@@ -608,7 +608,7 @@ public class BasicDatasourceController {
                 TBExamRecord tbExamRecord = new TBExamRecord();
                 tbExamRecord.setId(examRecordId);
                 tbExamRecord.setExamId(examId);
-                tbExamRecord.setPaperId(tbPaperService.findByForeignKey(examId,courseCode,courseName,paperType).getId());
+                tbExamRecord.setPaperId(tbPaperService.findByForeignKey(examId, courseCode, courseName, paperType).getId());
                 tbExamRecord.setPaperType(paperType);
                 tbExamRecord.setExamStudentId(examStudentId);
                 tbExamRecord.setSubjectiveScore(BigDecimal.valueOf(Double.parseDouble(subjectiveScore)));
@@ -660,23 +660,23 @@ public class BasicDatasourceController {
         for (String s : courseInfoList) {
             String[] arr = s.split(SystemConstant.HYPHEN);
             Set<Long> ids = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
-                    .eq(TBExamStudent::getCourseCode,arr[0])
-                    .eq(TBExamStudent::getCourseName,arr[1]))
+                    .eq(TBExamStudent::getCourseCode, arr[0])
+                    .eq(TBExamStudent::getCourseName, arr[1]))
                     .stream().map(TBExamStudent::getId).collect(Collectors.toSet());
             examStudentRemoveIdSet.addAll(ids);
         }
 
-        if (examStudentRemoveIdSet.size() > 0){
+        if (examStudentRemoveIdSet.size() > 0) {
             // 删除考生表
             tbExamStudentService.removeByIds(examStudentRemoveIdSet);
             List<TBExamRecord> willRemoveRecord = tbExamRecordService.list(new QueryWrapper<TBExamRecord>()
-                    .lambda().in(TBExamRecord::getExamStudentId,examStudentRemoveIdSet));
-            if (willRemoveRecord.size() > 0){
+                    .lambda().in(TBExamRecord::getExamStudentId, examStudentRemoveIdSet));
+            if (willRemoveRecord.size() > 0) {
                 List<Long> willRemoveRecordIdList = willRemoveRecord.stream().map(TBExamRecord::getId).collect(Collectors.toList());
                 // 删除考生作答
                 tbExamRecordService.removeByIds(willRemoveRecordIdList);
                 // 删除考生作答
-                tbAnswerService.remove(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId,willRemoveRecordIdList));
+                tbAnswerService.remove(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId, willRemoveRecordIdList));
             }
         }
 
@@ -691,40 +691,40 @@ public class BasicDatasourceController {
     @RequestMapping(value = "/special/assignScore", method = RequestMethod.POST)
     @Transactional(rollbackFor = Exception.class)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result specialAssignScore(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long examId,@RequestParam Long schoolId,
+    public Result specialAssignScore(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @RequestParam Long examId, @RequestParam Long schoolId,
                                      @ApiParam(value = "该Excel中包含多科目赋分时,各科目编号用','隔开", required = true) @RequestParam String courseCodeS) throws IOException, NoSuchFieldException {
 
         List<String> courseCodeList = Arrays.asList(courseCodeS.split(","));
         // 数据同步操作
         // 获取当前课程下所有学生考试成绩记录
-        List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId,courseCodeList);
+        List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId, courseCodeList);
         Set<TAExamCourseRecord> taExamCourseRecordDatasource = new HashSet<>();
         for (String s : courseCodeList) {
-            if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,s,basicCourseService.findByCourseCode(s).getName())){
+            if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, s, basicCourseService.findByCourseCode(s).getName())) {
                 throw ExceptionResultEnum.ERROR.exception("课程编号[" + s + "]的课程分析数据已测试或发布,不能变更基础数据");
             }
             List<BasicExamRecordDto> basicExamRecordDtoList = basicExamRecordDtoDatasource.stream()
                     .filter(e -> s.equals(e.getCourseCode())).collect(Collectors.toList());
-            if (basicExamRecordDtoList.size() > 0){
+            if (basicExamRecordDtoList.size() > 0) {
                 // 删除源数据
                 taExamCourseRecordService.remove(new QueryWrapper<TAExamCourseRecord>()
-                        .lambda().eq(TAExamCourseRecord::getExamId,examId).eq(TAExamCourseRecord::getCourseCode,s));
+                        .lambda().eq(TAExamCourseRecord::getExamId, examId).eq(TAExamCourseRecord::getCourseCode, s));
                 // 迁移数据至't_a_exam_course_record'
                 List<TAExamCourseRecord> taExamCourseRecordList = new ArrayList<>();
                 for (BasicExamRecordDto basicExamRecordDto : basicExamRecordDtoList) {
                     // 正常公式赋分操作
                     Long paperId = basicExamRecordDto.getPaperId();
                     TBPaper tbPaper = tbPaperService.getById(paperId);
-                    if (Objects.isNull(tbPaper)){
+                    if (Objects.isNull(tbPaper)) {
                         throw ExceptionResultEnum.ERROR.exception("试卷信息数据异常");
                     }
                     BigDecimal fullScore = tbPaper.getTotalScore();
                     BigDecimal myScore = basicExamRecordDto.getTotalScore();
                     BigDecimal coefficient = tbPaper.getCoefficient();
                     BigDecimal assignScore;
-                    if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0){
-                        assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient,0,BigDecimal.ROUND_HALF_DOWN));
-                    }else {
+                    if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0) {
+                        assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 0, BigDecimal.ROUND_HALF_DOWN));
+                    } else {
                         assignScore = myScore;
                     }
 
@@ -732,8 +732,9 @@ public class BasicDatasourceController {
                     taExamCourseRecord.setId(SystemConstant.getDbUuid());
                     taExamCourseRecord.setExamRecordId(basicExamRecordDto.getTbExamRecordId());
                     // 数据同步默认赋分成绩为卷面成绩
+                    taExamCourseRecord.setSchoolId(tbExamService.getById(examId).getSchoolId());
                     taExamCourseRecord.setAssignedScore(assignScore);
-                    taExamCourseRecord.setExamId(basicExamRecordDto.getExamId());
+                    taExamCourseRecord.setExamId(examId);
                     taExamCourseRecord.setCourseCode(basicExamRecordDto.getCourseCode());
                     taExamCourseRecord.setPaperId(basicExamRecordDto.getPaperId());
                     taExamCourseRecord.setPaperType(basicExamRecordDto.getPaperType());
@@ -771,7 +772,7 @@ public class BasicDatasourceController {
                     if (assignList.get(y) instanceof AssignDto) {
                         AssignDto assignDto = (AssignDto) assignList.get(y);
                         Long assExamId = Long.parseLong(assignDto.getExamId());
-                        if (!examId.equals(assExamId)){
+                        if (!examId.equals(assExamId)) {
                             throw ExceptionResultEnum.ERROR.exception("excel考试数据异常");
                         }
                         String assCourseCodeS = assignDto.getPaperCodeS();
@@ -782,7 +783,7 @@ public class BasicDatasourceController {
                             List<TAExamCourseRecord> taExamCourseRecordList = taExamCourseRecordDatasource.stream()
                                     .filter(e -> assExamId.equals(e.getExamId()) && s.equals(e.getCourseCode()) && assStudentCode.equals(e.getStudentCode()))
                                     .collect(Collectors.toList());
-                            if (taExamCourseRecordList.size() != 1){
+                            if (taExamCourseRecordList.size() != 1) {
                                 System.out.println("-----------------------");
                                 System.out.println(JSON.toJSONString(taExamCourseRecordList));
                                 throw ExceptionResultEnum.ERROR.exception("赋分异常,考生记录分析表数据异常");
@@ -805,29 +806,30 @@ public class BasicDatasourceController {
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     public Result configImport(@RequestParam Long schoolId, @RequestParam Long examId, @RequestParam String courseCode) {
         String courseName = basicCourseService.findByCourseCode(courseCode).getName();
-        if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,courseName)){
+        if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, courseName)) {
             throw ExceptionResultEnum.ERROR.exception("课程编号[" + courseCode + "]的课程分析数据已测试或发布,不能变更基础数据");
         }
-        tbCommonLevelConfigService.importLevelConfig(examId,courseCode,courseName);
-        tbCommonRankLevelConfigService.importRankLevelConfig(examId,courseCode,courseName);
+        tbCommonLevelConfigService.importLevelConfig(examId, courseCode, courseName);
+        tbCommonRankLevelConfigService.importRankLevelConfig(examId, courseCode, courseName);
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }
 
     /**
      * 更新或新增专业信息
+     *
      * @param tbSchoolMajorDtoList 基础专业数据源
      */
-    private void saveMajorInfo(List<TBSchoolMajorDto> tbSchoolMajorDtoList){
+    private void saveMajorInfo(List<TBSchoolMajorDto> tbSchoolMajorDtoList) {
         List<TBSchoolMajor> tbSchoolMajorList = new ArrayList<>();
         for (TBSchoolMajorDto tbSchoolMajorDto : tbSchoolMajorDtoList) {
             TBSchoolMajor old = tbSchoolMajorService.getOne(new QueryWrapper<TBSchoolMajor>().lambda()
-                    .eq(TBSchoolMajor::getSchoolId,tbSchoolMajorDto.getSchoolId())
-                    .eq(TBSchoolMajor::getMajorCode,tbSchoolMajorDto.getMajorCode())
-                    .eq(TBSchoolMajor::getMajorName,tbSchoolMajorDto.getMajorName()));
+                    .eq(TBSchoolMajor::getSchoolId, tbSchoolMajorDto.getSchoolId())
+                    .eq(TBSchoolMajor::getMajorCode, tbSchoolMajorDto.getMajorCode())
+                    .eq(TBSchoolMajor::getMajorName, tbSchoolMajorDto.getMajorName()));
             Long id;
-            if (Objects.nonNull(old)){
+            if (Objects.nonNull(old)) {
                 id = old.getId();
-            }else {
+            } else {
                 id = SystemConstant.getDbUuid();
             }
 
@@ -846,19 +848,20 @@ public class BasicDatasourceController {
 
     /**
      * 更新或新增班级信息
+     *
      * @param tbSchoolClazzDtoList 基础班级数据源
      */
-    private void saveClazzInfo(List<TBSchoolClazzDto> tbSchoolClazzDtoList){
+    private void saveClazzInfo(List<TBSchoolClazzDto> tbSchoolClazzDtoList) {
         List<TBSchoolClazz> tbSchoolClazzList = new ArrayList<>();
         for (TBSchoolClazzDto tbSchoolClazzDto : tbSchoolClazzDtoList) {
             TBSchoolClazz old = tbSchoolClazzService.getOne(new QueryWrapper<TBSchoolClazz>().lambda()
-                    .eq(TBSchoolClazz::getSchoolId,tbSchoolClazzDto.getSchoolId())
-                    .eq(TBSchoolClazz::getClazzCode,tbSchoolClazzDto.getClazzCode())
-                    .eq(TBSchoolClazz::getClazzName,tbSchoolClazzDto.getClazzName()));
+                    .eq(TBSchoolClazz::getSchoolId, tbSchoolClazzDto.getSchoolId())
+                    .eq(TBSchoolClazz::getClazzCode, tbSchoolClazzDto.getClazzCode())
+                    .eq(TBSchoolClazz::getClazzName, tbSchoolClazzDto.getClazzName()));
             Long id;
-            if (Objects.nonNull(old)){
+            if (Objects.nonNull(old)) {
                 id = old.getId();
-            }else {
+            } else {
                 id = SystemConstant.getDbUuid();
             }
 
@@ -877,19 +880,20 @@ public class BasicDatasourceController {
 
     /**
      * 更新或新增学院信息
+     *
      * @param tbSchoolCollegeDtoList 基础学院数据源
      */
-    private void saveCollegeInfo(List<TBSchoolCollegeDto> tbSchoolCollegeDtoList){
+    private void saveCollegeInfo(List<TBSchoolCollegeDto> tbSchoolCollegeDtoList) {
         List<SysOrg> sysOrgList = new ArrayList<>();
         for (TBSchoolCollegeDto tbSchoolCollegeDto : tbSchoolCollegeDtoList) {
             SysOrg old = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
-                    .eq(SysOrg::getSchoolId,tbSchoolCollegeDto.getSchoolId())
-                    .eq(SysOrg::getCode,tbSchoolCollegeDto.getCollegeCode())
-                    .eq(SysOrg::getName,tbSchoolCollegeDto.getCollegeName()));
+                    .eq(SysOrg::getSchoolId, tbSchoolCollegeDto.getSchoolId())
+                    .eq(SysOrg::getCode, tbSchoolCollegeDto.getCollegeCode())
+                    .eq(SysOrg::getName, tbSchoolCollegeDto.getCollegeName()));
             Long id;
-            if (Objects.nonNull(old)){
+            if (Objects.nonNull(old)) {
                 id = old.getId();
-            }else {
+            } else {
                 id = SystemConstant.getDbUuid();
             }
 
@@ -906,17 +910,17 @@ public class BasicDatasourceController {
 
     /**
      * 更新或新增教师信息
+     *
      * @param tbSchoolTeacherDtoList 基础教师数据源
      */
-    private void saveTeacherInfo(List<TBSchoolTeacherDto> tbSchoolTeacherDtoList){
-        List<SysUser> tbSchoolTeacherList = new ArrayList<>();
+    private void saveTeacherInfo(List<TBSchoolTeacherDto> tbSchoolTeacherDtoList) {
         for (TBSchoolTeacherDto tbSchoolTeacherDto : tbSchoolTeacherDtoList) {
             SysUser old = sysUserService.getOne(new QueryWrapper<SysUser>().lambda()
-                    .eq(SysUser::getSchoolId,tbSchoolTeacherDto.getSchoolId())
-                    .eq(SysUser::getLoginName,tbSchoolTeacherDto.getTeacherCode())
-                    .eq(SysUser::getRealName,tbSchoolTeacherDto.getTeacherName()));
+                    .eq(SysUser::getSchoolId, tbSchoolTeacherDto.getSchoolId())
+                    .eq(SysUser::getLoginName, tbSchoolTeacherDto.getTeacherCode())
+                    .eq(SysUser::getRealName, tbSchoolTeacherDto.getTeacherName()));
             Long id = 0L;
-            if (Objects.nonNull(old)){
+            if (Objects.nonNull(old)) {
                 id = old.getId();
             }
             SysRole teacherRole = sysRoleService.list(new QueryWrapper<SysRole>().lambda().eq(SysRole::getType, RoleTypeEnum.TEACHER)).get(0);
@@ -924,7 +928,7 @@ public class BasicDatasourceController {
             roleIds.add(teacherRole.getId());
 
             UserSaveParams userSaveParams = new UserSaveParams();
-            if (id > 0){
+            if (id > 0) {
                 userSaveParams.setId(id);
             }
 
@@ -939,5 +943,4 @@ public class BasicDatasourceController {
             sysUserService.save(userSaveParams);
         }
     }
-
 }

+ 9 - 9
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/StudentReportController.java

@@ -27,12 +27,12 @@ public class StudentReportController {
     @ApiOperation(value = "学生报告预览-列表接口")
     @RequestMapping(value = "/report/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TBExamStudentResult.class)})
-    public Result reportList(@ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
-                             @ApiParam(value = "考试id", required = true) @RequestParam String examId,
-                             @ApiParam(value = "学院id", required = true) @RequestParam String collegeId,
-                             @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
-                             @ApiParam(value = "班级id", required = true) @RequestParam String clazzId,
-                             @ApiParam(value = "是否缺考", required = true) @RequestParam Boolean absent,
+    public Result reportList(@ApiParam(value = "学校id", required = false) @RequestParam(required = false) String schoolId,
+                             @ApiParam(value = "考试id", required = true) @RequestParam(required = false) String examId,
+                             @ApiParam(value = "学院id", required = true) @RequestParam(required = false) String collegeId,
+                             @ApiParam(value = "科目编码", required = true) @RequestParam(required = false) String courseCode,
+                             @ApiParam(value = "班级id", required = true) @RequestParam(required = false) String clazzId,
+                             @ApiParam(value = "是否缺考", required = true) @RequestParam(required = false) Boolean absent,
                              @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
                              @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
         return ResultUtil.ok(tbExamStudentService.reportList(new Page<>(pageNumber, pageSize), SystemConstant.convertIdToLong(schoolId),
@@ -46,7 +46,7 @@ public class StudentReportController {
     @ApiOperation(value = "学生报告-个人成绩总览接口")
     @RequestMapping(value = "/report/result", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TBExamStudentResult.class)})
-    public Result reportResult(@ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
+    public Result reportResult(@ApiParam(value = "学校id", required = false) @RequestParam(required = false) String schoolId,
                                @ApiParam(value = "学号", required = true) @RequestParam String studentCode) {
         return ResultUtil.ok(tbExamStudentService.reportResult(SystemConstant.convertIdToLong(schoolId), studentCode));
     }
@@ -54,10 +54,10 @@ public class StudentReportController {
     @ApiOperation(value = "学生报告接口")
     @RequestMapping(value = "/report/mark", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TBExamStudentResult.class)})
-    public Result reportMark(@ApiParam(value = "学校id", required = true) @RequestParam String schoolId,
+    public Result reportMark(@ApiParam(value = "学校id", required = false) @RequestParam(required = false) String schoolId,
                              @ApiParam(value = "学号", required = true) @RequestParam String studentCode,
                              @ApiParam(value = "考试id", required = true) @RequestParam String examId,
                              @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode) {
-        return ResultUtil.ok(tbExamStudentService.reportMark(schoolId, studentCode, examId, courseCode));
+        return ResultUtil.ok(tbExamStudentService.reportMark(SystemConstant.convertIdToLong(schoolId), studentCode, examId, courseCode));
     }
 }

+ 20 - 13
teachcloud-report/src/test/java/com/qmth/teachcloud/report/AnalyzeForStudentServiceTest.java

@@ -1,6 +1,6 @@
 package com.qmth.teachcloud.report;
 
-import com.qmth.teachcloud.report.business.service.AnalyzeForStudentService;
+import com.qmth.teachcloud.report.business.service.AnalyzeForReportService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -17,12 +17,12 @@ import javax.annotation.Resource;
 @RunWith(SpringRunner.class)
 public class AnalyzeForStudentServiceTest {
     @Resource
-    private AnalyzeForStudentService analyzeForStudentService;
+    private AnalyzeForReportService analyzeForReportService;
     @Test
     public void buildAnalyzeExamCourse() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourse(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourse(examId,courseCode));
 
     }
 
@@ -30,68 +30,75 @@ public class AnalyzeForStudentServiceTest {
     public void buildAnalyzeExamCourseRecord() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseRecord(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseRecord(examId,courseCode));
     }
 
     @Test
     public void buildAnalyzeExamCourseCollegeInspectByOther() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseCollegeInspect(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseCollegeInspect(examId,courseCode));
     }
 
     @Test
     public void buildAnalyzeExamCourseClazz() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseClazz(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseClazz(examId,courseCode));
     }
 
     @Test
     public void analyzePointScoreRate() throws Exception {
         Long examId = 1L;
         String courseCode = "1013";
-        analyzeForStudentService.AnalyzePointScoreRate(examId,courseCode);
+        analyzeForReportService.AnalyzePointScoreRate(examId,courseCode);
     }
 
     @Test
     public void buildAnalyzeExamCourseCollegeInspectDio() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseCollegeInspectDio(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseCollegeInspectDio(examId,courseCode));
     }
 
     @Test
     public void buildAnalyzePaperStruct() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzePaperStruct(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzePaperStruct(examId,courseCode));
     }
 
     @Test
     public void buildExamPaperDifficult(){
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildExamPaperDifficult(examId,courseCode));
+        System.out.println(analyzeForReportService.buildExamPaperDifficult(examId,courseCode));
     }
 
     @Test
     public void buildAnalyzeExamTotal() {
         Long examId = 1L;
-        System.out.println(analyzeForStudentService.buildAnalyzeExamTotal(examId));
+        System.out.println(analyzeForReportService.buildAnalyzeExamTotal(examId));
     }
 
     @Test
     public void buildAnalyzeExamCourseCollegeTeacher() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseCollegeTeacher(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseCollegeTeacher(examId,courseCode));
     }
 
     @Test
     public void buildAnalyzeExamCourseTeacher() {
         Long examId = 1L;
         String courseCode = "1013";
-        System.out.println(analyzeForStudentService.buildAnalyzeExamCourseTeacher(examId,courseCode));
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseTeacher(examId,courseCode));
+    }
+
+    @Test
+    public void finishCalculate(){
+        Long examId = 1L;
+        String courseCode = "1013";
+        System.out.println(analyzeForReportService.finishCalculate(examId,courseCode));
     }
 }