Ver código fonte

日常更新

wangliang 4 anos atrás
pai
commit
d8c8309569

+ 6 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/result/TeacherClassRankResult.java

@@ -1,9 +1,14 @@
 package com.qmth.teachcloud.report.business.bean.result;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.io.Serializable;
+
 /**
  * @Date: 2021/6/8.
  */
-public class TeacherClassRankResult {
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class TeacherClassRankResult implements Serializable {
 
     private String teacherName;
     private String inspectCollegeName;

+ 92 - 18
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourse.java

@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
 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 io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Objects;
 
 /**
  * <p>
@@ -320,7 +322,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getAvgScore() {
-        return avgScore;
+        if (Objects.nonNull(avgScore)) {
+            return avgScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return avgScore;
+        }
     }
 
     public void setAvgScore(BigDecimal avgScore) {
@@ -352,7 +358,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentPassRate() {
-        return currentPassRate;
+        if (Objects.nonNull(currentPassRate)) {
+            return currentPassRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentPassRate;
+        }
     }
 
     public void setCurrentPassRate(BigDecimal currentPassRate) {
@@ -360,7 +370,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getTotalScore() {
-        return totalScore;
+        if (Objects.nonNull(totalScore)) {
+            return totalScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return totalScore;
+        }
     }
 
     public void setTotalScore(BigDecimal totalScore) {
@@ -392,7 +406,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentMinScore() {
-        return currentMinScore;
+        if (Objects.nonNull(currentMinScore)) {
+            return currentMinScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentMinScore;
+        }
     }
 
     public void setCurrentMinScore(BigDecimal currentMinScore) {
@@ -400,7 +418,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentMaxScore() {
-        return currentMaxScore;
+        if (Objects.nonNull(currentMaxScore)) {
+            return currentMaxScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentMaxScore;
+        }
     }
 
     public void setCurrentMaxScore(BigDecimal currentMaxScore) {
@@ -408,7 +430,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentAvgScore() {
-        return currentAvgScore;
+        if (Objects.nonNull(currentAvgScore)) {
+            return currentAvgScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentAvgScore;
+        }
     }
 
     public void setCurrentAvgScore(BigDecimal currentAvgScore) {
@@ -416,7 +442,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentScoreRate() {
-        return currentScoreRate;
+        if (Objects.nonNull(currentScoreRate)) {
+            return currentScoreRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentScoreRate;
+        }
     }
 
     public void setCurrentScoreRate(BigDecimal currentScoreRate) {
@@ -448,7 +478,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentRealityRate() {
-        return currentRealityRate;
+        if (Objects.nonNull(currentRealityRate)) {
+            return currentRealityRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentRealityRate;
+        }
     }
 
     public void setCurrentRealityRate(BigDecimal currentRealityRate) {
@@ -480,7 +514,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getPastRealityRate() {
-        return pastRealityRate;
+        if (Objects.nonNull(pastRealityRate)) {
+            return pastRealityRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return pastRealityRate;
+        }
     }
 
     public void setPastRealityRate(BigDecimal pastRealityRate) {
@@ -488,7 +526,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentUpperQuartile() {
-        return currentUpperQuartile;
+        if (Objects.nonNull(currentUpperQuartile)) {
+            return currentUpperQuartile.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentUpperQuartile;
+        }
     }
 
     public void setCurrentUpperQuartile(BigDecimal currentUpperQuartile) {
@@ -496,7 +538,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentMedian() {
-        return currentMedian;
+        if (Objects.nonNull(currentMedian)) {
+            return currentMedian.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentMedian;
+        }
     }
 
     public void setCurrentMedian(BigDecimal currentMedian) {
@@ -504,7 +550,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentLowerQuartile() {
-        return currentLowerQuartile;
+        if (Objects.nonNull(currentLowerQuartile)) {
+            return currentLowerQuartile.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentLowerQuartile;
+        }
     }
 
     public void setCurrentLowerQuartile(BigDecimal currentLowerQuartile) {
@@ -520,7 +570,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCurrentStandardDeviation() {
-        return currentStandardDeviation;
+        if (Objects.nonNull(currentStandardDeviation)) {
+            return currentStandardDeviation.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return currentStandardDeviation;
+        }
     }
 
     public void setCurrentStandardDeviation(BigDecimal currentStandardDeviation) {
@@ -536,7 +590,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getPaperAvgScore() {
-        return paperAvgScore;
+        if (Objects.nonNull(paperAvgScore)) {
+            return paperAvgScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return paperAvgScore;
+        }
     }
 
     public void setPaperAvgScore(BigDecimal paperAvgScore) {
@@ -544,7 +602,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getPaperCurrentAvgScore() {
-        return paperCurrentAvgScore;
+        if (Objects.nonNull(paperCurrentAvgScore)) {
+            return paperCurrentAvgScore.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return paperCurrentAvgScore;
+        }
     }
 
     public void setPaperCurrentAvgScore(BigDecimal paperCurrentAvgScore) {
@@ -552,7 +614,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getPaperPassRate() {
-        return paperPassRate;
+        if (Objects.nonNull(paperPassRate)) {
+            return paperPassRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return paperPassRate;
+        }
     }
 
     public void setPaperPassRate(BigDecimal paperPassRate) {
@@ -560,7 +626,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getPaperCurrentPassRate() {
-        return paperCurrentPassRate;
+        if (Objects.nonNull(paperCurrentPassRate)) {
+            return paperCurrentPassRate.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return paperCurrentPassRate;
+        }
     }
 
     public void setPaperCurrentPassRate(BigDecimal paperCurrentPassRate) {
@@ -568,7 +638,11 @@ public class TAExamCourse implements Serializable {
     }
 
     public BigDecimal getCoefficient() {
-        return coefficient;
+        if (Objects.nonNull(coefficient)) {
+            return coefficient.setScale(SystemConstant.FINAL_SCALE, BigDecimal.ROUND_HALF_UP);
+        } else {
+            return coefficient;
+        }
     }
 
     public void setCoefficient(BigDecimal coefficient) {

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

@@ -1,6 +1,7 @@
 package com.qmth.teachcloud.report.business.service;
 
 import com.qmth.teachcloud.report.business.bean.result.*;
+import com.qmth.teachcloud.report.business.entity.TAExamCourse;
 
 import java.util.List;
 
@@ -63,7 +64,7 @@ public interface ReportCommonService {
      * @param teacherId
      * @return
      */
-    QuestionInfoResult findSituationOfQuestions(Long examId, String courseCode, Long collegeId,Long teacherId);
+    QuestionInfoResult findSituationOfQuestions(Long examId, String courseCode, Long collegeId, Long teacherId);
 
     /**
      * 查找老师信息
@@ -84,4 +85,14 @@ public interface ReportCommonService {
      * @return
      */
     QuestionListResult findQuestionInfo(Long examId, String courseCode, Long collegeId);
+
+    /**
+     * 取总体平均分
+     *
+     * @param schoolId
+     * @param courseCode
+     * @param examId
+     * @return
+     */
+    SurveyTeacherExamCourseResult findAvgScore(Long schoolId, String courseCode, Long examId);
 }

+ 31 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/ReportCommonServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.Gson;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.report.business.bean.result.*;
+import com.qmth.teachcloud.report.business.entity.TAExamCourse;
 import com.qmth.teachcloud.report.business.entity.TBDimension;
 import com.qmth.teachcloud.report.business.entity.TBPaper;
 import com.qmth.teachcloud.report.business.enums.GradeScopeEnum;
@@ -16,6 +17,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -54,6 +56,9 @@ public class ReportCommonServiceImpl implements ReportCommonService {
     @Resource
     TBPaperStructService tbPaperStructService;
 
+    @Resource
+    TAExamCourseService taExamCourseService;
+
     /**
      * 学院学科报表查询科目信息
      *
@@ -464,4 +469,30 @@ public class ReportCommonServiceImpl implements ReportCommonService {
         }
         return new QuestionListResult(questionList);
     }
+
+    /**
+     * 取总体平均分
+     *
+     * @param schoolId
+     * @param courseCode
+     * @param examId
+     * @return
+     */
+    @Override
+    public SurveyTeacherExamCourseResult findAvgScore(Long schoolId, String courseCode, Long examId) {
+        //取总体和应届平均分
+        QueryWrapper<TAExamCourse> taExamCourseQueryWrapper = new QueryWrapper<>();
+        if (Objects.nonNull(schoolId)) {
+            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getSchoolId, schoolId);
+        }
+        if (Objects.nonNull(examId)) {
+            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getExamId, examId);
+        }
+        if (Objects.nonNull(courseCode)) {
+            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getCourseCode, courseCode);
+        }
+        TAExamCourse taExamCourse = taExamCourseService.getOne(taExamCourseQueryWrapper);
+        BigDecimal bigDecimal = new BigDecimal(1);
+        return new SurveyTeacherExamCourseResult(taExamCourse.getAvgScore(), bigDecimal.subtract(taExamCourse.getPassRate()), taExamCourse.getPaperCurrentAvgScore(), bigDecimal.subtract(taExamCourse.getPaperPassRate()));
+    }
 }

