|
@@ -3,21 +3,19 @@ package com.qmth.teachcloud.report.business.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
-import com.qmth.teachcloud.report.business.bean.result.CourseInfoResult;
|
|
|
|
-import com.qmth.teachcloud.report.business.bean.result.DescriptiveStatisticsResult;
|
|
|
|
-import com.qmth.teachcloud.report.business.bean.result.TAExamCourseCollegeInspectResult;
|
|
|
|
-import com.qmth.teachcloud.report.business.bean.result.TBPaperInfoResult;
|
|
|
|
|
|
+import com.qmth.teachcloud.report.business.bean.result.*;
|
|
import com.qmth.teachcloud.report.business.entity.TBPaper;
|
|
import com.qmth.teachcloud.report.business.entity.TBPaper;
|
|
-import com.qmth.teachcloud.report.business.service.ReportCommonService;
|
|
|
|
-import com.qmth.teachcloud.report.business.service.TAExamCourseCollegeInspectService;
|
|
|
|
-import com.qmth.teachcloud.report.business.service.TBPaperService;
|
|
|
|
|
|
+import com.qmth.teachcloud.report.business.enums.GradeScopeEnum;
|
|
|
|
+import com.qmth.teachcloud.report.business.enums.PiecewiseScopeEnum;
|
|
|
|
+import com.qmth.teachcloud.report.business.service.*;
|
|
|
|
+import com.qmth.teachcloud.report.business.utils.AnalyzeScopeUtil;
|
|
|
|
+import com.qmth.teachcloud.report.business.utils.MathUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -37,6 +35,12 @@ public class ReportCommonServiceImpl implements ReportCommonService {
|
|
@Resource
|
|
@Resource
|
|
TAExamCourseCollegeInspectService taExamCourseCollegeInspectService;
|
|
TAExamCourseCollegeInspectService taExamCourseCollegeInspectService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TAExamCourseRecordService taExamCourseRecordService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TBDimensionService tbDimensionService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 学院学科报表查询科目信息
|
|
* 学院学科报表查询科目信息
|
|
*
|
|
*
|
|
@@ -71,7 +75,7 @@ public class ReportCommonServiceImpl implements ReportCommonService {
|
|
|
|
|
|
// 学院该科目的描述统计
|
|
// 学院该科目的描述统计
|
|
List<TAExamCourseCollegeInspectResult> collegeDescriptiveStatisticsList = taExamCourseCollegeInspectResultList
|
|
List<TAExamCourseCollegeInspectResult> collegeDescriptiveStatisticsList = taExamCourseCollegeInspectResultList
|
|
- .stream().filter(e -> collegeId.intValue() == e.getCollegeId().intValue()).collect(Collectors.toList());
|
|
|
|
|
|
+ .stream().filter(e -> collegeId.longValue() == e.getCollegeId().longValue()).collect(Collectors.toList());
|
|
if (collegeDescriptiveStatisticsList.size() != 1) {
|
|
if (collegeDescriptiveStatisticsList.size() != 1) {
|
|
throw ExceptionResultEnum.DATA_COUNT_EXCEPTION.exception();
|
|
throw ExceptionResultEnum.DATA_COUNT_EXCEPTION.exception();
|
|
}
|
|
}
|
|
@@ -95,7 +99,151 @@ public class ReportCommonServiceImpl implements ReportCommonService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Object findCourseDistribution(Long examId, String courseCode, Long collegeId) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public CollegeAndSchoolGradeDistributionResult findCourseDistribution(Long examId, String courseCode, Long collegeId) {
|
|
|
|
+ List<ExamRecordResult> examPaperTikForSchool = taExamCourseRecordService.findExamRecordByExamIdAndCourseCode(examId, courseCode);
|
|
|
|
+ List<ExamRecordResult> examPaperTikForCollege = examPaperTikForSchool
|
|
|
|
+ .stream().filter(e -> collegeId.longValue() == e.getCollegeId().longValue()).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ double colTotalCount = examPaperTikForCollege.size(); // 学院总参考人数
|
|
|
|
+ double schTotalCount = examPaperTikForSchool.size(); // 全校总参考人数
|
|
|
|
+ if (schTotalCount < 1 || colTotalCount < 1) {
|
|
|
|
+ throw ExceptionResultEnum.DATA_ERROR.exception();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 计算成绩分布图
|
|
|
|
+ List<GradeDistributionResult> gradeDistributionList = new ArrayList<>();
|
|
|
|
+ for (GradeScopeEnum value : GradeScopeEnum.values()) {
|
|
|
|
+ String describe = value.getDescribe();
|
|
|
|
+ double colCount = 0;
|
|
|
|
+ double schCount = 0;
|
|
|
|
+
|
|
|
|
+ Map<String, Object> scopeMap = AnalyzeScopeUtil.analyzeScope(value.getScope());
|
|
|
|
+ String minSign = String.valueOf(scopeMap.get("minSign"));
|
|
|
|
+ String maxSign = String.valueOf(scopeMap.get("maxSign"));
|
|
|
|
+ double minValue = Double.parseDouble(String.valueOf(scopeMap.get("minValue")));
|
|
|
|
+ double maxValue = Double.parseDouble(String.valueOf(scopeMap.get("maxValue")));
|
|
|
|
+ if ("(".equals(minSign) && ")".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue < e.getAssignedScore().doubleValue() && maxValue > e.getAssignedScore().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue < e.getAssignedScore().doubleValue() && maxValue > e.getAssignedScore().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("(".equals(minSign) && "]".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue < e.getAssignedScore().doubleValue() && maxValue >= e.getAssignedScore().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue < e.getAssignedScore().doubleValue() && maxValue >= e.getAssignedScore().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("[".equals(minSign) && ")".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getAssignedScore().doubleValue() && maxValue > e.getAssignedScore().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getAssignedScore().doubleValue() && maxValue > e.getAssignedScore().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("[".equals(minSign) && "]".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getAssignedScore().doubleValue() && maxValue >= e.getAssignedScore().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getAssignedScore().doubleValue() && maxValue >= e.getAssignedScore().doubleValue()).count();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ gradeDistributionList.add(new GradeDistributionResult(colCount, schCount, describe));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 计算分数段分布
|
|
|
|
+ List<PiecewiseDistributionResult> piecewiseDistributionList = new ArrayList<>();
|
|
|
|
+ for (PiecewiseScopeEnum value : PiecewiseScopeEnum.values()) {
|
|
|
|
+ String remark = value.getRemark();
|
|
|
|
+ String name = value.getName();
|
|
|
|
+ double colCount = 0;
|
|
|
|
+ double schCount = 0;
|
|
|
|
+
|
|
|
|
+ Map<String, Object> scopeMap = AnalyzeScopeUtil.analyzeScope(value.getScope());
|
|
|
|
+ String minSign = String.valueOf(scopeMap.get("minSign"));
|
|
|
|
+ String maxSign = String.valueOf(scopeMap.get("maxSign"));
|
|
|
|
+ double minValue = Double.parseDouble(String.valueOf(scopeMap.get("minValue")));
|
|
|
|
+ double maxValue = Double.parseDouble(String.valueOf(scopeMap.get("maxValue")));
|
|
|
|
+ if ("(".equals(minSign) && ")".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue < e.getPercentGrade().doubleValue() && maxValue > e.getPercentGrade().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue < e.getPercentGrade().doubleValue() && maxValue > e.getPercentGrade().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("(".equals(minSign) && "]".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue < e.getPercentGrade().doubleValue() && maxValue >= e.getPercentGrade().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue < e.getPercentGrade().doubleValue() && maxValue >= e.getPercentGrade().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("[".equals(minSign) && ")".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getPercentGrade().doubleValue() && maxValue > e.getPercentGrade().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getPercentGrade().doubleValue() && maxValue > e.getPercentGrade().doubleValue()).count();
|
|
|
|
+
|
|
|
|
+ } else if ("[".equals(minSign) && "]".equals(maxSign)) {
|
|
|
|
+ colCount = (int) examPaperTikForCollege.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getPercentGrade().doubleValue() && maxValue >= e.getPercentGrade().doubleValue()).count();
|
|
|
|
+ schCount = (int) examPaperTikForSchool.stream()
|
|
|
|
+ .filter(e -> minValue <= e.getPercentGrade().doubleValue() && maxValue >= e.getPercentGrade().doubleValue()).count();
|
|
|
|
+ }
|
|
|
|
+ double colCountRate = MathUtil.formatDouble2(colCount / colTotalCount * 100); //本院比率 保留2位小数
|
|
|
|
+ double schCountRate = MathUtil.formatDouble2(schCount / schTotalCount * 100); //全校比率 保留2位小数
|
|
|
|
+
|
|
|
|
+ piecewiseDistributionList.add(new PiecewiseDistributionResult(name, colCount, colCountRate, schCount, schCountRate, remark));
|
|
|
|
+ }
|
|
|
|
+ return new CollegeAndSchoolGradeDistributionResult(gradeDistributionList, piecewiseDistributionList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 学院学科报表查询维度
|
|
|
|
+ *
|
|
|
|
+ * @param examId
|
|
|
|
+ * @param courseCode
|
|
|
|
+ * @param collegeId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Object findDimensionInfo(Long examId, String courseCode, Long collegeId) {
|
|
|
|
+ List<Map<String, Object>> dimensionAnalyzeList = new ArrayList<>();
|
|
|
|
+ //查找维度
|
|
|
|
+ List<CourseDimensionResult> dimensionInfoDatasource = tbDimensionService.findDimensionInfo(examId, courseCode, collegeId);
|
|
|
|
+ if (dimensionInfoDatasource.size() < 1) {
|
|
|
|
+ throw ExceptionResultEnum.DATA_ERROR.exception();
|
|
|
|
+ }
|
|
|
|
+ Set<String> moduleSet = dimensionInfoDatasource.stream().map(e -> e.getModule()).collect(Collectors.toSet()); // 考察模块集合
|
|
|
|
+ for (String module : moduleSet) {
|
|
|
|
+ List<CourseDimensionResult> dimensionInfoList = dimensionInfoDatasource
|
|
|
|
+ .stream().filter(e -> module.equals(e.getModule())).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<DimensionInfoResult> dioList = new ArrayList<>();
|
|
|
|
+ List<DimensionInfoResult> batterThanAll = new ArrayList<>(); // 掌握较好
|
|
|
|
+ List<DimensionInfoResult> worseThanAll = new ArrayList<>(); // 掌握较差
|
|
|
|
+ for (CourseDimensionResult courseDimensionResult : dimensionInfoList) {
|
|
|
|
+ String dimensionCode = String.valueOf(courseDimensionResult.getDimensionCode());
|
|
|
|
+ String dimensionName = String.valueOf(courseDimensionResult.getDimensionName());
|
|
|
|
+
|
|
|
|
+ double schScoreRate = courseDimensionResult.getSchScoreRate();
|
|
|
|
+ double colScoreRate = courseDimensionResult.getColScoreRate();
|
|
|
|
+
|
|
|
|
+ if (colScoreRate >= schScoreRate) {
|
|
|
|
+ batterThanAll.add(new DimensionInfoResult(dimensionCode, dimensionName));
|
|
|
|
+ } else {
|
|
|
|
+ worseThanAll.add(new DimensionInfoResult(dimensionCode, dimensionName));
|
|
|
|
+ }
|
|
|
|
+ dioList.add(new DimensionInfoResult(dimensionCode, dimensionName, String.valueOf(courseDimensionResult.getTotalCount()), String.valueOf(schScoreRate), String.valueOf(colScoreRate)));
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> moduleMap = new HashMap<>();
|
|
|
|
+ moduleMap.put("moduleName", module);
|
|
|
|
+ moduleMap.put("dioList", dioList);
|
|
|
|
+ moduleMap.put("batterThanAll", batterThanAll);
|
|
|
|
+ moduleMap.put("worseThanAll", worseThanAll);
|
|
|
|
+ dimensionAnalyzeList.add(moduleMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> dimensionAnalyzeMap = new HashMap<>();
|
|
|
|
+ dimensionAnalyzeMap.put("dimensionAnalyzeList", dimensionAnalyzeList);
|
|
|
|
+ return dimensionAnalyzeMap;
|
|
}
|
|
}
|
|
}
|
|
}
|