feat(shipping-notice): 升级货代发货流程为五阶段,完善业务校验

将货代发货流程从四阶段扩展为五阶段,拆分上传相关逻辑至独立的货代上传阶段;
统一多语言文案修正客户状态语义,将"客户尚未识别"调整为符合业务的"客户尚未确认";
新增严格的上传成功验证谓词,需同时满足任务状态、全部预约单上传成功、存在有效成功上传尝试三个条件方可标记为完成;
新增坐标取值模型配置,支持Legacy冻结绝对坐标和锚点框架受限平移两种模式;
更新全链路相关文档、前端组件、后端服务与测试用例,确保业务逻辑对齐新业务规则。
This commit is contained in:
hugo committed 2026-08-21 09:20:47 +08:00
1 parent 1b6483a4ea
commit 935bf26fa6
86 files changed
+2743 -311

No files matched your search

@@ -1,7 +1,7 @@
"""
services/shipping_notice/lifecycle_projection.py
用途:为批次进度、任务详情与订单生命周期工作台裁决同一份四阶段业务生命周期。
用途:为批次进度、任务详情与订单生命周期工作台裁决同一份五阶段业务生命周期。
依赖:process_gate_contract 的阻断原因归属;调用方提供正式 Gate、Case/Candidate 或历史兜底事实。
逻辑:正式 Process Gate 优先,其次是可解释阻断原因;仅无正式事实时才使用旧阶段兜底。
本模块只做只读业务投影,不授权任何写操作;阶段入口与实际动作权限必须分开。
@@ -18,6 +18,7 @@ LIFECYCLE_STAGES: tuple[dict[str, str], ...] = (
{'code': 'intake_parse', 'label': '接收解析'},
{'code': 'order_review', 'label': '订单复核'},
{'code': 'fulfillment_prep', 'label': '通知准备'},
{'code': 'freight_upload', 'label': '货代上传'},
{'code': 'upload_complete', 'label': '通知完成'},
)
@@ -43,8 +44,8 @@ LIFECYCLE_STAGE_BY_GATE: dict[str, str] = {
'inventory_sufficiency': 'fulfillment_prep',
'excel_readiness': 'fulfillment_prep',
'artifact_generation': 'fulfillment_prep',
'freight_upload_rpa': 'upload_complete',
'manual_upload_handoff': 'upload_complete',
'freight_upload_rpa': 'freight_upload',
'manual_upload_handoff': 'freight_upload',
}
# 没有正式 Gate 的历史项才能使用此映射。它必须保持在共享裁决器内,避免各入口漂移。
@@ -60,7 +61,9 @@ LIFECYCLE_STAGE_RANGES: tuple[tuple[str, set[str]], ...] = (
'inventory_matching', 'inventory_match', 'inventory_matched', 'excel_generating',
'excel_generate', 'excel_generated',
}),
('upload_complete', {'freight_uploading', 'freight_upload', 'upload_receipt_recorded', 'completed'}),
('freight_upload', {
'freight_uploading', 'freight_upload', 'upload_receipt_recorded', 'upload_complete', 'completed',
}),
)
@@ -104,6 +107,7 @@ def project_lifecycle(
legacy_stage: str | None,
has_candidate_context: bool,
has_intake_parse_context: bool = False,
verified_upload_success: bool = False,
) -> dict[str, Any]:
"""按 Gate → 阻断归属 → 历史阶段的固定优先级裁决生命周期和入口。
@@ -111,7 +115,12 @@ def project_lifecycle(
"""
gate = current_gate if isinstance(current_gate, dict) else {}
gate_code = str(gate.get('gate_code') or gate.get('code') or '').strip().lower()
if gate_code in LIFECYCLE_STAGE_BY_GATE:
# 成功事实高于当前 Gate/历史阶段:异步回调成功后旧 Gate 尚未清理时,用户仍应
# 看到已完成;反之任何技术完成、回执文本或旧 completed 都不能越过此条件。
if verified_upload_success:
lifecycle_stage = 'upload_complete'
authority = 'verified_upload_success'
elif gate_code in LIFECYCLE_STAGE_BY_GATE:
lifecycle_stage = LIFECYCLE_STAGE_BY_GATE[gate_code]
authority = 'process_gate'
else: