From 1080f90a2470c1049f2bf10f59cc25284e33f752 Mon Sep 17 00:00:00 2001 From: hdka <823267011@qq.com> Date: Thu, 12 Jun 2025 18:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E4=B8=AA=E6=AD=BB=E8=B4=A2=E5=8A=A1?= =?UTF-8?q?=E6=8F=90=E7=9A=84=E8=8E=AB=E5=90=8D=E5=85=B6=E5=A6=99=E7=9A=84?= =?UTF-8?q?=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/oa/SysOaAttendanceMapper.xml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ruoyi-oa/src/main/resources/mapper/oa/SysOaAttendanceMapper.xml b/ruoyi-oa/src/main/resources/mapper/oa/SysOaAttendanceMapper.xml index b324057..d3318db 100644 --- a/ruoyi-oa/src/main/resources/mapper/oa/SysOaAttendanceMapper.xml +++ b/ruoyi-oa/src/main/resources/mapper/oa/SysOaAttendanceMapper.xml @@ -319,12 +319,26 @@ (#{calcTime} IS NOT NULL AND #{calcTime} >= oas.create_time) - OR (#{calcTime} IS NULL AND oas.create_time BETWEEN - -- 提取relationMonth的年月部分并构造第一天 + OR ( + #{calcTime} IS NULL AND ( + -- 如果 relationMonth 是当前月,则查询本月最晚的记录 + (DATE_FORMAT(#{relationMonth}, '%Y-%m') = DATE_FORMAT(CURRENT_DATE, '%Y-%m') + AND oas.create_time BETWEEN DATE_FORMAT(#{relationMonth}, '%Y-%m-01') + AND ( + SELECT MAX(oar.calc_time) + FROM oa_attendance_record oar + WHERE oar.user_id = #{userId} + AND oar.del_flag = 0 + ) + -- 如果 relationMonth 不是当前月,则查询整个 relationMonth 的记录 + OR oas.create_time BETWEEN DATE_FORMAT(#{relationMonth}, '%Y-%m-01') - AND LAST_DAY(STR_TO_DATE(#{relationMonth}, '%Y-%m-%d')) + AND LAST_DAY(STR_TO_DATE(#{relationMonth}, '%Y-%m-01')) ) ) + ) + ) +