!3731 添加功能

Merge pull request !3731 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-07-08 10:00:15 +00:00
committed by Gitee
@@ -309,16 +309,34 @@ class AppletAttendance(Controller):
def process_attendances(self, attendances, user_id):
records = []
for att in attendances:
if not att.shift_id:
year = att.current_data.year
month = att.current_data.month
day = att.current_data.day
current_date = datetime.today()
min_hour_from = att.employee_id.resource_id.calendar_id.attendance_ids[0].hour_from
min_hour = int(min_hour_from)
min_minute = int(min_hour_from * 10 % min_hour_from)
will_datetime_start = current_date.replace(year=year, month=month, day=day, hour=min_hour,
minute=min_minute)
max_hour_to = att.employee_id.resource_id.calendar_id.attendance_ids[-1].hour_to
max_hour = int(max_hour_to)
max_minute = int(max_hour_to * 10 % max_hour_to)
will_datetime_end = current_date.replace(year=year, month=month, day=day, hour=max_hour,
minute=max_minute)
standard_check_in_str = will_datetime_start.strftime('%H:%M')
standard_check_out_str = will_datetime_end.strftime('%H:%M')
else:
# 获取班次信息
check_in_start = att.shift_id.template_id.check_in_start if att.shift_id and att.shift_id.template_id else 0
check_out_end = att.shift_id.template_id.check_out_end if att.shift_id and att.shift_id.template_id else 0
start_hour = int(check_in_start)
start_minute = int((check_in_start - start_hour) * 60)
end_hour = int(check_out_end)
end_minute = int((check_out_end - end_hour) * 60)
# 格式化标准时间
standard_check_in_str = f"{start_hour:02d}:{start_minute:02d}"
standard_check_out_str = f"{end_hour:02d}:{end_minute:02d}"
check_in_start = att.shift_id.template_id.check_in_start if att.shift_id and att.shift_id.template_id else 0
check_out_end = att.shift_id.template_id.check_out_end if att.shift_id and att.shift_id.template_id else 0
start_hour = int(check_in_start)
start_minute = int((check_in_start - start_hour) * 60)
end_hour = int(check_out_end)
end_minute = int((check_out_end - end_hour) * 60)
# 格式化标准时间
standard_check_in_str = f"{start_hour:02d}:{start_minute:02d}"
standard_check_out_str = f"{end_hour:02d}:{end_minute:02d}"
# 实际打卡时间
check_in = att.check_in
@@ -377,8 +395,8 @@ class AppletAttendance(Controller):
# 处理法定节假日和调休日- 直接从date_from和date_to获取
if leaves.date_from and leaves.date_to:
# 将datetime类型转换为date类型并格式化为YYYY-MM-DD
date_from = leaves.date_from.date().isoformat()
date_to = leaves.date_to.date().isoformat()
date_from = (leaves.date_from + timedelta(hours=8)).date().isoformat()
date_to = (leaves.date_to + timedelta(hours=8)).date().isoformat()
# 处理日期范围,添加从date_from到date_to的所有日期
start_date_obj = datetime.strptime(date_from, '%Y-%m-%d').date()
end_date_obj = datetime.strptime(date_to, '%Y-%m-%d').date()
@@ -389,9 +407,10 @@ class AppletAttendance(Controller):
# 处理调班补班
if leaves.shift_replacement_day:
for shift_day in leaves.shift_replacement_day.split(','):
month, day = shift_day.replace('月', '').replace('日', '').split()
formatted_date = f"{current_year}-{int(month):02d}-{int(day):02d}"
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)
return {