Crazy 8 months ago
parent
commit
b6eedfa6f2

+ 44 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java

@@ -123,17 +123,35 @@ public class DeptController {
     @PreAuthorize("@ss.hasPermission('system:dept:query')")
     public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
         List<DeptDO> list = deptService.getDeptList(reqVO);
+        UserPageReqVO req =new UserPageReqVO();
         for (DeptDO L :list){
             DeptRespVO newDept =BeanUtils.toBean(L, DeptRespVO.class);
             List<Long> leaderUserIds = newDept.getLeaderUserId();
             List<AdminUserDO> userList =  new ArrayList<>();
-            if (leaderUserIds.size()>0) {
+            if (leaderUserIds!=null&&!leaderUserIds.isEmpty()) {
                 for (Long leaderUserId : leaderUserIds) {
                     AdminUserDO user = (leaderUserId != null) ? adminUserService.getUser(leaderUserId) : null;
                     userList.add(user);
                 }
                 newDept.setUser(userList);
             }
+//            //毕业达成率
+//            req.setDeptId(L.getId());
+//            List<AdminUserDO> studentList =adminUserService.getUserList1(req);//获取这个工作间下的学生
+//
+//            // 计算毕业达成率
+//            if (studentList != null && !studentList.isEmpty()) {
+//                long totalStudents = studentList.size();
+//                long graduatedStudents = studentList.stream()
+//                        .filter(student -> student.getIsGraduate() == 0) // isGraduate == 0 代表已达成毕业条件
+//                        .count();
+//
+//                // 计算达成率
+//                double graduationRate = (double) graduatedStudents / totalStudents * 100;  // 转换成百分比
+//                L.setGraduationRate(graduationRate);  // 设置到部门对象 L 中
+//            } else {
+//                L.setGraduationRate(Double.valueOf(0));  // 如果没有学生,则设定为 0
+//            }
         }
         return success(BeanUtils.toBean(list, DeptRespVO.class));
     }
@@ -243,4 +261,29 @@ public class DeptController {
         return success(newDept);
     }
 
+    @GetMapping("/getGraduationSource")
+    @Operation(summary = "获取毕业达成率")
+    public CommonResult<List<DeptRespVO>> getGraduationSource(DeptListReqVO reqVO) {
+        List<DeptDO> list = deptService.getDeptList(reqVO);
+        UserPageReqVO req =new UserPageReqVO();
+        for (DeptDO dept :list){
+            //毕业达成率
+            req.setDeptId(dept.getId());
+            List<AdminUserDO> studentList =adminUserService.getUserList1(req);//获取这个工作间下的学生
+            // 计算毕业达成率
+            if (studentList != null && !studentList.isEmpty()) {
+                long totalStudents = studentList.size();
+                long graduatedStudents = studentList.stream()
+                        .filter(student -> student.getIsGraduate() == 0) //
+                        .count();
+                // 计算达成率
+                double graduationRate = (double) graduatedStudents / totalStudents * 100;  // 转换成百分比
+                dept.setGraduationRate(graduationRate);
+            } else {
+                dept.setGraduationRate(Double.valueOf(0));  // 如果没有学生,则设定为 0
+            }
+        }
+        return success(BeanUtils.toBean(list, DeptRespVO.class));
+    }
+
 }

+ 3 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptRespVO.java

@@ -58,4 +58,7 @@ public class DeptRespVO {
     @Schema(description = "负责人信息")
     private List<AdminUserDO> user;
 
+    @Schema(description = "毕业达成率")
+    private Double graduationRate;
+
 }

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

