From bbcd2e5bbe92ea2578b5655de789123a2584bb28 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Mon, 23 Mar 2026 11:48:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=88=9B=E5=BB=BA=EF=BC=8CVLM=E5=A4=8D?= =?UTF-8?q?=E6=A0=B8=E9=80=9A=E8=BF=87=E5=90=8E=E8=87=AA=E5=8A=A8=E8=B0=83?= =?UTF-8?q?IoT=E5=88=9B=E5=BB=BA=E5=B7=A5=E5=8D=95=E5=B9=B6=E5=AD=98orderI?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/notify_dispatch.py | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/services/notify_dispatch.py b/app/services/notify_dispatch.py index 93b3b9f..a1c6ba1 100644 --- a/app/services/notify_dispatch.py +++ b/app/services/notify_dispatch.py @@ -163,30 +163,30 @@ async def process_alarm_notification(alarm_data: Dict): else: logger.warning(f"个人卡片发送失败: {alarm_id}") - # ---- 4. 创建安保工单(暂未上线,待本地测试通过后启用) ---- - # wo_client = get_work_order_client() - # if wo_client.enabled: - # wo_area_id = _get_alarm_area_id(alarm_id) or area_id_int - # if wo_area_id: - # type_name = ALARM_TYPE_NAMES.get(alarm_type, alarm_type) - # wo_title = f"{type_name}告警" - # trigger_source = _get_trigger_source(alarm_id) - # permanent_url = _get_permanent_url(snapshot_url) - # order_id = await wo_client.create_order( - # title=wo_title, - # area_id=wo_area_id, - # alarm_id=alarm_id, - # alarm_type=type_name, - # description=description, - # priority=alarm_level, - # trigger_source=trigger_source, - # camera_id=device_id, - # image_url=permanent_url, - # ) - # if order_id: - # _save_order_id(alarm_id, order_id) - # else: - # logger.warning(f"告警无 area_id,跳过工单创建: {alarm_id}") + # ---- 4. 创建安保工单 ---- + wo_client = get_work_order_client() + if wo_client.enabled: + wo_area_id = _get_alarm_area_id(alarm_id) or area_id_int + if wo_area_id: + type_name = ALARM_TYPE_NAMES.get(alarm_type, alarm_type) + wo_title = f"{type_name}告警" + trigger_source = _get_trigger_source(alarm_id) + permanent_url = _get_permanent_url(snapshot_url) + order_id = await wo_client.create_order( + title=wo_title, + area_id=wo_area_id, + alarm_id=alarm_id, + alarm_type=type_name, + description=description, + priority=alarm_level, + trigger_source=trigger_source, + camera_id=device_id, + image_url=permanent_url, + ) + if order_id: + _save_order_id(alarm_id, order_id) + else: + logger.warning(f"告警无 area_id,跳过工单创建: {alarm_id}") except Exception as e: logger.error(f"告警通知处理失败: {alarm_id}, error={e}", exc_info=True)