浏览代码

新需求的数据计算部分

caozixuan 3 年之前
父节点
当前提交
063b76ba98
共有 12 个文件被更改,包括 449 次插入26 次删除
  1. 33 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/query/ValidAnswerDetailDto.java
  2. 12 7
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseCollegePaperStruct.java
  3. 1 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseTeacherCollegeDifficult.java
  4. 10 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseTeacherCollegeDioMapper.java
  5. 44 2
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java
  6. 6 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/TAExamCourseTeacherCollegeDioService.java
  7. 259 6
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java
  8. 8 6
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/ReportCommonServiceImpl.java
  9. 26 0
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TAExamCourseTeacherCollegeDioServiceImpl.java
  10. 27 0
      teachcloud-report-business/src/main/resources/mapper/TAExamCourseTeacherCollegeDioMapper.xml
  11. 2 0
      teachcloud-report-business/src/main/resources/mapper/TBAnswerMapper.xml
  12. 21 0
      teachcloud-report/src/test/java/com/qmth/teachcloud/report/AnalyzeForStudentServiceTest.java

+ 33 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/query/ValidAnswerDetailDto.java

@@ -1,24 +1,39 @@
 package com.qmth.teachcloud.report.business.bean.dto.query;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 
 import java.math.BigDecimal;
 import java.util.Objects;
 
 /**
- * @Description:
+ * @Description: 有效的作答记录
  * @Author: CaoZixuan
- * @Date:
+ * @Date: 2021-07-21改
  */
 public class ValidAnswerDetailDto {
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long answerId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long examRecordId;
     private String numberType;
     private String mainNumber;
     private String subNumber;
     private BigDecimal score;
+
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long taExamRecordId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long inspectCollegeId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long teacherId;
     private int percentGrade;
+
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long paperId;
     private String paperType;
     private int rank;
@@ -114,4 +129,20 @@ public class ValidAnswerDetailDto {
     public void setRank(int rank) {
         this.rank = rank;
     }
+
+    public Long getInspectCollegeId() {
+        return inspectCollegeId;
+    }
+
+    public void setInspectCollegeId(Long inspectCollegeId) {
+        this.inspectCollegeId = inspectCollegeId;
+    }
+
+    public Long getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Long teacherId) {
+        this.teacherId = teacherId;
+    }
 }

