From 3da564c545375e4e1403455652a0a2babf6923f0 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Thu, 27 Nov 2025 03:44:48 +0000
Subject: [PATCH] 获取用户调休假剩余时长异常问题修改
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java | 11 +++++++----
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
index 082a9d3..5c59aff 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
@@ -8,6 +8,7 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
@Data
@AllArgsConstructor
@@ -77,4 +78,26 @@
return result;
}
+
+ /**
+ * 判断与另一个时间区间是否有交集
+ */
+ public Boolean overlapsWith(Calculate otherCalculate) {
+ Objects.requireNonNull(otherCalculate, "另一个时间区间不能为null");
+ return !this.end.isBefore(otherCalculate.start) && !otherCalculate.end.isBefore(this.start);
+ }
+
+ /**
+ * 获取交集区间(没有返回null)
+ */
+ public Calculate getOverlap(Calculate other) {
+ if (!overlapsWith(other)) {
+ return null;
+ }
+
+ LocalDateTime overlapStart = this.start.isAfter(other.start) ? this.start : other.start;
+ LocalDateTime overlapEnd = this.end.isBefore(other.end) ? this.end : other.end;
+
+ return new Calculate(overlapStart, overlapEnd);
+ }
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
index 4cb5424..f71af67 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -561,11 +561,14 @@
LocalDateTime endLocalDateTime = localDateTime.withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59);
// 因换休3个月后会被结算,只能统计未结算的,仅当前时间3个月内(只参考月份)的可统计。
- LocalDateTime nowLocalDateTime = localDateTime.now().minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
- if (nowLocalDateTime.isBefore(startLocalDateTime) || nowLocalDateTime.isAfter(endLocalDateTime)) {
- return Double.valueOf(0);
+ LocalDateTime currentStartLocalDateTime = localDateTime.now().minusMonths(2L).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
+ LocalDateTime currentEndLocalDateTime = localDateTime.now().withDayOfMonth(1).plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
+ Calculate finalCalculate = new Calculate(currentStartLocalDateTime, currentEndLocalDateTime).getOverlap(new Calculate(startLocalDateTime, endLocalDateTime));
+ if (finalCalculate != null) {
+ startLocalDateTime = finalCalculate.getStart();
+ endLocalDateTime = finalCalculate.getEnd();
} else {
- startLocalDateTime = nowLocalDateTime;
+ return Double.valueOf(0);
}
// 查询可用调休申请
--
Gitblit v1.9.3