浏览代码

新需求的数据计算部分

caozixuan 3 年之前
父节点
当前提交
002d37e2ab

+ 13 - 7
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseTeacherCollegePaperStruct.java

@@ -5,9 +5,11 @@ 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;
 
+import java.awt.print.Paper;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Objects;
@@ -126,7 +128,7 @@ public class TAExamCourseTeacherCollegePaperStruct implements Serializable {
 
     @ApiModelProperty(value = "标准难度系数(得分率)")
     @TableField(value = "standard_score_rate")
-    private String standardScoreRate;
+    private BigDecimal standardScoreRate;
 
     @ApiModelProperty(value = "得分率")
     @TableField(value = "score_rate")
@@ -138,7 +140,7 @@ public class TAExamCourseTeacherCollegePaperStruct 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;
@@ -332,11 +334,15 @@ public class TAExamCourseTeacherCollegePaperStruct 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;
     }
 
@@ -360,11 +366,11 @@ public class TAExamCourseTeacherCollegePaperStruct 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;
     }
 }

+ 12 - 7
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourseTeacherPaperStruct.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 TAExamCourseTeacherPaperStruct 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 TAExamCourseTeacherPaperStruct 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 TAExamCourseTeacherPaperStruct 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 TAExamCourseTeacherPaperStruct 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;
     }
 }

+ 0 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/AnalyzeForReportService.java

