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,7 +2,7 @@
|
||||
services/shipping_notice/dify_inputs.py
|
||||
|
||||
用途:识别发货通知 Dify Chatflow Agent,并构建会话级 Dify inputs。
|
||||
依赖:agent_runtime_context 平台协议、models.ShippingBatch/ShippingTask、shipping_notice.runtime_context。
|
||||
依赖:agent_runtime_context 平台协议、models.ShippingNotice、shipping_notice.runtime_context。
|
||||
逻辑:由 Context Adapter / api/chat 调用;本模块按会话号解析当前批次/任务焦点,
|
||||
仅输出 agent_runtime_context JSON 字符串,供 Dify 画布统一读取平台运行态快照。
|
||||
发货通知识别请使用 agent_registry.resolver.resolve_agent_code == 'shipping_notice'。
|
||||
@@ -13,30 +13,24 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from app.models import ShippingBatch, ShippingTask, ShippingTemporaryInventorySession
|
||||
from app.models import ShippingNotice, ShippingTemporaryInventorySession
|
||||
from app.services.agent_runtime_context.builder import serialize_for_dify
|
||||
from app.services.agent_runtime_context.schema import AGENT_RUNTIME_CONTEXT_INPUT
|
||||
from app.services.shipping_notice.runtime_context import build_shipping_runtime_context
|
||||
|
||||
|
||||
def _latest_batch_for_conversation(conversation_id: str) -> ShippingBatch | None:
|
||||
"""按会话号获取最近一个发货批次,用于恢复当前批次焦点。"""
|
||||
conv_id = str(conversation_id or "").strip()
|
||||
if not conv_id:
|
||||
return None
|
||||
return (
|
||||
ShippingBatch.query.filter_by(conversation_id=conv_id)
|
||||
.order_by(ShippingBatch.id.desc())
|
||||
.first()
|
||||
)
|
||||
def _latest_batch_for_conversation(conversation_id: str) -> None:
|
||||
"""shipping_batches 已删除;固定返回 None。"""
|
||||
del conversation_id
|
||||
return None
|
||||
|
||||
|
||||
def _task_by_task_no(task_id: str) -> ShippingTask | None:
|
||||
def _task_by_task_no(task_id: str) -> ShippingNotice | None:
|
||||
"""按显式 task_id 获取任务;仅用于补齐批次 ref,禁止按会话号猜测当前任务。"""
|
||||
normalized = str(task_id or "").strip().upper()
|
||||
if not normalized:
|
||||
return None
|
||||
return ShippingTask.query.filter_by(task_no=normalized).first()
|
||||
return ShippingNotice.query.filter_by(task_no=normalized).first()
|
||||
|
||||
|
||||
def _latest_pending_temporary_inventory_session(conversation_id: str) -> str | None:
|
||||
@@ -68,7 +62,7 @@ def _latest_pending_temporary_inventory_session(conversation_id: str) -> str | N
|
||||
return str(item.session_no or '').strip().upper() or None if item else None
|
||||
|
||||
|
||||
def _focus_task_row(focus_task: str, explicit_task_row: ShippingTask | None) -> ShippingTask | None:
|
||||
def _focus_task_row(focus_task: str, explicit_task_row: ShippingNotice | None) -> ShippingNotice | None:
|
||||
"""
|
||||
解析当前显式焦点任务行。
|
||||
|
||||
@@ -87,7 +81,7 @@ def _focus_task_row(focus_task: str, explicit_task_row: ShippingTask | None) ->
|
||||
return None
|
||||
if explicit_task_row and str(explicit_task_row.task_no or "").strip().upper() == normalized:
|
||||
return explicit_task_row
|
||||
return ShippingTask.query.filter_by(task_no=normalized).first()
|
||||
return ShippingNotice.query.filter_by(task_no=normalized).first()
|
||||
|
||||
|
||||
def build_dify_chat_inputs(
|
||||
|
||||
Reference in new issue
Block a user