功能:area_id 存储 + 工单对接代码完善 + 心跳端点

- AlarmEvent 模型添加 area_id 字段
- create_from_edge_report 提取 ext_data.area_id 存储
- 心跳端点 POST /api/ai/device/heartbeat
- work_order_client: create_order 支持完整参数(description/priority/triggerSource/cameraId/imageUrl)
- notify_dispatch: 工单标题中文化、alarmType 中文映射、永久 COS URL、triggerSource 来源判断
- oss_storage: 新增 get_permanent_url 方法
- 工单创建测试脚本

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 16:05:05 +08:00
parent ab338a509c
commit 44c5df7302
7 changed files with 508 additions and 47 deletions

View File

@@ -80,10 +80,26 @@ class WorkOrderClient:
area_id: int,
alarm_id: str,
alarm_type: str,
description: str = "",
priority: Optional[int] = None,
trigger_source: str = "自动上报",
camera_id: str = "",
image_url: str = "",
) -> Optional[str]:
"""
创建安保工单
Args:
title: 工单标题(中文告警类型,如"人员离岗告警"
area_id: 区域ID
alarm_id: 告警ID
alarm_type: 告警类型编码leave_post/intrusion等
description: VLM 大模型描述
priority: 优先级0紧急 1重要 2普通 3轻微
trigger_source: 来源(自动上报/人工上报)
camera_id: 摄像头ID
image_url: 截图URL
Returns:
orderId 字符串,失败返回 None
"""
@@ -97,6 +113,17 @@ class WorkOrderClient:
"alarmId": alarm_id,
"alarmType": alarm_type,
}
if description:
body["description"] = description
if priority is not None:
body["priority"] = priority
if trigger_source:
body["triggerSource"] = trigger_source
if camera_id:
body["cameraId"] = camera_id
if image_url:
body["imageUrl"] = image_url
body_json = json.dumps(body, ensure_ascii=False, separators=(",", ":"))
try: