From d526b031d167f76ae22ad53d3221a59d38abc388 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期五, 24 五月 2024 18:08:23 +0800
Subject: [PATCH] feat:人数分布统计支持随机试卷

---
 src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
index cc3f478..3f362f2 100644
--- a/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
+++ b/src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -32,6 +32,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -317,7 +318,25 @@
     @Override
     public Map<String, Object> statistic(ExamPaperStatisticVO examPaperStatisticVO) {
         // 鑾峰彇鍘熷鏁版嵁
-        Map<String, Object> histogram = examPaperAnswerMapper.histogram(examPaperStatisticVO);
+        Map<String, Object> histogram;
+        ExamPaperDataExportVO examPaperDataExportVO;
+        if (Objects.equals(examPaperStatisticVO.getExamPaperType(), 7)) {
+            histogram = examPaperAnswerMapper.histogramByTemplate(examPaperStatisticVO);
+            examPaperDataExportVO = examPaperAnswerMapper.totalByTemplate(new ExamPaperDataVO().setId(examPaperStatisticVO.getExamPaperId()).setDeptIds(examPaperStatisticVO.getDepartmentId()));
+        } else {
+            histogram = examPaperAnswerMapper.histogram(examPaperStatisticVO);
+            examPaperDataExportVO = examPaperAnswerMapper.totalByPaper(new ExamPaperDataVO().setId(examPaperStatisticVO.getExamPaperId()).setDeptIds(examPaperStatisticVO.getDepartmentId()));
+        }
+
+        // 涓嶅瓨鍦ㄦ椂濉厖0
+        if (Objects.isNull(examPaperDataExportVO)) {
+            examPaperDataExportVO = new ExamPaperDataExportVO()
+                    .setExamTotal(examPaperAnswerMapper.getExamTotal(examPaperStatisticVO))
+                    .setFactPeopleTotal(0)
+                    .setAverageScore(BigDecimal.ZERO)
+                    .setReferencePercentage(BigDecimal.ZERO);
+        }
+
         Map<String, Object> pieChart = examPaperAnswerMapper.pieChart(examPaperStatisticVO);
         // 鍒濆鍖栫粨鏋滃鍣�
         HashMap<String, Object> map = new HashMap<>();
@@ -349,6 +368,7 @@
         map.put("score", score);
         map.put("age", age);
         map.put("examPeopleNum", examPeopleNum);
+        map.put("total", examPaperDataExportVO);
         return map;
     }
 

--
Gitblit v1.8.0