@@ -328,68 +328,140 @@ public class StudentAttendanceController {
 
 
 
-    //当周有一次未打卡则异常
+//    //当周有一次未打卡则异常
+//    @GetMapping("/weekendAttendance")
+//    @Operation(summary = "周出勤统计")
+////    @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
+//    public CommonResult<weekendAttendanceResVO> getWeekendAttendance () {
+//
+//        //获取当天所在的一周内
+//        LocalDate today = LocalDate.now();
+//        LocalDate startDate = today.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY));
+//        LocalDate endDate = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
+////        reqVO.setDateRange(startDate,endDate);
+//        //每天的正常/未打卡/请假
+//
+//        Map<LocalDate, Object> dailyNormalList = new HashMap<>();
+//        Map<LocalDate, Object> dailyErrorList = new HashMap<>();
+//        Map<LocalDate, Object> dailyExcuseList = new HashMap<>();
+//
+//        LocalDate currentDay = startDate;
+//        while (!currentDay.isAfter(endDate)) {//不等于最后一天
+//            dailyNormalList.put(currentDay, new ArrayList<>());
+//            dailyErrorList.put(currentDay, new ArrayList<>());
+//            dailyExcuseList.put(currentDay, new ArrayList<>());
+//            currentDay = currentDay.plusDays(1);
+//        }
+//
+//        currentDay = startDate;//重新设置
+//        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+//        while (!currentDay.isAfter(endDate)) {
+//            attendanceReqVO.setDate(currentDay); // 设置为当前一天
+//            attendanceReqVO.setClockInStatus("0");
+//            List<StudentAttendanceDO> normalList= studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+//            attendanceReqVO.setClockInStatus("1");
+//            List<StudentAttendanceDO> errorList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+//            attendanceReqVO.setClockInStatus("2");
+//            List<StudentAttendanceDO> excuseList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+//
+//            // 如果当天没有打卡记录,则添加该学生到对应日期的错误列表中
+//            if (!normalList.isEmpty()) {
+//                dailyNormalList.put(currentDay,normalList.size());
+//            }
+//            if (!errorList.isEmpty()) {
+//                dailyErrorList.put(currentDay,errorList.size());
+//            }
+//            if (!excuseList.isEmpty()) {
+//                dailyExcuseList.put(currentDay,excuseList.size());
+//            }
+//            // 转到下一个日期
+//            currentDay = currentDay.plusDays(1);
+//        }
+//        weekendAttendanceResVO result = new weekendAttendanceResVO();
+//        result.setDailyNormalList(dailyNormalList);
+//        result.setDailyErrorList(dailyErrorList);
+//        result.setDailyExcuseList(dailyExcuseList);
+//        return success(result);
+//    }
+
     @GetMapping("/weekendAttendance")
     @Operation(summary = "周出勤统计")
 //    @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
     public CommonResult<weekendAttendanceResVO> getWeekendAttendance () {
-        List<AdminUserDO>studentList = adminUserService.getAllUserList();
+
         //获取当天所在的一周内
         LocalDate today = LocalDate.now();
         LocalDate startDate = today.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY));
         LocalDate endDate = today.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
