feat: 事件异常主账起停等待接口

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 18:21:03 +08:00
co-authored by Cursor
parent 9e27bada94
commit 1bab19f1a2
4 changed files with 241 additions and 0 deletions
@@ -7,11 +7,14 @@
from __future__ import annotations
import logging
from typing import Any
from agent.schema.land_options import canonicalize_land_class
from agent.schema.sea_options import canonicalize_sea_class
logger = logging.getLogger(__name__)
WAIT_AIR_QUOTE = "air_quote"
WAIT_PRODUCT_QUOTE = "product_quote"
WAIT_ADOPT = "adopt"
@@ -106,6 +109,50 @@ def format_timeout_hours(hours: float) -> str:
return text or "0"
def append_summary(existing: str, type_name: str) -> str:
"""多次异常用分号拼接,同一类型不重复。"""
add = (type_name or "").strip()
cur = (existing or "").strip()
if not add:
return cur
if not cur or cur == "-":
return add
parts = [p.strip() for p in cur.split(";") if p.strip()]
if add in parts:
return cur
parts.append(add)
return ";".join(parts)
def start_wait(ledger: Any, *, work_order_no: str, wait_kind: str) -> None:
"""开始盯等待。失败只打日志,不抛给回调。"""
no = (work_order_no or "").strip()
kind = (wait_kind or "").strip()
if not no or not kind or ledger is None:
return
fn = getattr(ledger, "start_event_wait", None)
if not callable(fn):
return
try:
fn(work_order_no=no, wait_kind=kind)
except Exception:
logger.exception("start_event_wait 失败 wo=%s kind=%s", no, kind)
def clear_wait(ledger: Any, *, work_order_no: str) -> None:
"""清空当前等待,不改事件异常摘要。失败只打日志。"""
no = (work_order_no or "").strip()
if not no or ledger is None:
return
fn = getattr(ledger, "clear_event_wait", None)
if not callable(fn):
return
try:
fn(work_order_no=no)
except Exception:
logger.exception("clear_event_wait 失败 wo=%s", no)
def pick_mentions(
*,
wait_kind: str,