|
@@ -1,5 +1,9 @@
|
|
|
package cn.iocoder.yudao.module.system.controller.admin.studentAttendance;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -11,6 +15,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
import javax.validation.constraints.*;
|
|
|
import javax.validation.*;
|
|
|
import javax.servlet.http.*;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.io.IOException;
|
|
|
|
|
@@ -38,6 +44,73 @@ public class StudentAttendanceController {
|
|
|
@Resource
|
|
|
private StudentAttendanceService studentAttendanceService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AdminUserService adminUserService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptService deptService;
|
|
|
+
|
|
|
+ //检测打卡情况并且创建警告的打卡记录
|
|
|
+ @Scheduled(cron = "0 20 21 * * ?") // 每天22:30检测
|
|
|
+ public void attendanceNormal() {
|
|
|
+ checkAttendanceSecond();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 19 21 * * ?") // 每天11:00检测
|
|
|
+ public void attendanceNormalMorning() {
|
|
|
+ checkAttendanceFirst();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkAttendanceFirst() {
|
|
|
+ List<AdminUserDO> userList = adminUserService.getAllUserList();
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+
|
|
|
+ for (AdminUserDO user : userList) {
|
|
|
+ List<StudentAttendanceDO> result = studentAttendanceService.getStudentAttendanceDay(user.getUserNumber(),localDate);
|
|
|
+ if ("1".equals(user.getUserType())) {//只对在校生
|
|
|
+ if (result != null && result.size() == 0) { //
|
|
|
+ StudentAttendanceDO attendance = new StudentAttendanceDO();
|
|
|
+ attendance.setClockInStatus("1"); // 未打卡
|
|
|
+ attendance.setDate(localDate);
|
|
|
+ attendance.setStudentName(user.getUsername()); // 名字
|
|
|
+ attendance.setStudentId(user.getId()); // id
|
|
|
+ attendance.setUserNumber(user.getUserNumber()); // 学号
|
|
|
+ attendance.setDeptId(user.getDeptId()); // 工作间id
|
|
|
+ attendance.setSupervisorId(user.getSupervisorId()); // 导师id
|
|
|
+ studentAttendanceService.createStudentAttendance(BeanUtils.toBean(attendance, StudentAttendanceSaveReqVO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkAttendanceSecond() {
|
|
|
+ List<AdminUserDO> userList = adminUserService.getAllUserList();
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+
|
|
|
+ for (AdminUserDO user : userList) {
|
|
|
+ List<StudentAttendanceDO> result = studentAttendanceService.getStudentAttendanceDay(user.getUserNumber(),localDate);
|
|
|
+ if ("1".equals(user.getUserType())) {//只对在校生
|
|
|
+ if (result.size()>2) {//打了卡
|
|
|
+ for (StudentAttendanceDO re : result) {
|
|
|
+ if ("1".equals(re.getClockInStatus())) {//未打卡
|
|
|
+ re.setClockInStatus("3");//恢复正常
|
|
|
+ studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (result.size()==1){//只有一次,未打卡或者打了卡
|
|
|
+ for (StudentAttendanceDO re : result) {
|
|
|
+ if ("1".equals(re.getClockInStatus())) {//未打卡
|
|
|
+ re.setClockInStatus("2");//变成警告
|
|
|
+ studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建学生考勤记录")
|
|
|
@PreAuthorize("@ss.hasPermission('system:student-attendance:create')")
|
|
@@ -72,7 +145,7 @@ public class StudentAttendanceController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
- @Operation(summary = "获得学生考勤记录分页")
|
|
|
+ @Operation(summary = "导师获得学生考勤记录分页")
|
|
|
@PreAuthorize("@ss.hasPermission('system:student-attendance:query')")
|
|
|
public CommonResult<PageResult<StudentAttendanceRespVO>> getStudentAttendancePage(@Valid StudentAttendancePageReqVO pageReqVO) {
|
|
|
PageResult<StudentAttendanceDO> pageResult = studentAttendanceService.getStudentAttendancePage(pageReqVO);
|
|
@@ -81,7 +154,7 @@ public class StudentAttendanceController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/errorPage")
|
|
|
- @Operation(summary = "获得学生考勤异常记录分页")
|
|
|
+ @Operation(summary = "导师获得学生考勤异常记录分页")
|
|
|
@PreAuthorize("@ss.hasPermission('system:student-attendance:ErrorQuery')")
|
|
|
public CommonResult<PageResult<StudentAttendanceRespVO>> getStudentAttendanceErrorPage(@Valid StudentAttendancePageReqVO pageReqVO) {
|
|
|
PageResult<StudentAttendanceDO> pageResult = studentAttendanceService.getStudentAttendanceErrorPage(pageReqVO);
|
|
@@ -102,5 +175,70 @@ public class StudentAttendanceController {
|
|
|
BeanUtils.toBean(list, StudentAttendanceRespVO.class));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/selfPage")
|
|
|
+ @Operation(summary = "获得学生自己的考勤记录分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-attendance:SelfQuery')")
|
|
|
+ public CommonResult<PageResult<StudentAttendanceRespVO>> getStudentAttendanceSelfPage(@Valid StudentAttendancePageReqVO pageReqVO) {
|
|
|
+ PageResult<StudentAttendanceDO> pageResult = studentAttendanceService.getStudentAttendanceSelfPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, StudentAttendanceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/collegePage")
|
|
|
+ @Operation(summary = "学院获得学生考勤记录分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-attendance:college-query')")
|
|
|
+ public CommonResult<PageResult<StudentAttendanceRespVO>> TeacherGetStudentAttendancePage(@Valid StudentAttendancePageReqVO pageReqVO) {
|
|
|
+
|
|
|
+ PageResult<StudentAttendanceDO> pageResult = studentAttendanceService.getStudentAttendancePage(pageReqVO);
|
|
|
+
|
|
|
+ return success(BeanUtils.toBean(pageResult, StudentAttendanceRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/dayAttendance")
|
|
|
+ @Operation(summary = "获得所有人当日出勤列表")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
|
|
|
+ public CommonResult<List<StudentAttendanceDO>> getDayStudentAttendance () {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+
|
|
|
+ List<StudentAttendanceDO> attendanceList =studentAttendanceService.getStudentsAttendanceDay(localDate);
|
|
|
+ List<StudentAttendanceDO> result =new ArrayList<>();
|
|
|
+ for (StudentAttendanceDO attendance :attendanceList ){
|
|
|
+ attendance.setSupervisor(adminUserService.getUser(attendance.getSupervisorId()).getNickname());//导师名字
|
|
|
+ attendance.setDeptName(deptService.getDept(attendance.getDeptId()).getName());//工作间名称
|
|
|
+ result.add(attendance);
|
|
|
+ }
|
|
|
+ return success(result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/dayErrorAttendance")
|
|
|
+ @Operation(summary = "获得所有人当日警告列表")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
|
|
|
+ public CommonResult<List<StudentAttendanceDO>> getDayStudentErrorAttendance () {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ List<StudentAttendanceDO> attendanceList =studentAttendanceService.getStudentsAttendanceDay(localDate);
|
|
|
+ List<StudentAttendanceDO> result =new ArrayList<>();
|
|
|
+ for (StudentAttendanceDO attendance :attendanceList ){
|
|
|
+ if ("1".equals(attendance.getClockInStatus())){
|
|
|
+ attendance.setSupervisor(adminUserService.getUser(attendance.getSupervisorId()).getNickname());//导师名字
|
|
|
+ attendance.setDeptName(deptService.getDept(attendance.getDeptId()).getName());//工作间名称
|
|
|
+
|
|
|
+ result.add(attendance);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+// //TODO还没做的
|
|
|
+// @GetMapping("/weekendAttendance")
|
|
|
+// @Operation(summary = "周出勤统计")
|
|
|
+// @PreAuthorize("@ss.hasPermission('system:student-attendance:day')")
|
|
|
+// public CommonResult<Map<String,Integer>> getWeekendAttendance () {
|
|
|
+// List<AdminUserDO>studentList = adminUserService.getAllUserList();
|
|
|
+// for (AdminUserDO student :studentList){
|
|
|
+// if ()
|
|
|
+// }
|
|
|
+// return null;
|
|
|
+// }
|
|
|
|
|
|
}
|