feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口

完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
hugo committed 2026-08-11 14:04:39 +08:00
1 parent 8e0bbf7a81
commit c94d173f92
181 files changed
+12947 -1724

No files matched your search

+41 -12
View File
@@ -190,6 +190,39 @@ def test_parse_notice_tool_is_removed(app, client):
assert response.status_code == 404
def test_direct_excel_tool_dispatches_to_formal_auto_progress(monkeypatch):
"""旧 Tool 入口不能绕过 GateAttempt 直接生成 Excel。"""
from app.services.shipping_notice import fulfillment_workflow
submitted: dict[str, object] = {}
def _submit(task_no, **kwargs):
submitted['task_no'] = task_no
submitted.update(kwargs)
return {'status': 'running', 'data': {}}
monkeypatch.setattr(
'app.services.shipping_notice.progress_workflow.run_task_auto_progress',
_submit,
)
result = fulfillment_workflow.generate_excel({
'task_id': 'SN-FORMAL-EXCEL-ONLY',
'operator_id': 7,
'idempotency_key': 'formal-excel-only',
})
assert result['status'] == 'running'
assert submitted == {
'task_no': 'SN-FORMAL-EXCEL-ONLY',
'trigger': 'tool_api_generate_excel',
'expected_version': None,
'idempotency_key': 'formal-excel-only',
'resume_gate_code': 'artifact_generation',
'operator_id': 7,
}
def test_match_notice_lines_reports_progress():
seen: list[tuple[int, int]] = []
@@ -806,7 +839,7 @@ def test_submit_decision_requires_task_id_when_conversation_has_multiple_tasks(a
assert rows["SN-MULTI-CONV-002"].process_status == "pending_review"
def test_submit_decision_retry_rpa_routes_to_inventory_workflow(app, client, monkeypatch):
def test_submit_decision_retry_rpa_routes_to_formal_gate_action(app, client, monkeypatch):
headers = _tool_headers(app)
create_res = client.post(
@@ -820,15 +853,11 @@ def test_submit_decision_retry_rpa_routes_to_inventory_workflow(app, client, mon
captured: dict[str, object] = {}
def fake_ensure_inventory(payload):
captured.update(payload)
return {
"status": "running",
"task_id": payload["task_id"],
"message": "已触发库存获取(测试桩)",
}
def fake_request_formal_gate_action(**kwargs):
captured.update(kwargs)
return {"status": "running", "task_id": task_id, "message": "已提交正式 20-Gate 恢复动作"}
monkeypatch.setattr(decision_workflow, "ensure_inventory", fake_ensure_inventory)
monkeypatch.setattr(decision_workflow, "_request_formal_gate_action", fake_request_formal_gate_action)
res = client.post(
"/api/shipping-notice/tools/submit_decision",
@@ -838,9 +867,9 @@ def test_submit_decision_retry_rpa_routes_to_inventory_workflow(app, client, mon
data = res.get_json()
assert data["status"] == "running"
assert data["task_id"] == task_id
assert data["message"] == "已触发库存获取(测试桩)"
assert captured["task_id"] == task_id
assert captured["mode"] == "retry_rpa"
assert data["message"] == "已提交正式 20-Gate 恢复动作"
assert captured["task"].task_no == task_id
assert captured["action_code"] == "retry_inventory_preparation"
def test_parse_inventory_oversized_text_route_is_removed(app, client):