feat(shipping-notice): 收敛订单处理状态与履约门禁
This commit is contained in:
1 parent
bffcd55b40
commit
70dd0051b8
153 files changed
+10916
-4296
No files matched your search
@@ -12,7 +12,8 @@ from __future__ import annotations
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
from app.models import ShippingNotice
|
||||
from app import db
|
||||
from app.models import ShippingNotice, ShippingOrderIntake, ShippingOrderTask
|
||||
from app.services.agent_runtime_context.builder import build_agent_runtime_context
|
||||
from app.services.shipping_notice.reference_context import build_shipping_reference_context
|
||||
|
||||
@@ -74,7 +75,9 @@ def _build_refs(
|
||||
"""
|
||||
refs: dict[str, str] = {}
|
||||
task_no = _task_no(task)
|
||||
file_name = _clean_text(getattr(task, "source_file_name", None))
|
||||
file_name = ''
|
||||
if getattr(task, 'source_intake_id', None):
|
||||
file_name = _clean_text(getattr(db.session.get(ShippingOrderIntake, int(task.source_intake_id)), 'filename', None))
|
||||
normalized_run_purpose = _clean_text(run_purpose)
|
||||
if task_no:
|
||||
refs["task_no"] = task_no
|
||||
@@ -114,16 +117,26 @@ def _build_state_hint(task: ShippingNotice | None) -> dict[str, Any]:
|
||||
state_hint["focus_task_no"] = task_no
|
||||
|
||||
if task is not None:
|
||||
owner = task
|
||||
if isinstance(task, ShippingNotice) and task.order_task_id:
|
||||
owner = db.session.get(ShippingOrderTask, int(task.order_task_id)) or task
|
||||
from app.services.shipping_notice.line_inventory_match_projection import aggregate_match_status_for_task
|
||||
from app.services.shipping_notice.upload_attempt_service import latest_upload_attempt
|
||||
match_status = aggregate_match_status_for_task(getattr(owner, 'id', None)) or ''
|
||||
upload_status = str(getattr(latest_upload_attempt(task), 'status', None) or '').strip()
|
||||
for attr, key in (
|
||||
("current_step", "current_step"),
|
||||
("review_status", "review_status"),
|
||||
("match_status", "match_status"),
|
||||
("pending_human_reason", "pending_human_reason"),
|
||||
("upload_status", "upload_status"),
|
||||
(None, "match_status"),
|
||||
(None, "upload_status"),
|
||||
):
|
||||
value = _clean_text(getattr(task, attr, None))
|
||||
value = match_status if key == 'match_status' else upload_status if key == 'upload_status' else _clean_text(getattr(owner, attr, None))
|
||||
if value:
|
||||
state_hint[key] = value
|
||||
from app.services.shipping_notice.process_gate_projection import task_blocking_reason
|
||||
pending_reason = _clean_text(task_blocking_reason(task))
|
||||
if pending_reason:
|
||||
state_hint['pending_human_reason'] = pending_reason
|
||||
|
||||
return state_hint
|
||||
|
||||
@@ -145,10 +158,16 @@ def _build_summary(
|
||||
Returns:
|
||||
200 字以内的现场摘要。
|
||||
"""
|
||||
owner = task
|
||||
if isinstance(task, ShippingNotice) and task.order_task_id:
|
||||
owner = db.session.get(ShippingOrderTask, int(task.order_task_id)) or task
|
||||
pieces: list[str] = []
|
||||
task_no = _task_no(task)
|
||||
file_name = _clean_text(getattr(task, "source_file_name", None))
|
||||
current_step = _clean_text(getattr(task, "current_step", None))
|
||||
file_name = ''
|
||||
if getattr(owner, 'intake_id', None):
|
||||
intake = db.session.get(ShippingOrderIntake, int(owner.intake_id))
|
||||
file_name = _clean_text(getattr(intake, 'filename', None))
|
||||
current_step = _clean_text(getattr(owner, "current_step", None))
|
||||
normalized_run_purpose = _clean_text(run_purpose)
|
||||
if task_no:
|
||||
pieces.append(f"当前任务 {task_no}")
|
||||
|
||||
Reference in new issue
Block a user