fix: 区分误报(IGNORED)和自动结单(DONE)状态
- VLM误报和手动忽略的handle_status改为IGNORED - 自动结单(resolve_alarm)检查IGNORED状态,不覆盖误报 - 前端忽略操作兼容转换时自动设置handleStatus=IGNORED Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -94,7 +94,7 @@ async def alarm_action_callback(
|
||||
},
|
||||
"ignore": {
|
||||
"alarm_status": "FALSE",
|
||||
"handle_status": "DONE",
|
||||
"handle_status": "IGNORED",
|
||||
"remark": "标记误报",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 = "人员回岗自动关闭"
|
||||
|
||||
@@ -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复核时间 - 事件时间)
|
||||
|
||||
Reference in New Issue
Block a user