教育训练处考试制证系统后端
zhangf
2024-09-11 1a316551c8e46b793904090cfa84781bf77fef2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.gkhy.exam.institutionalaccess.service.serviceImpl;
 
import com.gkhy.exam.institutionalaccess.model.query.ThStatisticQuery;
import com.gkhy.exam.institutionalaccess.model.resp.ThStatisticRespDTO;
import com.gkhy.exam.institutionalaccess.model.vo.ThTrainVO;
import com.gkhy.exam.institutionalaccess.service.ThExamRecordService;
import com.gkhy.exam.institutionalaccess.service.ThStudentBatchService;
import com.gkhy.exam.institutionalaccess.service.ThstatisticService;
import com.ruoyi.system.domain.InstitutionalManager;
import com.ruoyi.system.service.InstitutionalManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
 
@Service("ThstatisticService")
public class ThstatisticServiceImpl implements ThstatisticService {
    @Autowired
    private InstitutionalManagerService institutionalManagerService;
    @Autowired
    private ThStudentBatchService thStudentBatchService;
    @Autowired
    private ThExamRecordService thExamRecordService;
    @Override
    public List<ThStatisticRespDTO> getStatistic(ThStatisticQuery thStatisticQuery) {
        //获取所有平台
        List<InstitutionalManager> allList = institutionalManagerService.getAllList();
        //获取培训人员数量
        List<ThTrainVO> thTrainVOS = thStudentBatchService.getStatistic(thStatisticQuery);
        //获取考试数据
        List<ThTrainVO> examList = thExamRecordService.getStatistic(thStatisticQuery);
 
        //获取有考试的学生人数
        List<ThTrainVO> sudentCountList = thStudentBatchService.getStatisticHaveExam(thStatisticQuery);
 
        List<ThStatisticRespDTO> thStatisticRespDTOList = new ArrayList<ThStatisticRespDTO>();
        //循环平台
        for (InstitutionalManager institutionalManager : allList) {
            List<ThTrainVO> selectTrainVoList = thTrainVOS.stream().filter(thTrainVO -> thTrainVO.getInstitutionId().equals(institutionalManager.getId())).collect(Collectors.toList());
            ThStatisticRespDTO thStatisticRespDTO = new ThStatisticRespDTO();
            thStatisticRespDTO.setInstitutionName(institutionalManager.getInstitutionalName());
            if(selectTrainVoList.size() > 0){
                thStatisticRespDTO.setStudentCount(selectTrainVoList.get(0).getStudentCount());
                thStatisticRespDTO.setFinishCount(selectTrainVoList.get(0).getFinishCount());
            }else {
                thStatisticRespDTO.setStudentCount(0);
                thStatisticRespDTO.setFinishCount(0);
            }
            List<ThTrainVO> selectExamList = examList.stream().filter(thTrainVO -> thTrainVO.getInstitutionId().equals(institutionalManager.getId())).collect(Collectors.toList());
            if(selectExamList.size() > 0){
                thStatisticRespDTO.setPassCount(selectExamList.get(0).getPassCount());
            }else {
                thStatisticRespDTO.setPassCount(0);
            }
            //考试合格率
            List<ThTrainVO> selectList = sudentCountList.stream().filter(s -> s.getInstitutionId().equals(institutionalManager.getId())).collect(Collectors.toList());
            int examStudentCount = 0;
            if(selectList.size() > 0){
                examStudentCount = selectList.get(0).getStudentCount();
            }
            thStatisticRespDTO.setEaxmStudentCount(examStudentCount);
            if(examStudentCount > 0){
                thStatisticRespDTO.setPassRate((new BigDecimal(thStatisticRespDTO.getPassCount()).divide(new BigDecimal(examStudentCount), 2, BigDecimal.ROUND_HALF_UP)).multiply(new BigDecimal(100)));
            }else {
                thStatisticRespDTO.setPassRate(new BigDecimal(0));
            }
            thStatisticRespDTOList.add(thStatisticRespDTO);
 
        }
 
        return thStatisticRespDTOList;
    }
}