feat(rohs-check): 新增 RoHS 检核工具 API 及相关功能

This commit is contained in:
hugo committed 2026-06-10 15:17:09 +08:00
1 parent 8a541211b7
commit 24551e9a9a
39 files changed
+3128 -189

No files matched your search

+52 -30
View File
@@ -6,7 +6,7 @@
- 一个提交只做一件事(或同一类紧密相关的事)。
- 提交信息要让不了解上下文的人也能快速理解“改了什么、为什么改”。
- 优先使用英文提交信息,避免中英文混用造成解析不一致。
- **`type` 与 `scope` 使用英文**;**`subject` 与 `body` 使用中文**,便于团队阅读且 scope 与代码模块一一对应。
- 所有人遵循同一格式,减少代码评审和回溯成本。
## 2. 标准格式(必须)
@@ -21,10 +21,10 @@
说明:
- `type`:变更类型(必填)。
- `scope`:影响范围(选填,但推荐填写)。
- `subject`:一句话概述(必填)。
- `body`:详细说明(选填,建议在复杂改动时填写)。
- `type`:变更类型(必填,**英文枚举**)。
- `scope`:影响模块(选填但推荐,**英文 kebab-case**,与代码目录/包名一致)。
- `subject`:一句话概述(必填,**中文**)。
- `body`:详细说明(选填,建议在复杂改动时填写,**中文**)。
- `footer`:关联任务、破坏性变更等(选填)。
## 3. Header 书写规则(必须)
@@ -32,16 +32,18 @@
Header 即第一行:`<type>(<scope>): <subject>`
- 必须小写 `type`,后接英文冒号和空格。
- `subject` 使用祈使语气,简明描述动作,如 `add` `fix` `remove` `refactor`。
- `scope` 小写英文,多词用 kebab-case(如 `shipping-notice`),**禁止中文**。
- `subject` 使用祈使语气,简明描述动作,如「新增」「修复」「移除」「重构」。
- 不以句号结尾。
- Header 最大长度建议不超过 100 个字符。
正确示例:
```text
feat(auth): add SMS login support
fix(order): handle null coupon in checkout
refactor(api): split user service and repository
feat(schedule): 新增 RoHS 知识库同步字段
fix(shipping-notice): 修复 Dify 入参解析空值问题
refactor(rohs-check): 拆分 Agent 解析与工具 API
build(jenkins): 保留最近 10 组镜像并自动清理旧镜像
```
错误示例:
@@ -50,6 +52,9 @@ refactor(api): split user service and repository
Feat: Added login feature.
fix: bug
update code
feat(排程): 新增 RoHS 知识库同步字段
feat(schedule): add kb sync fields
fix(shipping-notice): handle null coupon
```
## 4. Type 定义(必须使用以下枚举)
@@ -68,18 +73,33 @@ update code
## 5. Scope 约定(推荐)
Scope 用于快速识别改动模块,建议使用以下命名:
Scope 应对齐代码模块,便于从提交信息定位到目录。选取规则:
- 按业务域:`auth` `order` `payment` `user`
- 按技术层:`api` `db` `ui` `deps` `config`
- 按工程对象:`docker` `github-actions` `eslint`
1. 看主要改动文件所在目录(`backend/app/services/<module>/`、`backend/app/api/`、`frontend/src/features/`)。
2. 目录名转 kebab-case:`shipping_notice` → `shipping-notice`,`rohs_check` → `rohs-check`。
3. 跨模块改动选影响最大的模块;纯基建用 `jenkins`、`migration`、`deps`、`ci` 等。
| scope | 典型目录/模块 |
| --- | --- |
| `schedule` | `services/schedule/`、`api/schedule_admin`、前端 `features/admin/modules/schedules/` |
| `shipping-notice` | `services/shipping_notice/`、`api/workspace_shipping_notice` |
| `rohs-check` | `services/rohs_check*`、`api/rohs_check_tools` |
| `knowledge-base` | `api/knowledge_base`、`services/knowledge_cleaning/` |
| `chat` | `api/chat`、前端 chat 相关 |
| `auth` | 登录认证 |
| `admin` | 管理后台通用 |
| `agents` | Agent 管理 |
| `api` | 跨模块 API 层重构 |
| `migration` | Alembic 迁移 |
| `jenkins` / `ci` / `deps` | 工程与依赖 |
示例:
```text
fix(payment): prevent duplicate callback handling
ci(github-actions): cache pnpm store
build(deps): upgrade axios to v1.9.0
fix(shipping-notice): 防止回调重复处理
ci(github-actions): 缓存 pnpm store
build(deps): 升级 axios 至 v1.9.0
perf(schedule): 优化排程查询分页加载
```
## 6. Body 编写建议(复杂改动强烈建议)
@@ -93,11 +113,10 @@ Body 与 Header 空一行,重点写“为什么”和“影响面”:
示例:
```text
feat(order): support partial shipment
feat(shipping-notice): 支持部分发货
Allow splitting one order into multiple shipment packages to support
warehouse stock differences. This change updates shipment status flow
and adds validation for package-level tracking numbers.
允许将同一订单拆分为多个发货包裹,以应对仓库库存差异。
本次变更更新发货状态流转,并增加包裹级运单号校验。
```
## 7. Footer 约定(推荐)
@@ -112,7 +131,7 @@ and adds validation for package-level tracking numbers.
若存在不兼容修改,必须明确标注:
```text
BREAKING CHANGE: remove legacy /v1/login endpoint, use /v2/login instead.
BREAKING CHANGE: 移除旧版 /v1/login 接口,请改用 /v2/login。
```
## 8. 常见场景示例
@@ -120,36 +139,36 @@ BREAKING CHANGE: remove legacy /v1/login endpoint, use /v2/login instead.
新增功能:
```text
feat(profile): add avatar upload API
feat(auth): 新增头像上传接口
```
修复问题:
```text
fix(cart): recalculate total when item quantity is zero
fix(shipping-notice): 商品数量为 0 时重新计算总价
```
依赖升级:
```text
build(deps): bump spring-boot to 3.3.2
build(deps): 升级 spring-boot 至 3.3.2
```
仅文档:
```text
docs(readme): add local development instructions
docs(readme): 补充本地开发说明
```
回滚提交:
```text
revert: feat(payment): support WeChat QR checkout
revert: feat(shipping-notice): 支持微信扫码结账
```
## 9. Pull Request 要求(建议)
- PR 标题建议复用同样格式:`type(scope): subject`
- PR 标题建议复用同样格式:`type(scope): subject`(scope 英文模块名,subject 中文)
- 一个 PR 尽量聚焦一个主题。
- 合并前整理提交历史,避免大量无意义提交(如 `update` `fix` `test`)。
@@ -158,12 +177,14 @@ revert: feat(payment): support WeChat QR checkout
- 禁止无语义提交信息:`update` `fix bug` `modify` `111`
- 禁止把多个无关改动放在同一提交中。
- 禁止漏写破坏性变更说明。
- 禁止 `scope` 使用中文(如 `排程`、`发货通知`)。
- 禁止 `subject` 使用英文(历史英文提交可保留,新提交统一中文)。
## 11. 自检清单(提交前)
- 提交类型是否正确(`feat/fix/...`)?
- `subject` 是否清晰说明“做了什么”?
- 是否需要 `scope` 来提升可读性?
- `scope` 是否为英文模块名且与改动目录一致?
- `subject` 是否为中文且清晰说明“做了什么”?
- 是否存在破坏性变更,若有是否标注 `BREAKING CHANGE`?
- 是否关联了任务编号(`Refs/Closes #id`)?
@@ -171,9 +192,10 @@ revert: feat(payment): support WeChat QR checkout
仓库已通过 Git Hook 自动校验提交信息,配置如下:
- **commitlint**:根目录 `commitlint.config.cjs`,规则与本文档对齐。
- **commitlint**:根目录 `commitlint.config.cjs`,规则与本文档对齐(校验 type 格式与 Header 长度,不限制 subject 语言)。
- **commit-msg Hook**:`.githooks/commit-msg`,在 `git commit` 时自动运行。
- **安装**:`./scripts/install_git_hooks.sh`(会设置 `core.hooksPath` 并执行根目录 `npm install`)。
- **Cursor IDE**:源代码管理 ✨「Generate commit message」仅读取根目录 **`.cursorrules`**;Agent 对话代提交读取 **`.cursor/rules/git-commit-zh.mdc`**。两者内容需保持一致。
详见 [Git Hooks 团队启用指南](../GIT_HOOKS.md)。
+9
View File
@@ -22,6 +22,15 @@
## 3. 范围说明
### 3.x RoHS 文件检核补充需求
- **核心目标**:提供 RoHS 文件检核能力(发起检核、查询实时结果、获取报告、可选同步知识库、基于知识库查询历史报告)。对用户统一称为「检核」,不区分排程触发与对话触发等实现方式。
- 新增 `RoHSCheckService` 作为统一判定入口,内部复用现有 Dify RoHS Workflow 中的 Prompt 与模型配置。
- 新增 Dify Chatflow 显式 HTTP Tool,用于对话中发起检核、查询检核状态与展示结果;不使用 Agent 节点做逐条判定。
- 检核成功或部分成功并生成 Excel 报告后,可按配置自动同步到指定知识库分组;Chatflow 通过 Knowledge Retrieval 检索已入库历史报告(与 Tool API 实时查询并存)。
- 后台执行、定时触发、数据抓取与写回沿用现有任务引擎(实现细节对用户透明)。
- Dify Chatflow 编排与 OpenAPI 导入见 [docs/rohs_chatflow_guide.md](rohs_chatflow_guide.md)。
### 3.1 本期范围
- 查询员工本人假期余额
+9
View File
@@ -16,6 +16,15 @@
## 2. 详细功能拆分
### RoHS 文件检核
| 功能项 | 状态 | 说明 |
| --- | --- | --- |
| RoHSCheckService 判定入口 | 已实现 | 检核执行链路统一调用,内部复用现有 Dify Workflow |
| Chatflow 发起与查询检核 | 已实现 | Tool API:查检核任务、启动检核、查检核批次、查最近检核、Excel 报告链接 |
| RoHS Chatflow 编排手册 | 已文档化 | 见 [docs/rohs_chatflow_guide.md](rohs_chatflow_guide.md) |
| 检核报告同步知识库 | 已实现 | 检核 success / partial_failed 且生成 Excel 后同步到所选知识库分组 |
### F-01 本人假期查询
#### 目标
+635
View File
@@ -0,0 +1,635 @@
{
"openapi": "3.0.3",
"info": {
"title": "HXOPS RoHS Check Tool API",
"description": "RoHS 文件检核 Chatflow 显式 HTTP Tool API:检核任务列表、发起检核、查询检核批次、下载检核报告。鉴权:Authorization Bearer 或 X-Integration-Key。",
"version": "1.0.0"
},
"servers": [
{
"url": "http://192.168.100.192:8891",
"description": "HXOPS_TOOLS_API_BASE"
}
],
"security": [
{
"BearerAuth": []
},
{
"IntegrationKey": []
}
],
"paths": {
"/api/rohs-check/tools/tasks": {
"get": {
"operationId": "list_rohs_tasks",
"summary": "查询 RoHS 检核任务列表",
"tags": [
"RoHS Check"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListTasksResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"503": {
"$ref": "#/components/responses/MissingAuth"
}
}
}
},
"/api/rohs-check/tools/tasks/run": {
"post": {
"operationId": "run_rohs_check",
"summary": "异步启动 RoHS 检核",
"tags": [
"RoHS Check"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RunCheckRequest"
}
}
}
},
"responses": {
"200": {
"description": "启动成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RunCheckSuccessResponse"
}
}
}
},
"409": {
"description": "检核进行中,同任务不可重复启动",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CheckRunningResponse"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
}
}
}
},
"/api/rohs-check/tools/runs/{run_id}": {
"get": {
"operationId": "get_rohs_run",
"summary": "查询指定检核批次",
"tags": [
"RoHS Check"
],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 88
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
"/api/rohs-check/tools/tasks/{task_id}/latest-run": {
"get": {
"operationId": "get_latest_rohs_run",
"summary": "查询检核任务最近一次检核",
"tags": [
"RoHS Check"
],
"parameters": [
{
"name": "task_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 12
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
"/api/rohs-check/tools/runs/{run_id}/excel": {
"get": {
"operationId": "download_rohs_run_excel",
"summary": "下载检核报告 Excel(短期签名 token)",
"tags": [
"RoHS Check"
],
"security": [],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 88
}
},
{
"name": "token",
"in": "query",
"required": true,
"description": "由 get_rohs_run 返回的 excel.download_url 中的 JWT,有效期 600 秒",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Excel 文件流",
"content": {
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"409": {
"$ref": "#/components/responses/ExcelNotReady"
}
}
}
}
},
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"description": "ROHS_TOOL_API_KEY 或 INTEGRATION_API_KEY"
},
"IntegrationKey": {
"type": "apiKey",
"in": "header",
"name": "X-Integration-Key",
"description": "与 Bearer 二选一"
}
},
"schemas": {
"TaskSummary": {
"type": "object",
"properties": {
"task_id": {
"type": "integer",
"example": 12
},
"task_no": {
"type": "string",
"example": "CHK202606090001"
},
"name": {
"type": "string",
"example": "RoHS 自动检核"
},
"enabled": {
"type": "boolean"
},
"last_status": {
"type": "string",
"nullable": true,
"example": "success"
},
"last_run_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"next_run_at": {
"type": "string",
"format": "date-time",
"nullable": true
}
}
},
"RunExcel": {
"type": "object",
"properties": {
"file_name": {
"type": "string",
"nullable": true,
"example": "RUN202606090001.xlsx"
},
"file_size": {
"type": "integer",
"nullable": true,
"example": 45678
},
"download_url": {
"type": "string",
"nullable": true,
"example": "http://192.168.100.192:8891/api/rohs-check/tools/runs/88/excel?token=..."
}
}
},
"RunKnowledgeBase": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"sync_status": {
"type": "string",
"nullable": true,
"enum": [
"skipped",
"queued",
"cleaning",
"syncing",
"ready",
"success",
"failed"
]
},
"group_id": {
"type": "integer",
"nullable": true
},
"document_id": {
"type": "integer",
"nullable": true
},
"document_version_id": {
"type": "integer",
"nullable": true
},
"sync_job_id": {
"type": "integer",
"nullable": true
},
"error_message": {
"type": "string",
"nullable": true
}
}
},
"RunDetail": {
"type": "object",
"properties": {
"run_id": {
"type": "integer",
"example": 88
},
"run_no": {
"type": "string",
"example": "RUN202606090001"
},
"task_id": {
"type": "integer",
"example": 12
},
"task_name": {
"type": "string",
"example": "RoHS 自动检核"
},
"status": {
"type": "string",
"enum": [
"running",
"success",
"partial_failed",
"failed",
"queued",
"cancelled"
]
},
"total_count": {
"type": "integer"
},
"success_count": {
"type": "integer"
},
"failed_count": {
"type": "integer"
},
"skipped_count": {
"type": "integer"
},
"started_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"finished_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"duration_ms": {
"type": "integer",
"nullable": true
},
"error_message": {
"type": "string",
"nullable": true
},
"excel": {
"$ref": "#/components/schemas/RunExcel"
},
"knowledge_base": {
"$ref": "#/components/schemas/RunKnowledgeBase"
}
}
},
"ListTasksResponse": {
"type": "object",
"required": [
"ok",
"tasks"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TaskSummary"
}
}
}
},
"RunCheckRequest": {
"type": "object",
"properties": {
"task_id": {
"type": "integer",
"example": 12
},
"task_no": {
"type": "string",
"example": "CHK202606090001"
},
"trigger_source": {
"type": "string",
"default": "dify_chatflow"
},
"conversation_id": {
"type": "string",
"nullable": true
},
"user_message": {
"type": "string",
"nullable": true
}
},
"description": "task_id 与 task_no 至少提供一个;优先使用 task_id"
},
"RunCheckSuccessResponse": {
"type": "object",
"required": [
"ok",
"message",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "检核已启动"
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"CheckRunningResponse": {
"type": "object",
"required": [
"ok",
"error_code",
"message",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": false
},
"error_code": {
"type": "string",
"example": "check_running"
},
"message": {
"type": "string",
"example": "该检核任务正在执行中,请稍后查询结果"
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"GetRunResponse": {
"type": "object",
"required": [
"ok",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"ErrorResponse": {
"type": "object",
"required": [
"ok",
"error_code",
"message"
],
"properties": {
"ok": {
"type": "boolean",
"example": false
},
"error_code": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
},
"responses": {
"Unauthorized": {
"description": "鉴权失败",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"examples": {
"missing_auth": {
"value": {
"ok": false,
"error_code": "missing_auth",
"message": "missing_auth"
}
},
"invalid_auth": {
"value": {
"ok": false,
"error_code": "invalid_auth",
"message": "invalid_auth"
}
}
}
}
}
},
"MissingAuth": {
"description": "服务端未配置 ROHS_TOOL_API_KEY / INTEGRATION_API_KEY",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "missing_auth",
"message": "ROHS_TOOL_API_KEY or INTEGRATION_API_KEY is not configured"
}
}
}
},
"BadRequest": {
"description": "请求无效或检核任务已停用",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "task_disabled",
"message": "task_disabled"
}
}
}
},
"TaskNotFound": {
"description": "检核任务不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "task_not_found",
"message": "task_not_found"
}
}
}
},
"RunNotFound": {
"description": "检核批次不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "run_not_found",
"message": "run_not_found"
}
}
}
},
"ExcelNotReady": {
"description": "Excel 尚未生成",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "excel_not_ready",
"message": "excel_not_ready"
}
}
}
}
}
}
}
+14 -12
View File
@@ -65,9 +65,10 @@ flask db upgrade
### 1.2 环境变量(`.env.dev` 示例)
```env
# Tool API(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
# Tool API 基地址(RoHS / 货代共用,无尾斜杠)
HXOPS_TOOLS_API_BASE=http://192.168.100.192:8890
# 货代 Tool API Key(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
SHIPPING_NOTICE_TOOL_API_KEY=your-tool-key
SHIPPING_NOTICE_TOOL_API_BASE=http://192.168.36.114:5052
# 文件存储(相对 backend/ 根目录;勿写 backend/data/… 以免 cwd 在 backend/ 时变成 backend/backend/…)
SHIPPING_NOTICE_STORAGE_ROOT=data/shipping_notice
@@ -194,7 +195,7 @@ curl -s http://192.168.100.192:8890/api/shipping-notice/tools/openapi.json | hea
```bash
cd backend
set SHIPPING_NOTICE_TOOL_API_BASE=http://192.168.100.192:8890
set HXOPS_TOOLS_API_BASE=http://192.168.100.192:8890
python scripts/export_shipping_notice_openapi.py
# → docs/openapi/shipping_notice_tools.dify.json
```
@@ -409,21 +410,21 @@ flowchart TD
| 输入变量名 | 类型 | 必填 | 说明 |
|------------|------|------|------|
| `hxops_tool_api_base` | string | 否 | hxops 后端根地址,**无**尾斜杠,例 `http://host:8890` |
| `HXOPS_TOOLS_API_BASE` | string | 否 | hxops 后端根地址,**无**尾斜杠,例 `http://host:8890` |
| `hxops_tool_api_key` | string | 否 | 与 hxops `SHIPPING_NOTICE_TOOL_API_KEY` 一致 |
2. **hxops 自动注入**:用户经前端聊天调用 `货代发货通知 Agent` 时,`/api/chat/completions` 会把上述两项写入 Dify `inputs`(读 `SHIPPING_NOTICE_TOOL_API_BASE` / `SHIPPING_NOTICE_TOOL_API_KEY`)。**切换 dev / test / prod 只改 hxops 环境变量,Dify 画布 YAML 可原样导入**。
2. **hxops 自动注入**:用户经前端聊天调用 `货代发货通知 Agent` 时,`/api/chat/completions` 会把上述两项写入 Dify `inputs`(读 `HXOPS_TOOLS_API_BASE` / `SHIPPING_NOTICE_TOOL_API_KEY`)。**切换 dev / test / prod 只改 hxops 环境变量,Dify 画布 YAML 可原样导入**。
3. **HTTP 节点统一模板**(所有 `HTTP_*` 节点 URL / Header 均按此填写,勿再写死 IP):
| 项 | 模板 |
|----|------|
| URL | `{{#hxops_tool_api_base#}}/api/shipping-notice/tools/<endpoint>`,例 `…/api/shipping-notice/tools/create_task` |
| URL | `{{#HXOPS_TOOLS_API_BASE#}}/api/shipping-notice/tools/<endpoint>`,例 `…/api/shipping-notice/tools/create_task` |
| Header `X-Shipping-Tool-Key` | `{{#hxops_tool_api_key#}}` |
> Dify 版本差异:若 UI 无法直接填 `{{#变量名#}}`,用变量选择器绑定 **输入变量** `hxops_tool_api_base` / `hxops_tool_api_key` 即可,语义相同。
> Dify 版本差异:若 UI 无法直接填 `{{#变量名#}}`,用变量选择器绑定 **输入变量** `HXOPS_TOOLS_API_BASE` / `hxops_tool_api_key` 即可,语义相同。
**Agent 自定义工具(OpenAPI)**:导入地址 `{hxops_tool_api_base}/api/shipping-notice/tools/openapi.json`(或 Dify 环境变量拼 URL);换环境时重新「从 URL 导入」或改工具 Server URL 一次,**不必改 Chatflow 连线**。
**Agent 自定义工具(OpenAPI)**:导入地址 `{HXOPS_TOOLS_API_BASE}/api/shipping-notice/tools/openapi.json`(或 Dify 环境变量拼 URL);换环境时重新「从 URL 导入」或改工具 Server URL 一次,**不必改 Chatflow 连线**。
**HTTP 公共配置**
@@ -432,7 +433,7 @@ flowchart TD
| Method | POST |
| Header | `X-Shipping-Tool-Key: {{#hxops_tool_api_key#}}` |
| Header | `Content-Type: application/json`(JSON Body 节点) |
| 基 URL | `{{#hxops_tool_api_base#}}/api/shipping-notice/tools/`(**禁止**写死 IP;旧示例 IP 仅作联调参考) |
| 基 URL | `{{#HXOPS_TOOLS_API_BASE#}}/api/shipping-notice/tools/`(**禁止**写死 IP;旧示例 IP 仅作联调参考) |
**Dify Code 节点配置说明**
@@ -715,7 +716,7 @@ def main(
| 项 | 值 |
|----|-----|
| Method | POST |
| URL | `{{#hxops_tool_api_base#}}/api/shipping-notice/tools/create_task` |
| URL | `{{#HXOPS_TOOLS_API_BASE#}}/api/shipping-notice/tools/create_task` |
| Header | `X-Shipping-Tool-Key: {{#hxops_tool_api_key#}}`;`Content-Type: application/json` |
| Body | `{{#拼装 create_task Body.create_body_json#}}`(JSON 对象,勿再加引号) |
| 出参 | `body` · **String** |
@@ -839,7 +840,7 @@ def main(text: str) -> dict:
| 项 | 值 |
|----|-----|
| URL | `{{#hxops_tool_api_base#}}/api/shipping-notice/tools/parse_notice` |
| URL | `{{#HXOPS_TOOLS_API_BASE#}}/api/shipping-notice/tools/parse_notice` |
| Header | `X-Shipping-Tool-Key`;`Content-Type: application/json` |
| Body | 见下 |
| 出参 | `body` · **String** |
@@ -927,7 +928,7 @@ def main(body: str) -> dict:
| 项 | 值 |
|----|-----|
| Method | POST |
| URL | `{{#hxops_tool_api_base#}}/api/shipping-notice/tools/upload_inventory_file` |
| URL | `{{#HXOPS_TOOLS_API_BASE#}}/api/shipping-notice/tools/upload_inventory_file` |
| Header | `X-Shipping-Tool-Key: {{#hxops_tool_api_key#}}` |
| Body 类型 | **form-data** |
| form `task_id` | `{{#conversation.task_id#}}` · String |
@@ -3024,3 +3025,4 @@ GET /api/shipping-notice/tools/checkpoint-catalog
| `backend/tests/test_shipping_notice_tools.py` | Tool 集成测试 |
| `backend/tests/test_shipping_notice_state_machine.py` | registry / task UI 快照 |
| `scripts/rpa/freight_rpa_worker.py` | RPA Worker |
+9
View File
@@ -10,6 +10,14 @@
## 2. 现有可复用能力
### 2.x RoHS 文件检核可复用能力
- **产品语义**:对外统一为 RoHS 文件检核(发起、实时查询、报告、知识库同步、历史报告检索);Tool API 使用 `/api/rohs-check/tools/tasks` 与 `task_id` / `task_no` 字段;历史查询走 Dify Knowledge Retrieval(绑定检核报告同步的 Dataset);对外基地址由环境变量 `HXOPS_TOOLS_API_BASE` 配置。
- 通过 `RoHSCheckService.evaluate()` 包装现有 Dify Workflow 调用,保持 `dify_result / dify_message` 输出兼容。
- 新增 `/api/rohs-check/tools/*` 显式 HTTP Tool API,供 Dify Chatflow 发起检核、查询检核结果并返回 Excel 报告短期签名链接。
- Chatflow 完整编排、Dify 逐步配置与 OpenAPI 导入见 **[docs/rohs_chatflow_guide.md](rohs_chatflow_guide.md)**;OpenAPI 规范见 **[docs/openapi/rohs_check_tools_openapi.json](openapi/rohs_check_tools_openapi.json)**(`python backend/scripts/export_rohs_check_openapi.py` 重新生成)。
- 复用知识库 `KbDocument / KbDocumentVersion / KbJob` 清洗与 Dify 同步链路,将检核报告 Excel 作为独立文档入库。
### 2.1 已有聊天路由能力
- 后端 `chat` 接口已支持按意图分流
@@ -878,3 +886,4 @@ const update = () => { isMobile.value = window.innerHeight > window.innerWidth;
- Web 进程压力下降,系统稳定性提升
- 失败任务可重试,进度展示更清晰
- 整体知识库链路更适合后续扩展为高并发、多批次处理模式