- 新增PO号提取、预约ID解析(支持`PR@xxx`格式)工具,完善库存匹配逻辑 - 新增库存映射缓存、匹配/解析结果格式化摘要,优化用户提示 - 修复数据库迁移脚本未检查表存在的问题,避免全新部署失败 - 新增路径工具类统一管理相对路径,优化配置文件处理逻辑 - 归档旧文档,将部署、Dify配置合并到`shipping_notice.md` - 新增完整单元测试与集成测试覆盖核心流程 - 更新前端国际化与会话管理逻辑,优化界面交互
535 lines
17 KiB
JSON
535 lines
17 KiB
JSON
{
|
||
"openapi": "3.0.0",
|
||
"info": {
|
||
"title": "Hxops Shipping Notice Tools",
|
||
"version": "1.0.0",
|
||
"description": "货代发货通知 Agent Tool API。仅包含 Chatflow 编排工具,不含 RPA 回调。"
|
||
},
|
||
"servers": [
|
||
{
|
||
"url": "http://127.0.0.1:5052/api/shipping-notice"
|
||
}
|
||
],
|
||
"paths": {
|
||
"/tools/create_task": {
|
||
"post": {
|
||
"operationId": "create_task",
|
||
"summary": "创建发货任务 task",
|
||
"description": "创建发货任务 task",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"user_id": {
|
||
"type": "integer",
|
||
"description": "Hxops 用户 ID(可选)"
|
||
},
|
||
"conversation_id": {
|
||
"type": "string",
|
||
"description": "Dify 会话 ID,便于工作台关联"
|
||
},
|
||
"source_type": {
|
||
"type": "string",
|
||
"description": "来源:manual|email|wecom|pdf",
|
||
"enum": [
|
||
"manual",
|
||
"email",
|
||
"wecom",
|
||
"pdf"
|
||
]
|
||
},
|
||
"raw_content": {
|
||
"type": "string",
|
||
"description": "原始发货通知文本(可选,后续 parse 也可传入)"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/parse_notice": {
|
||
"post": {
|
||
"operationId": "parse_notice",
|
||
"summary": "解析发货通知文本",
|
||
"description": "解析发货通知文本",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"raw_text": {
|
||
"type": "string",
|
||
"description": "待解析的发货通知全文"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/parse_inventory": {
|
||
"post": {
|
||
"operationId": "parse_inventory",
|
||
"summary": "解析库存。大 Excel 禁止 raw_inventory_text(会超 LLM token);先 POST /tools/upload_inventory_file 上传,再 get_inventory_schema_preview → apply_inventory_mapping;或 use_uploaded_file=true(规则映射兜底)。小表可粘贴文本。成功后 stop_agent_turn,等 confirm_inventory_mapping 后再 match。",
|
||
"description": "解析库存。大 Excel 禁止 raw_inventory_text(会超 LLM token);先 POST /tools/upload_inventory_file 上传,再 get_inventory_schema_preview → apply_inventory_mapping;或 use_uploaded_file=true(规则映射兜底)。小表可粘贴文本。成功后 stop_agent_turn,等 confirm_inventory_mapping 后再 match。",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"use_uploaded_file": {
|
||
"type": "string",
|
||
"description": "true=解析该 task 已上传的 Excel(服务端直传,不经过 LLM)",
|
||
"enum": [
|
||
"true",
|
||
"false"
|
||
]
|
||
},
|
||
"column_mapping_json": {
|
||
"type": "string",
|
||
"description": "可选,列映射 JSON 字符串,如 {\"sku\":\"AWS Sku\",\"available_qty\":\"Qty Available\"}"
|
||
},
|
||
"raw_inventory_text": {
|
||
"type": "string",
|
||
"description": "仅小表(约 <8 万字符)。大 Excel 勿传此字段,改用 upload_inventory_file"
|
||
},
|
||
"inventory_lines_json": {
|
||
"type": "string",
|
||
"description": "可选,已整理好的 JSON 数组字符串,如 [{\"sku\":\"A001\",\"available_qty\":10}]"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/get_inventory_schema_preview": {
|
||
"post": {
|
||
"operationId": "get_inventory_schema_preview",
|
||
"summary": "读取已上传库存 Excel 的表头与样例行(小 payload,供 LLM 推断列映射)",
|
||
"description": "读取已上传库存 Excel 的表头与样例行(小 payload,供 LLM 推断列映射)",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/apply_inventory_mapping": {
|
||
"post": {
|
||
"operationId": "apply_inventory_mapping",
|
||
"summary": "应用 LLM/人工列映射并解析完整库存文件;返回 field_alignment 等待用户确认",
|
||
"description": "应用 LLM/人工列映射并解析完整库存文件;返回 field_alignment 等待用户确认",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"column_mapping_json": {
|
||
"type": "string",
|
||
"description": "列映射 JSON,如 {\"sku\":\"料号\",\"reservation_id\":\"COM ID\",\"available_qty\":\"Qty Available\"}"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id",
|
||
"column_mapping_json"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/ensure_inventory": {
|
||
"post": {
|
||
"operationId": "ensure_inventory",
|
||
"summary": "确保库存快照可用(RPA 自动导出;对话库存请优先用 parse_inventory)",
|
||
"description": "确保库存快照可用(RPA 自动导出;对话库存请优先用 parse_inventory)",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"mode": {
|
||
"type": "string",
|
||
"description": "auto=自动/RPA;retry_rpa=重试 RPA",
|
||
"enum": [
|
||
"auto",
|
||
"retry_rpa"
|
||
]
|
||
},
|
||
"inventory_lines_json": {
|
||
"type": "string",
|
||
"description": "手工库存 JSON 数组字符串,如 [{\"sku\":\"A001\",\"available_qty\":10}]"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/match_inventory": {
|
||
"post": {
|
||
"operationId": "match_inventory",
|
||
"summary": "匹配发货需求与库存。前置条件:submit_decision(confirm_inventory_mapping) 已成功;未确认时调用会被拒绝并返回 forbidden_next_tools",
|
||
"description": "匹配发货需求与库存。前置条件:submit_decision(confirm_inventory_mapping) 已成功;未确认时调用会被拒绝并返回 forbidden_next_tools",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"inventory_lines_json": {
|
||
"type": "string",
|
||
"description": "可选,覆盖库存 JSON 数组后再匹配"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/submit_decision": {
|
||
"post": {
|
||
"operationId": "submit_decision",
|
||
"summary": "人工复核决策",
|
||
"description": "人工复核决策",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"decision": {
|
||
"type": "string",
|
||
"description": "confirm=确认继续;reject=驳回;rematch=重新匹配;reparse=重新解析;confirm_inventory_mapping=确认库存字段对齐;reparse_inventory=重新上传库存",
|
||
"enum": [
|
||
"confirm",
|
||
"reject",
|
||
"rematch",
|
||
"reparse",
|
||
"confirm_inventory_mapping",
|
||
"reparse_inventory"
|
||
]
|
||
},
|
||
"comment": {
|
||
"type": "string",
|
||
"description": "备注(可选)"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id",
|
||
"decision"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/generate_shipment_excel": {
|
||
"post": {
|
||
"operationId": "generate_shipment_excel",
|
||
"summary": "生成固定模板发货 Excel",
|
||
"description": "生成固定模板发货 Excel",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/upload_to_freight": {
|
||
"post": {
|
||
"operationId": "upload_to_freight",
|
||
"summary": "上传 Excel 到货代系统(RPA 或手工确认)",
|
||
"description": "上传 Excel 到货代系统(RPA 或手工确认)",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
},
|
||
"mode": {
|
||
"type": "string",
|
||
"description": "auto=触发 RPA;retry_upload=重试;manual_confirm=手工上传完成",
|
||
"enum": [
|
||
"auto",
|
||
"retry_upload",
|
||
"manual_confirm"
|
||
]
|
||
},
|
||
"freight_ref_no": {
|
||
"type": "string",
|
||
"description": "货代系统单号(manual_confirm 时填写)"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/tools/get_task_status": {
|
||
"post": {
|
||
"operationId": "get_task_status",
|
||
"summary": "查询 task 当前状态与 human_options",
|
||
"description": "查询 task 当前状态与 human_options",
|
||
"parameters": [],
|
||
"requestBody": {
|
||
"required": true,
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"task_id": {
|
||
"type": "string",
|
||
"description": "发货任务编号,如 SN-20260529-ABCD1234"
|
||
}
|
||
},
|
||
"required": [
|
||
"task_id"
|
||
]
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"responses": {
|
||
"200": {
|
||
"description": "Tool response (status: ok|running|needs_human|failed)",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|