BAOLH
2025-11-27 3da564c545375e4e1403455652a0a2babf6923f0
获取用户调休假剩余时长异常问题修改
2 files modified
34 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java 23 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java 11 ●●●●● patch | view | raw | blame | history
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);
    }
}
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);
        }
        // 查询可用调休申请