Merge branch 'weicd' of http://192.168.1.110:5678/r/pms-upgrade into master
| | |
| | | |
| | | // 查询出差记录 |
| | | @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time <= ?3 and travel_end_time >= ?2 and approval_status in ('business_approve_status_agree')", nativeQuery = true) |
| | | AttendanceBusinessTravel findByUserAndDate(Long userId, String startDate, String endDate); |
| | | AttendanceBusinessTravel findByUserAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate); |
| | | } |
| | |
| | | Double getSurplusYearTime(Long userId,String startTime,String endTime); |
| | | |
| | | //查询请假记录 |
| | | @Query(value = "SELECT * from attendance_leave where user_id = ?1 and leave_start_time <= ?3 and leave_end_time >= ?2 and approval_status IN ('approval_status_passed')", nativeQuery = true) |
| | | @Query(value = "SELECT * from attendance_leave where user_id = ?1 and leave_start_time < ?3 and leave_end_time > ?2 and approval_status IN ('approval_status_passed')", nativeQuery = true) |
| | | List<AttendanceLeave> findByUserIdAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate); |
| | | } |
| | |
| | | } |
| | | |
| | | @PutMapping(value = "/approve") |
| | | @Log("审核功能") |
| | | @ApiOperation("审核功能") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceBusinessTravel resources){ |
| | | @Log("审核/撤销功能") |
| | | @ApiOperation("审核/撤销功能") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceBusinessTravel resources) throws Exception { |
| | | attendanceBusinessTravelService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @PutMapping(value = "/revoke") |
| | | @Log("出差撤销") |
| | | @ApiOperation("出差撤销") |
| | | public ResponseEntity<Object> revokeBussiness(@Validated @RequestBody AttendanceBusinessTravel resources){ |
| | | attendanceBusinessTravelService.updateRevoke(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| | |
| | | @PostMapping(value = "/addAttendanceInfo") |
| | | @Log("考勤信息补充") |
| | | @ApiOperation("考勤信息补充") |
| | | @PreAuthorize("@el.check('attendance:addAttendanceInfo')") |
| | | public ResponseEntity<Object> addAttendanceInfo(@Validated @RequestBody Attendance attendance) throws Exception { |
| | | attendanceService.addAttendanceInfo(attendance); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | } |
| | |
| | | @PutMapping(value = "/approve") |
| | | @Log("审核功能") |
| | | @ApiOperation("审核功能") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceGoOut resources){ |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceGoOut resources) throws Exception { |
| | | attendanceGoOutService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @PutMapping(value = "/revoke") |
| | | @Log("外出撤销") |
| | | @ApiOperation("外出撤销") |
| | | public ResponseEntity<Object> revokeGoOut(@Validated @RequestBody AttendanceGoOut resources){ |
| | | attendanceGoOutService.updateRevoke(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| | |
| | | @PutMapping(value = "/approve") |
| | | @Log("审核功能") |
| | | @ApiOperation("审核功能") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources){ |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources) throws Exception { |
| | | attendanceLeaveService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | |
| | | * 审核功能 |
| | | * @param resources / |
| | | */ |
| | | void updateApprove(AttendanceBusinessTravel resources); |
| | | void updateApprove(AttendanceBusinessTravel resources) throws Exception; |
| | | |
| | | /** |
| | | * 审核撤销 |
| | | * @param resources |
| | | */ |
| | | void updateRevoke(AttendanceBusinessTravel resources); |
| | | } |
| | |
| | | * 审核功能 |
| | | * @param resources / |
| | | */ |
| | | void updateApprove(AttendanceGoOut resources); |
| | | |
| | | /** |
| | | * 撤销功能 |
| | | * @param resources |
| | | */ |
| | | void updateRevoke(AttendanceGoOut resources); |
| | | void updateApprove(AttendanceGoOut resources) throws Exception; |
| | | } |
| | |
| | | * 审核功能 |
| | | * @param resources / |
| | | */ |
| | | void updateApprove(AttendanceLeave resources); |
| | | void updateApprove(AttendanceLeave resources) throws Exception; |
| | | |
| | | /** |
| | | * 多选删除 |
| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto; |
| | | 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; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.*; |
| | |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable){ |
| | |
| | | public void download(List<AttendanceBusinessTravelDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AttendanceBusinessTravelDto attendanceBusinessTravel : all) { |
| | | String bussDurationUnit = attendanceBusinessTravel.getDurationUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.CARD_APPROVE_STATUS, attendanceBusinessTravel.getDurationUnit()).getLabel() : ""; |
| | | String bussStatus = attendanceBusinessTravel.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.BUSSINESS_APPROVE_STATUS, attendanceBusinessTravel.getApprovalStatus()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户id", attendanceBusinessTravel.getUserId()); |
| | | map.put("审批用户id", attendanceBusinessTravel.getApprovalUserId()); |
| | | map.put("出差开始时间", attendanceBusinessTravel.getTravelStartTime()); |
| | | map.put("出差结束时间", attendanceBusinessTravel.getTravelEndTime()); |
| | | map.put("出差时长", attendanceBusinessTravel.getTravelDuration()); |
| | | map.put("时长单位", attendanceBusinessTravel.getDurationUnit()); |
| | | map.put("时长单位", bussDurationUnit); |
| | | map.put("出差原因", attendanceBusinessTravel.getTravelReason()); |
| | | map.put("出发城市", attendanceBusinessTravel.getDepartureCity()); |
| | | map.put("到达城市", attendanceBusinessTravel.getArrivalCity()); |
| | | map.put("审批状态", attendanceBusinessTravel.getApprovalStatus()); |
| | | map.put("审批状态", bussStatus); |
| | | map.put("审批说明", attendanceBusinessTravel.getApprovalDescription()); |
| | | map.put("备注", attendanceBusinessTravel.getRemarks()); |
| | | map.put("创建者", attendanceBusinessTravel.getCreateBy()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 审核功能 |
| | | * 审核/撤销功能 |
| | | * @param resources / |
| | | */ |
| | | @Override |
| | | public void updateApprove(AttendanceBusinessTravel resources) { |
| | | public void updateApprove(AttendanceBusinessTravel resources) throws Exception { |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new); |
| | | ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId()); |
| | | attendanceBusinessTravel.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getTravelStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_BUSINESS); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_BUSINESS); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceBusinessTravelRepository.save(attendanceBusinessTravel); |
| | | // 调用定时任务修改考勤记录 |
| | | List<User> userList = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(attendanceBusinessTravel.getUserId())){ |
| | | User user = userRepository.findById(attendanceBusinessTravel.getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | | } |
| | | |
| | | /** |
| | | * 审核撤销 |
| | | * @param resources |
| | | */ |
| | | @Override |
| | | public void updateRevoke(AttendanceBusinessTravel resources) { |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new); |
| | | ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId()); |
| | | attendanceBusinessTravel.copy(resources); |
| | | attendanceBusinessTravel.setApprovalStatus(Constant.BUSSINESS_APPROVE_STATUS_REVIEWED); |
| | | // 查询考勤记录是否存在,修改状态为等待 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getTravelStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | attendanceBusinessTravelRepository.save(attendanceBusinessTravel); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String attendanceDate = df.format(attendanceBusinessTravel.getTravelStartTime()); |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList); |
| | | } |
| | | } |
| | |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.SysConfigProportion; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.RoleRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigProportionRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | |
| | | private final RoleRepository roleRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final SysConfigProportionRepository sysConfigProportionRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){ |
| | |
| | | public void download(List<AttendanceCardreplacementDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AttendanceCardreplacementDto attendanceCardreplacement : all) { |
| | | String attCardreplacementType = attendanceCardreplacement.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.CARD_APPROVE_STATUS, attendanceCardreplacement.getApprovalStatus()).getLabel() : ""; |
| | | String attCardReplacementDistinguish = attendanceCardreplacement.getCardReplacementDistinguish() != null ? dictDetailRepository.findByDictNameAndValue(Constant.CARD_REPLACEMENT_DIFFERENTIATION, attendanceCardreplacement.getCardReplacementDistinguish()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户id", attendanceCardreplacement.getUserId()); |
| | | map.put("审批用户id", attendanceCardreplacement.getApprovalUserId()); |
| | | map.put("补卡时间", attendanceCardreplacement.getCardReplacementTime()); |
| | | map.put("补卡原因", attendanceCardreplacement.getCardReplacementReason()); |
| | | map.put("审批状态", attendanceCardreplacement.getApprovalStatus()); |
| | | map.put("审批状态", attCardreplacementType); |
| | | map.put("审批说明", attendanceCardreplacement.getApprovalDescription()); |
| | | map.put("补卡区分", attendanceCardreplacement.getCardReplacementDistinguish()); |
| | | map.put("补卡区分", attCardReplacementDistinguish); |
| | | map.put("备注", attendanceCardreplacement.getRemarks()); |
| | | map.put("创建者", attendanceCardreplacement.getCreateBy()); |
| | | map.put("创建时间", attendanceCardreplacement.getCreateTime()); |
| | |
| | | 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; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.*; |
| | |
| | | private final AttendanceRepository attendanceRepository; |
| | | 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){ |
| | |
| | | public void download(List<AttendanceGoOutDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AttendanceGoOutDto attendanceGoOut : all) { |
| | | String outOfOfficeType = attendanceGoOut.getOutOfOfficeType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.GOOUT_APPROVE_STATUS, attendanceGoOut.getOutOfOfficeType()).getLabel() : ""; |
| | | String outDurationUnit = attendanceGoOut.getDurationUnit() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TIME_TYPE, attendanceGoOut.getDurationUnit()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户id", attendanceGoOut.getUserId()); |
| | | map.put("审批用户id", attendanceGoOut.getApprovalUserId()); |
| | | map.put("外出开始时间", attendanceGoOut.getOutStartTime()); |
| | | map.put("外出结束时间", attendanceGoOut.getOutEndTime()); |
| | | map.put("外出时长", attendanceGoOut.getOutDuration()); |
| | | map.put("时长单位", attendanceGoOut.getDurationUnit()); |
| | | map.put("外出类型", attendanceGoOut.getOutOfOfficeType()); |
| | | map.put("时长单位", outDurationUnit); |
| | | map.put("外出类型", outOfOfficeType); |
| | | map.put("外出原因", attendanceGoOut.getOutReason()); |
| | | map.put("审批状态", attendanceGoOut.getApprovalStatus()); |
| | | map.put("审批说明", attendanceGoOut.getApprovalDescription()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 审核功能 |
| | | * 审核/撤销功能 |
| | | * @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); |
| | | } |
| | | } |
| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto; |
| | | 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.*; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){ |
| | |
| | | * @param resources / |
| | | */ |
| | | @Override |
| | | public void updateApprove(AttendanceLeave resources) { |
| | | public void updateApprove(AttendanceLeave resources) throws Exception { |
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new); |
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId()); |
| | | attendanceLeave.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getLeaveStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) && resources.getLeaveStartTime().toLocalDateTime().compareTo(attendance.getRosteringWorkStartTime().toLocalDateTime()) <= 0) { |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LEAVE); |
| | | } |
| | | if (!attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) &&resources.getLeaveEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) >= 0) { |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LEAVE); |
| | | } |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceLeaveRepository.save(attendanceLeave); |
| | | // 调用定时任务修改考勤记录 |
| | | List<User> userList = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){ |
| | | User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | | } |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String attendanceDate = df.format(attendanceLeave.getLeaveStartTime()); |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public void download(List<AttendanceLeaveDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AttendanceLeaveDto attendanceLeave : all) { |
| | | String leavrType = attendanceLeave.getLeaveType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TYPE, attendanceLeave.getLeaveType()).getLabel() : ""; |
| | | String leaveStatus = attendanceLeave.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVAL_STATUS, attendanceLeave.getApprovalStatus()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户ID", attendanceLeave.getUserId()); |
| | | map.put("审批用户ID", attendanceLeave.getApprovalUserId()); |
| | | map.put("请假类型", attendanceLeave.getLeaveType()); |
| | | map.put("请假类型", leavrType); |
| | | map.put("请假开始时间", attendanceLeave.getLeaveStartTime()); |
| | | map.put("请假结束时间", attendanceLeave.getLeaveEndTime()); |
| | | map.put("请假时长", attendanceLeave.getLeaveDuration()); |
| | | map.put("请假原因", attendanceLeave.getLeaveReason()); |
| | | map.put("审批状态", attendanceLeave.getApprovalStatus()); |
| | | map.put("审批状态", leaveStatus); |
| | | map.put("审批说明", attendanceLeave.getApprovalDescription()); |
| | | map.put("备注", attendanceLeave.getRemarks()); |
| | | map.put("创建者", attendanceLeave.getCreateBy()); |
| | |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | private final OapiDingTalkMethod oapiDingTalkMethod; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable){ |
| | |
| | | */ |
| | | @Override |
| | | public void addAttendanceInfo(Attendance attendance) throws Exception { |
| | | // 获取今天日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String todayDate = sdf.format(new Date()); |
| | | if(attendance.getAttendanceDate().compareTo(Timestamp.valueOf(todayDate)) >= 0){ |
| | | throw new BadRequestException("只能更新小于等于今天的考勤信息"); |
| | | } |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String attendanceDate = df.format(attendance.getAttendanceDate()); |
| | | List<User> userList = new ArrayList<>(); |
| | |
| | | User user = userRepository.findById(attendance.getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | | } |
| | | // 调用0时定时任务 |
| | | dingTalkService.getDingTalkAttendanceList(attendance.getAttendanceDate()); |
| | | // 选择日期和员工更新员工的考勤信息,未选择员工则更新所有人 |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate ,userList); |
| | | } |
| | |
| | | |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | |
| | | private final SysRosteringRepository sysRosteringRepository; |
| | | |
| | | /** |
| | | * 每天0点执行,新增用户考勤信息 |
| | | * @throws Exception |
| | | */ |
| | | public void getDingTalkAttendanceList(Timestamp attendDate) throws Exception { |
| | | //查询状态正常的员工 |
| | | List<User> userList = getUserList(); |
| | | //获取今天时间 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String todayDate = df.format(new Date()); |
| | | //获取当前时间 |
| | | Calendar calTodayDay = Calendar.getInstance(); |
| | | calTodayDay.setTime(Timestamp.valueOf(todayDate + " 00:00:00")); |
| | | //查询节假日表是否有记录 |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(todayDate); |
| | | // attendDate为null(这是定时任务) 或者 参数日期小于等于今天在创建(这是考勤按钮调用) |
| | | if(ObjectUtils.isEmpty(attendDate) || attendDate.compareTo(Timestamp.valueOf(todayDate+ " 00:00:00")) <= 0) { |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList) { |
| | | // 没有钉钉号的不更新 |
| | | if (ObjectUtils.isNotEmpty(user.getDingding())) { |
| | | //查询当前用户的排班 |
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId()); |
| | | //查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), (attendDate == null ? todayDate : df.format(attendDate))); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | if (ObjectUtil.isEmpty(attendance)) { |
| | | attendance = new Attendance(); |
| | | } |
| | | //添加记录 |
| | | attendance.setUserId(user.getId()); |
| | | Date date = df.parse((attendDate == null ? todayDate : df.format(attendDate))); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String today = sdf.format(date); |
| | | attendance.setAttendanceDate(Timestamp.valueOf(today)); |
| | | //状态为等待 |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | if (calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && sysConfigHoliday == null || calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY && sysConfigHoliday == null) { |
| | | //双休 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND); |
| | | } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) { |
| | | //法定 |
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS); |
| | | } else { |
| | | //除了法定节假日和双休都属于工作日 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY); |
| | | } |
| | | |
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf((attendDate == null ? todayDate : df.format(attendDate)) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime()))); |
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf((attendDate == null ? todayDate : df.format(attendDate)) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime()))); |
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf((attendDate == null ? todayDate : df.format(attendDate)) + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime()))); |
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf((attendDate == null ? todayDate : df.format(attendDate)) + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime()))); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 中午12点30或凌晨02:30执行定时任务 |
| | | * @throws Exception |
| | |
| | | }else { |
| | | calDay.setTime(Timestamp.valueOf(yesterday + " 00:00:00")); |
| | | } |
| | | String timeResult = ""; |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList) { |
| | | if(ObjectUtils.isNotEmpty(user.getDingding())){ |
| | |
| | | attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), yesterday); |
| | | oapiDingTalkRecordResultList = opaiDingTalkService.getAttendanceList(oapiDingTalkRecordResultList, oapiDingTalkAccessToken.getAccessToken(), yesterday + " 00:00:00", userDinDingList, 0l, 50l); |
| | | } |
| | | // attendance为空, attendDate不为空是考勤信息补全功能,创建考勤 |
| | | if(ObjectUtils.isEmpty(attendance) && ObjectUtils.isNotEmpty(attendDate)){ |
| | | attendance = new Attendance(); |
| | | Date date = df.parse(attendDate); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String attDate =simpleDateFormat.format(date); |
| | | Calendar calTodayDay = Calendar.getInstance(); |
| | | calTodayDay.setTime(Timestamp.valueOf(attendDate + " 00:00:00")); |
| | | //查询节假日表是否有记录 |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(todayDate); |
| | | attendance.setUserId(user.getId()); |
| | | attendance.setAttendanceDate(Timestamp.valueOf(attDate)); |
| | | if(calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && sysConfigHoliday == null || calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY && sysConfigHoliday == null){ |
| | | //双休 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND); |
| | | }else if(sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | //法定 |
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS); |
| | | }else{ |
| | | //除了法定节假日和双休都属于工作日 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY); |
| | | } |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime()))); |
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkEndTime()))); |
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getLunchStartTime()))); |
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getLunchEndTime()))); |
| | | } |
| | | for (OapiDingTalkRecordResult oapiDingTalkRecordResult : oapiDingTalkRecordResultList) { |
| | | |
| | | if ("NotSigned".equals(oapiDingTalkRecordResult.getTimeResult())) { |
| | | oapiDingTalkRecordResult.setUserCheckTime(null); |
| | | timeResult = "NotSigned"; |
| | | } |
| | | if ("OnDuty".equals(oapiDingTalkRecordResult.getCheckType())) { |
| | | // 状态不等于等待,说明有审批通过,不修改 |
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setStartClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? oapiDingTalkRecordResult.getTimeResult() : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 1)); |
| | | } |
| | | attendance.setStartClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 1)); |
| | | attendance.setStartLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkStartTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | }else if("OffDuty".equals(oapiDingTalkRecordResult.getCheckType())){ |
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setEndClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? oapiDingTalkRecordResult.getTimeResult() : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 2)); |
| | | } |
| | | attendance.setEndClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 2)); |
| | | attendance.setEndLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkEndTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | } |
| | | } |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下) |
| | | if(calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | if((ObjectUtils.isNotEmpty(attendance)) && (calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))){ |
| | | // 上午 |
| | | if(day && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST); |
| | |
| | | } |
| | | |
| | | // 修改考勤打卡状态 |
| | | attendance = updateRecord(user, attendance, timeResult, day, attendDate); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance = updateRecord(user, attendance, day, attendDate); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | * 查询其他状态表并调用方法修改 |
| | | * @param user |
| | | */ |
| | | public Attendance updateRecord(User user, Attendance attendance, String timeResult, Boolean day, String attendDate){ |
| | | public Attendance updateRecord(User user, Attendance attendance, Boolean day, String attendDate){ |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | List<AttendanceLeave> attendanceLeaveLists = attendanceLeaveRepository.findByUserIdAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveLists){ |
| | | // 上午/下午/全天 |
| | | if(attendanceLeave.getLeaveStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceLeave.getLeaveEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0){ |
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(), attendance.getRosteringLunchEndTime(),day); |
| | | }else if(attendanceLeave.getLeaveStartTime().toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 && attendanceLeave.getLeaveEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) <= 0){ |
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringLunchStartTime(),attendance.getRosteringWorkEndTime(),day); |
| | | }else{ |
| | | getMornOrNoon(user,attendance,attendDate,attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),day); |
| | | } |
| | | } |
| | | //查询出差表 |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findByUserAndDate(user.getId(),attendance.getAttendanceDate().toLocalDateTime(),attendance.getAttendanceDate().toLocalDateTime()); |
| | | if(ObjectUtils.isNotEmpty(attendanceBusinessTravel)){ |
| | | getMornOrNoon(user,attendance,attendDate,attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),day); |
| | | }// 查询外出表o |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) { |
| | | // 上午/下午 |
| | | if (attendanceGoOut.getOutStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) { |
| | | getMornOrNoon(user, attendance, attendDate, attendance.getRosteringWorkStartTime(), attendance.getRosteringLunchEndTime(), day); |
| | | } else if (attendanceGoOut.getOutStartTime().toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) <= 0) { |
| | | getMornOrNoon(user, attendance, attendDate, attendance.getRosteringLunchStartTime(),attendance.getRosteringWorkEndTime() ,day); |
| | | } else { |
| | | getMornOrNoon(user, attendance, attendDate, attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), day); |
| | | } |
| | | } |
| | | return attendance; |
| | | } |
| | | |
| | | /** |
| | | * 请假优先于出差优先于外出 |
| | | * @param user |
| | | * @param attendance |
| | | * @param attendDate |
| | | * @param startDate |
| | | * @param endDate |
| | | */ |
| | | public void getMornOrNoon(User user,Attendance attendance,String attendDate,Timestamp startDate,Timestamp endDate,Boolean day){ |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(),startDate.toLocalDateTime(),endDate.toLocalDateTime()); |
| | | Double leaveDuration = new Double(0.00);//钉钉方法的时长 |
| | | Double leaveStartDuration = new Double(0.00);//考勤按钮的时长 |
| | | Double leaveEndDuration = new Double(0.00);//考勤按钮的时长 |
| | | //请假优先于出差优先于外出 |
| | | if(attendanceLeaveList.size() < 1){ |
| | | // 查询考勤出差表 |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findByUserAndDate(user.getId(),attendance.getAttendanceDate().toString().substring(0,10),attendance.getAttendanceDate().toString().substring(0,10)); |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findByUserAndDate(user.getId(),attendance.getAttendanceDate().toLocalDateTime(),attendance.getAttendanceDate().toLocalDateTime()); |
| | | Double bussDuration = new Double(0.00); |
| | | Double bussStartDuration = new Double(0.00);//考勤按钮的时长 |
| | | Double bussEndDuration = new Double(0.00);//考勤按钮的时长 |
| | |
| | | outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(null,attendance,timeResult,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration); |
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day); |
| | | updateAttendanceRecord(outDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_GOOUT, day,null,null); |
| | | updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | bussStartDuration += getStartDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance); |
| | | bussEndDuration += getEndDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(null,attendance,timeResult,Constant.ATTENDANCE_STATE_BUSINESS,day,bussStartDuration,bussEndDuration); |
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_BUSINESS,day,bussStartDuration,bussEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | bussDuration += getDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance,day); |
| | | updateAttendanceRecord(bussDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_BUSINESS,day,null,null); |
| | | updateAttendanceRecord(bussDuration,attendance,Constant.ATTENDANCE_STATE_BUSINESS,day,null,null); |
| | | } |
| | | } |
| | | } |
| | |
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){ |
| | | // attendDate不等于null 说明是考勤信息按钮 |
| | | if(ObjectUtils.isNotEmpty(attendDate)){ |
| | | // 上午时长、下午时长 |
| | | // 上午总时长、下午总时长 |
| | | leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance); |
| | | leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(null,attendance,timeResult,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration); |
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(leaveDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_LEAVE,day,null,null); |
| | | updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null); |
| | | } |
| | | } |
| | | } |
| | | return attendance; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 修改考勤记录打卡状态 |
| | | * @param attendance |
| | | * @param timeResult |
| | | * @param type |
| | | */ |
| | | public void updateAttendanceRecord(Double duration, Attendance attendance, String timeResult, String type, Boolean day,Double stDuration,Double enDuration){ |
| | | public void updateAttendanceRecord(Double duration, Attendance attendance, String type, Boolean day,Double stDuration,Double enDuration){ |
| | | // 上午排班开始时间到排班午休开始时间的时长 |
| | | Integer workMorningTime = calculateTimes(attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()); |
| | | Double result = Double.valueOf(new BigDecimal((float) workMorningTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | |
| | | noonResult1 = Double.valueOf(new BigDecimal((float) actualTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | // 没打卡的情况下,修改考勤打卡状态 |
| | | if(timeResult.equals("NotSigned")){ |
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_NOTSIGNED) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_NOTSIGNED)){ |
| | | // duration为null说明是考勤信息按钮 |
| | | if(ObjectUtils.isEmpty(duration)){ |
| | | if(stDuration > 0 && enDuration == 0){ |
| | | setAttendance(stDuration,null,result,null,attendance,type); |
| | | }else if(enDuration > 0 && stDuration == 0){ |
| | | setAttendance(null,enDuration,null,noonResult,attendance,type); |
| | | }else{ |
| | | setAttendance(stDuration,null,result,null,attendance,type); |
| | | setAttendance(null,enDuration,null,noonResult,attendance,type); |
| | | } |
| | | }else{ |
| | | // 上午 |
| | | if(day){ |
| | |
| | | }else{ |
| | | // duration为null说明是考勤信息按钮 |
| | | if(ObjectUtils.isEmpty(duration)){ |
| | | if(stDuration > 0 && enDuration == 0){ |
| | | setAttendanceStart(stDuration,null,result1,result,null,attendance,type); |
| | | }else if(enDuration > 0 && stDuration == 0){ |
| | | setAttendanceStart(null,enDuration,noonResult1,null,noonResult,attendance,type); |
| | | }else{ |
| | | setAttendanceStart(stDuration,null,result1,result,null,attendance,type); |
| | | setAttendanceStart(null,enDuration,noonResult1,null,noonResult,attendance,type); |
| | | } |
| | | }else{ |
| | | //打卡的情况,修改考勤状态 |
| | | if(day){ |
| | |
| | | package me.zhengjie.modules.quartz.task; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkAccessToken; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkRecordResult; |
| | | import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.SysRostering; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.repository.SysRosteringRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Duration; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 钉钉定时任务(取考勤记录) |
| | | */ |
| | |
| | | @Async |
| | | public class OapiDingTalkMethod { |
| | | |
| | | private final AttendanceRepository attendanceRepository; |
| | | |
| | | private final UserRepository userRepository; |
| | | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | |
| | | private final SysRosteringRepository sysRosteringRepository; |
| | | |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | |
| | | /** |
| | | * 每天0点执行,新增用户考勤信息 |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | public void getDingTalkAttendanceList() throws Exception { |
| | | //查询状态正常的员工 |
| | | List<User> userList = getUserList(); |
| | | //获取今天时间 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String todayDate = df.format(new Date()); |
| | | //获取当前时间 |
| | | Calendar calTodayDay = Calendar.getInstance(); |
| | | calTodayDay.setTime(Timestamp.valueOf(todayDate + " 00:00:00")); |
| | | //查询节假日表是否有记录 |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(todayDate); |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList){ |
| | | if(ObjectUtils.isNotEmpty(user.getDingding())){ |
| | | //查询当前用户的排班 |
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId()); |
| | | //查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), todayDate); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | if (ObjectUtil.isEmpty(attendance)) { |
| | | attendance = new Attendance(); |
| | | } |
| | | //添加记录 |
| | | attendance.setUserId(user.getId()); |
| | | Date date = df.parse(todayDate); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String today=sdf.format(date); |
| | | attendance.setAttendanceDate(Timestamp.valueOf(today)); |
| | | //状态为等待 |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | if(calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && sysConfigHoliday == null || calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY && sysConfigHoliday == null){ |
| | | //双休 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND); |
| | | }else if(sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | //法定 |
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS); |
| | | }else{ |
| | | //除了法定节假日和双休都属于工作日 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY); |
| | | } |
| | | |
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime()))); |
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime()))); |
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime()))); |
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime()))); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | dingTalkService.getDingTalkAttendanceList(null); |
| | | } |
| | | |
| | | /** |
| | | * 定时任务调用 |
| | | *中午晚上定时任务调用 |
| | | */ |
| | | public void getDingTalkAttendance() throws Exception { |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(null,null); |
| | | } |
| | | |
| | | /** |
| | | * 查询用户 |
| | | */ |
| | | public List<User> getUserList(){ |
| | | List<User> userList = userRepository.findAllByEnabled(true); |
| | | return userList; |
| | | } |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | export function revoke(data) { |
| | | return request({ |
| | | url: 'api/attendanceBusinessTravel/revoke', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, getRemainingTime, approve, revoke } |
| | | export default { add, edit, del, getAll, getRemainingTime, approve } |
| | |
| | | }) |
| | | } |
| | | |
| | | export function revoke(data) { |
| | | return request({ |
| | | url: 'api/attendanceGoOut/revoke', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, getRemainingTime, approve, revoke } |
| | | export default { add, edit, del, getAll, getRemainingTime, approve } |
| | |
| | | <template slot="left"> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.addAttendanceInfo" |
| | | size="mini" |
| | | type="info" |
| | | icon="el-icon-document" |
| | |
| | | add: ['admin', 'attendance:add'], |
| | | edit: ['admin', 'attendance:edit'], |
| | | del: ['admin', 'attendance:del'], |
| | | download: ['admin', 'attendance:download'] |
| | | download: ['admin', 'attendance:download'], |
| | | addAttendanceInfo: ['admin', 'attendance:addAttendanceInfo'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | |
| | | <p>确定撤销该记录?</p> |
| | | <div style="text-align: right; margin: 0"> |
| | | <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | </div> |
| | | <el-button |
| | | v-if="scope.row.approvalUserId === $store.state.user.user.id" |
| | |
| | | }) |
| | | }, |
| | | // 审批页面赋值 |
| | | toApprove(data) { |
| | | toApprove(data, Number) { |
| | | if (Number !== '1') { |
| | | this.makeUpCardVisible = true |
| | | } |
| | | this.form.id = data.id |
| | | this.form.userId = data.userId |
| | | this.form.userName = data.userName |
| | |
| | | return |
| | | } |
| | | } |
| | | this.successLoading = true |
| | | crudAttendanceBusinessTravel.approve(this.form).then(res => { |
| | | this.crud.refresh() |
| | | this.makeUpCardVisible = false |
| | |
| | | }, |
| | | // 撤消功能 |
| | | revoke(data) { |
| | | crudAttendanceBusinessTravel.revoke(data).then(res => { |
| | | this.toApprove(data, '1') |
| | | this.form.approvalStatus = this.dictGoOutAppRev |
| | | this.successLoading = true |
| | | crudAttendanceBusinessTravel.approve(this.form).then(res => { |
| | | this.crud.refresh() |
| | | this.successLoading = false |
| | | this.$message({ type: 'success', message: '撤销成功' }) |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | |
| | | <p>确定撤销该记录?</p> |
| | | <div style="text-align: right; margin: 0"> |
| | | <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | <el-button :loading="successLoading" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | </div> |
| | | <el-button |
| | | v-if="scope.row.approvalUserId === $store.state.user.user.id" |
| | |
| | | }) |
| | | }, |
| | | // 审批页面赋值 |
| | | toApprove(data) { |
| | | toApprove(data, Number) { |
| | | if (Number !== '1') { |
| | | this.makeUpCardVisible = true |
| | | } |
| | | this.form.id = data.id |
| | | this.form.userId = data.userId |
| | | this.form.userName = data.userName |
| | |
| | | return |
| | | } |
| | | } |
| | | this.successLoading = true |
| | | crudAttendanceGoOut.approve(this.form).then(res => { |
| | | this.crud.refresh() |
| | | this.makeUpCardVisible = false |
| | |
| | | }, |
| | | // 撤消功能 |
| | | revoke(data) { |
| | | crudAttendanceGoOut.revoke(data).then(res => { |
| | | this.toApprove(data, '1') |
| | | this.form.approvalStatus = this.dictGoOutAppRev |
| | | this.successLoading = true |
| | | crudAttendanceGoOut.approve(this.form).then(res => { |
| | | this.crud.refresh() |
| | | this.successLoading = false |
| | | this.$message({ type: 'success', message: '撤销成功' }) |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | |
| | | return |
| | | } |
| | | } |
| | | this.successLoading = true |
| | | crudAttendanceLeave.approve(this.form).then(res => { |
| | | this.crud.refresh() |
| | | this.makeUpCardVisible = false |