@@ -112,7 +112,6 @@ public interface AnalyzeForReportService {
      * @param courseCode 课程编号
      * @return 结果
      */
-    // TODO: 2021/7/20  
     String buildAnalyzeCollegePaperStruct(Long examId,String courseCode);
 
     /**
@@ -121,7 +120,6 @@ public interface AnalyzeForReportService {
      * @param courseCode 课程编号
      * @return 结果
      */
-    // TODO: 2021/7/20  
     String buildAnalyzeTeacherPaperStruct(Long examId,String courseCode);
 
     /**
@@ -130,7 +128,6 @@ public interface AnalyzeForReportService {
      * @param courseCode 课程编号
      * @return 结果
      */
-    // TODO: 2021/7/20
     String buildAnalyzeTeacherCollegePaperStruct(Long examId,String courseCode);
 
     /**

+ 221 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -1063,19 +1063,237 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             }
             taExamCourseCollegePaperStructService.saveBatch(taExamCourseCollegePaperStructList);
         }
-        return " 't_a_paper_struct'表构建成功 ";
+        return "'t_a_exam_course_college_paper_struct'表构建成功 ";
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildAnalyzeTeacherPaperStruct(Long examId, String courseCode) {
-        return null;
+        // 可分析有效课程信息
+        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("基础试卷信息异常");
+            }
+            // 删除原有数据
+            taExamCourseTeacherPaperStructService.remove(new QueryWrapper<TAExamCourseTeacherPaperStruct>().lambda()
+                    .eq(TAExamCourseTeacherPaperStruct::getExamId, examId)
+                    .eq(TAExamCourseTeacherPaperStruct::getCourseCode, effectiveCourseCode));
+            List<TAExamCourseTeacherPaperStruct> taExamCourseTeacherPaperStructList = new ArrayList<>();
+            // 该课程有效试卷结构数据
+            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, effectiveCourseCode);
+            for (TBPaper tbPaper : tbPaperList) {
+                Long paperId = tbPaper.getId();
+                String paperType = tbPaper.getPaperType();
+
+                // 参考该试卷的考察学院id集合
+                Set<Long> teacherIdSet = answerDetailDtoList.stream()
+                        .filter(e -> paperId.equals(e.getPaperId()))
+                        .map(ValidAnswerDetailDto::getTeacherId)
+                        .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 teacherId : teacherIdSet) {
+                    String teacherName = sysUserService.getById(teacherId).getRealName();
+                    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()) &&
+                                        teacherId.equals(e.getTeacherId()) &&
+                                        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());
+
+                        TAExamCourseTeacherPaperStruct taExamCourseTeacherPaperStruct = new TAExamCourseTeacherPaperStruct();
+                        taExamCourseTeacherPaperStruct.setId(SystemConstant.getDbUuid());
+                        taExamCourseTeacherPaperStruct.setPaperStructId(paperStruct.getId());
+                        taExamCourseTeacherPaperStruct.setExamId(examId);
+                        taExamCourseTeacherPaperStruct.setSchoolId(tbExamService.getById(examId).getSchoolId());
+                        taExamCourseTeacherPaperStruct.setCourseCode(effectiveCourseCode);
+                        taExamCourseTeacherPaperStruct.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
+                        taExamCourseTeacherPaperStruct.setPaperId(paperId);
+                        taExamCourseTeacherPaperStruct.setTeacherId(teacherId);
+                        taExamCourseTeacherPaperStruct.setTeacherName(teacherName);
+                        taExamCourseTeacherPaperStruct.setPaperType(paperType);
+                        taExamCourseTeacherPaperStruct.setQuestionName(paperStruct.getQuestionName());
+                        taExamCourseTeacherPaperStruct.setNumberType(paperStruct.getNumberType());
+                        taExamCourseTeacherPaperStruct.setBigQuestionNumber(paperStruct.getBigQuestionNumber());
+                        taExamCourseTeacherPaperStruct.setSmallQuestionNumber(paperStruct.getSmallQuestionNumber());
+                        taExamCourseTeacherPaperStruct.setQuestionType(paperStruct.getQuestionType());
+                        taExamCourseTeacherPaperStruct.setFullScore(paperStruct.getFullScore());
+                        taExamCourseTeacherPaperStruct.setScoreRules(paperStruct.getScoreRules());
+                        taExamCourseTeacherPaperStruct.setRulesDesc(paperStruct.getRulesDesc());
+                        taExamCourseTeacherPaperStruct.setKnowledgeDimension(paperStruct.getKnowledgeDimension());
+                        taExamCourseTeacherPaperStruct.setAbilityDimension(paperStruct.getAbilityDimension());
+                        taExamCourseTeacherPaperStruct.setLiteracyDimension(paperStruct.getLiteracyDimension());
+                        taExamCourseTeacherPaperStruct.setStandardScoreRate(standardScoreRate);
+                        taExamCourseTeacherPaperStruct.setScoreRate(scoreRate);
+                        taExamCourseTeacherPaperStruct.setDifficult(difficult);
+                        taExamCourseTeacherPaperStruct.setPaperStructJudge(paperStructJudgeEnum);
+                        taExamCourseTeacherPaperStructList.add(taExamCourseTeacherPaperStruct);
+                    }
+                }
+
+            }
+            taExamCourseTeacherPaperStructService.saveBatch(taExamCourseTeacherPaperStructList);
+        }
+        return "'t_a_exam_course_teacher_paper_struct'表构建成功 ";
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
     public String buildAnalyzeTeacherCollegePaperStruct(Long examId, String courseCode) {
-        return null;
+        // 可分析有效课程信息
+        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("基础试卷信息异常");
+            }
+            // 删除原有数据
+            taExamCourseTeacherCollegePaperStructService.remove(new QueryWrapper<TAExamCourseTeacherCollegePaperStruct>().lambda()
+                    .eq(TAExamCourseTeacherCollegePaperStruct::getExamId, examId)
+                    .eq(TAExamCourseTeacherCollegePaperStruct::getCourseCode, effectiveCourseCode));
+            List<TAExamCourseTeacherCollegePaperStruct> tAExamCourseTeacherCollegePaperStructList = new ArrayList<>();
+            // 该课程有效试卷结构数据
+            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, effectiveCourseCode);
+            for (TBPaper tbPaper : tbPaperList) {
+                Long paperId = tbPaper.getId();
+                String paperType = tbPaper.getPaperType();
+
+                // 参考该试卷的考察学院id集合
+                Set<Long> teacherIdSet = answerDetailDtoList.stream()
+                        .filter(e -> paperId.equals(e.getPaperId()))
+                        .map(ValidAnswerDetailDto::getTeacherId)
+                        .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 teacherId : teacherIdSet) {
+                    /**
+                     * 教师下
+                     */
+                    String teacherName = sysUserService.getById(teacherId).getRealName();
+
+                    // 参考该试卷的考察学院id集合
+                    Set<Long> inspectCollegeIdSet = answerDetailDtoList.stream()
+                            .filter(e -> paperId.equals(e.getPaperId()))
+                            .filter(e -> teacherId.equals(e.getTeacherId()))
+                            .map(ValidAnswerDetailDto::getInspectCollegeId)
+                            .collect(Collectors.toSet());
+
+                    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()) &&
+                                            teacherId.equals(e.getTeacherId()) &&
+                                            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());
+
+                            TAExamCourseTeacherCollegePaperStruct taExamCourseTeacherCollegePaperStruct = new TAExamCourseTeacherCollegePaperStruct();
+                            taExamCourseTeacherCollegePaperStruct.setId(SystemConstant.getDbUuid());
+                            taExamCourseTeacherCollegePaperStruct.setPaperStructId(paperStruct.getId());
+                            taExamCourseTeacherCollegePaperStruct.setExamId(examId);
+                            taExamCourseTeacherCollegePaperStruct.setSchoolId(tbExamService.getById(examId).getSchoolId());
+                            taExamCourseTeacherCollegePaperStruct.setCourseCode(effectiveCourseCode);
+                            taExamCourseTeacherCollegePaperStruct.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
+                            taExamCourseTeacherCollegePaperStruct.setPaperId(paperId);
+                            taExamCourseTeacherCollegePaperStruct.setTeacherId(teacherId);
+                            taExamCourseTeacherCollegePaperStruct.setTeacherName(teacherName);
+                            taExamCourseTeacherCollegePaperStruct.setInspectCollegeId(inspectCollegeId);
+                            taExamCourseTeacherCollegePaperStruct.setInspectCollegeName(inspectCollegeName);
+                            taExamCourseTeacherCollegePaperStruct.setPaperType(paperType);
+                            taExamCourseTeacherCollegePaperStruct.setQuestionName(paperStruct.getQuestionName());
+                            taExamCourseTeacherCollegePaperStruct.setNumberType(paperStruct.getNumberType());
+                            taExamCourseTeacherCollegePaperStruct.setBigQuestionNumber(paperStruct.getBigQuestionNumber());
+                            taExamCourseTeacherCollegePaperStruct.setSmallQuestionNumber(paperStruct.getSmallQuestionNumber());
+                            taExamCourseTeacherCollegePaperStruct.setQuestionType(paperStruct.getQuestionType());
+                            taExamCourseTeacherCollegePaperStruct.setFullScore(paperStruct.getFullScore());
+                            taExamCourseTeacherCollegePaperStruct.setScoreRules(paperStruct.getScoreRules());
+                            taExamCourseTeacherCollegePaperStruct.setRulesDesc(paperStruct.getRulesDesc());
+                            taExamCourseTeacherCollegePaperStruct.setKnowledgeDimension(paperStruct.getKnowledgeDimension());
+                            taExamCourseTeacherCollegePaperStruct.setAbilityDimension(paperStruct.getAbilityDimension());
+                            taExamCourseTeacherCollegePaperStruct.setLiteracyDimension(paperStruct.getLiteracyDimension());
+                            taExamCourseTeacherCollegePaperStruct.setStandardScoreRate(standardScoreRate);
+                            taExamCourseTeacherCollegePaperStruct.setScoreRate(scoreRate);
+                            taExamCourseTeacherCollegePaperStruct.setDifficult(difficult);
+                            taExamCourseTeacherCollegePaperStruct.setPaperStructJudge(paperStructJudgeEnum);
+                            tAExamCourseTeacherCollegePaperStructList.add(taExamCourseTeacherCollegePaperStruct);
+                        }
+
+                    }
+                }
+
+            }
+            taExamCourseTeacherCollegePaperStructService.saveBatch(tAExamCourseTeacherCollegePaperStructList);
+        }
+        return "'t_a_exam_course_teacher_college_paper_struct'表构建成功 ";
     }
 
     @Transactional(rollbackFor = Exception.class)

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

@@ -5,6 +5,7 @@
     <select id="findQuestionInfo" resultType="com.qmth.teachcloud.report.business.bean.result.TBPaperStructResult">
         SELECT
             paper_type AS paperType,
+            question_name AS questionName,
             big_question_number AS mainNumber,
             small_question_number AS subNumber,
             full_score AS fullScore,

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

@@ -146,4 +146,18 @@ public class AnalyzeForStudentServiceTest {
         String courseCode = null;
         System.out.println(analyzeForReportService.buildAnalyzeCollegePaperStruct(examId,courseCode));
     }
+
+    @Test
+    public void buildAnalyzeTeacherPaperStruct(){
+        Long examId = 1L;
+        String courseCode = null;
+        System.out.println(analyzeForReportService.buildAnalyzeTeacherPaperStruct(examId,courseCode));
+    }
+
+    @Test
+    public void buildAnalyzeTeacherCollegePaperStruct(){
+        Long examId = 1L;
+        String courseCode = null;
+        System.out.println(analyzeForReportService.buildAnalyzeTeacherCollegePaperStruct(examId,courseCode));
+    }
 }