feat(shipping-notice): 新增发货批次和任务管理功能,支持批次创建与任务处理
This commit is contained in:
1 parent
457f0f4e5e
commit
634dee4b81
81 files changed
+9088
-3625
No files matched your search
@@ -1,3 +1,11 @@
|
||||
"""
|
||||
services/shipping_notice/openapi_spec.py
|
||||
|
||||
用途:构建发货通知 Tool API 的 OpenAPI 描述,供 Dify 导入和联调用。
|
||||
依赖:shipping_notice.constants 中的请求字段常量、标准 `typing` 类型。
|
||||
逻辑:由 api/shipping_notice_tools.py 调用本文件生成 JSON/YAML OpenAPI 文档,再暴露给 Dify 或开发工具。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
@@ -64,6 +72,7 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
server = f"{server}/api/shipping-notice" if server else "/api/shipping-notice"
|
||||
|
||||
task_id = _str_prop("发货任务编号(task id),如 SN-20260529-ABCD1234")
|
||||
batch_id = _str_prop("发货批次编号(batch id),如 SB-20260617-ABCD1234")
|
||||
|
||||
return {
|
||||
"openapi": "3.0.0",
|
||||
@@ -74,14 +83,29 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
},
|
||||
"servers": [{"url": server}],
|
||||
"paths": {
|
||||
"/tools/create_batch": _post_op(
|
||||
"create_batch",
|
||||
"创建发货批次 batch(一次多文件上传的聚合容器)",
|
||||
{
|
||||
"batch_no": _str_prop("已存在的批次编号(可选)。传入时将直接复用该批次。"),
|
||||
"user_id": _int_prop("Hxops 用户 ID(可选)"),
|
||||
"conversation_id": _str_prop("Dify 会话 ID,便于工作台关联"),
|
||||
"file_count": _int_prop("本批通知文件数量"),
|
||||
},
|
||||
),
|
||||
"/tools/create_task": _post_op(
|
||||
"create_task",
|
||||
"创建发货任务 task",
|
||||
"创建发货任务 task(可挂到某个 batch)",
|
||||
{
|
||||
"batch_no": batch_id,
|
||||
"task_id": _str_prop("已存在的发货任务编号(可选)。传入时将直接复用该任务,禁止重复创建。"),
|
||||
"user_id": _int_prop("Hxops 用户 ID(可选)"),
|
||||
"conversation_id": _str_prop("Dify 会话 ID,便于工作台关联"),
|
||||
"source_type": _str_prop("来源:manual|email|wecom|pdf", enum=["manual", "email", "wecom", "pdf"]),
|
||||
"source_file_name": _str_prop("原始通知文件名(多文件场景建议传)"),
|
||||
"source_file_type": _str_prop("原始通知文件类型(多文件场景建议传)"),
|
||||
"batch_index": _int_prop("当前任务在批次中的顺序,从 1 开始"),
|
||||
"batch_total": _int_prop("当前批次总任务数"),
|
||||
"raw_content": _str_prop("原始发货通知文本(可选,后续 parse 也可传入)"),
|
||||
},
|
||||
),
|
||||
@@ -94,6 +118,59 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
},
|
||||
required=["task_id"],
|
||||
),
|
||||
"/tools/update_notice_fields": _post_op(
|
||||
"update_notice_fields",
|
||||
"更新解析后的发货通知单头字段,如客户、PO、交期、收货地",
|
||||
{
|
||||
"task_id": task_id,
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"description": "可更新字段:customer_name/customer_code/ship_to/po_number/required_date",
|
||||
"additionalProperties": True,
|
||||
},
|
||||
"comment": _str_prop("修改备注(可选)"),
|
||||
},
|
||||
required=["task_id", "fields"],
|
||||
),
|
||||
"/tools/update_notice_line": _post_op(
|
||||
"update_notice_line",
|
||||
"更新解析结果中的某一行,如 SKU、Reservation ID、数量、交期",
|
||||
{
|
||||
"task_id": task_id,
|
||||
"line_index": _int_prop("行下标,从 0 开始"),
|
||||
"patch": {
|
||||
"type": "object",
|
||||
"description": "可更新字段:sku/reservation_id/quantity/qty/required_date/uom",
|
||||
"additionalProperties": True,
|
||||
},
|
||||
"comment": _str_prop("修改备注(可选)"),
|
||||
},
|
||||
required=["task_id", "line_index", "patch"],
|
||||
),
|
||||
"/tools/add_notice_line": _post_op(
|
||||
"add_notice_line",
|
||||
"向解析结果新增一行发货需求",
|
||||
{
|
||||
"task_id": task_id,
|
||||
"line": {
|
||||
"type": "object",
|
||||
"description": "新增行,至少包含 sku 和 qty/quantity",
|
||||
"additionalProperties": True,
|
||||
},
|
||||
"comment": _str_prop("修改备注(可选)"),
|
||||
},
|
||||
required=["task_id", "line"],
|
||||
),
|
||||
"/tools/remove_notice_line": _post_op(
|
||||
"remove_notice_line",
|
||||
"删除解析结果中的某一行发货需求",
|
||||
{
|
||||
"task_id": task_id,
|
||||
"line_index": _int_prop("行下标,从 0 开始"),
|
||||
"comment": _str_prop("修改备注(可选)"),
|
||||
},
|
||||
required=["task_id", "line_index"],
|
||||
),
|
||||
"/tools/parse_inventory": _post_op(
|
||||
"parse_inventory",
|
||||
"解析库存。大 Excel 禁止 raw_inventory_text(会超 LLM token);"
|
||||
@@ -216,5 +293,23 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
"conversation_id": _str_prop("Dify 会话 ID"),
|
||||
},
|
||||
),
|
||||
"/tools/get_batch_status": _post_op(
|
||||
"get_batch_status",
|
||||
"查询批次当前状态、任务列表与当前聚焦任务",
|
||||
{
|
||||
"batch_no": batch_id,
|
||||
},
|
||||
required=["batch_no"],
|
||||
),
|
||||
"/tools/switch_focus_task": _post_op(
|
||||
"switch_focus_task",
|
||||
"切换当前批次的聚焦任务",
|
||||
{
|
||||
"batch_no": batch_id,
|
||||
"task_no": task_id,
|
||||
"target_task_no": task_id,
|
||||
},
|
||||
required=["batch_no"],
|
||||
),
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user