feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

@@ -2,7 +2,7 @@
backend/app/services/shipping_notice/runtime_context.py
用途:构建货代发货通知 Agent 的 agent_runtime_context 领域适配层。
依赖:models.ShippingBatch/ShippingTask、agent_runtime_context.builder。
依赖:models.ShippingNotice、agent_runtime_context.builder。
逻辑:dify_inputs 与后台编排器在调用 Dify 前通过本模块生成最新业务现场,
Dify 只消费 snapshot,任务推进仍以 HXOPS 状态机和 Tool API 为准。
"""
@@ -12,7 +12,7 @@ from __future__ import annotations
import json
from typing import Any
from app.models import ShippingBatch, ShippingTask
from app.models import ShippingNotice
from app.services.agent_runtime_context.builder import build_agent_runtime_context
from app.services.shipping_notice.reference_context import build_shipping_reference_context
@@ -34,28 +34,21 @@ def _clean_text(value: Any) -> str:
return str(value or "").strip()
def _batch_no(batch: ShippingBatch | None, task: ShippingTask | None) -> str:
def _batch_no(batch: Any | None, task: ShippingNotice | None) -> str:
"""
获取当前上下文的批次号。
核心逻辑:优先使用显式 batch;缺失时从 task.batch 补齐,避免后台单票 run 丢失批次锚点。
Args:
batch: 当前批次。
task: 当前任务。
核心逻辑:shipping_batches 已删除;仅保留显式传入 batch 对象的兼容读取。
Returns:
批次号;无法识别时返回空字符串。
"""
if batch and _clean_text(getattr(batch, "batch_no", None)):
return _clean_text(batch.batch_no).upper()
task_batch = getattr(task, "batch", None)
if task_batch and _clean_text(getattr(task_batch, "batch_no", None)):
return _clean_text(task_batch.batch_no).upper()
return ""
def _task_no(task: ShippingTask | None) -> str:
def _task_no(task: ShippingNotice | None) -> str:
"""
获取当前上下文的任务号。
@@ -72,8 +65,8 @@ def _task_no(task: ShippingTask | None) -> str:
def _build_refs(
*,
task: ShippingTask | None,
batch: ShippingBatch | None,
task: ShippingNotice | None,
batch: Any | None,
run_purpose: str | None,
intake_nos: list[str] | None = None,
capability: str | None = None,
@@ -122,7 +115,7 @@ def _build_refs(
return refs
def _build_state_hint(task: ShippingTask | None, batch: ShippingBatch | None) -> dict[str, Any]:
def _build_state_hint(task: ShippingNotice | None, batch: Any | None) -> dict[str, Any]:
"""
构建发货通知运行态提示。
@@ -163,8 +156,8 @@ def _build_state_hint(task: ShippingTask | None, batch: ShippingBatch | None) ->
def _build_summary(
*,
task: ShippingTask | None,
batch: ShippingBatch | None,
task: ShippingNotice | None,
batch: Any | None,
run_purpose: str | None,
) -> str:
"""
@@ -207,8 +200,8 @@ def _build_summary(
def build_shipping_runtime_context(
*,
session_id: str,
task: ShippingTask | None = None,
batch: ShippingBatch | None = None,
task: ShippingNotice | None = None,
batch: Any | None = None,
trigger_source: str | None = None,
request_id: str | None = None,
locale: str | None = None,