Files
syops/backend/app/services/shipping_notice/tools.py
T

82 lines
3.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
services/shipping_notice/tools.py
用途:发货通知 Agent Tool 统一门面(API 唯一业务入口,无编排实现)。
依赖:customer_identity_gate、task_workflow、inventory_workflow、inventory_rpa_workflow、fulfillment_workflow;order_extraction 延迟导入以避免建批循环依赖。
逻辑:shipping_notice_tools / workspace_shipping_notice 仅 import 本模块公开符号。
"""
from __future__ import annotations
from app.services.shipping_notice import (
fulfillment_workflow,
inventory_rpa_workflow,
inventory_workflow,
task_workflow,
)
from app.services.shipping_notice import customer_identity_gate
def get_order_extraction_context(payload: dict):
"""
返回点击发送后的完整订单抽取上下文。
【AI 触发时机】:仅在 Dify 订单抽取固定分支的 LLM 节点之前调用。
核心逻辑:延迟导入实现,避免 batch_from_intakes 与 Tool 门面形成模块初始化环。
Args:
payload: 必须包含完整 agent_runtime_context。
Returns:
邮件/附件文本、输入快照与抽取契约。
"""
from app.services.shipping_notice.order_extraction import get_order_extraction_context as _get
return _get(payload)
def submit_order_extraction(payload: dict):
"""
提交 LLM 完整订单结果并执行自动建单。
【AI 触发时机】:订单抽取 LLM 与 JSON 标准化节点成功后调用。
核心逻辑:延迟导入实现,保留 Tool 门面为唯一 API 业务入口且不引入建批循环依赖。
Args:
payload: 完整运行态上下文、输入快照、契约版本与 orders[]。
Returns:
自动建单、打开已有任务和待处理订单摘要。
"""
from app.services.shipping_notice.order_extraction import submit_order_extraction as _submit
return _submit(payload)
# 任务 / 批次 / 解析 / 决策
create_batch = task_workflow.create_batch
create_batch_tasks = task_workflow.create_batch_tasks
create_task = task_workflow.create_task
parse_notice = task_workflow.parse_notice
auto_progress = task_workflow.auto_progress
submit_decision = task_workflow.submit_decision
get_task_status = task_workflow.get_task_status
retry_task = task_workflow.retry_task
update_notice_fields = task_workflow.update_notice_fields
update_notice_line = task_workflow.update_notice_line
add_notice_line = task_workflow.add_notice_line
remove_notice_line = task_workflow.remove_notice_line
confirm_customer = customer_identity_gate.confirm_customer
# 库存阶段
ensure_inventory = inventory_workflow.ensure_inventory
parse_inventory = inventory_workflow.parse_inventory
get_inventory_schema_preview = inventory_workflow.get_inventory_schema_preview
apply_inventory_mapping = inventory_workflow.apply_inventory_mapping
upload_inventory_file = inventory_workflow.upload_inventory_file
rpa_report_inventory = inventory_rpa_workflow.rpa_report_inventory
rpa_report_inventory_batch = inventory_rpa_workflow.rpa_report_inventory_batch
repair_task_inventory_attachment = inventory_rpa_workflow.repair_task_inventory_attachment
confirm_inventory_source = inventory_rpa_workflow.confirm_inventory_source
# 履约阶段
match_inventory = fulfillment_workflow.match_inventory
generate_excel = fulfillment_workflow.generate_excel
upload_to_freight = fulfillment_workflow.upload_to_freight
rpa_report_upload = fulfillment_workflow.rpa_report_upload