1 files added
29 files modified
1 files deleted
| | |
| | | |
| | | // 查询出差记录 |
| | | @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; |
| | |
| | | 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){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 审核功能 |
| | | * 审核/撤销功能 |
| | | * @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.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); |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | public void salarySettlement() { |
| | | // 日历类 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.MONTH, -1); |
| | | // 格式化日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 目标年月 |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import me.zhengjie.modules.project.repository.ProjectProgressRepository; |
| | | import me.zhengjie.modules.project.repository.ProjectRepository; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskDaliyCollectInterface; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | |
| | |
| | | for (Task task : taskList) { |
| | | timeTotalInit = timeTotalInit + task.getPlanHours(); |
| | | workTotalInit = workTotalInit + (task.getPlanWorkload() == null ? 0.0 : task.getPlanWorkload()); |
| | | TaskDaliyCollectInterface taskDaliyCollection = taskDaliyRepository.collectTaskDaliyUntilDate(task.getId(), projectProgress.getBelongDate()); |
| | | TaskDailyInterface taskDailyInterface = taskDaliyRepository.collectTaskDaliyUntilDate(task.getId(), projectProgress.getBelongDate()); |
| | | boolean flg = true; |
| | | if (flg) { // TODO 任务状态:未结束 task.getStatus() |
| | | timeTotalCost += BigDecimal.valueOf(task.getPlanHours()).multiply(BigDecimal.valueOf(taskDaliyCollection.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue(); |
| | | timeTotalCost += BigDecimal.valueOf(task.getPlanHours()).multiply(BigDecimal.valueOf(taskDailyInterface.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue(); |
| | | } else { |
| | | timeTotalCost += task.getPlanHours(); |
| | | } |
| | | workTotalCost += taskDaliyCollection.getConsumedWorkload(); |
| | | realLastCost += taskDaliyCollection.getConsumedHours(); |
| | | workTotalCost += taskDailyInterface.getConsumedWorkload(); |
| | | realLastCost += taskDailyInterface.getConsumedHours(); |
| | | } |
| | | // 真实时长 |
| | | projectProgress.setRealLastCost(realLastCost); |
| New file |
| | |
| | | package me.zhengjie.modules.task.domain; |
| | | |
| | | public interface TaskDailyInterface { |
| | | |
| | | /** |
| | | * 消耗工时 |
| | | * @return |
| | | */ |
| | | Double getConsumedHours(); |
| | | |
| | | /** |
| | | * 消耗工作量 |
| | | * @return |
| | | */ |
| | | Double getConsumedWorkload(); |
| | | |
| | | /** |
| | | * 任务进度 |
| | | * @return |
| | | */ |
| | | Double getTaskProgress(); |
| | | } |
| | |
| | | */ |
| | | package me.zhengjie.modules.task.repository; |
| | | |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskDaliyCollectInterface; |
| | | |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | |
| | | |
| | | |
| | | @Query(value = "SELECT avg(task_progress) as taskProgress, COALESCE(sum(consumed_workload), 0.0) as consumedWorkload, sum(consumed_hours) as consumedHours FROM task_daliy WHERE task_id = ?1 AND create_time < ?2", nativeQuery = true) |
| | | TaskDaliyCollectInterface collectTaskDaliyUntilDate(Long taskId, Date belongDate); |
| | | TaskDailyInterface collectTaskDaliyUntilDate(Long taskId, Date belongDate); |
| | | |
| | | /** |
| | | * 根据项目ID、任务ID查询各用户填报的最大任务进度日报信息 |
| | |
| | | * @return |
| | | */ |
| | | List<TaskDaliy> findByProjectIdAndTaskId(Long projectId, Long taskId); |
| | | |
| | | /** |
| | | * 根据项目ID、任务ID、用户ID查询总消耗工时、总消耗工作量、最大任务进度 |
| | | * @param projectId |
| | | * @param taskId |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(consumed_hours), 0) AS consumedHours, COALESCE(SUM(consumed_workload), 0) AS consumedWorkload, COALESCE(MAX(task_progress), 0) AS taskProgress FROM task_daliy WHERE project_id = ?1 AND task_id = ?2 AND user_id = ?3", nativeQuery = true) |
| | | TaskDailyInterface findSumConsumedHoursAndSumConsumedWorkloadAndMaxTaskProgressByProjectIdAndTaskIdAndUserId(Long projectId, Long taskId, Long userId); |
| | | } |
| | |
| | | /** 用户昵称 */ |
| | | private String userNickName; |
| | | |
| | | /** 消耗工时 */ |
| | | private Double consumedHours; |
| | | |
| | | /** 消耗工作量 */ |
| | | private Double consumedWorkload; |
| | | |
| | | /** 任务进度 */ |
| | | private Double taskProgress; |
| | | |
| | | /** 多用户ID */ |
| | | private List<Long> userIds; |
| | | } |
| | |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | |
| | | ValidationUtil.isNull(user.getId(),"User","id",taskUserDto.getUserId()); |
| | | // 用户昵称 |
| | | taskUserDto.setUserNickName(user.getNickName()); |
| | | // 根据项目ID、任务ID、用户ID查询总消耗工时、总消耗工作量、最大任务进度 |
| | | TaskDailyInterface taskDailyInterface = taskDaliyRepository.findSumConsumedHoursAndSumConsumedWorkloadAndMaxTaskProgressByProjectIdAndTaskIdAndUserId(taskUserDto.getProjectId(), taskUserDto.getTaskId(), taskUserDto.getUserId()); |
| | | // 消耗工时 |
| | | taskUserDto.setConsumedHours(taskDailyInterface.getConsumedHours()); |
| | | // 消耗工作量 |
| | | taskUserDto.setConsumedWorkload(taskDailyInterface.getConsumedWorkload()); |
| | | // 任务进度 |
| | | taskUserDto.setTaskProgress(taskDailyInterface.getTaskProgress()); |
| | | // 返回处理好的DTO |
| | | return taskUserDto; |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 |
| | |
| | | > |
| | | 分配 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeDivide" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeDivide(crud.selections[0])" |
| | | > |
| | | 查看分配 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeDaliy" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeDaliy(crud.selections[0])" |
| | | > |
| | | 查看日报 |
| | | </el-button> |
| | | </crudOperation> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | |
| | | edit: ['admin', 'task:edit'], |
| | | del: ['admin', 'task:del'], |
| | | download: ['admin', 'task:download'], |
| | | divide: ['admin', 'task:divide'] |
| | | divide: ['admin', 'task:divide'], |
| | | seeDivide: ['admin', 'task:seeDivide'], |
| | | seeDaliy: ['admin', 'task:seeDaliy'] |
| | | }, |
| | | rules: { |
| | | name: [ |
| | |
| | | // 分配表单状态 |
| | | this.divideStatus = true |
| | | }, |
| | | // 查看任务分配 |
| | | toSeeDivide(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'TaskUser', |
| | | params: { |
| | | projectId: data.projectId, |
| | | taskId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 查看任务日报 |
| | | toSeeDaliy(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'TaskDaliy', |
| | | params: { |
| | | projectId: data.projectId, |
| | | taskId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 分配表单关闭 |
| | | divideClose() { |
| | | // 分配表单状态 |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | // 获取任务列表 |
| | | crudTask.getAll({ projectId: this.query.projectId }).then(res => { |
| | | // 检索任务列表 |
| | | this.queryTasks = res |
| | | }) |
| | | } |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.taskId != null && this.$route.params.taskId !== '' && this.crud.query.taskId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'taskId', Number(this.$route.params.taskId)) |
| | | } |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskEndDate" label="任务结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskWorkload" label="任务工作量" width="80" /> |
| | | <el-table-column :show-overflow-tooltip="true" label="消耗 / 任务工时" width="110"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.consumedHours }} / {{ scope.row.taskHours }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="消耗 / 任务工作量" width="120"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.consumedWorkload }} / {{ scope.row.taskWorkload == null || scope.row.taskWorkload == '' ? 0 : scope.row.taskWorkload }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskWorkloadUnit" label="任务工作量单位" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.taskWorkloadUnit != null && scope.row.taskWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.taskWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度" width="80"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.taskProgress }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStatus" label="任务状态" width="80"> |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | // 获取任务列表 |
| | | crudTask.getAll({ projectId: this.query.projectId }).then(res => { |
| | | // 检索任务列表 |
| | | this.queryTasks = res |
| | | }) |
| | | } |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.taskId != null && this.$route.params.taskId !== '' && this.crud.query.taskId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'taskId', Number(this.$route.params.taskId)) |
| | | } |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | |
| | | // 检索任务列表 |
| | | this.queryTasks = [] |
| | | } else { |
| | | // 获取父级任务 |
| | | // 获取任务列表 |
| | | crudTask.getAll({ projectId: this.query.projectId }).then(res => { |
| | | // 检索任务列表 |
| | | this.queryTasks = res |