| | |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.domain.Calculate; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceGoOutMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final AttendanceLeaveServiceImpl attendanceLeaveService; |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | private final AttendanceRepository attendanceRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){ |
| | |
| | | //查询审批者信息 |
| | | User appUser = userRepository.getOne(resources.getApprovalUserId()); |
| | | sendList.add(appUser.getDingding()); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card"); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了外出审批,请登录PMS系统处理", "card"); |
| | | } |
| | | return attendanceGoOutMapper.toDto(resources); |
| | | } |
| | |
| | | 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)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_GOOUT); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_GOOUT); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceGoOutRepository.save(attendanceGoOut); |
| | | } |
| | | |
| | | /** |
| | | * 外出撤销 |
| | | * @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); |
| | | } |
| | | } |