+ 21 - 45
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TAExamCourseServiceImpl.java

@@ -18,7 +18,6 @@ import com.qmth.teachcloud.report.business.mapper.TAExamCourseRecordMapper;
 import com.qmth.teachcloud.report.business.service.ReportCommonService;
 import com.qmth.teachcloud.report.business.service.TAExamCourseService;
 import com.qmth.teachcloud.report.business.service.TBPaperService;
-import com.qmth.teachcloud.report.business.service.TBPaperStructService;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
@@ -90,32 +89,21 @@ public class TAExamCourseServiceImpl extends ServiceImpl<TAExamCourseMapper, TAE
     @Override
     public Map<String, Object> getGradeDistribute(SemesterEnum semester, Long examId, String courseCode) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Map<String, Object> map = new HashMap<>();
-        // 不及格率
-        Map<String, String> scoreAndRate = taExamCourseMapper.getScoreAndRate(schoolId, Objects.nonNull(semester) ? semester.name() : null, examId, courseCode);
-        map.put("scoreAndRate", scoreAndRate);
-        // 成绩正态分布
-        String[] strings = {"90~100", "80~89", "70~79", "60~69", "55~59", "1~54"};
+        //取总体和应届平均分
+        SurveyTeacherExamCourseResult surveyTeacherExamCourseResult = reportCommonService.findAvgScore(schoolId, courseCode, examId);
+        map.put("scoreAndRate", surveyTeacherExamCourseResult);
+        //学院学科报表科目描述
         List<Map<String, Object>> mapList = new ArrayList<>();
