| | |
| | | @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)
|
| | | List<AttendanceBusinessTravel> findByUserAndSEDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | // 查询出差天数
|
| | | @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time >= ?2 and travel_end_time < ?3 and approval_status in ('business_approve_status_agree')", nativeQuery = true)
|
| | | List<AttendanceBusinessTravel> findByUserIdAndYearMonth(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | // 查询某天出差总时长
|
| | | @Query(value = "SELECT COALESCE(SUM(travel_duration), 0) FROM attendance_business_travel WHERE user_id = ?2 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND id != ?3 AND travel_start_time LIKE CONCAT(?1, '%')", nativeQuery = true)
|
| | | BigDecimal countTravelDuration(String date, Long userId, Long id);
|
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
|
| | | // 获取月初日期
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
|
| | | // 获取下月初日期
|
| | | LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
| | | // 获取月末最后一天日期
|
| | | LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
|
| | |
|
| | | // 查询出差表的记录
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(criteria.getUserId(), firstDayOfMonth, lastDayOfMonth);
|
| | | // TODO:因一天可填多条出差记录,每条最小的时长是0.5天,导致可能会有当天总时长超出1天的情况。(每天出差类型只会有一种,不考虑多种的情况)
|
| | | List<AttendanceBusinessTravel> calcAttendanceBusinessTravelList = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(
|
| | | (AttendanceBusinessTravel businessTravel) -> businessTravel.getTravelStartTime().toLocalDateTime().toLocalDate().toString(),
|