refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段

统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成
设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程
删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本
替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段
更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
hugo committed 2026-08-15 10:19:10 +08:00
1 parent 6684e7181a
commit 5ef8329bd8
178 files changed
+5091 -1734

No files matched your search

@@ -242,16 +242,21 @@ def _pending_snapshot_batches(run: ShippingOrderProcessingRun, plan: ShippingOrd
def _should_expand_after_wave(*, wave_units: list[ShippingOrderProcessingUnit], wave_orders: list[dict]) -> bool:
"""仅在可通过更多附件补证的业务缺口出现时才扩下一轮。"""
"""兼容旧诊断调用:返回本轮业务缺口,不能作为兄弟附件执行门控。"""
return bool(_expansion_trigger_reason_codes(wave_units=wave_units, wave_orders=wave_orders))
def _should_activate_planned_batches(*, pending_batches: list[int]) -> bool:
"""计划内后续附件必须独立执行,不受首轮字段结果或兄弟附件状态门控。"""
return bool(pending_batches)
def _expansion_trigger_reason_codes(
*,
wave_units: list[ShippingOrderProcessingUnit],
wave_orders: list[dict],
) -> list[str]:
"""汇总当前批次触发扩批的业务原因码,供事件与工作台共享。"""
"""汇总当前批次业务缺口原因,供事件、交叉裁决与工作台共享。"""
if not wave_units:
return []
reason_codes = {
@@ -318,7 +323,7 @@ def _mark_expandable_business_gaps(
*,
orders: list[dict[str, Any]],
) -> list[dict[str, Any]]:
"""把可由后续附件补证的业务缺口标记到订单上,供扩批决策复用。"""
"""标记跨附件裁决可补证的业务缺口;该事实不影响附件执行。"""
field_ids_by_code = _schema_field_ids_by_code(run)
reservation_field_ids = field_ids_by_code.get('reservation_id', set())
if not reservation_field_ids:
@@ -340,7 +345,7 @@ def _wave_orders_for_expansion(
*,
orders: list[dict[str, Any]],
) -> list[dict[str, Any]]:
"""为当前批次生成扩批判定所需的业务事实视图。"""
"""为当前批次生成交叉附件裁决所需的业务事实视图。"""
if not orders:
return []
schema_snapshot = run.input_snapshot_json.get('schema') if isinstance(run.input_snapshot_json, dict) else {}
@@ -804,7 +809,7 @@ def run_shipping_order_extraction(ctx: JobContext, payload: dict) -> None:
expansion_reason_codes = _expansion_trigger_reason_codes(wave_units=units, wave_orders=wave_orders)
next_existing_batch = _next_existing_batch(plan, after_batch=current_batch)
if expansion_reason_codes and next_existing_batch is not None:
if next_existing_batch is not None:
source_batch = current_batch
current_batch = next_existing_batch
if current_batch not in expansion_events_emitted:
@@ -817,6 +822,7 @@ def run_shipping_order_extraction(ctx: JobContext, payload: dict) -> None:
'unit_count': len(_units_for_batch(plan, selection_batch=current_batch)),
'triggered_by_batch': source_batch,
'reason_codes': expansion_reason_codes,
'activation_reason': 'planned_attachment_batch',
},
job_id=job.id,
commit=False,
@@ -826,7 +832,7 @@ def run_shipping_order_extraction(ctx: JobContext, payload: dict) -> None:
continue
pending_batches = _pending_snapshot_batches(run, plan)
if expansion_reason_codes and pending_batches:
if _should_activate_planned_batches(pending_batches=pending_batches):
next_batch = pending_batches[0]
created_units = _activate_expansion_batch(run=run, plan=plan, selection_batch=next_batch)
db.session.flush()
@@ -841,6 +847,7 @@ def run_shipping_order_extraction(ctx: JobContext, payload: dict) -> None:
'unit_count': len(_units_for_batch(plan, selection_batch=next_batch)),
'triggered_by_batch': current_batch,
'reason_codes': expansion_reason_codes,
'activation_reason': 'planned_attachment_batch',
},
job_id=job.id,
commit=False,