From cd380823f7e21eebf07f87040f1b4cacbf5a8863 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Tue, 8 Jul 2025 18:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/applet_attendance.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py index c5ae07881..47031c10d 100644 --- a/yuthon_hr_attendance/controllers/applet_attendance.py +++ b/yuthon_hr_attendance/controllers/applet_attendance.py @@ -372,7 +372,8 @@ class AppletAttendance(Controller): 包含假期和调休信息的字典 """ # 从start_date中提取年份 - current_year = start_date.year + target_year = start_date.year + target_month = start_date.month domain = [("calendar_id", "=", "行政考勤工作日")] if start_date and end_date: # 将date对象转换为datetime对象 @@ -401,17 +402,25 @@ class AppletAttendance(Controller): start_date_obj = datetime.strptime(date_from, '%Y-%m-%d').date() end_date_obj = datetime.strptime(date_to, '%Y-%m-%d').date() delta = end_date_obj - start_date_obj + for i in range(delta.days + 1): day = start_date_obj + timedelta(days=i) - holidays_list.append(day.isoformat()) + # 只添加年份和月份匹配的日期 + if day.year == target_year and day.month == target_month: + holidays_list.append(day.isoformat()) # 处理调班补班 if leaves.shift_replacement_day: day_strings = leaves.shift_replacement_day.split(',') for day_str in day_strings: month_str, day_str = day_str.strip().replace('日', '').split('月') - formatted_date = f"{current_year}-{int(month_str):02d}-{int(day_str):02d}" - shift_days_list.append(formatted_date) + month = int(month_str) + day = int(day_str) + + # 只添加月份匹配的日期 + if month == target_month: + formatted_date = f"{target_year}-{month:02d}-{day:02d}" + shift_days_list.append(formatted_date) return { "holiday_list": holidays_list,