+ 12 - 7
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseCollegePaperStruct.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.report.business.enums.PaperStructJudgeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -117,7 +118,7 @@ public class TAExamCourseCollegePaperStruct implements Serializable {
 
     @ApiModelProperty(value = "标准难度系数(得分率)")
     @TableField(value = "standard_score_rate")
-    private String standardScoreRate;
+    private BigDecimal standardScoreRate;
 
     @ApiModelProperty(value = "得分率")
     @TableField(value = "score_rate")
@@ -129,7 +130,7 @@ public class TAExamCourseCollegePaperStruct implements Serializable {
 
     @ApiModelProperty(value = "试卷结构每道题目正确(全对),错误枚举\nALL_CORRECT('全对'), NOT_QUITE_RIGHT('不完全正确的'),")
     @TableField(value = "paper_struct_judge")
-    private String paperStructJudge;
+    private PaperStructJudgeEnum paperStructJudge;
 
     public static long getSerialVersionUID() {
         return serialVersionUID;
@@ -307,11 +308,15 @@ public class TAExamCourseCollegePaperStruct implements Serializable {
         this.literacyDimension = literacyDimension;
     }
 
-    public String getStandardScoreRate() {
-        return standardScoreRate;
+    public BigDecimal getStandardScoreRate() {
+        if (Objects.nonNull(standardScoreRate)) {
+            return standardScoreRate.setScale(SystemConstant.CALCULATE_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return standardScoreRate;
+        }
     }
 
-    public void setStandardScoreRate(String standardScoreRate) {
+    public void setStandardScoreRate(BigDecimal standardScoreRate) {
         this.standardScoreRate = standardScoreRate;
     }
 
@@ -335,11 +340,11 @@ public class TAExamCourseCollegePaperStruct implements Serializable {
         this.difficult = difficult;
     }
 
-    public String getPaperStructJudge() {
+    public PaperStructJudgeEnum getPaperStructJudge() {
         return paperStructJudge;
     }
 
-    public void setPaperStructJudge(String paperStructJudge) {
+    public void setPaperStructJudge(PaperStructJudgeEnum paperStructJudge) {
         this.paperStructJudge = paperStructJudge;
     }
 }

+ 1 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseTeacherCollegeDifficult.java

@@ -32,7 +32,7 @@ public class TAExamCourseTeacherCollegeDifficult implements Serializable {
 
     @ApiModelProperty(value = "考试id")
     @JsonSerialize(using = ToStringSerializer.class)
-    @TableField(value = "school_id")
+    @TableField(value = "exam_id")
     private Long examId;
 
     @ApiModelProperty(value = "学校id")

+ 10 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/mapper/TAExamCourseTeacherCollegeDioMapper.java

@@ -2,6 +2,9 @@ package com.qmth.teachcloud.report.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherCollegeDio;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +15,11 @@ import com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherCollegeDio;
  * @since 2021-07-20
  */
 public interface TAExamCourseTeacherCollegeDioMapper extends BaseMapper<TAExamCourseTeacherCollegeDio> {
-
+    /**
+     * 根据't_a_exam_course_record_dio'表归集't_a_exam_course_teacher_college_dio'的数据
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果集
+     */
+    List<TAExamCourseTeacherCollegeDio> findByTAExamCourseRecordDio(@Param("examId") Long examId,@Param("courseCode") String courseCode);
 }

+ 44 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java

@@ -35,8 +35,7 @@ public interface AnalyzeForReportService {
      * @return 结果
      */
     String buildAnalyzeExamCourseCollegeInspect(Long examId, String courseCode);
-
-    // TODO: 2021/6/7 专业
+    
 
     /**
      * 构建考试课程-班级维度的分析表 ’t_a_exam_course_clazz‘
@@ -90,6 +89,14 @@ public interface AnalyzeForReportService {
      */
     String buildAnalyzeExamCourseTeacherDio(Long examId, String courseCode);
 
+    /**
+     * 构建表't_a_exam_course_teacher_college_dio'表来记录教师在每个授课学院各个考察点的得分率
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    String buildAnalyzeExamCourseTeacherCollegeDio(Long examId,String courseCode);
+
     /**
      * 构建分析试卷结构表 't_a_paper_struct'表
      *
@@ -99,6 +106,33 @@ public interface AnalyzeForReportService {
      */
     String buildAnalyzePaperStruct(Long examId, String courseCode);
 
+    /**
+     * 构建't_a_exam_course_college_paper_struct'表记录各个考察学院下学生的各个题目的难度情况
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    // TODO: 2021/7/20  
+    String buildAnalyzeCollegePaperStruct(Long examId,String courseCode);
+
+    /**
+     * 构建't_a_exam_course_teacher_paper_struct'表记录该教师下所教学生的各个题目的难度情况
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    // TODO: 2021/7/20  
+    String buildAnalyzeTeacherPaperStruct(Long examId,String courseCode);
+
+    /**
+     * 构建't_a_exam_course_teacher_college_paper_struct'表记录该教师在某学院下所教学生的各个题目的难度情况
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    // TODO: 2021/7/20
+    String buildAnalyzeTeacherCollegePaperStruct(Long examId,String courseCode);
+
     /**
      * 构建科目题目难度分类得分率表 - 学院与学校
      *
@@ -117,6 +151,14 @@ public interface AnalyzeForReportService {
      */
     String buildExamPaperTeacherDifficult(Long examId, String courseCode);
 
+    /**
+     * 构建't_a_exam_course_teacher_college_difficult'表记录该教师在某学院的各难度题作答分析
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @return 结果
+     */
+    String buildAnalyzeExamCourseTeacherCollegeDifficult(Long examId,String courseCode);
+
     /**
      * 构建表 ‘t_a_exam_total’
      *

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

@@ -12,5 +12,10 @@ import com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherCollegeDio;
  * @since 2021-07-20
  */
 public interface TAExamCourseTeacherCollegeDioService extends IService<TAExamCourseTeacherCollegeDio> {
-
+    /**
+     * 根据考试编号和课程编号和‘t_a_exam_course_record_dio’表向‘t_a_exam_course_teacher_college_dio’表插入数据
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     */
+    void insertByTAExamCourseRecordDio(Long examId,String courseCode);
 }

+ 259 - 6
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -97,6 +97,16 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
     private TAExamCourseTeacherDioService taExamCourseTeacherDioService;
     @Resource
     private TBExamRecordService tbExamRecordService;
+    @Resource
+    private TAExamCourseTeacherCollegeDioService taExamCourseTeacherCollegeDioService;
+    @Resource
+    private TAExamCourseTeacherCollegeDifficultService taExamCourseTeacherCollegeDifficultService;
+    @Resource
+    private TAExamCourseCollegePaperStructService taExamCourseCollegePaperStructService;
+    @Resource
+    private TAExamCourseTeacherPaperStructService taExamCourseTeacherPaperStructService;
+    @Resource
+    private TAExamCourseTeacherCollegePaperStructService taExamCourseTeacherCollegePaperStructService;
 
 
     @Transactional(rollbackFor = Exception.class)
@@ -114,7 +124,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     .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) {
@@ -224,7 +233,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             // 计算标准差
             double currentStandardDeviation = MathUtil.calculateStandardDeviation(currentScoreList);
 
-            // TODO: 2021/6/7 难度系数使用标准分计算
             BigDecimal scoreRate;
             double standardAvgScore = currentDatasource.stream().collect(Collectors.summarizingDouble(e -> e.getTotalScore().doubleValue())).getAverage();
             if (standardAvgScore != 0 && totalScore.compareTo(BigDecimal.ZERO) > 0) {
@@ -245,7 +253,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             /*
                 学院信息
              */
-            // TODO: 2021/6/7 考查学院数量算进去往届和缺考的吗
             List<TBExamStudent> tbExamStudentList = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
                     .eq(TBExamStudent::getExamId, examId).eq(TBExamStudent::getCourseCode, effectiveCourseCode));
 
@@ -413,7 +420,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 double median = MathUtil.calculateQuantile(assignedScoreList, QuantileEnum.MEDIAN.getValue());
                 double lowerQuartile = MathUtil.calculateQuantile(assignedScoreList, QuantileEnum.LOWER_QUARTILE.getValue());
 
-                // TODO: 2021/6/7 缺考的学院信息处理
                 if (effectiveList.size() == 0) {
                     minScore = 0;
                     maxScore = 0;
@@ -606,7 +612,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 // 计算每个模块在此次考试中所占分数
                 Map<String, Object> everyModuleTotalScore = this.handleEveryPointTotalScore(moduleToPaper);
 
-                // TODO: 2021/6/7 数据组装
                 // 7.计算每个考生各个考查点和考查模块得分率并更新't_a_exam_course_record_dio'表和't_a_exam_course_record_mod'表
                 List<TAExamCourseRecordDio> taExamCourseRecordDioList = new ArrayList<>();
                 List<TAExamCourseRecordMod> taExamCourseRecordModList = new ArrayList<>();
@@ -854,6 +859,22 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         return "'t_a_exam_course_teacher_dio'表构建完成 ";
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String buildAnalyzeExamCourseTeacherCollegeDio(Long examId, String courseCode) {
+        // 可分析有效课程信息
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
+        for (String effectiveCourseCode : effectiveCourseCodeList) {
+            // 删除原有数据
+            taExamCourseTeacherCollegeDioService.remove(new QueryWrapper<TAExamCourseTeacherCollegeDio>().lambda()
+                    .eq(TAExamCourseTeacherCollegeDio::getExamId,examId)
+                    .eq(TAExamCourseTeacherCollegeDio::getCourseCode,effectiveCourseCode));
+
+            taExamCourseTeacherCollegeDioService.insertByTAExamCourseRecordDio(examId, effectiveCourseCode);
+        }
+        return "'t_a_exam_course_teacher_college_dio'表构建完成 ";
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildAnalyzePaperStruct(Long examId, String courseCode) {
@@ -944,6 +965,119 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         return " 't_a_paper_struct'表构建成功 ";
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String buildAnalyzeCollegePaperStruct(Long examId, String 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) {
+                throw ExceptionResultEnum.ERROR.exception("基础试卷信息异常");
+            }
+            // 删除原有数据
+            taExamCourseCollegePaperStructService.remove(new QueryWrapper<TAExamCourseCollegePaperStruct>().lambda()
+                    .eq(TAExamCourseCollegePaperStruct::getExamId, examId)
+                    .eq(TAExamCourseCollegePaperStruct::getCourseCode, effectiveCourseCode));
+            List<TAExamCourseCollegePaperStruct> taExamCourseCollegePaperStructList = new ArrayList<>();
+            // 该课程有效试卷结构数据
+            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, effectiveCourseCode);
+            for (TBPaper tbPaper : tbPaperList) {
+                Long paperId = tbPaper.getId();
+                String paperType = tbPaper.getPaperType();
+
+                // 参考该试卷的考察学院id集合
+                Set<Long> inspectCollegeIdSet = answerDetailDtoList.stream()
+                        .filter(e -> paperId.equals(e.getPaperId()))
+                        .map(ValidAnswerDetailDto::getInspectCollegeId)
+                        .collect(Collectors.toSet());
+
+                List<TBPaperStruct> tbPaperStructList = tbPaperStructService.list(new QueryWrapper<TBPaperStruct>().lambda()
+                        .eq(TBPaperStruct::getPaperId, paperId));
+                if (tbPaperStructList.size() == 0) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷结构数据异常");
+                }
+                for (Long inspectCollegeId : inspectCollegeIdSet) {
+                    String inspectCollegeName = sysOrgService.getById(inspectCollegeId).getName();
+                    for (TBPaperStruct paperStruct : tbPaperStructList) {
+                        String numberType = paperStruct.getNumberType();
+                        String mainNumber = paperStruct.getBigQuestionNumber();
+                        String subNumber = paperStruct.getSmallQuestionNumber();
+
+                        List<ValidAnswerDetailDto> oneQuestionAnswerDetailList = answerDetailDtoList
+                                .stream().filter(e -> paperType.equals(e.getPaperType()) &&
+                                        inspectCollegeId.equals(e.getInspectCollegeId()) &&
+                                        numberType.equals(e.getNumberType()) &&
+                                        mainNumber.equals(e.getMainNumber()) &&
+                                        subNumber.equals(e.getSubNumber())).collect(Collectors.toList()); //某学院某道小题的所有参考学生作答信息(并且按照该科目的参考学生百分等级从高到低排序了)
+                        if (oneQuestionAnswerDetailList.size() == 0){
+                            System.out.println("异常");
+                        }
+                        BigDecimal fullScore = paperStruct.getFullScore();
+                        PaperStructJudgeEnum paperStructJudgeEnum;
+                        if (oneQuestionAnswerDetailList.stream().anyMatch(e -> fullScore.compareTo(e.getScore()) != 0)){
+                            paperStructJudgeEnum = PaperStructJudgeEnum.NOT_QUITE_RIGHT;
+                        }else {
+                            paperStructJudgeEnum = PaperStructJudgeEnum.ALL_CORRECT;
+                        }
+
+                        DoubleSummaryStatistics descriptiveStatistics = oneQuestionAnswerDetailList.stream()
+                                .collect(Collectors.summarizingDouble(e -> e.getScore().doubleValue()));
+
+                        double scoreAvg = descriptiveStatistics.getAverage();
+                        BigDecimal standardScoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal scoreRate = standardScoreRate.setScale(1, BigDecimal.ROUND_HALF_UP);
+                        String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
+
+                        TAExamCourseCollegePaperStruct taExamCourseCollegePaperStruct = new TAExamCourseCollegePaperStruct();
+                        taExamCourseCollegePaperStruct.setId(SystemConstant.getDbUuid());
+                        taExamCourseCollegePaperStruct.setPaperStructId(paperStruct.getId());
+                        taExamCourseCollegePaperStruct.setExamId(examId);
+                        taExamCourseCollegePaperStruct.setSchoolId(tbExamService.getById(examId).getSchoolId());
+                        taExamCourseCollegePaperStruct.setCourseCode(effectiveCourseCode);
+                        taExamCourseCollegePaperStruct.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
+                        taExamCourseCollegePaperStruct.setPaperId(paperId);
+                        taExamCourseCollegePaperStruct.setInspectCollegeId(inspectCollegeId);
+                        taExamCourseCollegePaperStruct.setInspectCollegeName(inspectCollegeName);
+                        taExamCourseCollegePaperStruct.setPaperType(paperType);
+                        taExamCourseCollegePaperStruct.setQuestionName(paperStruct.getQuestionName());
+                        taExamCourseCollegePaperStruct.setNumberType(paperStruct.getNumberType());
+                        taExamCourseCollegePaperStruct.setBigQuestionNumber(paperStruct.getBigQuestionNumber());
+                        taExamCourseCollegePaperStruct.setSmallQuestionNumber(paperStruct.getSmallQuestionNumber());
+                        taExamCourseCollegePaperStruct.setQuestionType(paperStruct.getQuestionType());
+                        taExamCourseCollegePaperStruct.setFullScore(paperStruct.getFullScore());
+                        taExamCourseCollegePaperStruct.setScoreRules(paperStruct.getScoreRules());
+                        taExamCourseCollegePaperStruct.setRulesDesc(paperStruct.getRulesDesc());
+                        taExamCourseCollegePaperStruct.setKnowledgeDimension(paperStruct.getKnowledgeDimension());
+                        taExamCourseCollegePaperStruct.setAbilityDimension(paperStruct.getAbilityDimension());
+                        taExamCourseCollegePaperStruct.setLiteracyDimension(paperStruct.getLiteracyDimension());
+                        taExamCourseCollegePaperStruct.setStandardScoreRate(standardScoreRate);
+                        taExamCourseCollegePaperStruct.setScoreRate(scoreRate);
+                        taExamCourseCollegePaperStruct.setDifficult(difficult);
+                        taExamCourseCollegePaperStruct.setPaperStructJudge(paperStructJudgeEnum);
+                        taExamCourseCollegePaperStructList.add(taExamCourseCollegePaperStruct);
+                    }
+                }
+
+            }
+            taExamCourseCollegePaperStructService.saveBatch(taExamCourseCollegePaperStructList);
+        }
+        return " 't_a_paper_struct'表构建成功 ";
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String buildAnalyzeTeacherPaperStruct(Long examId, String courseCode) {
+        return null;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String buildAnalyzeTeacherCollegePaperStruct(Long examId, String courseCode) {
+        return null;
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildExamPaperDifficult(Long examId, String courseCode) {
@@ -1125,6 +1259,126 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         return "'t_a_exam_course_teacher_difficult' 表构建完成";
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public String buildAnalyzeExamCourseTeacherCollegeDifficult(Long examId, String courseCode) {
+        // 可分析有效课程信息
+        List<String> effectiveCourseCodeList = tbExamCourseService.findEffectiveByExamId(examId, courseCode);
+
+        for (String effectiveCourseCode : effectiveCourseCodeList) {
+            taExamCourseTeacherCollegeDifficultService.remove(new QueryWrapper<TAExamCourseTeacherCollegeDifficult>().lambda()
+                    .eq(TAExamCourseTeacherCollegeDifficult::getExamId, examId)
+                    .eq(TAExamCourseTeacherCollegeDifficult::getCourseCode, effectiveCourseCode));
+
+            List<TAExamCourseTeacherCollegeDifficult> taExamCourseTeacherCollegeDifficultList = new ArrayList<>();
+
+            List<TBCommonLevelConfig> configLevelDatasource = tbCommonLevelConfigService.list(new QueryWrapper<TBCommonLevelConfig>().lambda()
+                    .eq(TBCommonLevelConfig::getExamId, examId)
+                    .eq(TBCommonLevelConfig::getCourseCode, effectiveCourseCode)
+                    .eq(TBCommonLevelConfig::getLevelType, "难度等级"));// 该科目试题难度情况数据源
+
+            List<TAPaperStruct> questionDatasource = taPaperStructService.list(new QueryWrapper<TAPaperStruct>().lambda()
+                    .eq(TAPaperStruct::getExamId, examId).eq(TAPaperStruct::getCourseCode, effectiveCourseCode));// 该科目试题情况数据源
+
+            LinkedList<AnswerDetailBean> answerDetailDatasource = tbAnswerService.findValidAnswerDetailWithPap(examId, effectiveCourseCode);
+            Set<Long> paperTypeList = questionDatasource.stream().map(TAPaperStruct::getPaperId).collect(Collectors.toSet());
+
+            for (Long paperId : paperTypeList) {
+                for (TBCommonLevelConfig levelTemp : configLevelDatasource) {
+                    String interpret = levelTemp.getInterpret();
+                    String scope = levelTemp.getScope();
+
+                    List<TAPaperStruct> questionList = questionDatasource.stream()
+                            .filter(e -> paperId.equals(e.getPaperId()) && interpret.equals(e.getDifficult()))
+                            .collect(Collectors.toList()); // 题目信息
+
+                    // 学院id集合
+                    List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
+                            .eq(TAExamCourseRecord::getExamId, examId)
+                            .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                            .eq(TAExamCourseRecord::getPaperId, paperId)
+                            .eq(TAExamCourseRecord::getAbsent, false)
+                            .eq(TAExamCourseRecord::getStudentCurrent, true))
+                            .stream()
+                            .map(TAExamCourseRecord::getInspectCollegeId).distinct()
+                            .collect(Collectors.toList());
+
+                    // 学校作答集合
+                    List<AnswerDetailBean> answerDetailForSch = answerDetailDatasource.stream()
+                            .filter(e -> paperId.equals(e.getPaperId()) && interpret.equals(e.getDifficult()))
+                            .collect(Collectors.toList());
+
+                    double schAvgScoreRate = 0;
+                    if (answerDetailForSch.size() > 0) {
+                        schAvgScoreRate = answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForSch.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                    }
+
+                    for (Long collegeId : collegeIdList) {
+                        String collegeName = sysOrgService.getById(collegeId).getName();
+                        // 考察学院作答集合
+                        List<AnswerDetailBean> answerDetailForCol = answerDetailForSch.stream()
+                                .filter(e -> collegeId.equals(e.getCollegeId())).collect(Collectors.toList());
+
+                        double colAvgScoreRate = 0;
+                        if (answerDetailForCol.size() > 0){
+                            colAvgScoreRate = answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForCol.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                        }
+
+                        // 教师id集合
+                        List<Long> teacherIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
+                                .eq(TAExamCourseRecord::getExamId, examId)
+                                .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
+                                .eq(TAExamCourseRecord::getPaperId, paperId)
+                                .eq(TAExamCourseRecord::getInspectCollegeId,collegeId)
+                                .eq(TAExamCourseRecord::getAbsent, false)
+                                .eq(TAExamCourseRecord::getStudentCurrent, true))
+                                .stream()
+                                .map(TAExamCourseRecord::getTeacherId).distinct()
+                                .collect(Collectors.toList());
+
+                        for (Long teacherId : teacherIdList) {
+                            List<AnswerDetailBean> answerDetailForColTea = answerDetailForCol.stream()
+                                    .filter(e -> teacherId.equals(e.getTeacherId())).collect(Collectors.toList());
+
+                            double teaColAvgScoreRate = 0;
+                            if (answerDetailForColTea.size() > 0) {
+                                teaColAvgScoreRate = answerDetailForColTea.stream().collect(Collectors.summarizingDouble(e -> e.getAnswerScore().doubleValue())).getSum() / answerDetailForColTea.stream().collect(Collectors.summarizingDouble(e -> e.getFullScore().doubleValue())).getSum();
+                            }
+
+                            // 得分率保留2位小数处理
+                            Integer count = questionList.size();
+                            TAExamCourseTeacherCollegeDifficult taExamCourseTeacherCollegeDifficult = new TAExamCourseTeacherCollegeDifficult();
+                            taExamCourseTeacherCollegeDifficult.setId(SystemConstant.getDbUuid());
+                            taExamCourseTeacherCollegeDifficult.setExamId(examId);
+                            taExamCourseTeacherCollegeDifficult.setPaperId(paperId);
+                            taExamCourseTeacherCollegeDifficult.setPaperType(tbPaperService.getById(paperId).getPaperType());
+                            taExamCourseTeacherCollegeDifficult.setCourseCode(effectiveCourseCode);
+                            taExamCourseTeacherCollegeDifficult.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
+                            taExamCourseTeacherCollegeDifficult.setTeacherId(teacherId);
+                            taExamCourseTeacherCollegeDifficult.setTeacherName(sysUserService.getById(teacherId).getRealName());
+                            taExamCourseTeacherCollegeDifficult.setInspectCollegeId(collegeId);
+                            taExamCourseTeacherCollegeDifficult.setInspectCollegeName(collegeName);
+                            taExamCourseTeacherCollegeDifficult.setSchoolId(tbExamService.getById(examId).getSchoolId());
+                            taExamCourseTeacherCollegeDifficult.setInterpret(interpret);
+                            taExamCourseTeacherCollegeDifficult.setCount(count);
+                            taExamCourseTeacherCollegeDifficult.setScope(scope);
+                            taExamCourseTeacherCollegeDifficult.setColAvgScoreRate(BigDecimal.valueOf(colAvgScoreRate));
+                            taExamCourseTeacherCollegeDifficult.setTeaColAvgScoreRate(BigDecimal.valueOf(teaColAvgScoreRate));
+
+                            taExamCourseTeacherCollegeDifficultList.add(taExamCourseTeacherCollegeDifficult);
+                        }
+                    }
+
+
+                }
+            }
+
+            taExamCourseTeacherCollegeDifficultService.saveBatch(taExamCourseTeacherCollegeDifficultList);
+        }
+
+        return "'t_a_exam_course_teacher_college_difficult' 表构建完成";
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildAnalyzeExamTotal(Long examId) {
@@ -1137,7 +1391,6 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 .eq(TAExamCourseRecord::getExamId, examId));
 
         //考查学院
-        // TODO: 2021/6/8 是否计算只有缺考的学院 是否计算只有往届的学院
         List<Long> inspectCollegeInfo = taExamCourseRecordList.stream()
                 .map(TAExamCourseRecord::getInspectCollegeId).distinct().collect(Collectors.toList());
         // 考查学院数量

+ 8 - 6
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/ReportCommonServiceImpl.java

@@ -346,7 +346,7 @@ public class ReportCommonServiceImpl implements ReportCommonService {
 //            throw ExceptionResultEnum.DATA_ERROR.exception();
 //        }
         List<ModuleDimensionResult> dimensionAnalyzeList = new ArrayList<>();
-        Set<String> moduleSet = dimensionInfoDatasource.stream().map(e -> e.getModule()).collect(Collectors.toSet()); // 考查模块集合
+        Set<String> moduleSet = dimensionInfoDatasource.stream().map(CourseDimensionResult::getModule).collect(Collectors.toSet()); // 考查模块集合
         for (String module : moduleSet) {
             List<CourseDimensionResult> dimensionInfoList = dimensionInfoDatasource
                     .stream().filter(e -> module.equals(e.getModule())).collect(Collectors.toList());
@@ -436,14 +436,16 @@ public class ReportCommonServiceImpl implements ReportCommonService {
         Set<String> paperTypeSet = questionDatasource.stream().map(TBPaperStructResult::getPaperType).collect(Collectors.toSet());
         List<QuestionResult> questionList = new ArrayList<>();
         for (String paperType : paperTypeSet) {
-            List<TBPaperStructResult> errorCellList = questionDatasource.stream()
-                    .filter(e -> paperType.equals(e.getPaperType()) && PaperStructJudgeEnum.NOT_QUITE_RIGHT.equals(e.getPaperStructJudge())).collect(Collectors.toList());
+            // 考题
+            List<TBPaperStructResult> cellList = questionDatasource.stream()
+                    .filter(e -> paperType.equals(e.getPaperType())).collect(Collectors.toList());
 
-            for (TBPaperStructResult cell : errorCellList) {
+            for (TBPaperStructResult cell : cellList) {
                 cell.setPaperType(null);
             }
             Set<String> knowledgeDimensionSet = new HashSet<>(), abilityDimensionSet = new HashSet<>();
-
+            // 错题
+            List<TBPaperStructResult> errorCellList = cellList.stream().filter(e -> PaperStructJudgeEnum.NOT_QUITE_RIGHT.equals(e.getPaperStructJudge())).collect(Collectors.toList());
             // 获取考察点集合
             for (TBPaperStructResult cell : errorCellList) {
                 String knowledgeDimension = cell.getKnowledgeDimension();
@@ -498,7 +500,7 @@ public class ReportCommonServiceImpl implements ReportCommonService {
                 }
                 abilityDimensionList.add(new DimensionInfoResult(dimensionCode, dimensionName));
             }
-            questionList.add(new QuestionResult(paperType, errorCellList, dimensionList, abilityDimensionList));
+            questionList.add(new QuestionResult(paperType, cellList, dimensionList, abilityDimensionList));
         }
         return new QuestionListResult(questionList);
     }

+ 26 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TAExamCourseTeacherCollegeDioServiceImpl.java

@@ -1,10 +1,19 @@
 package com.qmth.teachcloud.report.business.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherCollegeDio;
+import com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherDio;
 import com.qmth.teachcloud.report.business.mapper.TAExamCourseTeacherCollegeDioMapper;
+import com.qmth.teachcloud.report.business.mapper.TAExamCourseTeacherDioMapper;
 import com.qmth.teachcloud.report.business.service.TAExamCourseTeacherCollegeDioService;
+import com.qmth.teachcloud.report.business.service.TBExamService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * <p>
@@ -16,5 +25,22 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class TAExamCourseTeacherCollegeDioServiceImpl extends ServiceImpl<TAExamCourseTeacherCollegeDioMapper, TAExamCourseTeacherCollegeDio> implements TAExamCourseTeacherCollegeDioService {
+    @Resource
+    private TAExamCourseTeacherCollegeDioMapper taExamCourseTeacherCollegeDioMapper;
+    @Resource
+    private TBExamService tbExamService;
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void insertByTAExamCourseRecordDio(Long examId, String courseCode) {
+        if (examId == 0 || courseCode == null || courseCode.length() == 0) {
+            throw ExceptionResultEnum.ERROR.exception("参数异常");
+        }
+        List<TAExamCourseTeacherCollegeDio> taExamCourseTeacherCollegeDioList = taExamCourseTeacherCollegeDioMapper.findByTAExamCourseRecordDio(examId, courseCode);
+        for (TAExamCourseTeacherCollegeDio taExamCourseTeacherCollegeDio : taExamCourseTeacherCollegeDioList) {
+            taExamCourseTeacherCollegeDio.setSchoolId(tbExamService.getById(taExamCourseTeacherCollegeDio.getExamId()).getSchoolId());
+            taExamCourseTeacherCollegeDio.setId(SystemConstant.getDbUuid());
+        }
+        this.saveBatch(taExamCourseTeacherCollegeDioList);
+    }
 }

+ 27 - 0
teachcloud-report-business/src/main/resources/mapper/TAExamCourseTeacherCollegeDioMapper.xml

@@ -2,4 +2,31 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.teachcloud.report.business.mapper.TAExamCourseTeacherCollegeDioMapper">
 
+    <select id="findByTAExamCourseRecordDio"
+            resultType="com.qmth.teachcloud.report.business.entity.TAExamCourseTeacherCollegeDio">
+        SELECT
+            exam_id AS examId,
+            course_code AS courseCode,
+            MAX(course_name) AS courseName,
+            teacher_id AS teacherId,
+            MAX(teacher_name) AS teacherName,
+            inspect_college_id AS inspectCollegeId,
+            MAX(inspect_college_name) AS inspectCollegeName,
+            dimension_type AS dimensionType,
+            dimension_code AS dimensionCode,
+            AVG(student_score) AS avgScore,
+            AVG(score_rate) AS scoreRate
+        FROM
+            t_a_exam_course_record_dio
+        <where>
+            <if test="examId != null and examId > 0">
+                and exam_id = #{examId}
+            </if>
+            <if test="courseCode != null and courseCode.length > 0">
+                and course_code = #{courseCode}
+            </if>
+        </where>
+        GROUP BY exam_id , course_code , teacher_id , inspect_college_id , dimension_type , dimension_code
+        ORDER BY exam_id DESC , course_code , teacher_id , inspect_college_id , dimension_type , dimension_code;
+    </select>
 </mapper>

+ 2 - 0
teachcloud-report-business/src/main/resources/mapper/TBAnswerMapper.xml

@@ -38,6 +38,8 @@
             answer.sub_number AS subNumber,
             answer.score,
             record.id AS taExamRecordId,
+            record.inspect_college_id AS inspectCollegeId,
+            record.teacher_id AS teacherId,
             record.percent_grade AS percentGrade,
             record.paper_id AS paperId,
             record.paper_type AS paperType

+ 21 - 0
teachcloud-report/src/test/java/com/qmth/teachcloud/report/AnalyzeForStudentServiceTest.java

@@ -125,4 +125,25 @@ public class AnalyzeForStudentServiceTest {
         String courseCode = "1013";
         System.out.println(analyzeForReportService.updateCoursePublishStatus(examId,courseCode, PublishStatusEnum.WILL_COMPUTE));
     }
+
+    @Test
+    public void buildAnalyzeExamCourseTeacherCollegeDio(){
+        Long examId = 2L;
+        String courseCode = null;
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseTeacherCollegeDio(examId,courseCode));
+    }
+
+    @Test
+    public void buildAnalyzeExamCourseTeacherCollegeDifficult(){
+        Long examId = 2L;
+        String courseCode = null;
+        System.out.println(analyzeForReportService.buildAnalyzeExamCourseTeacherCollegeDifficult(examId,courseCode));
+    }
+
+    @Test
+    public void buildAnalyzeCollegePaperStruct(){
+        Long examId = 1L;
+        String courseCode = null;
+        System.out.println(analyzeForReportService.buildAnalyzeCollegePaperStruct(examId,courseCode));
+    }
 }