Crazy 7 months ago
parent
commit
6725f1af0b

+ 9 - 10
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentAttendance/StudentAttendanceController.java

@@ -441,29 +441,28 @@ public class StudentAttendanceController {
         while (!currentDay.isAfter(endDate)) {
             attendanceReqVO.setDate(currentDay); // 设置为当前一天
             attendanceReqVO.setClockInStatus("0");
+            Set<String> normalSet = new HashSet<>();
             List<StudentAttendanceDO> normalList= studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+            for (StudentAttendanceDO attendance : normalList) {
+                normalSet.add(attendance.getUserNumber()); // 使用学生学号进行去重
+            }
+
             attendanceReqVO.setClockInStatus("1");
             List<StudentAttendanceDO> errorList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+
             attendanceReqVO.setClockInStatus("2");
             List<StudentAttendanceDO> excuseList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
 
             if (normalList.isEmpty()) {
                 result.getDailyNormalList().add(0);
             } else {
-                Set<String> uniqueNormalStudents = normalList.stream()
-                        .map(StudentAttendanceDO::getUserNumber)  // 获取学生名字
-                        .collect(Collectors.toSet());  // 转换为 Set 去重
-                result.getDailyNormalList().add(uniqueNormalStudents.size());
+                result.getDailyNormalList().add(normalSet.size());
             }
 
             if (errorList.isEmpty()) {
                 result.getDailyErrorList().add(0);
             } else {
-                //TODO未打卡的异常去重(以防万一)
-                Set<String> uniqueErrorStudents = normalList.stream()
-                        .map(StudentAttendanceDO::getUserNumber)  // 获取学生名字
-                        .collect(Collectors.toSet());  // 转换为 Set 去重
-                result.getDailyErrorList().add(uniqueErrorStudents.size());
+                result.getDailyErrorList().add(errorList.size());
             }
 
             if (excuseList.isEmpty()) {
@@ -498,7 +497,7 @@ public class StudentAttendanceController {
                 .map(StudentAttendanceDO::getUserNumber)  // 获取学生名字
                 .collect(Collectors.toSet());  // 转换为 Set 去重
         //TODO未打卡的异常去重(以防万一)
-        Set<String> uniqueErrorStudents = normalList.stream()
+        Set<String> uniqueErrorStudents = errorList.stream()
                 .map(StudentAttendanceDO::getUserNumber)  // 获取学生名字
                 .collect(Collectors.toSet());  // 转换为 Set 去重