瀏覽代碼

1.3互选项目存在判断和一些修改

Crazy 5 月之前
父節點
當前提交
716f8f15d5

+ 35 - 29
yudao-module-md/yudao-module-md-biz/src/main/java/Acs/EventSearch.java

@@ -174,29 +174,46 @@ public final class EventSearch {
                 StudentAttendanceDO ST  = studentAttendanceService.getStudentAttendanceOne(employeeNo,parsedTime);//获取这个学生对应的这个考勤记录
                 AdminUserDO user = adminUserService.findUserByUserNumber(employeeNo);//找到这个学生
                 //插入到attendance表
+                LocalDate localDate = LocalDate.now();
                 if (ST==null) { // 如果不存在,则进行打卡记录的创建
                     if (employeeNo != null && !employeeNo.equals("0")) {
                         if (user != null &&"1".equals(user.getUserType())) {//在校生
-                            StudentAttendancePageReqVO attendanceReqVO = new StudentAttendancePageReqVO();
-                            LocalDate localDate = LocalDate.now();
                             if (localDate.equals(date)) {
-                                attendanceReqVO.setDate(localDate);
-                                attendanceReqVO.setUserNumber(user.getUserNumber());
-                                attendance.setClockInStatus("1");
-                                List<StudentAttendanceDO> result = studentAttendanceService.getStudentAttendanceAllList(attendanceReqVO);//找到这天的未打卡记录
-                                if (result!=null&&!result.isEmpty()) {//有未打卡记录更新未打卡记录
-                                    StudentAttendanceDO re = result.get(0);
-                                    if ("1".equals(re.getClockInStatus())) {//找到未打卡的
-                                        re.setClockInStatus("0");//变成正常
-                                        re.setClockInTime(parsedTime);//更新打卡时间
-                                        re.setCreateTime(parsedTime);
-                                        re.setUpdateTime(parsedTime);//更新时间
-                                        if (photoUrl != null) {
-                                            re.setPhoto(photoUrl); //
-                                        }
-                                        studentAttendance.add(re);//
-                                        studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
+                                StudentAttendanceDO re = studentAttendanceService.getOneErrorOrExcusedStudentAttendance(user.getUserNumber(),localDate,"1");//找到这天的未打卡记录
+                                if (re!=null) {//有未打卡记录更新未打卡记录
+                                    re.setClockInStatus("0");//变成正常
+                                    re.setClockInTime(parsedTime);//更新打卡时间
+                                    re.setCreateTime(parsedTime);
+                                    re.setUpdateTime(parsedTime);//更新时间
+                                    if (photoUrl != null) {
+                                        re.setPhoto(photoUrl); //
                                     }
+                                    studentAttendance.add(re);//
+                                    studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
+                                }else {//无未打卡记录直接插入
+                                    attendance.setStudentName(user.getNickname()); // 昵称
+                                    attendance.setStudentId(user.getId()); // 学生id
+                                    attendance.setDeptId(user.getDeptId()); // 工作间id
+                                    attendance.setSupervisorId(user.getSupervisorId()); // 导师id
+                                    attendance.setClockInStatus(transformClockStatus(parsedTime)); // 打卡状态
+                                    attendance.setClockInTime(parsedTime);//打卡时间
+                                    attendance.setCreateTime(parsedTime);
+                                    attendance.setUpdateTime(parsedTime);
+                                    studentAttendance.add(attendance);
+                                    studentAttendanceService.createStudentAttendance(BeanUtils.toBean(attendance, StudentAttendanceSaveReqVO.class));
+                                }
+                            }else if (yesterday.equals(date)){//前一天的以免没有加载
+                                StudentAttendanceDO re = studentAttendanceService.getOneErrorOrExcusedStudentAttendance(user.getUserNumber(),yesterday,"1");//找到前一天的未打卡记录
+                                if (re!=null) {//有未打卡记录更新未打卡记录
+                                    re.setClockInStatus("0");
+                                    re.setClockInTime(parsedTime);
+                                    re.setCreateTime(parsedTime);
+                                    re.setUpdateTime(parsedTime);
+                                    if (photoUrl != null) {
+                                        re.setPhoto(photoUrl);
+                                    }
+                                    studentAttendance.add(re);
+                                    studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
                                 }else {//无未打卡记录直接插入
                                     attendance.setStudentName(user.getNickname()); // 昵称
                                     attendance.setStudentId(user.getId()); // 学生id
@@ -209,17 +226,6 @@ public final class EventSearch {
                                     studentAttendance.add(attendance);
                                     studentAttendanceService.createStudentAttendance(BeanUtils.toBean(attendance, StudentAttendanceSaveReqVO.class));
                                 }
-                            }else {//前一天的以免没有加载
-                                attendance.setStudentName(user.getNickname()); // 昵称
-                                attendance.setStudentId(user.getId()); // 学生id
-                                attendance.setDeptId(user.getDeptId()); // 工作间id
-                                attendance.setSupervisorId(user.getSupervisorId()); // 导师id
-                                attendance.setClockInStatus(transformClockStatus(parsedTime)); // 打卡状态
-                                attendance.setClockInTime(parsedTime);//打卡时间
-                                attendance.setCreateTime(parsedTime);
-                                attendance.setUpdateTime(parsedTime);
-                                studentAttendance.add(attendance);
-                                studentAttendanceService.createStudentAttendance(BeanUtils.toBean(attendance, StudentAttendanceSaveReqVO.class));
                             }
                         } else {
                             System.out.println("没有找到该用户" + employeeNo);

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectSupervisorRecord/StudentSelectSupervisorRecordController.java

@@ -79,6 +79,9 @@ public class StudentSelectSupervisorRecordController {
         LocalDate date =LocalDate.now();
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
 
+        if (project==null){
+            return;
+        }
         //没有选择成功导师的学生
         List<AdminUserDO> studentList =adminUserService.getStudentAndSupervisorNull(project.getStudentGrade());
         //更新所有待处理的记录=>撤回
@@ -403,6 +406,9 @@ public class StudentSelectSupervisorRecordController {
 
         LocalDate date =LocalDate.now();
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
+        if (project==null){
+            return error(1,"请检查今年是否创建了项目");
+        }
         //填写简介
         UserSaveReqVO userSaveReqVO = new UserSaveReqVO();
         userSaveReqVO.setId(loginId);

+ 7 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java

@@ -47,6 +47,7 @@ import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
 
@@ -600,6 +601,9 @@ public class UserController {
         Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
 
         studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
+        if (project==null){
+            return error(1,"请检查今年是否创建了项目");
+        }
 
         Integer isStudent = result.getIsStudent();
         Integer isSupervisor =result.getIsSupervisor();
@@ -629,6 +633,9 @@ public class UserController {
             userService.updatePop(popData);
             LocalDate date =LocalDate.now();
             studentSelectionProjectSaveReqVO project = BeanUtils.toBean(studentSelectionProjectService.getStudentSelectionProjectByYear(date.getYear()),studentSelectionProjectSaveReqVO.class);
+            if (project==null){
+                return error(1,"请检查今年是否创建了项目");
+            }
             //更新导师的
             List<Long> supervisorIds = project.getSupervisorIds();
             UserSaveReqVO saveReqVO =new UserSaveReqVO();

+ 4 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/studentAttendance/StudentAttendanceMapper.java

@@ -30,6 +30,7 @@ import java.util.Set;
 @Mapper
 public interface StudentAttendanceMapper extends BaseMapperX<StudentAttendanceDO> {
 
+
     //根据登录人员不同显示全部的考勤记录列表
     default List<StudentAttendanceDO> selectAllList(StudentAttendancePageReqVO reqVO, Set<Long> roleIds,Long loginId) {
         Long dept_id = SecurityFrameworkUtils.getLoginUserDeptId();
@@ -378,5 +379,8 @@ public interface StudentAttendanceMapper extends BaseMapperX<StudentAttendanceDO
     @Select("SELECT * FROM system_student_attendance WHERE user_number = #{userNumber} AND clock_in_time = #{clockTime}")
     StudentAttendanceDO getStudentAttendanceOne(@Param("userNumber") String userNumber,
                                                 @Param("clockTime") LocalDateTime clockTime);
+    //请假或未打卡
+    @Select("SELECT * FROM system_student_attendance WHERE user_number = #{userNumber} AND date = #{date} AND clock_in_status =#{clockInStatus}")
+    StudentAttendanceDO getOneErrorOrExcusedStudentAttendance(@Param("userNumber") String userNumber,@Param("date") LocalDate date,@Param("clockInStatus") String clockInStatus);
 
 }

+ 2 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/studentAttendance/StudentAttendanceService.java

@@ -74,5 +74,7 @@ public interface StudentAttendanceService {
 
     StudentAttendanceDO getStudentAttendanceOne(String userNumber,LocalDateTime clockTime);
 
+    StudentAttendanceDO getOneErrorOrExcusedStudentAttendance(String userNumber,LocalDate date, String clockInStatus);
+
 
 }

+ 7 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/studentAttendance/StudentAttendanceServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.*;
@@ -252,8 +253,13 @@ public class StudentAttendanceServiceImpl implements StudentAttendanceService {
         return result;
     }
 
-
+    @Override
    public StudentAttendanceDO getStudentAttendanceOne(String userNumber, LocalDateTime clockTime){
         return studentAttendanceMapper.getStudentAttendanceOne(userNumber,clockTime);
     }
+    @Override
+    public  StudentAttendanceDO getOneErrorOrExcusedStudentAttendance(String userNumber, LocalDate date, String clockInStatus){
+        return studentAttendanceMapper.getOneErrorOrExcusedStudentAttendance(userNumber,date,clockInStatus);
+    }
+
 }