Explorar o código

考培档案统计bug处理

chenminghua hai 1 ano
pai
achega
4e4ee6cd2c

+ 2 - 1
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/impl/CourseServiceImpl.java

@@ -122,7 +122,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
 
         pageData.getRecords().stream().forEach(i->{
             SysUser user = baseService.getById(i.getCreateBy());
-            i.setCreateName(user.getRealName());
+            if (null != user)
+                i.setCreateName(user.getRealName());
         });
         return pageData;
     }

+ 2 - 18
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/impl/ExamServiceImpl.java

@@ -272,14 +272,12 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
 
         List<ExamDepartTotalDTO> allList = new ArrayList<>();
         List<ExamDepartTotalDTO> examList = baseMapper.examDepartTotal(reqDTO);
-        List<ExamDepartTotalDTO> examList2 = baseMapper.examDepartTotal2(reqDTO);
         List<ExamDepartTotalDTO> userList = baseMapper.selectUserTotal(reqDTO);
         List<String> exams = examList.stream().map(ExamDepartTotalDTO::getDeptCode).collect(Collectors.toList());
         List<String> users = userList.stream().map(ExamDepartTotalDTO::getDeptCode).collect(Collectors.toList());
         ExamDepartTotalDTO totalDTO = null;
         Map<String, List<ExamDepartTotalDTO>> groupexam = examList.stream().collect(Collectors.groupingBy(ExamDepartTotalDTO::getDeptCode));
         Map<String, List<ExamDepartTotalDTO>> groupuser = userList.stream().collect(Collectors.groupingBy(ExamDepartTotalDTO::getDeptCode));
-        Map<String, List<ExamDepartTotalDTO>> groupexam2 = examList2.stream().collect(Collectors.groupingBy(ExamDepartTotalDTO::getDeptCode));
 
         // 差集 (list1 - list2)
         List<String> reduce = exams.stream().filter(item -> !users.contains(item)).collect(Collectors.toList());
@@ -292,7 +290,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
             totalDTO.setDeptCode(groupexam.get(key).get(0).getDeptCode());
             totalDTO.setDeptName(groupexam.get(key).get(0).getDeptName());
             totalDTO.setEeActualUser(groupexam.get(key).get(0).getEeActualUser()+groupuser.get(key).get(0).getEeActualUser());
-            totalDTO.setEePassUser(null == groupexam2.get(key) ? 0 : groupexam2.get(key).get(0).getEePassUser()+groupuser.get(key).get(0).getEePassUser());
+            totalDTO.setEePassUser(groupexam.get(key).get(0).getEePassUser()+groupuser.get(key).get(0).getEePassUser());
             totalDTO.setEeTotalUser(groupexam.get(key).get(0).getEeTotalUser()+groupuser.get(key).get(0).getEeTotalUser());
             allList.add(totalDTO);
         }
@@ -301,14 +299,13 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
 
             List<ExamDepartTotalDTO> groupexams = groupexam.get(key)== null ? null : groupexam.get(key);
             List<ExamDepartTotalDTO> groupusers = groupuser.get(key) == null ? null : groupuser.get(key);
-            List<ExamDepartTotalDTO> groupexams2 = groupexam2.get(key)== null ? null : groupexam.get(key);
 
             totalDTO = new ExamDepartTotalDTO();
             totalDTO.setDeptCode(null != groupexams ? groupexams.get(0).getDeptCode() : groupusers.get(0).getDeptCode());
             totalDTO.setDeptName(null != groupexams ? groupexams.get(0).getDeptName() : groupusers.get(0).getDeptName());
             if (null != groupexams && groupexams.size() == 1){
                 totalDTO.setEeActualUser(groupexams.get(0).getEeActualUser());
-                totalDTO.setEePassUser(null == groupexams2 ? 0: groupexams2.get(0).getEePassUser());
+                totalDTO.setEePassUser(groupexams.get(0).getEePassUser());
                 totalDTO.setEeTotalUser(groupexams.get(0).getEeTotalUser());
                 allList.add(totalDTO);
             }
@@ -321,19 +318,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
             }
 
         }
-
-
-//
-//
-//        for (String key : intersection){
-//            totalDTO = new ExamDepartTotalDTO();
-//            totalDTO.setDeptCode(groupexam.get(key).get(0).getDeptCode());
-//            totalDTO.setDeptName(groupexam.get(key).get(0).getDeptName());
-//            totalDTO.setEeActualUser(groupexam.get(key).get(0).getEeActualUser()+groupuser.get(key).get(0).getEeActualUser());
-//            totalDTO.setEePassUser(groupexam.get(key).get(0).getEePassUser()+groupuser.get(key).get(0).getEePassUser());
-//            totalDTO.setEeTotalUser(groupexam.get(key).get(0).getEeTotalUser()+groupuser.get(key).get(0).getEeTotalUser());
-//            examList.add(totalDTO);
-//        }
         return allList;
     }
 

+ 1 - 1
exam-06173-api/src/main/resources/mapper/course/CourseMapper.xml

@@ -214,7 +214,7 @@
         sd.dept_name deptName,
         dept.dept_code deptCode,
         COUNT( uc.id) AS ecTotalUser,-- 应培训人数
-        COUNT(DISTINCT cl.user_id) AS ecActualUser,-- 学习人数
+        COUNT( cl.user_id) AS ecActualUser,-- 学习人数
         COUNT(IF( cl.state = 1 ,1, NULL)) AS ecPassUser -- 学完人数
         FROM el_course ec
         LEFT JOIN el_course_depart dept on ec.id =  dept.course_id

+ 2 - 2
exam-06173-api/src/main/resources/mapper/exam/ExamMapper.xml

@@ -201,9 +201,9 @@
         SELECT
         sd.dept_name deptName,
         dept.dept_code deptCode,
-        COUNT(uc.id) AS eeTotalUser,
+        COUNT(DISTINCT uc.id) AS eeTotalUser,
         COUNT(DISTINCT ue.user_id) AS eeActualUser,
-        COUNT(IF( ue.passed = 1 ,1, NULL)) AS eePassUser
+        COUNT(DISTINCT ue.user_id, IF(ue.passed = 1 ,1, NULL)) AS eePassUser
         FROM el_exam ee
         INNER JOIN el_exam_depart dept on ee.id = dept.exam_id
         LEFT JOIN sys_depart sd on sd.dept_code = dept.dept_code