From 0a73f646e35f36dc5b828fe1b9f5cfeb9357c99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Thu, 6 Aug 2026 15:56:40 +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 --- yuthon_issue/models/inherit_room_booking.py | 65 ++++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/yuthon_issue/models/inherit_room_booking.py b/yuthon_issue/models/inherit_room_booking.py index acf77af07..58ff31ab4 100644 --- a/yuthon_issue/models/inherit_room_booking.py +++ b/yuthon_issue/models/inherit_room_booking.py @@ -164,51 +164,58 @@ class RoomBooking(models.Model): """两个时间范围是否有重叠""" return b1_start < b2_stop and b2_start < b1_stop - # 班子会:党的 party_char 非空(党已上会),班子与党的时间不能重叠 - if is_class_meeting: + def _check_time_order_and_overlap(target_bookings, target_type_name): + """ + 检查前置会议是否早于当前会议,且时间不重叠 + target_bookings: 前置会议记录集 + target_type_name: 前置会议类型名称(用于错误提示) + """ + for tb in target_bookings: + if not (tb.start_datetime and tb.stop_datetime): + continue + + # 前置会议必须早于当前会议 + if tb.start_datetime >= record.start_datetime: + raise UserError( + f'议题“{issue.name}”的{target_type_name}会议时间({tb.start_datetime} ~ {tb.stop_datetime})' + f'必须早于{record.meeting_type_id.name}会议时间({record.start_datetime} ~ {record.stop_datetime})!' + ) + + # 时间不能重叠 + if _has_overlap(record.start_datetime, record.stop_datetime, + tb.start_datetime, tb.stop_datetime): + raise UserError( + f'议题“{issue.name}”的{target_type_name}会议时间({tb.start_datetime} ~ {tb.stop_datetime})' + f'与{record.meeting_type_id.name}会议时间({record.start_datetime} ~ {record.stop_datetime})有重叠!' + ) + + # ========== 班子会:党的 party_char 非空(党已上会),班子必须晚于党,且时间不能重叠 ========== + if is_class_meeting and line.issue_library_id.is_party == True: clean_party = re.sub(r'<[^>]+>', '', issue.party_char or '').strip() if clean_party: party_bookings = other_bookings.filtered( lambda b: b.meeting_type_id and '党' in str(b.meeting_type_id.name) - and b.start_datetime and b.stop_datetime + and b.start_datetime and b.stop_datetime ) - for pb in party_bookings: - if _has_overlap(record.start_datetime, record.stop_datetime, - pb.start_datetime, pb.stop_datetime): - raise UserError( - f'议题“{issue.name}”的党会议时间({pb.start_datetime} ~ {pb.stop_datetime})' - f'与班子会议时间({record.start_datetime} ~ {record.stop_datetime})有重叠' - ) + _check_time_order_and_overlap(party_bookings, '党') - # 董事会:如果班子已上会,董事与班子的时间不能重叠;否则如果党已上会,董事与党的时间不能重叠 - if is_boss_meeting: + # ========== 董事会:如果班子已上会,董事必须晚于班子;否则如果党已上会,董事必须晚于党 ========== + if is_boss_meeting and line.issue_library_id.is_class == True: clean_class = re.sub(r'<[^>]+>', '', issue.class_char or '').strip() if clean_class: class_bookings = other_bookings.filtered( lambda b: b.meeting_type_id and '班子' in str(b.meeting_type_id.name) - and b.start_datetime and b.stop_datetime + and b.start_datetime and b.stop_datetime ) - for cb in class_bookings: - if _has_overlap(record.start_datetime, record.stop_datetime, - cb.start_datetime, cb.stop_datetime): - raise UserError( - f'议题“{issue.name}”的班子会议时间({cb.start_datetime} ~ {cb.stop_datetime})' - f'与董事会议时间({record.start_datetime} ~ {record.stop_datetime})有重叠' - ) + _check_time_order_and_overlap(class_bookings, '班子') else: clean_party = re.sub(r'<[^>]+>', '', issue.party_char or '').strip() - if clean_party: + if clean_party and line.issue_library_id.is_party == True: party_bookings = other_bookings.filtered( lambda b: b.meeting_type_id and '党' in str(b.meeting_type_id.name) - and b.start_datetime and b.stop_datetime + and b.start_datetime and b.stop_datetime ) - for pb in party_bookings: - if _has_overlap(record.start_datetime, record.stop_datetime, - pb.start_datetime, pb.stop_datetime): - raise UserError( - f'议题“{issue.name}”的党会议时间({pb.start_datetime} ~ {pb.stop_datetime})' - f'与董事会议时间({record.start_datetime} ~ {record.stop_datetime})有重叠' - ) + _check_time_order_and_overlap(party_bookings, '党') @api.depends_context('uid', 'company') @api.depends('company_id')