BAOLH
2026-03-30 029316bf586f147b681aa26cfc55ed337ed7522c
Merge branch 'wcd-2411-update' into wcd
2 files modified
42 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java 15 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java 27 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
@@ -28,6 +28,21 @@
        return Duration.between(start, end);
    }
    public static List<Calculate> calculateRemainingCalculate(Calculate mainPeriod, Calculate... excludedPeriods) {
        List<Calculate> remainPeriods = new ArrayList<>();
        remainPeriods.add(mainPeriod);
        for (Calculate excluded : excludedPeriods) {
            List<Calculate> newRemaining = new ArrayList<>();
            for (Calculate remain : remainPeriods) {
                newRemaining.addAll(subtractPeriod(remain, excluded));
            }
            remainPeriods = newRemaining;
        }
        return remainPeriods;
    }
    public static Duration calculateRemainingDuration(Calculate mainPeriod, Calculate... excludedPeriods) {
        List<Calculate> remainPeriods = new ArrayList<>();
        remainPeriods.add(mainPeriod);
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -661,7 +661,7 @@
        return Stream.iterate(startDate, d -> d.plusDays(1)).limit(distance + 1).filter(localDate -> {
            SysConfigHoliday currentSysConfigHoliday = sysConfigHolidayMonthList.stream().filter(sch -> sch.getHolidayDate().toLocalDateTime().isEqual(localDate.atStartOfDay())).findFirst().orElse(null);
            if (StringUtils.isBlank(type)) {
            if (StringUtils.isBlank(type) || type.equals(Constant.DATE_TYPE_WEEKDAY)) {
                // 默认(工作日)
                if (currentSysConfigHoliday != null) {
                    return Constant.DATE_TYPE_WEEKDAY.equals(currentSysConfigHoliday.getDateType());
@@ -697,7 +697,16 @@
            // 正常时间管理
            List<Calculate> breakParts = new ArrayList<>();
            if (StringUtils.isBlank(type) || type.equals(Constant.DATE_TYPE_WEEKDAY)) {
                // 工作日:去除工作时间及休息时间
            breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30)));
            } else {
                // 其他:仅去除休息时间
                LocalDateTime lunchStartTime = attendanceDate.getRosteringLunchStartTime() == null ? null : attendanceDate.getRosteringLunchStartTime().toLocalDateTime();
                LocalDateTime lunchEndTime = attendanceDate.getRosteringLunchEndTime() == null ? null : attendanceDate.getRosteringLunchEndTime().toLocalDateTime();
                breakParts.add(new Calculate(lunchStartTime, lunchEndTime));
                breakParts.add(new Calculate(rosteringWorkEndTime, rosteringWorkEndTime.plusMinutes(30)));
            }
            // 查询调休(因工作日加班过0点加班时间可转调休的规定,部分调休与加班时间重复,需要扣除这部分时间,具体可咨询Lief)
            List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
            breakParts.addAll(attendanceOvertimeList.stream().map(ao -> new Calculate(ao.getOvertimeStartTime().toLocalDateTime(), ao.getOvertimeEndTime().toLocalDateTime())).collect(Collectors.toList()));
@@ -732,21 +741,7 @@
                return result;
            }, (o1, o2) -> null).forEach(calculate -> {
                // 去除休息时间:午休等
                for (Calculate breakPart : breakParts) {
                    if ((!calculate.getStart().isAfter(breakPart.getStart()) && !calculate.getEnd().isBefore(breakPart.getStart()))
                            || (!calculate.getStart().isAfter(breakPart.getEnd()) && !calculate.getEnd().isBefore(breakPart.getEnd()))) {
                        Calculate calculate1 = new Calculate(calculate.getStart(), breakPart.getStart());
                        Calculate calculate2 = new Calculate(breakPart.getEnd(), calculate.getEnd());
                        if (calculate1.getStart().isBefore(calculate1.getEnd())) {
                            resultParts.add(calculate1);
                        }
                        if (calculate2.getStart().isBefore(calculate2.getEnd())) {
                            resultParts.add(calculate2);
                        }
                    } else if (calculate.getEnd().isBefore(breakPart.getStart()) || calculate.getStart().isAfter(breakPart.getEnd())) {
                        resultParts.add(calculate);
                    }
                }
                resultParts.addAll(Calculate.calculateRemainingCalculate(calculate, breakParts.toArray(new Calculate[0])));
            });
            // 出勤时间累计