日程管理

This commit is contained in:
李鹏宇
2026-03-09 11:10:44 +08:00
parent 3aecbfca22
commit 8dfb1c28b4
+20 -8
View File
@@ -159,19 +159,31 @@ class YuthonWillTask(models.Model):
}
from_time = hour_mapping.get(record.request_hour_from, "")
to_time = hour_mapping.get(record.request_hour_to, "")
if date_str and from_time and to_time:
# 当类型为会议且关联了会议室预订时,拼接结束时间
if record.task_type == 'meet' and record.room_booking_id:
# 获取会议室预订的结束时间(本地时间 UTC+8)
stop_datetime = record.room_booking_id.stop_datetime
if stop_datetime:
if date_str and from_time:
# 当类型为会议时,显示开始时间和结束时间
if record.task_type == 'meet':
if record.room_booking_id and record.room_booking_id.start_datetime and record.room_booking_id.stop_datetime:
# 有关联会议室预订,使用会议室的时间
start_datetime = record.room_booking_id.start_datetime
stop_datetime = record.room_booking_id.stop_datetime
# 转换为本地时间
local_start = start_datetime + timedelta(hours=8)
local_stop = stop_datetime + timedelta(hours=8)
start_date_str = local_start.strftime("%Y/%m/%d")
start_time_str = local_start.strftime("%H:%M")
stop_time_str = local_stop.strftime("%H:%M")
record.task_time = f"{date_str} {record.task_week} {from_time}-{stop_time_str}"
# 计算周几
weekdays = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
week_str = weekdays[local_start.weekday()]
record.task_time = f"{start_date_str} {week_str} {start_time_str}-{stop_time_str}"
else:
record.task_time = f"{date_str} {record.task_week} {from_time}"
# 没有关联会议室,使用日程的开始和结束时间
if to_time:
record.task_time = f"{date_str} {record.task_week} {from_time}-{to_time}"
else:
record.task_time = f"{date_str} {record.task_week} {from_time}"
else:
# 日程类型,只显示开始时间
record.task_time = f"{date_str} {record.task_week} {from_time}"
else:
record.task_time = ""