Browse Source

10.26,基本

Crazy 8 months ago
parent
commit
be7589f808

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

@@ -52,12 +52,12 @@ public class StudentAttendanceController {
     private DeptService deptService;
 
     //检测打卡情况并且创建警告的打卡记录
-    @Scheduled(cron = "0 20 21 * * ?") // 每天22:30检测
+    @Scheduled(cron = "0 49 14 * * ?") // 每天22:30检测
     public void attendanceNormal() {
         checkAttendanceSecond();
     }
 
-    @Scheduled(cron = "0 19 21 * * ?") // 每天11:00检测
+    @Scheduled(cron = "0 47 14 * * ?") // 每天11:00检测
     public void attendanceNormalMorning() {
         checkAttendanceFirst();
     }
@@ -73,7 +73,7 @@ public class StudentAttendanceController {
                     StudentAttendanceDO attendance = new StudentAttendanceDO();
                     attendance.setClockInStatus("1"); // 未打卡
                     attendance.setDate(localDate);
-                    attendance.setStudentName(user.getUsername()); // 名字
+                    attendance.setStudentName(user.getNickname()); // 名字
                     attendance.setStudentId(user.getId()); // id
                     attendance.setUserNumber(user.getUserNumber()); // 学号
                     attendance.setDeptId(user.getDeptId()); // 工作间id
@@ -231,10 +231,11 @@ public class StudentAttendanceController {
     }
 
 
+    //当周有一次警告则异常
     @GetMapping("/weekendAttendance")
     @Operation(summary = "周出勤统计")
     @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
-    public CommonResult<Map<String,Integer>> getWeekendAttendance () {
+    public CommonResult<weekendAttendanceResVO> getWeekendAttendance () {
         List<AdminUserDO>studentList = adminUserService.getAllUserList();
         //获取当天所在的一周内
         LocalDate today = LocalDate.now();
@@ -242,23 +243,39 @@ public class StudentAttendanceController {
         LocalDate endDate = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
         List<AdminUserDO> errorList =new ArrayList<>();
         List<AdminUserDO> normalList =new ArrayList<>();
-        for (AdminUserDO student :studentList){
-          List<StudentAttendanceDO> attendanceList = studentAttendanceService.getStudentAttendanceInRange(student.getUserNumber(),startDate,endDate);
-          for (StudentAttendanceDO attendance :attendanceList){
-              if ("2".equals(attendance.getClockInStatus())){//有一个警告就添加
-                  errorList.add(student);
-                  break;
-              }else{
-                  normalList.add(student);
-              }
-          }
+        List<String> errorNameList =new ArrayList<>();
+        List<String> normalNameList =new ArrayList<>();
+        for (AdminUserDO student : studentList) {
+            if ("1".equals(student.getUserType())) {
+                List<StudentAttendanceDO> attendanceList = studentAttendanceService.getStudentAttendanceInRange(student.getUserNumber(), startDate, endDate);
+                boolean hasWarning = false; // 标志位,表示是否有警告
+                if (attendanceList != null && !attendanceList.isEmpty()) {
+                    for (StudentAttendanceDO attendance : attendanceList) {
+                        System.out.println("Checking clockInStatus: " + attendance.getClockInStatus());
+                        if ("2".equals(attendance.getClockInStatus())) { // 有一个警告就添加
+                            errorList.add(student);
+                            errorNameList.add(student.getNickname());
+                            hasWarning = true; // 设置标志为 true
+                            System.out.println("异常的" + student.getUsername());
+                            break; // 跳出循环
+                        }
+                    }
+                    // 只有在没有警告的情况下才添加到正常列表
+                    if (!hasWarning) {
+                        normalList.add(student);
+                        normalNameList.add(student.getNickname());
+                        System.out.println("正常的: " + student.getUsername());
+                    }
+                }
+            }
         }
         Integer errorNum =errorList.size();
         Integer normalNum =normalList.size();
-        Map<String, Integer> result = new HashMap<>();
-        result.put("errorNum", errorNum);
-        result.put("normalNum", normalNum);
-
+        weekendAttendanceResVO result = new weekendAttendanceResVO();
+        result.setErrorNum(errorNum);
+        result.setNormalNum(normalNum);
+        result.setErrorNameList(errorNameList);
+        result.setNormalNameList(normalNameList);
         return success(result);
     }
 

+ 26 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentAttendance/vo/weekendAttendanceResVO.java

@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+
+@Schema(description = "管理后台 - 学生周考勤统计 Response VO")
+@Data
+public class weekendAttendanceResVO {
+    @Schema(description = "异常人数")
+    private  Integer errorNum;
+    @Schema(description = "正常人数")
+    private  Integer normalNum;
+
+    @Schema(description = "异常人员名字列表")
+    private List<String> errorNameList;
+
+    @Schema(description = "正常人员名字列表")
+    private List<String> normalNameList;
+
+
+
+}