BAOLH
2025-08-06 a561153115514a8ac76037c1348f6d4ddb171f5e
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -74,13 +74,9 @@
public class AttendanceGoOutServiceImpl implements AttendanceGoOutService {
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceOvertimeService attendanceOvertimeService;
    private final AttendanceGoOutMapper attendanceGoOutMapper;
    private final UserRepository userRepository;
    private final AttendanceService attendanceService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final AttendanceRepository attendanceRepository;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final ApproveEventRepository approveEventRepository;
@@ -526,31 +522,41 @@
        LocalTime endTime = calculate.getEnd().toLocalTime();
        long distance = ChronoUnit.DAYS.between(startDate, endDate);
        return Stream.iterate(startDate, d -> d.plusDays(1)).limit(distance + 1).map(localDate -> {
            SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
            if ((sysConfigHolidayDto == null && !isWeekend) ||
                    sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
//            SysConfigHolidayDto sysConfigHolidayDto = sysConfigHolidayService.queryByHolidayDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//            Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
//            if ((sysConfigHolidayDto == null && !isWeekend) ||
//                    sysConfigHolidayDto != null && Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDto.getDateType())) {
//
//                LocalDateTime goOutStartTime = localDate.atTime(startTime);
//                LocalDateTime goOutEndTime = localDate.atTime(endTime);
//                LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
//                LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
//
//
//                if (goOutEndTime.isBefore(lunchStartTime) || goOutStartTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
//                } else if (!goOutEndTime.isBefore(lunchStartTime) && !goOutEndTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, lunchStartTime);
//                } else if (!goOutStartTime.isBefore(lunchStartTime) && !goOutStartTime.isAfter(lunchEndTime)) {
//                    return ChronoUnit.SECONDS.between(lunchEndTime, goOutEndTime);
//                } else {
//                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime) - 3600;
//                }
//            } else {
//                LocalDateTime goOutStartTime = localDate.atTime(startTime);
//                LocalDateTime goOutEndTime = localDate.atTime(endTime);
//                return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
//            }
                LocalDateTime goOutStartTime = localDate.atTime(startTime);
                LocalDateTime goOutEndTime = localDate.atTime(endTime);
                LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
                LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
                if (goOutEndTime.isBefore(lunchStartTime) || goOutStartTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
                } else if (!goOutEndTime.isBefore(lunchStartTime) && !goOutEndTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(goOutStartTime, lunchStartTime);
                } else if (!goOutStartTime.isBefore(lunchStartTime) && !goOutStartTime.isAfter(lunchEndTime)) {
                    return ChronoUnit.SECONDS.between(lunchEndTime, goOutEndTime);
                } else {
                    return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime) - 3600;
                }
            } else {
                LocalDateTime goOutStartTime = localDate.atTime(startTime);
                LocalDateTime goOutEndTime = localDate.atTime(endTime);
                return ChronoUnit.SECONDS.between(goOutStartTime, goOutEndTime);
            }
            // TODO:20250806修改 减去下班后休息时段
            LocalDateTime goOutStartTime = localDate.atTime(startTime);
            LocalDateTime goOutEndTime = localDate.atTime(endTime);
            LocalDateTime lunchStartTime = localDate.atTime(sysRostering.getLunchStartTime());
            LocalDateTime lunchEndTime = localDate.atTime(sysRostering.getLunchEndTime());
            LocalDateTime offStartTime = localDate.atTime(sysRostering.getWorkEndTime());
            LocalDateTime offEndTime = offStartTime.plusMinutes(30L);
            Duration duration = Calculate.calculateRemainingDuration(new Calculate(goOutStartTime, goOutEndTime), new Calculate(lunchStartTime, lunchEndTime), new Calculate(offStartTime, offEndTime));
            return duration.get(ChronoUnit.SECONDS);
        }).reduce(0L, (result, current) -> result + current);
    }