添加功能

This commit is contained in:
李鹏宇
2026-02-09 18:39:26 +08:00
parent 74510f684e
commit 18984d6474
11 changed files with 366 additions and 253 deletions
@@ -288,10 +288,9 @@ class HrAttendanceDetail(models.Model):
next_day = current_data + timedelta(days=1)
start_datetime = datetime.combine(current_data, datetime.min.time()) - timedelta(hours=8)
# 判断是否需要包含次日记录
if template.check_out_end < template.check_out_start:
end_datetime = datetime.combine(current_data, datetime.max.time()) - timedelta(hours=8)
if template.day2 == '次日':
end_datetime = datetime.combine(next_day, datetime.max.time()) - timedelta(hours=8)
else:
end_datetime = datetime.combine(current_data, datetime.max.time()) - timedelta(hours=8)
# 筛选当前员工当天的打卡记录
domain = [
('employee_id', '=', employee.id),
@@ -302,10 +301,9 @@ class HrAttendanceDetail(models.Model):
checkin_times = [rec.checkin_time + timedelta(hours=8) for rec in attendance_records if rec.checkin_time]
check_in_start = self.float_to_datetime(current_data, template.check_in_start)
if template.check_in_start > template.check_in_end:
check_in_end = self.float_to_datetime(current_data, template.check_in_end)
if template.day2 == '次日':
check_in_end = self.float_to_datetime(next_day, template.check_in_end)
else:
check_in_end = self.float_to_datetime(current_data, template.check_in_end)
valid_checkins = [
t for t in checkin_times
if check_in_start <= t <= check_in_end
@@ -314,11 +312,9 @@ class HrAttendanceDetail(models.Model):
# 上班时间:在上班范围内的最小打卡时间
check_in_time = min(valid_checkins) - timedelta(hours=8) if valid_checkins else None
check_out_start = self.float_to_datetime(current_data, template.check_out_start)
if template.check_out_end < template.check_out_start:
check_out_end = self.float_to_datetime(current_data, template.check_out_end)
if template.day2 == '次日':
check_out_end = self.float_to_datetime(next_day, template.check_out_end)
else:
check_out_end = self.float_to_datetime(current_data, template.check_out_end)
# 筛选在下班时间范围内的打卡记录
valid_checkouts = [t for t in checkin_times if check_out_start <= t <= check_out_end]
# 取最大的有效下班时间