feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
1 parent
8e0bbf7a81
commit
c94d173f92
181 files changed
+12947
-1724
No files matched your search
@@ -15,6 +15,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from flask import current_app
|
||||
from app.core.errors import ValidationError
|
||||
|
||||
|
||||
def _runtime_summary(mode: str) -> dict[str, str | bool]:
|
||||
@@ -153,9 +154,14 @@ def write_inventory_export_batch_trigger(
|
||||
"validation_run_no": source.get("validation_run_no"),
|
||||
}
|
||||
# v2 逐源身份必须由后端显式写入,Worker 不得重新生成。
|
||||
for identity_key in ("task_no", "attempt_no", "source_run_no", "candidate_set_id", "candidate_set_version", "expected_warehouse_id", "lease_token"):
|
||||
for identity_key in (
|
||||
"callback_id", "task_no", "attempt_no", "source_run_no", "candidate_set_id", "candidate_set_version",
|
||||
"execution_id", "gate_id", "expected_warehouse_id", "lease_token",
|
||||
):
|
||||
if source.get(identity_key) is not None:
|
||||
item[identity_key] = source[identity_key]
|
||||
if not item.get('callback_id') and item.get('source_run_no'):
|
||||
item['callback_id'] = f"{item['source_run_no']}:C1"
|
||||
inventory_sources.append(item)
|
||||
if not inventory_sources:
|
||||
return None
|
||||
@@ -163,6 +169,7 @@ def write_inventory_export_batch_trigger(
|
||||
body = {
|
||||
"action": "inventory_export_batch",
|
||||
"schema_version": "shipping_inventory_rpa.v2",
|
||||
"callback_id": f"{run_no}:batch:C1",
|
||||
"batch_run_no": run_no,
|
||||
"run_no": run_no, # 旧排程读取兼容;新回调不得依赖该字段
|
||||
"trigger_type": "scheduled",
|
||||
@@ -194,7 +201,8 @@ def write_inventory_export_trigger_for_task(
|
||||
写入按需库存 RPA trigger;batch 开启时包装为单源 batch trigger,与定时导出共用 worker 路径。
|
||||
【AI 触发时机】:ensure_inventory_via_rpa 触发单票 RPA 导出时调用。
|
||||
|
||||
核心逻辑:batch 模式写 inventory_export_batch(含 task_no);否则写 legacy inventory_export。
|
||||
核心逻辑:仅允许 v2 batch 模式写 inventory_export_batch;关闭时 fail-closed,
|
||||
不再生成 legacy inventory_export trigger。
|
||||
"""
|
||||
from app.services.shipping_notice.inventory_source_repository import get_rpa_trigger_inventory_source
|
||||
|
||||
@@ -211,11 +219,18 @@ def write_inventory_export_trigger_for_task(
|
||||
run_no = str(body.get("batch_run_no") or f"BATCH-{task_no}-{datetime.utcnow().strftime('%Y%m%d%H%M%S%f')}")
|
||||
source_item = dict(rpa_source)
|
||||
source_item.update({
|
||||
"callback_id": body.get("callback_id") or (
|
||||
f"{body.get('source_run_no')}:C1" if body.get('source_run_no') else None
|
||||
),
|
||||
"task_no": task_no,
|
||||
"attempt_no": body.get("attempt_no"),
|
||||
# 按需逐源回调必须携带 Attempt 身份;仅写在 batch 顶层会导致
|
||||
# Worker 结果丢失 source_run_no,后端无法把 Excel 绑定到最新 Attempt。
|
||||
"attempt_no": body.get("attempt_no") or body.get("attempt"),
|
||||
"source_run_no": body.get("source_run_no"),
|
||||
"candidate_set_id": body.get("candidate_set_id"),
|
||||
"candidate_set_version": body.get("candidate_set_version"),
|
||||
"execution_id": body.get("execution_id"),
|
||||
"gate_id": body.get("gate_id"),
|
||||
"expected_warehouse_id": body.get("expected_warehouse_id"),
|
||||
"lease_token": body.get("lease_token"),
|
||||
})
|
||||
@@ -229,12 +244,9 @@ def write_inventory_export_trigger_for_task(
|
||||
**body,
|
||||
},
|
||||
)
|
||||
return write_inventory_export_trigger(
|
||||
task_no,
|
||||
{
|
||||
"rpa_inventory_source": rpa_source,
|
||||
**body,
|
||||
},
|
||||
raise ValidationError(
|
||||
'shipping inventory RPA v2 batch trigger is required',
|
||||
code='SHIPPING.INVENTORY_RPA_V2_REQUIRED',
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user