-        StudentAttendancePageReqVO reqVO =new StudentAttendancePageReqVO();
-        reqVO.setDateRange(startDate,endDate);
-        List<AdminUserDO> errorList = new ArrayList<>();
-        List<AdminUserDO> normalList = new ArrayList<>();
-        for (AdminUserDO student : studentList) {
-            if ("1".equals(student.getUserType())) {
-                reqVO.setUserNumber(student.getUserNumber());
-                reqVO.setClockInStatus("1");//找他未打卡的
-                List<StudentAttendanceDO> attendanceList = studentAttendanceService.getStudentAttendanceList(reqVO);
-                if (!attendanceList.isEmpty()) {
-                    errorList.add(student);
-                } else {
-                    normalList.add(student);
-                }
+//        reqVO.setDateRange(startDate,endDate);
+        //每天的正常/未打卡/请假
+
+        Map<LocalDate, Object> dailyNormalList = new HashMap<>();
+        Map<LocalDate, Object> dailyErrorList = new HashMap<>();
+        Map<LocalDate, Object> dailyExcuseList = new HashMap<>();
+
+        LocalDate currentDay = startDate;
+        while (!currentDay.isAfter(endDate)) {//不等于最后一天
+            dailyNormalList.put(currentDay, new ArrayList<>());
+            dailyErrorList.put(currentDay, new ArrayList<>());
+            dailyExcuseList.put(currentDay, new ArrayList<>());
+            currentDay = currentDay.plusDays(1);
+        }
+
+        currentDay = startDate;//重新设置
+        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+        while (!currentDay.isAfter(endDate)) {
+            attendanceReqVO.setDate(currentDay); // 设置为当前一天
+            attendanceReqVO.setClockInStatus("0");
+            List<StudentAttendanceDO> normalList= studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+            attendanceReqVO.setClockInStatus("1");
+            List<StudentAttendanceDO> errorList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+            attendanceReqVO.setClockInStatus("2");
+            List<StudentAttendanceDO> excuseList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+
+            // 如果当天没有打卡记录,则添加该学生到对应日期的错误列表中
+            if (!normalList.isEmpty()) {
+                dailyNormalList.put(currentDay,normalList.size());
+            }
+            if (!errorList.isEmpty()) {
+                dailyErrorList.put(currentDay,errorList.size());
+            }
+            if (!excuseList.isEmpty()) {
+                dailyExcuseList.put(currentDay,excuseList.size());
             }
+            // 转到下一个日期
+            currentDay = currentDay.plusDays(1);
         }
-        Integer errorNum =errorList.size();
-        Integer normalNum =normalList.size();
         weekendAttendanceResVO result = new weekendAttendanceResVO();
-        result.setErrorNum(errorNum);
-        result.setNormalNum(normalNum);
+        result.setDailyNormalList(dailyNormalList);
+        result.setDailyErrorList(dailyErrorList);
+        result.setDailyExcuseList(dailyExcuseList);
         return success(result);
     }
 
 
+
     @GetMapping("/dayAttendanceCount")
     @Operation(summary = "日出勤统计")
     public CommonResult<weekendAttendanceResVO> getDayAttendance () {
-        List<AdminUserDO>studentList = adminUserService.getAllUserList();
+
         LocalDate today = LocalDate.now();
+        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+        attendanceReqVO.setDate(today);
+        attendanceReqVO.setClockInStatus("0");
+        List<StudentAttendanceDO> normalList= studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+        attendanceReqVO.setClockInStatus("1");
+        List<StudentAttendanceDO> errorList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
+        attendanceReqVO.setClockInStatus("2");
+        List<StudentAttendanceDO> excuseList = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);
 
-        StudentAttendancePageReqVO reqVO =new StudentAttendancePageReqVO();
-        reqVO.setDate(today);
-        List<AdminUserDO> errorList = new ArrayList<>();
-        List<AdminUserDO> normalList = new ArrayList<>();
-        for (AdminUserDO student : studentList) {
-            if ("1".equals(student.getUserType())) {
-                reqVO.setUserNumber(student.getUserNumber());
-                reqVO.setClockInStatus("1");//找他未打卡的
-                List<StudentAttendanceDO> attendanceList = studentAttendanceService.getStudentAttendanceList(reqVO);
-                if (!attendanceList.isEmpty()) {
-                    errorList.add(student);
-                } else {
-                    normalList.add(student);
-                }
-            }
-        }
         Integer errorNum =errorList.size();
         Integer normalNum =normalList.size();
+        Integer excuseNum =excuseList.size();
         weekendAttendanceResVO result = new weekendAttendanceResVO();
         result.setErrorNum(errorNum);
         result.setNormalNum(normalNum);
+        result.setExcuseNum(excuseNum);
         return success(result);
     }
 

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

@@ -4,16 +4,28 @@ package cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.time.LocalDate;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 
 @Schema(description = "管理后台 - 学生周考勤统计 Response VO")
 @Data
 public class weekendAttendanceResVO {
-    @Schema(description = "异常人数")
-    private  Integer errorNum;
     @Schema(description = "正常人数")
     private  Integer normalNum;
+    @Schema(description = "异常人数")
+    private  Integer errorNum;
+    @Schema(description = "请假人数")
+    private  Integer excuseNum;
+
+    @Schema(description = "每天正常人数")
+    private Map<LocalDate, Object> dailyNormalList;
+    @Schema(description = "每天异常人数")
+    private Map<LocalDate, Object> dailyErrorList;
+    @Schema(description = "每天请假人数")
+    private Map<LocalDate, Object> dailyExcuseList;
 
 //    @Schema(description = "异常人员名字列表")
 //    private List<String> errorNameList;

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/DeptDO.java

@@ -80,5 +80,11 @@ public class DeptDO extends TenantBaseDO {
      */
     private String description;
 
+    /**
+     * 毕业达成率
+     */
+    @TableField(exist = false)
+    private Double graduationRate;
+
 
 }