-        for (String string : strings) {
-            String[] str = string.split("~");
-            double startScore = Double.parseDouble(str[0]);
-            double endScore = Double.parseDouble(str[1]);
-            List<TAExamCourseRecord> taExamCourseRecords = taExamCourseRecordMapper.listExamCourseRecord(schoolId, Objects.nonNull(semester) ? semester.name() : null, examId, courseCode);
-            // 全部有效人数
-            long totalRealityCount = taExamCourseRecords.stream().filter(m -> Objects.nonNull(m.getAbsent()) && !m.getAbsent()).count();
-            // 本分数段人数
-            long totalScoreCount = taExamCourseRecords.stream().filter(m -> m.getAssignedScore().doubleValue() >= startScore && m.getAssignedScore().doubleValue() <= endScore).count();
-            // 应届有效人数
-            long totalCurrentCount = taExamCourseRecords.stream().filter(m -> Objects.nonNull(m.getAbsent()) && !m.getAbsent() && Objects.nonNull(m.getStudentCurrent()) && m.getStudentCurrent()).count();
-            // 本分数段应届有效人数
-            long totalScoreCurrentCount = taExamCourseRecords.stream().filter(m -> m.getStudentCurrent() && m.getAssignedScore().doubleValue() >= startScore && m.getAssignedScore().doubleValue() <= endScore).count();
+        List<SurveyTeacherGradeDistributionResult> surveyTeacherGradeDistributionResultList = reportCommonService.surveyTeacherDistribution(examId, courseCode, sysUser.getOrgId());
+        for (SurveyTeacherGradeDistributionResult s : surveyTeacherGradeDistributionResultList) {
             Map<String, Object> objectMap = new HashMap<>();
-            objectMap.put("scores", String.join(",", str));
-            objectMap.put("totalRealityCount", totalRealityCount);
-            objectMap.put("totalRate", totalRealityCount == 0 ? 0 : new BigDecimal(totalScoreCount * 100).divide(new BigDecimal(totalRealityCount), 1, BigDecimal.ROUND_HALF_UP));
-            objectMap.put("currentRealityCount", totalCurrentCount);
-            objectMap.put("currentRate", totalCurrentCount == 0 ? 0 : new BigDecimal(totalScoreCurrentCount * 100).divide(new BigDecimal(totalCurrentCount), 1, BigDecimal.ROUND_HALF_UP));
+            objectMap.put("scores", String.join(",", s.getDescribe()));
+            objectMap.put("totalRate", s.getAllCountRateAfter());
+            objectMap.put("totalRealityCount", s.getAllCountBefore());
+            objectMap.put("currentRealityCount", s.getCurrentCountRateAfter());
+            objectMap.put("currentRate", s.getCurrentCountAfter());
             mapList.add(objectMap);
         }
         map.put("grades", mapList);
@@ -172,19 +160,7 @@ public class TAExamCourseServiceImpl extends ServiceImpl<TAExamCourseMapper, TAE
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
         //取总体和应届平均分
-        QueryWrapper<TAExamCourse> taExamCourseQueryWrapper = new QueryWrapper<>();
-        if (Objects.nonNull(schoolId)) {
-            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getSchoolId, schoolId);
-        }
-        if (Objects.nonNull(examId)) {
-            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getExamId, examId);
-        }
-        if (Objects.nonNull(courseCode)) {
-            taExamCourseQueryWrapper.lambda().eq(TAExamCourse::getCourseCode, courseCode);
-        }
-        TAExamCourse taExamCourse = this.getOne(taExamCourseQueryWrapper);
-        BigDecimal bigDecimal = new BigDecimal(1);
-        SurveyTeacherExamCourseResult surveyTeacherExamCourseResult = new SurveyTeacherExamCourseResult(taExamCourse.getAvgScore(), bigDecimal.subtract(taExamCourse.getPassRate()), taExamCourse.getPaperCurrentAvgScore(), bigDecimal.subtract(taExamCourse.getPaperPassRate()));
+        SurveyTeacherExamCourseResult surveyTeacherExamCourseResult = reportCommonService.findAvgScore(schoolId, courseCode, examId);
 
         //学院学科报表科目描述
         List<SurveyTeacherGradeDistributionResult> surveyTeacherGradeDistributionResultList = reportCommonService.surveyTeacherDistribution(examId, courseCode, sysUser.getOrgId());
