| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @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<>(); |
| | |
| | | map.put("score", score); |
| | | map.put("age", age); |
| | | map.put("examPeopleNum", examPeopleNum); |
| | | map.put("total", examPaperDataExportVO); |
| | | return map; |
| | | } |
| | | |