feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-07 02:58:28 +08:00
1 parent 84a881b554
commit 74270adc22
149 files changed
+20111 -3871

No files matched your search

@@ -4,7 +4,8 @@ services/shipping_notice/query_service.py
用途:发货通知读模型 — 任务/批次查询、排序与序列化投影(含版本链、待办分类与任务中心字段)。
依赖:ShippingCase、ShippingOrderCandidate、ShippingNotice、ShippingTaskEvent、
ShippingReservation、ShippingOrderReviewCase、ShippingOrderProcessingRun、
ShippingOrderIntake / ShippingOrderProcessingRunIntake / FileAsset、state_machine、动态订单字段编辑器。
ShippingOrderIntake / ShippingOrderProcessingRunIntake / FileAsset、state_machine、动态订单字段编辑器、
order_review_projection(任务中心 STP retry 动作投影)。
逻辑:workspace_shipping_notice 与 shipping_notice_tools 的读路径统一经本模块;
co8 起 shipping_batches 已删除,批次 list API 返回空、按 batch_no 查询返回 None;
tools.py 通过 TaskProjection / BatchProjection 委托序列化与任务解析,写路径逐步下沉;
@@ -12,6 +13,7 @@ services/shipping_notice/query_service.py
以及统一 shipping_processing_status / progress_version / order_task_no(BE-02),
并注入 review_run_no 供任务中心深链订单处理工作台(UI-04);
list_my_todos / count_my_todos 合并建单前 Review Case、未建 OT Intake 与 Task 待办;
serialize_review_case_todo 在 STP failed/manual_fallback 时投影 retry_stp_auto_create;
客户关键字 SQL 同时过滤 Review Case / Intake(文件名)与 Task(客户快照/来源文件名);
待办 todo_category 下推为与状态机同序的 SQL CASE;list 用 UNION ALL + COUNT/OFFSET/LIMIT,
仅水合当前页(禁止 500 截断冒充总数);
@@ -1299,7 +1301,8 @@ def serialize_review_case_todo(
将建单前 Review Case 投影为「我的待办」列表项,供打开人工复核深链。
核心逻辑:附带 review_run_no / review_case_no / owner_agent_id / conversation_id;
todo_category 固定 review;entry_surface=review_workbench。
todo_category 固定 review;entry_surface=review_workbench;
STP failed/manual_fallback 时投影 retry_stp_auto_create(与工作台底栏同一幂等键)。
Args:
case: 开放中的 Review Case。
@@ -1321,6 +1324,35 @@ def serialize_review_case_todo(
and case.owner_user_id is not None
and int(case.owner_user_id) == int(viewer_user_id)
)
allowed_actions: list[str] = []
action_buttons: list[str] = []
automation_status: str | None = None
# [STEP] 任务中心与底栏共用 STP 重试入口:仅 failed/manual_fallback + 可处理人。
try:
from app.services.shipping_notice.order_review_projection import (
_project_case_automation_status,
_project_post_confirm_auto_progress,
)
draft = case.current_draft
automation = _project_case_automation_status(
case,
validation=dict(draft.validation_result_json or {}) if draft is not None else None,
post_confirm=_project_post_confirm_auto_progress(case),
)
if isinstance(automation, dict):
automation_status = str(automation.get('status') or '').strip() or None
if (
can_handle
and automation.get('retryable')
and automation_status in {'failed', 'manual_fallback'}
and not case.confirmed_task_id
):
allowed_actions.append('retry_stp_auto_create')
action_buttons.append('retry_stp_auto_create')
current_todo = '自动建单推进失败,可重试自动推进'
except Exception: # noqa: BLE001
automation_status = None
run_no = str(getattr(run, "run_no", None) or "").strip() or None
conversation_id = str(getattr(run, "conversation_id", None) or "").strip() or None
owner_agent_id = getattr(run, "owner_agent_id", None)
@@ -1343,7 +1375,7 @@ def serialize_review_case_todo(
"ui_state": {
"checkpoint": "order_review",
"checkpoint_kind": str(CheckpointKind.MUST_HUMAN),
"action_buttons": [],
"action_buttons": action_buttons,
"summary": {
"title": "待人工复核",
"message": current_todo,
@@ -1351,11 +1383,16 @@ def serialize_review_case_todo(
"checkpoint_kind": str(CheckpointKind.MUST_HUMAN),
"current_todo": current_todo,
"pause_reason": current_todo,
"pause_reason_code": f"review_case_{case.status}",
"pause_reason_code": (
f"stp_automation_{automation_status}"
if automation_status in {'failed', 'manual_fallback'}
else f"review_case_{case.status}"
),
"next_auto_step": None,
"event_at": case.updated_at.isoformat() if case.updated_at else None,
"entry_surface": "review_workbench",
"allowed_actions": [],
"allowed_actions": allowed_actions,
"automation_status": automation_status,
"issues": [],
"error_message": None,
},