@@ -301,20 +277,20 @@ public class TAExamCourseServiceImpl extends ServiceImpl<TAExamCourseMapper, TAE
         trialCalculationResult.setTotalCount(totalCount);
         trialCalculationResult.setCurrentCount(currentCount);
         // - 卷面-总体
-        trialCalculationResult.setAvgScore(BigDecimal.valueOf(paperTotalAvgScore).setScale(1,BigDecimal.ROUND_HALF_UP));
-        trialCalculationResult.setFailRate(paperTotalFailRate.setScale(1,BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setAvgScore(BigDecimal.valueOf(paperTotalAvgScore).setScale(1, BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setFailRate(paperTotalFailRate.setScale(1, BigDecimal.ROUND_HALF_UP));
         trialCalculationResult.setFailCount((int) paperTotalFailCount);
         // - 卷面-应届
-        trialCalculationResult.setCurrentAvgScore(BigDecimal.valueOf(paperCurrentAvgScore).setScale(1,BigDecimal.ROUND_HALF_UP));
-        trialCalculationResult.setCurrentFailRate(paperCurrentFailRate.setScale(1,BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setCurrentAvgScore(BigDecimal.valueOf(paperCurrentAvgScore).setScale(1, BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setCurrentFailRate(paperCurrentFailRate.setScale(1, BigDecimal.ROUND_HALF_UP));
         trialCalculationResult.setCurrentFailCount((int) paperCurrentFailCount);
         // - 赋分-总体
-        trialCalculationResult.setAvgScoreAssign(BigDecimal.valueOf(totalAvgScore).setScale(1,BigDecimal.ROUND_HALF_UP));
-        trialCalculationResult.setFailRateAssign(totalFailRate.setScale(1,BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setAvgScoreAssign(BigDecimal.valueOf(totalAvgScore).setScale(1, BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setFailRateAssign(totalFailRate.setScale(1, BigDecimal.ROUND_HALF_UP));
         trialCalculationResult.setFailCountAssign((int) totalFailCount);
         // - 赋分-应届
-        trialCalculationResult.setCurrentAvgScoreAssign(BigDecimal.valueOf(currentAvgScore).setScale(1,BigDecimal.ROUND_HALF_UP));
-        trialCalculationResult.setCurrentFailRateAssign(currentFailRate.setScale(1,BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setCurrentAvgScoreAssign(BigDecimal.valueOf(currentAvgScore).setScale(1, BigDecimal.ROUND_HALF_UP));
+        trialCalculationResult.setCurrentFailRateAssign(currentFailRate.setScale(1, BigDecimal.ROUND_HALF_UP));
         trialCalculationResult.setCurrentFailCountAssign((int) currentFailCount);
 
         return trialCalculationResult;

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

@@ -149,7 +149,7 @@
     <select id="listTeacherClassRank"
             resultType="com.qmth.teachcloud.report.business.bean.result.TeacherClassRankResult">
         SELECT
-        a.teach_college_name teachCollegeName,
+        a.inspect_college_name inspectCollegeName,
         a.teacher_name teacherName,
         round(a.avg_score_assign, 1) avgScoreAssign,
         a.teacher_rank `rank`
@@ -169,5 +169,6 @@
                 and a.course_code = #{courseCode}
             </if>
         </where>
+        order by a.inspect_college_name
     </select>
 </mapper>

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

@@ -139,8 +139,6 @@
             taecct.teacher_rank as teacherRank
         from
             t_a_exam_course_college_teacher taecct
-        join sys_org so on
-            so.id = taecct.inspect_college_id
         <where>
             <if test="schoolId != null and schoolId != ''">
                 and taecct.school_id = #{schoolId}