| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.domain.*; |
| | | import com.mindskip.xzs.domain.enums.AnswerInvalidEnum; |
| | | import com.mindskip.xzs.domain.enums.ExamPaperAnswerStatusEnum; |
| | | import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum; |
| | | import com.mindskip.xzs.domain.enums.QuestionTypeEnum; |
| | |
| | | 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 PageInfo<ExamPaperAnswer> adminPage(com.mindskip.xzs.viewmodel.admin.paper.ExamPaperAnswerPageRequestVM requestVM) { |
| | | return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "user_score desc").doSelectPageInfo(() -> |
| | | return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "create_time desc").doSelectPageInfo(() -> |
| | | examPaperAnswerMapper.adminPage(requestVM)); |
| | | } |
| | | |
| | |
| | | @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; |
| | | } |
| | | |
| | |
| | | return dataByPaper; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void maxGrade(ExamPaperAnswer examPaperAnswer, Integer templateId) { |
| | | // 获取某一场考试曾经的最高成绩 |
| | | ExamPaperAnswer maxGrade; |
| | | if (Objects.equals(examPaperAnswer.getPaperType(), 7)) { |
| | | maxGrade = examPaperAnswerMapper.getTemplateOtherExamAnswer(examPaperAnswer, templateId); |
| | | } else { |
| | | maxGrade = examPaperAnswerMapper.getPaperOtherExamAnswer(examPaperAnswer); |
| | | } |
| | | if (Objects.isNull(maxGrade)) { |
| | | return; |
| | | } |
| | | // 本次考试分数不如之前,本次无效 |
| | | if (maxGrade.getUserScore() > examPaperAnswer.getUserScore()) { |
| | | // 之前的成绩有效 |
| | | maxGrade.setInvalid(AnswerInvalidEnum.VALID); |
| | | examPaperAnswerMapper.updateByPrimaryKeySelective(maxGrade); |
| | | // 本次的不是最高分,无效 |
| | | examPaperAnswer.setInvalid(AnswerInvalidEnum.INVALID); |
| | | examPaperAnswerMapper.updateByPrimaryKeySelective(examPaperAnswer); |
| | | } |
| | | } |
| | | |
| | | } |