feat(shipping-notice): 新增发货通知重复检测与处理接口,支持重复决策保存与重新执行检测

This commit is contained in:
hugo committed 2026-07-14 21:12:36 +08:00
1 parent 729546a7b7
commit ceb49461e8
72 files changed
+14270 -460

No files matched your search

@@ -894,6 +894,43 @@ def test_inventory_source_review_chat_actions_do_not_list_all_sources(app):
]
def test_parse_stage_ui_state_lists_all_issues(app):
"""文件解析阶段 UI State 应一次列出库存源问题、解析 warnings(含存量延后低置信度提示)。"""
from app.services.shipping_notice.ui_state import build_task_ui_state
with app.app_context():
task = ShippingTask(
task_no="SN-PARSE-ISSUES-LIST",
source_type="pdf",
process_status="pending_review",
pending_human_reason="inventory_source_unresolved",
error_message="无法根据发货通知唯一确定库存查询来源",
parse_confidence=0.4,
step_payload_json={
"pending_parse_review_after_source": True,
"inventory_source_resolution": {"status": "unresolved", "candidates": []},
"current_step_progress": {
"extra": {
"warnings": [
"部分订单行缺少 Reservation ID,可能影响精确匹配。",
"parse_fallback_heuristic",
]
}
},
},
)
ui_state = build_task_ui_state(task)
issues = ui_state["summary"]["issues"]
assert ui_state["checkpoint"] == "inventory_source_review"
assert issues[0] == "无法根据发货通知唯一确定库存查询来源"
assert "部分订单行缺少 Reservation ID,可能影响精确匹配。" in issues
assert "解析引擎回退到启发式规则,请人工核对字段。" in issues
assert "解析置信度不足,确认库存源后仍需复核解析结果。" in issues
assert len(issues) == 4
def test_workspace_shipping_ui_state_is_embedded_in_workspace_reads(app, client):
"""任务/批次工作台读接口直接返回 UI State,Chat 和工作台不再各自推导状态。"""
headers = _workspace_headers(app)