feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -2,9 +2,9 @@
|
||||
services/shipping_notice/ui_state.py
|
||||
|
||||
用途:发货通知任务/批次 UI 状态读模型,作为通知摘要、人工复核与任务工作台的统一状态来源。
|
||||
依赖:models.ShippingTask/ShippingBatch、state_machine、query_service、constants、stp_progress_contract、
|
||||
依赖:models.ShippingNotice、state_machine、query_service、constants、stp_progress_contract、
|
||||
process_gate_projection(统一 Gate 用户摘要)。
|
||||
逻辑:从 ShippingTask DB 字段经状态机解析 checkpoint/checkpoint_kind/action_buttons,
|
||||
逻辑:从 ShippingNotice DB 字段经状态机解析 checkpoint/checkpoint_kind/action_buttons,
|
||||
再补充七步流程与可解释 summary(当前待办、暂停原因、下一自动步骤、操作入口、
|
||||
stp_facts、progress_nodes);
|
||||
若存在 ProcessExecution:阻断时清空 action_buttons;非阻断时仅保留
|
||||
@@ -16,7 +16,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.models import ShippingBatch, ShippingTask
|
||||
from app.models import ShippingNotice
|
||||
from app.services.shipping_notice.batch_legacy_removed import raise_shipping_batches_removed
|
||||
from app.services.shipping_notice.constants import (
|
||||
CP_COMPLETED,
|
||||
CP_CUSTOMER_REVIEW,
|
||||
@@ -133,7 +134,7 @@ _PAUSE_REASON_BY_CHECKPOINT: dict[str, tuple[str, str]] = {
|
||||
}
|
||||
|
||||
|
||||
def _derive_current_step_index(task: ShippingTask) -> int:
|
||||
def _derive_current_step_index(task: ShippingNotice) -> int:
|
||||
"""
|
||||
根据任务字段推导七步流程当前索引。
|
||||
|
||||
@@ -174,7 +175,7 @@ def _derive_current_step_index(task: ShippingTask) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def build_shipping_workflow_steps(task: ShippingTask, checkpoint: str | None) -> list[dict[str, str]]:
|
||||
def build_shipping_workflow_steps(task: ShippingNotice, checkpoint: str | None) -> list[dict[str, str]]:
|
||||
"""
|
||||
构造七步流程状态。
|
||||
|
||||
@@ -209,7 +210,7 @@ def build_shipping_workflow_steps(task: ShippingTask, checkpoint: str | None) ->
|
||||
return steps
|
||||
|
||||
|
||||
def _action_buttons_for_task(task: ShippingTask) -> list[dict[str, str]]:
|
||||
def _action_buttons_for_task(task: ShippingNotice) -> list[dict[str, str]]:
|
||||
"""
|
||||
从状态机解析当前任务可用动作按钮;多源匹配阻断时前置「人工指定库存源」。
|
||||
|
||||
@@ -291,7 +292,7 @@ def _parse_validation_issue_text(issue: dict[str, Any]) -> str:
|
||||
return f"第 {line_no} 行料号 {part_number}:缺少合法的 Reservation ID。"
|
||||
|
||||
|
||||
def _collect_parse_stage_issues(task: ShippingTask, checkpoint: str | None) -> list[str]:
|
||||
def _collect_parse_stage_issues(task: ShippingNotice, checkpoint: str | None) -> list[str]:
|
||||
"""
|
||||
汇总文件解析阶段(步骤 2)全部待处理问题,供工作台一次列出。
|
||||
|
||||
@@ -381,7 +382,7 @@ def _current_todo_label(checkpoint: str | None, action_buttons: list[dict[str, s
|
||||
return label or None
|
||||
|
||||
|
||||
def _build_stp_facts(task: ShippingTask) -> dict[str, Any] | None:
|
||||
def _build_stp_facts(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
"""
|
||||
投影 STP 履约事实供 Chat/工作台/待办同源消费。
|
||||
|
||||
@@ -453,7 +454,7 @@ def _build_stp_facts(task: ShippingTask) -> dict[str, Any] | None:
|
||||
|
||||
|
||||
def _build_task_summary(
|
||||
task: ShippingTask,
|
||||
task: ShippingNotice,
|
||||
checkpoint: str | None,
|
||||
*,
|
||||
checkpoint_kind: CheckpointKind,
|
||||
@@ -550,7 +551,7 @@ def _build_task_summary(
|
||||
return summary
|
||||
|
||||
|
||||
def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
|
||||
def build_task_ui_state(task: ShippingNotice) -> dict[str, Any]:
|
||||
"""
|
||||
构建单票任务 UI State。
|
||||
|
||||
@@ -594,7 +595,7 @@ def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
|
||||
summary['allowed_actions'] = []
|
||||
return {
|
||||
"task_no": task.task_no,
|
||||
"batch_no": task.batch.batch_no if task.batch is not None else None,
|
||||
"batch_no": None,
|
||||
"checkpoint": ui.checkpoint,
|
||||
"checkpoint_kind": str(ui.checkpoint_kind),
|
||||
"process_status": task.process_status,
|
||||
@@ -610,7 +611,7 @@ def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _process_gate_user_summary_for_task(task: ShippingTask) -> dict[str, Any] | None:
|
||||
def _process_gate_user_summary_for_task(task: ShippingNotice) -> dict[str, Any] | None:
|
||||
"""
|
||||
按 Task 查找活动 Execution 的用户 Gate 摘要。
|
||||
|
||||
@@ -638,30 +639,12 @@ def _process_gate_user_summary_for_task(task: ShippingTask) -> dict[str, Any] |
|
||||
return project_user_gate_summary(execution)
|
||||
|
||||
|
||||
def build_batch_ui_state(batch: ShippingBatch) -> dict[str, Any]:
|
||||
def build_batch_ui_state(batch: Any) -> dict[str, Any]:
|
||||
"""
|
||||
构建批次级会话上传集合摘要(非履约写操作面)。
|
||||
|
||||
核心逻辑:批次仅聚合各 PDF/Task 的同源 ui_state,供会话右侧「本次上传」摘要消费;
|
||||
履约写操作一律进入任务处理工作台。
|
||||
Raises:
|
||||
ValidationError: shipping_batches 表已物理删除(co8e9f0a1b2c)。
|
||||
"""
|
||||
tasks = list_sorted_batch_tasks(batch)
|
||||
focus_task_no = str(batch.current_focus_task_no or "").strip()
|
||||
focus_task = next((task for task in tasks if task.task_no == focus_task_no), None)
|
||||
if focus_task is None and tasks:
|
||||
focus_task = tasks[0]
|
||||
task_states = [
|
||||
{
|
||||
**serialize_task_summary(task),
|
||||
"ui_state": build_task_ui_state(task),
|
||||
}
|
||||
for task in tasks
|
||||
]
|
||||
return {
|
||||
**serialize_batch_summary(batch),
|
||||
"role": "upload_session_summary",
|
||||
"process_summary": batch.process_summary_json or compute_batch_process_summary(tasks),
|
||||
"focus_task": serialize_task_summary(focus_task) if focus_task else None,
|
||||
"focus_task_ui_state": build_task_ui_state(focus_task) if focus_task else None,
|
||||
"tasks": task_states,
|
||||
}
|
||||
del batch
|
||||
raise_shipping_batches_removed()
|
||||
Reference in new issue
Block a user