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;
|
}
|
}
|