From 3d2900f1f5c81042b8ee0345ac7bef1b2f71b621 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Fri, 14 Mar 2025 01:32:06 +0000
Subject: [PATCH] Merge branch 'wcd' into wcd-2411-update

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 45 insertions(+), 9 deletions(-)

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 7ba7007..83db201 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
@@ -455,20 +455,54 @@
      */
     @Override
     public Double getOverTimeLength(Long userId) {
-        //获取年假剩余(新)
+        //获取调休假剩余时长
         Double surplusYearTime = new Double(0.00);
 
-        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndApprovalStatus(userId, Constant.OVERTIME_PASS);
-        if (attendanceOvertimeList.size() > 0) {
+        LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(3);
+        LocalDate localDateEnd = LocalDate.now().plusDays(1);
+
+        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay());
+        if (!attendanceOvertimeList.isEmpty()) {
             surplusYearTime = attendanceOvertimeList.stream()
                     .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
                     .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
-            Double usedTime = attendanceLeaveRepository.sumLeaveDurationByUserIdAndLeaveType(userId, Constant.LEAVE_TYPE_REPLACE);
-            if (usedTime != null) {
+            Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+            if (usedTime > 0) {
                 surplusYearTime = surplusYearTime - usedTime;
             }
         }
-        return surplusYearTime;
+        if (surplusYearTime <= 0.0) {
+            return 0.0;
+        }
+        return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    /**
+     * 获取用户调休假结算时长
+     */
+    @Override
+    public Double getOverTimeCloseLength(Long userId) {
+        //获取年假剩余(新)
+        Double surplusYearTime = new Double(0.00);
+
+        LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(4);
+        LocalDate localDateEnd = LocalDate.now().plusDays(1);
+
+
+        List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateStart.plusMonths(1).withDayOfMonth(1).atStartOfDay());
+        if (!attendanceOvertimeList.isEmpty()) {
+            surplusYearTime = attendanceOvertimeList.stream()
+                    .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
+                    .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
+            Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
+            if (usedTime > 0) {
+                surplusYearTime = surplusYearTime - usedTime;
+            }
+        }
+        if (surplusYearTime <= 0.0) {
+            return 0.0;
+        }
+        return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
     }
 
     /**
@@ -487,9 +521,11 @@
             User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
             userList.add(user);
         }
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
-        String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
-        dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList);
+        if (attendanceLeave.getLeaveStartTime().before(new Date())) {
+            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+            String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
+            dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate,userList);
+        }
     }
 
     @Override

--
Gitblit v1.9.3