|
@@ -0,0 +1,80 @@
|
|
|
+package com.gyee.exam.modules.ectotal.service;
|
|
|
+
|
|
|
+
|
|
|
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
|
|
|
+import com.gyee.exam.modules.course.dto.response.CourseDepartTotalDTO;
|
|
|
+import com.gyee.exam.modules.course.service.CourseService;
|
|
|
+import com.gyee.exam.modules.ectotal.dto.response.ExamAndCourseTotalDTO;
|
|
|
+import com.gyee.exam.modules.exam.dto.response.ExamDepartTotalDTO;
|
|
|
+import com.gyee.exam.modules.exam.service.ExamService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ExamAndCourseTotalService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseService courseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ public List<ExamAndCourseTotalDTO> examAndCourseTotal(BaseQueryReqDTO reqDTO) {
|
|
|
+
|
|
|
+ List<ExamAndCourseTotalDTO> totalDTOS = new ArrayList<>();
|
|
|
+ List<CourseDepartTotalDTO> coursedtos = courseService.courseDepartTotal(reqDTO);
|
|
|
+ List<ExamDepartTotalDTO> examdtos = examService.examDepartTotal(reqDTO);
|
|
|
+
|
|
|
+ ExamAndCourseTotalDTO totalDTO = null;
|
|
|
+ if (coursedtos.size() >= examdtos.size()) {
|
|
|
+ Map<String, List<ExamDepartTotalDTO>> groupexamdtos = examdtos.stream().collect(Collectors.groupingBy(ExamDepartTotalDTO::getDeptCode));
|
|
|
+ for (int i = 0; i < coursedtos.size(); i++) {
|
|
|
+ totalDTO = new ExamAndCourseTotalDTO();
|
|
|
+ totalDTO.setDeptCode(coursedtos.get(i).getDeptCode());
|
|
|
+ totalDTO.setDeptName(coursedtos.get(i).getDeptName());
|
|
|
+ totalDTO.setEcTotalUser(coursedtos.get(i).getEcTotalUser());
|
|
|
+ totalDTO.setEcActualUser(coursedtos.get(i).getEcActualUser());
|
|
|
+ totalDTO.setEcPassUser(coursedtos.get(i).getEcPassUser());
|
|
|
+ totalDTO.setEcTotalMin(coursedtos.get(i).getEcTotalMin());
|
|
|
+ List<ExamDepartTotalDTO> groupexams = groupexamdtos.get(coursedtos.get(i).getDeptCode()) == null ? null : groupexamdtos.get(coursedtos.get(i).getDeptCode());
|
|
|
+ if (null != groupexams && groupexams.size() == 1) {
|
|
|
+ totalDTO.setEeTotalUser(groupexams.get(0).getEeTotalUser());
|
|
|
+ totalDTO.setEeActualUser(groupexams.get(0).getEePassUser());
|
|
|
+ totalDTO.setEePassUser(groupexams.get(0).getEePassUser());
|
|
|
+
|
|
|
+ }
|
|
|
+ totalDTOS.add(totalDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Map<String, List<CourseDepartTotalDTO>> groupcoursedtos = coursedtos.stream().collect(Collectors.groupingBy(CourseDepartTotalDTO::getDeptCode));
|
|
|
+ for (int i = 0; i < examdtos.size(); i++) {
|
|
|
+ totalDTO = new ExamAndCourseTotalDTO();
|
|
|
+ totalDTO.setDeptCode(examdtos.get(i).getDeptCode());
|
|
|
+ totalDTO.setDeptName(examdtos.get(i).getDeptName());
|
|
|
+ totalDTO.setEeTotalUser(examdtos.get(i).getEeTotalUser());
|
|
|
+ totalDTO.setEeActualUser(examdtos.get(i).getEePassUser());
|
|
|
+ totalDTO.setEePassUser(examdtos.get(i).getEePassUser());
|
|
|
+ List<CourseDepartTotalDTO> groupcourses = groupcoursedtos.get(examdtos.get(i).getDeptCode()) == null ? null : groupcoursedtos.get(examdtos.get(i).getDeptCode());
|
|
|
+
|
|
|
+ if (null != groupcourses && groupcourses.size() == 1) {
|
|
|
+ totalDTO.setEcTotalUser(groupcourses.get(0).getEcTotalUser());
|
|
|
+ totalDTO.setEcActualUser(groupcourses.get(0).getEcActualUser());
|
|
|
+ totalDTO.setEcPassUser(groupcourses.get(0).getEcPassUser());
|
|
|
+ totalDTO.setEcTotalMin(groupcourses.get(0).getEcTotalMin());
|
|
|
+ }
|
|
|
+ totalDTOS.add(totalDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return totalDTOS;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|