| | |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
| | | import org.springframework.data.jpa.repository.Query;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.time.LocalDateTime;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
| | | // 查询出差天数
|
| | | @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);
|
| | | } |
| | |
| | | if (dayResult.compareTo(BigDecimal.ZERO) == 0 && Math.abs(ChronoUnit.SECONDS.between(startTimestamp.toInstant(), endTimestamp.toInstant())) > 3600) { |
| | | dayResult = new BigDecimal(0.5); |
| | | } |
| | | |
| | | // TODO:20250804 由于存在一天多条出差记录的可能,需要同一天最大出差总时长不能超过1,故需要加入同天记录的差值判断 |
| | | BigDecimal dateCount = attendanceBusinessTravelRepository.countTravelDuration(date, Optional.ofNullable(attendanceBusinessTravel.getUserId()).orElse(user.getId()), Optional.ofNullable(attendanceBusinessTravel.getId()).orElse(0L)); |
| | | if (dateCount.compareTo(BigDecimal.ZERO) > 0) { |
| | | dayResult = BigDecimal.ONE.subtract(dateCount).max(BigDecimal.ZERO); |
| | | } |
| | | |
| | | result = result.add(dayResult); |
| | | } |
| | | } |
| | |
| | | // 计算时长 |
| | | checkTime() { |
| | | var data = JSON.stringify({ |
| | | id: this.form.id, |
| | | travelStartTime: this.form.travelStartTime, |
| | | travelEndTime: this.form.travelEndTime |
| | | travelEndTime: this.form.travelEndTime, |
| | | userId: this.form.userId |
| | | }) |
| | | crudAttendanceBusinessTravel.getRemainingTime(data).then(res => { |
| | | this.form.travelDuration = res |