yaozc
2024-05-30 86b0362eaf4c320dc6a54fc12ce80b0bf7890a85
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -71,7 +71,7 @@
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
//    private final AttendanceOvertimeRepository attendanceOvertimeRepository;
    private final AttendanceOvertimeRepository attendanceOvertimeRepository;
    private final DingTalkServiceImpl dingTalkService;
    @Override
@@ -367,6 +367,13 @@
                        new Calculate(attendanceGoOut.getOutStartTime().toLocalDateTime(), attendanceGoOut.getOutEndTime().toLocalDateTime())
                ).collect(Collectors.toList())
        );
        // 周末加班
        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, startOfDate, endOfDate);
        attendanceParts.addAll(
                attendanceOvertimeList.stream().map(attendanceOvertime ->
                        new Calculate(attendanceOvertime.getOvertimeStartTime().toLocalDateTime(), attendanceOvertime.getOvertimeEndTime().toLocalDateTime())
                ).collect(Collectors.toList())
        );
        attendanceParts.stream().sorted().reduce(new Stack<Calculate>(), (result, current) -> {
            // 删除重复时间,合并相连的时间段
            if (result.empty()) {
@@ -415,7 +422,7 @@
                .filter(attendanceLeave -> Constant.LEAVE_TYPE_ANNUAL_LEAVE.equals(attendanceLeave.getLeaveType())
                    || Constant.LEAVE_TYPE_MARRIAGE_HOLIDAY.equals(attendanceLeave.getLeaveType())
                    || Constant.LEAVE_TYPE_BEREAVEMENT_LEAVE.equals(attendanceLeave.getLeaveType())
                    || Constant.LEAVE_TYPE_REPLACE.equals(attendanceLeave.getLeaveType())
//                    || Constant.LEAVE_TYPE_REPLACE.equals(attendanceLeave.getLeaveType())
                ).map(attendanceLeave -> BigDecimal.valueOf(attendanceLeave.getLeaveDuration())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
        return result.add(annualLeaveHours).doubleValue();
    }