修复 Agent 对接 IoT 工单平台:状态同步、图片持久化、roiId 字段

1. agent_dispatcher: IoT 成功与否都更新本地告警状态,不再依赖回调同步
2. agent_dispatcher: submit_order_result 持久化图片 URL 到 alarm_event_ext
3. work_order_client: create_order 添加 roi_id/source_type 参数
4. notify_dispatch: 创建工单时传 scene_id 作为 roiId
This commit is contained in:
2026-03-25 12:37:00 +08:00
parent 7d4c916055
commit eb2d74bd4c
3 changed files with 60 additions and 40 deletions

View File

@@ -85,6 +85,8 @@ class WorkOrderClient:
trigger_source: str = "自动上报",
camera_id: str = "",
image_url: str = "",
roi_id: str = "",
source_type: str = "",
) -> Optional[str]:
"""
创建安保工单
@@ -123,19 +125,24 @@ class WorkOrderClient:
body["cameraId"] = camera_id
if image_url:
body["imageUrl"] = image_url
if roi_id:
body["roiId"] = roi_id
if source_type:
body["sourceType"] = source_type
body_json = json.dumps(body, ensure_ascii=False, separators=(",", ":"))
try:
headers = self._build_headers(body_json)
url = f"{self._base_url}/open-api/ops/security/order/create"
logger.info(f"创建工单请求: url={url}, body={body_json}")
async with httpx.AsyncClient(timeout=self._timeout) as client:
resp = await client.post(url, content=body_json, headers=headers)
data = resp.json()
if data.get("code") != 0:
logger.error(f"创建工单失败: {data}")
logger.error(f"创建工单失败: status={resp.status_code}, resp={data}, body={body_json}")
return None
# API 返回 {"code":0, "data": 1234567890} — data 直接是 orderId