From 9143022ee859e28c9d586ffe1dc995599ae9a925 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Tue, 10 Mar 2026 09:12:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8C=BA=E5=88=86=E8=AF=AF=E6=8A=A5(IGN?= =?UTF-8?q?ORED)=E5=92=8C=E8=87=AA=E5=8A=A8=E7=BB=93=E5=8D=95(DONE)?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - VLM误报和手动忽略的handle_status改为IGNORED - 自动结单(resolve_alarm)检查IGNORED状态,不覆盖误报 - 前端忽略操作兼容转换时自动设置handleStatus=IGNORED Co-Authored-By: Claude Opus 4.6 --- app/routers/wechat_callback.py | 2 +- app/routers/yudao_aiot_alarm.py | 5 ++++- app/services/alarm_event_service.py | 6 ++++-- app/services/notify_dispatch.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/routers/wechat_callback.py b/app/routers/wechat_callback.py index 4c65bb1..9838cec 100644 --- a/app/routers/wechat_callback.py +++ b/app/routers/wechat_callback.py @@ -94,7 +94,7 @@ async def alarm_action_callback( }, "ignore": { "alarm_status": "FALSE", - "handle_status": "DONE", + "handle_status": "IGNORED", "remark": "标记误报", }, } diff --git a/app/routers/yudao_aiot_alarm.py b/app/routers/yudao_aiot_alarm.py index fc51462..bea78da 100644 --- a/app/routers/yudao_aiot_alarm.py +++ b/app/routers/yudao_aiot_alarm.py @@ -228,7 +228,7 @@ async def handle_alert( alarmId: Optional[str] = Query(None, description="告警ID"), id: Optional[str] = Query(None, description="告警ID(兼容)"), alarmStatus: Optional[str] = Query(None, description="告警状态: CONFIRMED/FALSE/CLOSED"), - handleStatus: Optional[str] = Query(None, description="处理状态: HANDLING/DONE"), + handleStatus: Optional[str] = Query(None, description="处理状态: HANDLING/DONE/IGNORED"), status: Optional[str] = Query(None, description="处理状态(兼容旧接口)"), remark: Optional[str] = Query(None, description="处理备注"), service: AlarmEventService = Depends(get_alarm_event_service), @@ -244,6 +244,9 @@ async def handle_alert( if not alarmStatus and status: status_convert = {"handled": "CONFIRMED", "ignored": "FALSE", "resolved": "CLOSED"} alarmStatus = status_convert.get(status, status.upper()) + # 忽略操作设置 handle_status=IGNORED,区别于自动结单的 DONE + if status == "ignored" and not handleStatus: + handleStatus = "IGNORED" alarm = service.handle_alarm( alarm_id=alarm_id, diff --git a/app/services/alarm_event_service.py b/app/services/alarm_event_service.py index 0674ac1..ea34fe3 100644 --- a/app/services/alarm_event_service.py +++ b/app/services/alarm_event_service.py @@ -574,8 +574,10 @@ class AlarmEventService: except Exception: alarm.last_frame_time = beijing_now().replace(microsecond=0) - # 如果是人员回岗,标记为自动关闭 - if resolve_type == "person_returned": + # 如果已被 VLM 标记为误报(IGNORED),只更新时长,不覆盖状态 + if alarm.handle_status == "IGNORED": + logger.info(f"告警已为误报状态,仅更新时长: {alarm_id}") + elif resolve_type == "person_returned": alarm.alarm_status = "CLOSED" alarm.handle_status = "DONE" alarm.handle_remark = "人员回岗自动关闭" diff --git a/app/services/notify_dispatch.py b/app/services/notify_dispatch.py index 5c7c36f..3a080b1 100644 --- a/app/services/notify_dispatch.py +++ b/app/services/notify_dispatch.py @@ -154,7 +154,7 @@ def _mark_false_alarm(alarm_id: str): if alarm: now = beijing_now() alarm.alarm_status = "FALSE" - alarm.handle_status = "DONE" + alarm.handle_status = "IGNORED" alarm.handle_remark = "VLM复核判定误报" alarm.handled_at = now # 计算告警时长(VLM复核时间 - 事件时间)