feat(rohs-check): 新增 RoHS 检核执行进度中增加 Excel 下载功能及相关配置

This commit is contained in:
hugo committed 2026-06-11 17:35:16 +08:00
1 parent ee39270069
commit 599d492895
14 files changed
+845 -272

No files matched your search

@@ -12,26 +12,38 @@
}
],
"security": [
{ "BearerAuth": [] },
{ "IntegrationKey": [] }
{
"BearerAuth": []
},
{
"IntegrationKey": []
}
],
"paths": {
"/api/rohs-check/tools/tasks": {
"get": {
"operationId": "list_rohs_tasks",
"summary": "查询 RoHS 检核任务列表",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ListTasksResponse" }
"schema": {
"$ref": "#/components/schemas/ListTasksResponse"
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"503": { "$ref": "#/components/responses/MissingAuth" }
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"503": {
"$ref": "#/components/responses/MissingAuth"
}
}
}
},
@@ -39,35 +51,46 @@
"post": {
"operationId": "run_rohs_check",
"summary": "异步启动 RoHS 检核",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/RunCheckRequest" }
"schema": {
"$ref": "#/components/schemas/RunCheckRequest"
}
}
}
},
"responses": {
"200": {
"description": "启动成功",
"description": "启动成功;或已有 RoHS 检核进行中,返回 ok=false/error_code=check_running",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/RunCheckSuccessResponse" }
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/RunCheckSuccessResponse"
},
{
"$ref": "#/components/schemas/CheckRunningResponse"
}
]
}
}
}
},
"409": {
"description": "RoHS 检核进行中,全局不可重复启动",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CheckRunningResponse" }
}
}
"400": {
"$ref": "#/components/responses/BadRequest"
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/TaskNotFound" }
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
}
}
}
},
@@ -75,20 +98,30 @@
"get": {
"operationId": "list_rohs_runs",
"summary": "查询 RoHS 检核批次列表",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"parameters": [
{
"name": "task_id",
"in": "query",
"required": false,
"schema": { "type": "integer", "example": 12 },
"schema": {
"type": "integer",
"example": 12
},
"description": "可选;指定检核任务 ID 时只返回该任务批次"
},
{
"name": "limit",
"in": "query",
"required": false,
"schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 },
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
},
"description": "返回条数,最大 100"
}
],
@@ -97,12 +130,18 @@
"description": "成功",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ListRunsResponse" }
"schema": {
"$ref": "#/components/schemas/ListRunsResponse"
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/TaskNotFound" }
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
}
}
}
},
@@ -110,13 +149,18 @@
"get": {
"operationId": "get_rohs_run",
"summary": "查询指定检核批次",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": { "type": "integer", "example": 88 }
"schema": {
"type": "integer",
"example": 88
}
}
],
"responses": {
@@ -124,12 +168,18 @@
"description": "成功",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/GetRunResponse" }
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/RunNotFound" }
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
@@ -137,13 +187,18 @@
"get": {
"operationId": "get_latest_rohs_run",
"summary": "查询检核任务最近一次检核",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"parameters": [
{
"name": "task_id",
"in": "path",
"required": true,
"schema": { "type": "integer", "example": 12 }
"schema": {
"type": "integer",
"example": 12
}
}
],
"responses": {
@@ -151,12 +206,18 @@
"description": "成功",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/GetRunResponse" }
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/RunNotFound" }
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
@@ -164,21 +225,28 @@
"get": {
"operationId": "download_rohs_run_excel",
"summary": "下载检核报告 Excel(短期签名 token)",
"tags": ["RoHS Check"],
"tags": [
"RoHS Check"
],
"security": [],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": { "type": "integer", "example": 88 }
"schema": {
"type": "integer",
"example": 88
}
},
{
"name": "token",
"in": "query",
"required": true,
"description": "由 get_rohs_run 返回的 excel.download_url 中的 JWT,有效期 600 秒",
"schema": { "type": "string" }
"schema": {
"type": "string"
}
}
],
"responses": {
@@ -186,11 +254,16 @@
"description": "Excel 文件流",
"content": {
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
"schema": { "type": "string", "format": "binary" }
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"409": { "$ref": "#/components/responses/ExcelNotReady" }
"409": {
"$ref": "#/components/responses/ExcelNotReady"
}
}
}
}
@@ -213,20 +286,51 @@
"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 }
"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 },
"file_name": {
"type": "string",
"nullable": true,
"example": "RUN202606090001.xlsx"
},
"file_size": {
"type": "integer",
"nullable": true,
"example": 45678
},
"download_url": {
"type": "string",
"nullable": true,
@@ -237,111 +341,265 @@
"RunKnowledgeBase": {
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"enabled": {
"type": "boolean"
},
"sync_status": {
"type": "string",
"nullable": true,
"enum": ["skipped", "queued", "cleaning", "syncing", "ready", "success", "failed"]
"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 }
"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 自动检核" },
"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"]
"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" }
"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"],
"required": [
"ok",
"tasks"
],
"properties": {
"ok": { "type": "boolean", "example": true },
"ok": {
"type": "boolean",
"example": true
},
"tasks": {
"type": "array",
"items": { "$ref": "#/components/schemas/TaskSummary" }
"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 }
"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
}
},
"required": ["task_id"],
"required": [
"task_id"
],
"description": "Chatflow Start 节点固定配置 task_id;后端仍兼容 task_no,但 RoHS Chatflow 不使用任务选择流程"
},
"RunCheckSuccessResponse": {
"type": "object",
"required": ["ok", "message", "run"],
"required": [
"ok",
"message",
"run"
],
"properties": {
"ok": { "type": "boolean", "example": true },
"message": { "type": "string", "example": "检核已启动" },
"run": { "$ref": "#/components/schemas/RunDetail" }
"ok": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "检核已启动"
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"CheckRunningResponse": {
"type": "object",
"required": ["ok", "error_code", "message", "run"],
"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" }
"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"],
"required": [
"ok",
"run"
],
"properties": {
"ok": { "type": "boolean", "example": true },
"run": { "$ref": "#/components/schemas/RunDetail" }
"ok": {
"type": "boolean",
"example": true
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"ListRunsResponse": {
"type": "object",
"required": ["ok", "runs", "count"],
"required": [
"ok",
"runs",
"count"
],
"properties": {
"ok": { "type": "boolean", "example": true },
"count": { "type": "integer", "example": 2 },
"ok": {
"type": "boolean",
"example": true
},
"count": {
"type": "integer",
"example": 2
},
"runs": {
"type": "array",
"items": { "$ref": "#/components/schemas/RunDetail" }
"items": {
"$ref": "#/components/schemas/RunDetail"
}
}
}
},
"ErrorResponse": {
"type": "object",
"required": ["ok", "error_code", "message"],
"required": [
"ok",
"error_code",
"message"
],
"properties": {
"ok": { "type": "boolean", "example": false },
"error_code": { "type": "string" },
"message": { "type": "string" }
"ok": {
"type": "boolean",
"example": false
},
"error_code": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
},
@@ -350,13 +608,23 @@
"description": "鉴权失败",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"examples": {
"missing_auth": {
"value": { "ok": false, "error_code": "missing_auth", "message": "missing_auth" }
"value": {
"ok": false,
"error_code": "missing_auth",
"message": "missing_auth"
}
},
"invalid_auth": {
"value": { "ok": false, "error_code": "invalid_auth", "message": "invalid_auth" }
"value": {
"ok": false,
"error_code": "invalid_auth",
"message": "invalid_auth"
}
}
}
}
@@ -366,7 +634,9 @@
"description": "服务端未配置 ROHS_TOOLS_API_KEY / INTEGRATION_API_KEY",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "missing_auth",
@@ -379,7 +649,9 @@
"description": "请求参数无效",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "invalid_request",
@@ -392,7 +664,9 @@
"description": "检核任务不存在",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "task_not_found",
@@ -405,7 +679,9 @@
"description": "检核批次不存在",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "run_not_found",
@@ -418,7 +694,9 @@
"description": "Excel 尚未生成",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorResponse" },
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "excel_not_ready",
@@ -430,6 +708,3 @@
}
}
}