| | |
| | | import com.ruoyi.inspect.pojo.StaffAttendanceTrackingRecord; |
| | | import com.ruoyi.inspect.service.StaffAttendanceTrackingRecordService; |
| | | import com.ruoyi.inspect.util.HourDiffCalculator; |
| | | import com.ruoyi.inspect.util.TimeDiffCalculator; |
| | | import com.ruoyi.inspect.vo.StaffAttendanceVO; |
| | | import com.ruoyi.inspect.vo.StaffClockInVO; |
| | | import com.ruoyi.performance.dto.PerformanceShiftMapDto; |
| | |
| | | private final static List<String> syncDeviceCode = Arrays.asList("1001538", "1001539", "1001540", "1001541", |
| | | "1001626", "1001627", "1001628", "1001629"); |
| | | |
| | | /** |
| | | * 上班时间判定边界小时数 |
| | | */ |
| | | private final static long WORK_TIME_BOUNDARY = 2L; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean syncAttendanceRecord(LocalDateTime startDate, LocalDateTime endDate) { |
| | |
| | | public IPage<StaffAttendanceVO> pageAttendanceRecord(Page<StaffAttendanceTrackingRecord> page, |
| | | StaffAttendanceDTO staffAttendanceDTO) { |
| | | // 查询打卡记录 |
| | | System.out.println(staffAttendanceDTO.getStartDate()); |
| | | System.out.println(staffAttendanceDTO.getEndDate()); |
| | | System.out.println(ObjectUtils.allNotNull(staffAttendanceDTO.getStartDate(),staffAttendanceDTO.getEndDate())); |
| | | Wrapper<StaffAttendanceTrackingRecord> queryWrapper = Wrappers.<StaffAttendanceTrackingRecord>lambdaQuery() |
| | | .eq(StaffAttendanceTrackingRecord::getEnableReport, Boolean.TRUE) |
| | | .between(ObjectUtils.allNotNull(staffAttendanceDTO.getStartDate(),staffAttendanceDTO.getEndDate()), |
| | |
| | | LocalTime currentShiftStartTime = LocalTime.parse(p.getStartTime(), HHmm); |
| | | LocalDateTime currentShiftStartDateTime = LocalDateTime.of(p.getWorkTime().toLocalDate(), |
| | | currentShiftStartTime); |
| | | // 当前班次结束时间 |
| | | LocalTime currentShiftEndTime = LocalTime.parse(p.getEndTime(), HHmm); |
| | | LocalDateTime currentShiftEndDateTime = LocalDateTime.of(endDateTime.toLocalDate(), |
| | | currentShiftEndTime); |
| | | // 下一班次开始时间 |
| | | LocalDateTime nextShiftStartDateTime = getShiftStartDateTime(i + 1, performanceShifts, |
| | | startDateTime.plusDays(1L)); |
| | |
| | | // 如果小时差为负数,表示跨天,结束时间需加一 |
| | | endDateTime = endDateTime.plusDays(1L); |
| | | } |
| | | // 当前班次结束时间 |
| | | LocalTime currentShiftEndTime = LocalTime.parse(p.getEndTime(), HHmm); |
| | | LocalDateTime currentShiftEndDateTime = LocalDateTime.of(endDateTime.toLocalDate(), |
| | | currentShiftEndTime); |
| | | // 过滤出当前人员当前班次的进/出记录 |
| | | LocalDateTime workDateTime = null; |
| | | LocalDateTime offWorkDateTime = null; |
| | | List<StaffAttendanceTrackingRecord> enterRecords = filterAttendanceRecord(p.getPersonCode(), |
| | | EnterOrExitType.ENTER.getValue(), startDateTime, endDateTime, recordList); |
| | | //上班时间判定边界 |
| | | LocalDateTime boundaryTime = currentShiftStartDateTime.minusHours(WORK_TIME_BOUNDARY); |
| | | if (!enterRecords.isEmpty()) { |
| | | // 上班时间和状态 |
| | | StaffAttendanceTrackingRecord enterRecord = enterRecords.stream() |
| | | .filter(s -> !s.getSwingTime().isAfter(currentShiftStartDateTime)) |
| | | .filter(s -> !s.getSwingTime().isAfter(currentShiftStartDateTime) && !s.getSwingTime().isBefore(boundaryTime)) |
| | | .max(Comparator.comparing(StaffAttendanceTrackingRecord::getSwingTime)) |
| | | .orElse(new StaffAttendanceTrackingRecord()); |
| | | if (BeanUtil.isEmpty(enterRecord)) { |
| | |
| | | |
| | | } |
| | | if (ObjectUtils.allNotNull(workDateTime, offWorkDateTime)) { |
| | | vo.setActualWorkHours(HourDiffCalculator.getHourDiff(workDateTime.toLocalTime().format(HHmm), |
| | | offWorkDateTime.toLocalTime().format(HHmm))); |
| | | vo.setActualWorkHours(TimeDiffCalculator.getHourDiff(workDateTime, |
| | | offWorkDateTime)); |
| | | } |
| | | // 赋值 |
| | | vo.setShiftId(p.getShift()); |
| | | vo.setPersonCode(p.getPersonCode()); |
| | | vo.setPersonName(p.getUserName()); |
| | | vo.setPlannedWorkHours(hourDiff); |
| | | //应勤时长 |
| | | double plannedWorkHours = Math.abs(hourDiff); |
| | | vo.setPlannedWorkHours(plannedWorkHours); |
| | | vo.setSwingDate(startDateTime); |
| | | vo.setWorkDateTime(workDateTime); |
| | | vo.setOffWorkDateTime(offWorkDateTime); |