yaozc
2023-01-18 e818b1d6d438c2bfd3985d1edba1842fcf4af1d3
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -117,9 +117,9 @@
        String goStartTime = df.format(resources.getOutStartTime());
        String goEndTime = df.format(resources.getOutEndTime());
        // 查询其他状态的表是否有重复
        repeatValidation(goStartTime, goEndTime);
        repeatValidation(goStartTime, goEndTime, resources.getUserId());
        // 验证请假时间是否冲突
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(goStartTime, goEndTime, resources.getUserId());
        if(attendanceGoOutList.size() > 0){
            AttendanceGoOut errTime = attendanceGoOutList.get(0);
            //LocalDateTime转换为Date
@@ -137,7 +137,7 @@
                    + "已经存在外出记录,请调整时间");
        }else {
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            User user = userRepository.getOne(resources.getUserId());
            List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
            // 查询节假日
            List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
@@ -198,11 +198,11 @@
        String goStartTime = df.format(resources.getOutStartTime());
        String goEndTime = df.format(resources.getOutEndTime());
        // 查询其他状态的表是否有重复
        repeatValidation(goStartTime, goEndTime);
        repeatValidation(goStartTime, goEndTime, resources.getUserId());
        // 验证是否存在时间冲突的请假记录
        Set<Long> ids = new HashSet<>();
        ids.add(attendanceGoOut.getId());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateUpdateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId(), ids);
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateUpdateTime(goStartTime, goEndTime, resources.getUserId(), ids);
        if(attendanceGoOutList.size() > 0){
            AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
@@ -216,7 +216,7 @@
                attendanceGoOutRepository.deleteById(id);
            }
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            User user = userRepository.getOne(resources.getUserId());
            List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
            // 查询节假日
            List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
@@ -301,9 +301,9 @@
     * @param goStartTime
     * @param goEndTime
     */
    public void repeatValidation(String goStartTime, String goEndTime){
    public void repeatValidation(String goStartTime, String goEndTime, Long userId){
        // 查询请假表(时单位)
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime,goEndTime, SecurityUtils.getCurrentUserId());
        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime,goEndTime, userId);
        if(attendanceLeaveList.size() > 0){
            AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
@@ -311,7 +311,7 @@
                    + "已经存在请假记录,请调整时间");
        }
        // 查询出差表
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0,10),goEndTime.substring(0,10), SecurityUtils.getCurrentUserId());
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0,10),goEndTime.substring(0,10), userId);
        if(attendanceBusinessTravelList.size() > 0){
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
@@ -399,8 +399,12 @@
            // 查询考勤记录是否存在
            Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getOutStartTime().toLocalDateTime().toString().substring(0,10));
            if(ObjectUtils.isNotEmpty(attendance)){
                attendance.setStartClockResults(Constant.ATTENDANCE_STATE_GOOUT);
                attendance.setEndClockResults(Constant.ATTENDANCE_STATE_GOOUT);
                if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && resources.getOutStartTime().toLocalDateTime().compareTo(attendance.getRosteringWorkStartTime().toLocalDateTime()) <= 0) {
                    attendance.setStartClockResults(Constant.ATTENDANCE_STATE_GOOUT);
                }
                if (!attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) &&resources.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) >= 0) {
                    attendance.setEndClockResults(Constant.ATTENDANCE_STATE_GOOUT);
                }
                attendanceRepository.save(attendance);
            }
        }