Explorar o código

add. 归档管理-报告数据(大题分析)

caozixuan hai 10 meses
pai
achega
c1f1bd4870

+ 23 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/archivescore/QuestionVo.java

@@ -1,16 +1,39 @@
 package com.qmth.teachcloud.mark.bean.archivescore;
 
+import io.swagger.annotations.ApiModelProperty;
+
 public class QuestionVo {
+	@ApiModelProperty("考生总数")
 	private Integer studentCount;
+
+	@ApiModelProperty("有得分总数")
 	private Integer scoreCount;
+
+	@ApiModelProperty("满分总数")
 	private Integer fullScoreCount;
+
+	@ApiModelProperty("考生在该题目的总得分")
 	private Double scoreSum;
+
+	@ApiModelProperty("题目名称")
 	private String title;
+
+	@ApiModelProperty("大题号")
 	private Integer mainNumber;
+
+	@ApiModelProperty("小题号")
 	private Integer subNumber;
+
+	@ApiModelProperty("该题分数")
 	private Double score;
+
+	@ApiModelProperty("平均分")
 	private Double avgScore;
+
+	@ApiModelProperty("有分率")
 	private Double scoreRate;
+
+	@ApiModelProperty("满分率")
 	private Double fullScoreRate;
 	public String getTitle() {
 		return title;

+ 25 - 9
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/archivescore/ScoreReportVo.java

@@ -1,28 +1,40 @@
 package com.qmth.teachcloud.mark.bean.archivescore;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.util.List;
 
 public class ScoreReportVo {
 
+	@ApiModelProperty("考试名称")
 	private String examName;
+
+	@ApiModelProperty("学期名称")
 	private String semesterName;
-	
+
+	@ApiModelProperty("考试概况")
 	private OverViewVo overview;
 
+	@ApiModelProperty("成绩分数段分析")
 	private List<ScoreRangeVo> scoreRange;
-	
+
 	private List<CollegeVo> college;
-	
+
 	private List<ClassVo> classData;
-	
+
 	private List<TeacherVo> teacher;
 
 	private List<TeacherClassVo> teacherClass;
-	
+
+	@ApiModelProperty("客观题成绩分析")
 	private List<QuestionVo> objective;
-	
+
+	@ApiModelProperty("主观题成绩分析")
 	private List<QuestionVo> subjective;
 
+	@ApiModelProperty("大题分析")
+	private List<QuestionVo> mainQuestionAnalysis;
+
 	public String getExamName() {
 		return examName;
 	}
@@ -103,9 +115,13 @@ public class ScoreReportVo {
 		this.subjective = subjective;
 	}
 
-	
-	
-	
+	public List<QuestionVo> getMainQuestionAnalysis() {
+		return mainQuestionAnalysis;
+	}
+
+	public void setMainQuestionAnalysis(List<QuestionVo> mainQuestionAnalysis) {
+		this.mainQuestionAnalysis = mainQuestionAnalysis;
+	}
 }
 
 

+ 119 - 14
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkStudentServiceImpl.java

@@ -1,7 +1,6 @@
 package com.qmth.teachcloud.mark.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -72,7 +71,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.ss.usermodel.IndexedColors;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.FileCopyUtils;
@@ -90,7 +88,6 @@ import java.awt.image.ColorConvertOp;
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -106,28 +103,28 @@ import java.util.stream.Collectors;
 @Service
 public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkStudent> implements MarkStudentService {
 
-    @Autowired
+    @Resource
     private MarkPaperService markPaperService;
 
     @Resource
     private MarkPaperPackageService markPaperPackageService;
 
-    @Autowired
+    @Resource
     private ScanPackageService scanPackageService;
 
-    @Autowired
+    @Resource
     private ScanPaperService scanPaperService;
 
-    @Autowired
+    @Resource
     private ScanPaperPageService scanPaperPageService;
 
-    @Autowired
+    @Resource
     private ScanOmrTaskService scanOmrTaskService;
 
-    @Autowired
+    @Resource
     private ScanAnswerCardService answerCardService;
 
-    @Autowired
+    @Resource
     private ScanStudentPaperService studentPaperService;
 
     @Resource
@@ -136,7 +133,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
     @Resource
     private TeachcloudCommonService teachcloudCommonService;
 
-    @Autowired
+    @Resource
     private ConcurrentService concurrentService;
 
     @Resource
@@ -151,7 +148,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
     @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
 
-    @Autowired
+    @Resource
     private MarkSubjectiveScoreService markSubjectiveScoreService;
 
     @Resource
@@ -1212,8 +1209,8 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
             double total = ret.getOverview().getStudentCount() - ret.getOverview().getAbsentCount();
             ret.getOverview().setPassRate(
                     Calculator.divide2String(Calculator.multiply(ret.getOverview().getPassCount(), 100), total, 2));
-            ret.getOverview().setExcellentRate(Calculator
-                    .divide2String(Calculator.multiply(ret.getOverview().getExcellentCount(), 100), total, 2));
+            ret.getOverview().setExcellentRate(
+                    Calculator.divide2String(Calculator.multiply(ret.getOverview().getExcellentCount(), 100), total, 2));
             ret.getOverview().setAvgScore(Calculator.round(ret.getOverview().getAvgScore(), 2));
         }
         List<ArchiveStudentVo> studentList = baseMapper.studentList(sysUser.getSchoolId(), query, dpr);
@@ -1280,6 +1277,7 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
                 vo.setAvgScore(Calculator.round(vo.getAvgScore(), 2));
             }
         }
+        fillMainQuestionAnalysis(ret, studentList, query.getExamId(), query.getPaperNumber());
         return ret;
     }
 
