| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl; |
| | | import me.zhengjie.modules.system.domain.Job; |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 审核功能 |
| | | * 审核/撤销功能 |
| | | * @param resources / |
| | | */ |
| | | @Override |
| | | public void updateApprove(AttendanceGoOut resources) { |
| | | public void updateApprove(AttendanceGoOut resources) throws Exception { |
| | | AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new); |
| | | ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId()); |
| | | attendanceGoOut.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getOutStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | 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); |
| | | } |
| | | } |
| | | attendanceGoOutRepository.save(attendanceGoOut); |
| | | // 调用定时任务修改考勤记录 |
| | | List<User> userList = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(attendanceGoOut.getUserId())){ |
| | | User user = userRepository.findById(attendanceGoOut.getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | | } |
| | | |
| | | /** |
| | | * 外出撤销 |
| | | * @param resources |
| | | */ |
| | | @Override |
| | | public void updateRevoke(AttendanceGoOut resources) { |
| | | AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new); |
| | | ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId()); |
| | | attendanceGoOut.copy(resources); |
| | | attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED); |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getOutStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | attendanceGoOutRepository.save(attendanceGoOut); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String attendanceDate = df.format(attendanceGoOut.getOutStartTime()); |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList); |
| | | } |
| | | } |