fix(shipping-notice): 修复订单阶段投影与复核冻结门禁

This commit is contained in:
hugo committed 2026-09-15 10:29:59 +08:00
1 parent 9745bb78a7
commit 44c3bd0e80
8 files changed
+259 -17

No files matched your search

@@ -9,6 +9,8 @@ services/shipping_notice/ui_state.py
order_review_workbench_projection、inventory_source_repository(preparation.source_options)。
逻辑:优先 Gate 位置/用户模式投影 summary/entry_surface(flat position + user_mode);
Gate 摘要经 Notice.order_task_id→OT 查 Execution(禁止用 Notice.id);
五阶段 processing_stage 同样经 Notice→OT.stage(Notice 无 stage 列),
禁止仅靠 Gate 兜底把 order_freeze 误映射为订单复核;
stage_context.preparation 以 Snapshot 行 + 当前 Match 投影(Notice 经 order_task_id→OT),
行级拆 selected_source_code(CandidateSet 取数目标)与 source_code(Match 正式源);
短缺行复用放行模板字段;匹配成功无短缺下发 can_fulfill_complete_line;
@@ -106,10 +108,23 @@ _PAUSE_REASON_BY_POSITION: dict[str, tuple[str, str]] = {
def _task_lifecycle(
*, task: ShippingNotice, position: str | None, process_gate: dict[str, Any] | None,
) -> dict[str, Any]:
"""以共享裁决器投影正式任务生命周期;缺少正式事实时保持未分类。"""
"""以共享裁决器投影正式任务生命周期;缺少正式事实时保持未分类。
核心逻辑:``processing_stage`` 与批次/工作台同源——优先实体 ``stage``,
Notice 无 stage 列时经 ``order_task_id`` 读 OT.stage;再用正式 Gate 做
**仅向前**抬升(与 reconcile BE-08 / sync_order_task_stage_for_notice 同表)。
``order_freeze_readiness`` 不在抬升表中,故不能把 OT.stage=order_creating
压回「订单复核」。
"""
del position # 生命周期不再由位置码推导。
gate = (process_gate or {}).get('current_blocking_gate') or (process_gate or {}).get('current_gate')
from app.services.shipping_notice.upload_attempt_service import has_verified_upload_success
from app.services.shipping_notice.processing_projection_invariants import (
shipping_processing_stage_index,
)
from app.services.shipping_notice.order_task_stage_machine import (
_PROCESS_GATE_TO_PROCESSING_STAGE,
)
# 有正式 Gate 或已验证上传时才开放五阶段入口;否则保持 unclassified(禁止旧 CP 冒充)。
has_formal = bool(
@@ -120,6 +135,24 @@ def _task_lifecycle(
or process_gate.get('current_gate')
)
)
# [STEP 1] Notice 无 stage 列;进度权威在 OT。
processing_stage = str(getattr(task, 'stage', None) or '').strip() or None
if not processing_stage:
order_task = _resolve_order_task_for_gate_lookup(task)
if order_task is not None:
processing_stage = str(getattr(order_task, 'stage', None) or '').strip() or None
# [STEP 2] Gate→15 阶仅向前抬升;禁止 freeze 等建单前 Gate 回拉后半段。
gate_code = ''
if isinstance(gate, dict):
gate_code = str(gate.get('gate_code') or gate.get('code') or '').strip().lower()
if not gate_code and isinstance(process_gate, dict):
gate_code = str(process_gate.get('current_gate_code') or '').strip().lower()
gate_as_stage = _PROCESS_GATE_TO_PROCESSING_STAGE.get(gate_code)
if gate_as_stage:
stage_idx = shipping_processing_stage_index(processing_stage)
gate_idx = shipping_processing_stage_index(gate_as_stage)
if stage_idx is None or (gate_idx is not None and gate_idx >= stage_idx):
processing_stage = gate_as_stage
return project_lifecycle(
current_gate=gate if isinstance(gate, dict) else None,
blocking_reason=(
@@ -129,7 +162,7 @@ def _task_lifecycle(
),
has_candidate_context=has_formal or has_verified_upload_success(task),
verified_upload_success=has_verified_upload_success(task),
processing_stage=getattr(task, 'stage', None),
processing_stage=processing_stage,
)