@@ -1488,6 +1486,113 @@ public class MarkStudentServiceImpl extends ServiceImpl<MarkStudentMapper, MarkS
         ret.setObjective(list);
     }
 
+    /**
+     * 填充大题分析
+     *
+     * @param ret           ret
+     * @param studentList   涉及的考生集合
+     * @param examId        考试id
+     * @param paperNumber   试卷编号
+     */
+    private void fillMainQuestionAnalysis(ScoreReportVo ret, List<ArchiveStudentVo> studentList, Long examId, String paperNumber) {
+        // 试卷结构数据
+        Map<String, QuestionVo> mainQuestionMap = new HashMap<>();
+
+        List<MarkQuestion> questionDatasource = markQuestionService.listByExamIdAndPaperNumberAndPaperType(examId,
+                paperNumber, null, null);
+        for (MarkQuestion question : questionDatasource) {
+            Integer mainNumber = question.getMainNumber();
+            String key = getMainQuestionMapKey(mainNumber, question.getObjective());
+            if (mainQuestionMap.containsKey(key)) {
+                QuestionVo questionVo = mainQuestionMap.get(key);
+                questionVo.setScore(questionVo.getScore() + question.getTotalScore());
+            } else {
+                QuestionVo questionVo = new QuestionVo();
+                questionVo.setMainNumber(mainNumber);
+                questionVo.setScore(question.getTotalScore());
+                questionVo.setTitle(question.getMainTitle());
+
+                // 初始化
+                questionVo.setStudentCount(0);
+                questionVo.setScoreCount(0);
+                questionVo.setFullScoreCount(0);
+                questionVo.setScoreSum(0.0);
+                mainQuestionMap.put(key, questionVo);
+            }
+        }
+
+        List<Long> studentIdList = studentList.stream().map(ArchiveStudentVo::getStudentId).distinct().collect(Collectors.toList());
+        List<MarkSubjectiveScore> subjectiveScoreDatasource = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(studentIdList)) {
+            subjectiveScoreDatasource = markSubjectiveScoreService.list(
+                    new QueryWrapper<MarkSubjectiveScore>().lambda().eq(MarkSubjectiveScore::getExamId, examId)
+                            .eq(MarkSubjectiveScore::getPaperNumber, paperNumber).in(MarkSubjectiveScore::getStudentId, studentIdList));
+        }
+
+        List<MarkQuestion> objectiveQuestions = questionDatasource.stream().filter(MarkQuestion::getObjective).collect(Collectors.toList());
+        for (ArchiveStudentVo studentVo : studentList) {
+            List<ScoreItem> scoreItemList = studentVo.getScoreList(true, objectiveQuestions);
+            for (String key : mainQuestionMap.keySet()) {
+                String[] arr = key.split("-");
+                int mainNumber = Integer.parseInt(arr[0]);
+                boolean objective = Boolean.parseBoolean(arr[1]);
+                QuestionVo questionVo = mainQuestionMap.get(key);
+                // 考生总数
+                questionVo.setStudentCount(questionVo.getStudentCount() + 1);
+                // 考生在大题得分
+                double studentScore = 0;
+                if (objective) {
+                    // 客观题处理
+                    List<ScoreItem> mainScoreItemList = scoreItemList.stream()
+                            .filter(e -> Objects.equals(mainNumber, e.getMainNumber())).collect(Collectors.toList());
+
+                    for (ScoreItem scoreItem : mainScoreItemList) {
+                        studentScore = studentScore + scoreItem.getScore();
+                    }
+                } else {
+                    // 主观题处理
+                    List<MarkSubjectiveScore> subjectiveScoreList = subjectiveScoreDatasource.stream()
+                            .filter(e -> Objects.equals(mainNumber, e.getMainNumber()) && Objects.equals(studentVo.getStudentId(), e.getStudentId())).collect(Collectors.toList());
+
+                    for (MarkSubjectiveScore markSubjectiveScore : subjectiveScoreList) {
+                        studentScore = studentScore + markSubjectiveScore.getScore();
+                    }
+                }
+                // 有得分总数
+                if (studentScore > 0) {
+                    questionVo.setScoreCount(questionVo.getScoreCount() + 1);
+                }
+                // 满分总数
+                if (studentScore == questionVo.getScore()) {
+                    questionVo.setFullScoreCount(questionVo.getFullScoreCount() + 1);
+                }
+                // 考生总得分
+                questionVo.setScoreSum(questionVo.getScoreSum() + studentScore);
+            }
+        }
+        List<QuestionVo> questionVoList = new ArrayList<>(mainQuestionMap.values());
+        questionVoList.sort(Comparator.comparingInt(QuestionVo::getMainNumber));
+        questionVoList.forEach(e -> {
+            Integer total = e.getStudentCount();
+            Double avgScore = 0D;
+            double scoreRate = 0D;
+            double fullScoreRate = 0D;
+            if (total != null && total > 0) {
+                avgScore = Calculator.round(Calculator.divide(e.getScoreSum(), total), 2);
+                scoreRate = Calculator.divide(e.getScoreCount(), total, 2);
+                fullScoreRate = Calculator.divide(e.getFullScoreCount(), total, 2);
+            }
+            e.setAvgScore(avgScore);
+            e.setScoreRate(scoreRate);
+            e.setFullScoreRate(fullScoreRate);
+        });
+        ret.setMainQuestionAnalysis(questionVoList);
+    }
+
+    private String getMainQuestionMapKey(Integer mainNumber, boolean objective){
+        return mainNumber + "-" + objective;
+    }
+
     private List<MarkStudentVo> listByExamIdAndPaperNumberAndNotAbsent(Long examId, String paperNumber) {
         MarkStudentQuery markStudentQuery = new MarkStudentQuery();
         markStudentQuery.setExamId(examId);