feat(shipping_notice): 新增货代订单全流程业务模块及配套基建

本次提交新增货代订单处理全流程的完整业务能力、数据库迁移与测试用例:
1.  统一追加式审计事件体系,支持全链路不可篡改的业务追溯
2.  货代任务撤销、版本替代管控逻辑,规范已上传订单的合规版本更替
3.  订单抽取路由审计、模板自动冻结资格、路由计数等核心业务基建
4.  EML订单补充表解析契约与合并逻辑,完善订单补全能力
5.  Chatflow只读能力令牌校验机制,保障工具调用安全
6.  人工复核证据校验服务,规范人工审核的证据留存
所有变更均配套完整的单元测试与迁移契约测试,支持受控回退
This commit is contained in:
hugo committed 2026-07-28 08:56:58 +08:00
1 parent 90f77634d6
commit 1f3ecb87b7
128 files changed
+3635 -2074

No files matched your search

+16 -538
View File
@@ -3,7 +3,7 @@
"info": {
"title": "Shipping Notice Tools",
"version": "1.0.0",
"description": "货代发货通知 Agent Tool API。仅导出适合 Dify AI 编排层使用的工具:通知理解、字段修订、库存映射建议、人工确认收口与状态查询;不包含由后台任务统一续跑的主推进工具,也不包含 RPA 回调。推进类 Tool 的统一约束如下:必须依赖 HXOPS 状态机校验,必须基于唯一 task_id 推进;模糊指代不能直接推进,必须先通过 reference_context、get_task_status 或其他 HXOPS Tool 解析到唯一任务。submit_decision、match_inventory、generate_shipment_excel、upload_to_freight、retry_task、confirm_inventory_source、confirm_customer 这类推进动作都必须根据 HXOPS Tool 返回结果解释,不能脱离 Tool 返回自行编造状态。若 Tool 返回 needs_human 或 failed,不得自行改写成完成、成功上传或已处理完毕。如果响应包含 action_buttons,Dify 只解释当前状态、业务原因和影响,不要在自然语言正文列出按钮清单或“推荐下一步”动作列表;可点击按钮由宿主系统根据 action_buttons 统一渲染。鉴权:Authorization Bearer 或 X-Integration-Key。"
"description": "货代 Chatflow 仅作自然语言只读解释。所有写操作必须由 HXOPS 确认卡和后端状态机执行;本 OpenAPI 不包含改单、确认、冻结、库存、Excel 或上传接口。"
},
"servers": [
{
@@ -11,541 +11,6 @@
}
],
"paths": {
"/tools/create_temporary_inventory_session": {
"post": {
"operationId": "create_temporary_inventory_session",
"summary": "创建对话上传库存文件的临时分析会话",
"description": "仅在用户明确说明附件为库存文件的 temporary_inventory 分支调用。后端按会话用户校验资产归属并执行结构初检;不会创建生产库存快照、不会绑定库存站点、不会执行库存匹配。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"agent_runtime_context": {
"type": "string",
"description": "HXOPS 注入的完整 agent_runtime_context JSON 字符串;必须原样透传,禁止由 LLM 构造或修改"
},
"asset_no": {
"type": "string",
"description": "当前用户上传的 FileAsset 编号;必须是 xls、xlsx 或 csv"
}
},
"required": [
"agent_runtime_context",
"asset_no"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/get_temporary_inventory_session": {
"post": {
"operationId": "get_temporary_inventory_session",
"summary": "读取临时库存文件的脱敏结构分析和方案候选",
"description": "返回后端已分析的工作表、表头、字段目录和已发布方案候选,不返回样例库存值。Dify 不得读取文件路径、全量库存行,也不得据此直接宣称库存已可用于订单匹配。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"agent_runtime_context": {
"type": "string",
"description": "HXOPS 注入的完整 agent_runtime_context JSON 字符串;必须原样透传,禁止由 LLM 构造或修改"
},
"temporary_session_no": {
"type": "string",
"description": "create_temporary_inventory_session 返回的临时会话编号"
}
},
"required": [
"agent_runtime_context",
"temporary_session_no"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/submit_temporary_inventory_mapping_suggestion": {
"post": {
"operationId": "submit_temporary_inventory_mapping_suggestion",
"summary": "保存对话临时库存的候选字段映射",
"description": "仅在没有 exact 已发布方案可复用时调用。HXOPS 校验字段目录、真实表头、重复列和核心字段完整性,只保存待用户确认的候选;不会发布方案、绑定库存站点、创建库存快照或执行订单匹配。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"agent_runtime_context": {
"type": "string",
"description": "HXOPS 注入的完整 agent_runtime_context JSON 字符串;必须原样透传,禁止由 LLM 构造或修改"
},
"temporary_session_no": {
"type": "string",
"description": "临时库存会话编号"
},
"field_mapping": {
"type": "object",
"description": "库存字段目录 ID 到真实来源表头的映射;只能使用 get_temporary_inventory_session 返回的字段 ID 和表头",
"additionalProperties": {
"type": "string"
}
}
},
"required": [
"agent_runtime_context",
"temporary_session_no",
"field_mapping"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/confirm_temporary_inventory_use": {
"post": {
"operationId": "confirm_temporary_inventory_use",
"summary": "确认当前对话临时库存文件使用",
"description": "仅在用户明确确认本次使用后调用。HXOPS 重新确定性解析文件并校验料号、预约号、库存数量;只锁定当前对话的临时会话审计,不接受任务编号,绝不创建生产库存快照、绑定库存站点、写入任务库存行或执行库存匹配。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"agent_runtime_context": {
"type": "string",
"description": "HXOPS 注入的完整 agent_runtime_context JSON 字符串;必须原样透传,禁止由 LLM 构造或修改"
},
"temporary_session_no": {
"type": "string",
"description": "临时库存会话编号"
},
"selected_profile_id": {
"type": "integer",
"description": "仅 exact 已发布方案候选时由用户选择的方案 ID"
}
},
"required": [
"agent_runtime_context",
"temporary_session_no"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/update_notice_fields": {
"post": {
"operationId": "update_notice_fields",
"summary": "更新解析后的发货通知单头字段,如客户、PO、交期、收货地",
"description": "更新解析后的发货通知单头字段,如客户、PO、交期、收货地",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"fields": {
"type": "object",
"description": "可更新字段:customer_name/customer_code/ship_to/po_number/required_date",
"additionalProperties": true
},
"comment": {
"type": "string",
"description": "修改备注(可选)"
}
},
"required": [
"task_id",
"fields"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/update_notice_line": {
"post": {
"operationId": "update_notice_line",
"summary": "更新解析结果中的某一行,如内部料号、Reservation ID、数量、交期",
"description": "更新解析结果中的某一行,如内部料号、Reservation ID、数量、交期",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"line_index": {
"type": "integer",
"description": "行下标,从 0 开始"
},
"patch": {
"type": "object",
"description": "可更新字段:part_number/reservation_id/quantity/qty/required_date/uom/inventory_source_hint;inventory_source_hint 为可选订单路由线索",
"additionalProperties": true
},
"comment": {
"type": "string",
"description": "修改备注(可选)"
}
},
"required": [
"task_id",
"line_index",
"patch"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/add_notice_line": {
"post": {
"operationId": "add_notice_line",
"summary": "向解析结果新增一行发货需求",
"description": "向解析结果新增一行发货需求",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"line": {
"type": "object",
"description": "新增行,至少包含 part_number 和 qty/quantity",
"additionalProperties": true
},
"comment": {
"type": "string",
"description": "修改备注(可选)"
}
},
"required": [
"task_id",
"line"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/remove_notice_line": {
"post": {
"operationId": "remove_notice_line",
"summary": "删除解析结果中的某一行发货需求",
"description": "删除解析结果中的某一行发货需求",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"line_index": {
"type": "integer",
"description": "行下标,从 0 开始"
},
"comment": {
"type": "string",
"description": "修改备注(可选)"
}
},
"required": [
"task_id",
"line_index"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/confirm_inventory_source": {
"post": {
"operationId": "confirm_inventory_source",
"summary": "在库存源人工检查点确认正式库存查询来源(仅提交 source_code)",
"description": "库存连接器门禁:稳定身份须具备 source_code、connector_type;fixed Source 同时具备 warehouse_id,且 routing_fingerprint 与当前配置版本一致。Tool API 使用集成密钥鉴权,确认人审计由宿主会话内部链路写入,不接受外部 user_id。若返回 needs_human,说明身份未完整解析或需先完成解析确认。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"source_code": {
"type": "string",
"description": "启用配置中的库存源编码;Warehouse 由 fixed Source 配置或库存行匹配解析,禁止前端直传"
}
},
"required": [
"task_id",
"source_code"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/confirm_customer": {
"post": {
"operationId": "confirm_customer",
"summary": "在客户人工检查点确认标准客户(仅提交 customer_id)",
"description": "仅在 customer_review 检查点且用户已经明确选择标准客户后调用。禁止根据邮件中的不稳定客户名称自行猜测 customer_id;客户确认成功后由 HXOPS 决定后续流程。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"customer_id": {
"type": "integer",
"description": "用户从 HXOPS 标准客户列表中明确选择的客户 ID"
}
},
"required": [
"task_id",
"customer_id"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/submit_decision": {
"post": {
"operationId": "submit_decision",
"summary": "人工复核决策。task_id 与 conversation_id 至少传一个;用户确认时禁止 create_task。决策提交后由后台任务统一续跑。",
"description": "人工复核决策入口。必须先定位到唯一 task_id 才能推进;若 conversation_id 对应多个任务,必须先追问或调用状态查询工具确认,禁止用模糊指代直接推进。本 Tool 的返回结果以 HXOPS 状态机为准,Dify 必须根据实际返回的 status、checkpoint、forbidden_next_tools、human_options 或 action_buttons 解释当前现场。若返回 needs_human 或 failed,不得自行宣布完成、不得改写为成功,也不要在正文列出按钮清单;按钮由 HXOPS 前端渲染。",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"task_id": {
"type": "string",
"description": "发货任务引用:技术任务号 SN-20260529-ABCD1234 或业务号 WYC26071501"
},
"conversation_id": {
"type": "string",
"description": "Dify 会话 ID;用户仅回复「确认」时用于定位任务"
},
"decision": {
"type": "string",
"description": "confirm=确认继续;reject=驳回;retry_rpa=按已发布解析方案重新获取库存;rematch=重新匹配;reparse=重新解析",
"enum": [
"confirm",
"confirm_parse",
"reject",
"retry_rpa",
"rematch",
"reparse"
]
},
"comment": {
"type": "string",
"description": "备注(可选)"
}
},
"required": [
"decision"
]
}
}
}
},
"responses": {
"200": {
"description": "Tool response (status: ok|running|needs_human|failed). May include checkpoint, human_options, action_buttons.",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/tools/get_task_status": {
"post": {
"operationId": "get_task_status",
@@ -566,8 +31,16 @@
"conversation_id": {
"type": "string",
"description": "Dify 会话 ID"
},
"shipping_chat_capability_token": {
"type": "string",
"description": "HXOPS 每轮注入的短效只读能力令牌;必须原样透传"
}
}
},
"required": [
"task_id",
"shipping_chat_capability_token"
]
}
}
}
@@ -602,10 +75,15 @@
"batch_no": {
"type": "string",
"description": "发货批次编号(batch id),如 SB-20260617-ABCD1234"
},
"shipping_chat_capability_token": {
"type": "string",
"description": "HXOPS 每轮注入的短效只读能力令牌;必须原样透传"
}
},
"required": [
"batch_no"
"batch_no",
"shipping_chat_capability_token"
]
}
}