VWED_server/VWED任务模块接口文档/任务记录接口文档.md
2025-05-12 15:43:21 +08:00

698 lines
19 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# VWED任务记录接口文档
本文档描述了VWED系统任务运行记录相关的API接口主要用于查询任务执行过程中的块运行情况和详情。
## 基础信息
- 基础路径:`/api/vwed-task-record`
- 接口标签:`VWED任务运行记录`
## 接口清单
| 序号 | 接口名称 | 接口路径 | 请求方式 | 接口描述 |
| --- | --- | --- | --- | --- |
| 1 | 获取任务块运行记录 | `/blocks/{task_record_id}` | GET | 获取指定任务记录下的所有块运行情况 |
| 2 | 获取块记录详情 | `/block/{block_record_id}` | GET | 获取指定块记录的详细信息 |
| 3 | 终止任务 | `/stop/{task_record_id}` | POST | 停止指定任务记录下的所有运行任务实例 |
| 4 | 获取任务执行结果 | `/execution/block/results/{task_record_id}` | GET | 获取指定任务记录的执行结果 |
| 5 | 获取任务记录详情 | `/detail/{task_record_id}` | GET | 获取指定任务记录的详细信息 |
## 接口详情
### 1. 获取任务块运行记录
#### 接口说明
获取指定任务记录下的所有块运行情况,包括每个块的运行状态、执行时间、输入输出参数等信息。
#### 请求路径
```
GET /api/vwed-task-record/blocks/{task_record_id}
```
#### 路径参数
| 参数名 | 类型 | 是否必须 | 描述 |
| --- | --- | --- | --- |
| task_record_id | string | 是 | 任务记录ID由run_task接口返回的taskRecordId |
#### 响应结果
成功响应:
```json
{
"code": 200,
"message": "成功获取任务记录 {task_record_id} 的块运行情况",
"data": [
{
"id": "块记录ID",
"block_name": "块名称",
"block_id": "块ID",
"status": 块执行状态码,
"started_on": "开始时间",
"ended_on": "结束时间",
"ended_reason": "结束原因",
"block_execute_name": "块执行名称",
"block_input_params_value": {
"参数名": "参数值"
},
"block_out_params_value": {
"参数名": "参数值"
},
"remark": "备注"
}
]
}
```
失败响应:
```json
{
"code": 500,
"message": "获取任务块运行情况失败: {错误信息}"
}
```
#### 响应字段说明
| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| id | string | 块记录ID |
| block_name | string | 块名称 |
| block_id | string | 块ID |
| status | integer | 块执行状态1000:执行成功1001:执行中1002:未执行2000:执行失败2002:取消 |
| started_on | string | 开始时间ISO 8601格式 |
| ended_on | string | 结束时间ISO 8601格式 |
| ended_reason | string | 结束原因 |
| block_execute_name | string | 块执行名称 |
| block_input_params_value | object | 块输入参数值 |
| block_out_params_value | object | 块输出参数值 |
| remark | string | 备注 |
#### 示例
请求示例:
```
GET /api/vwed-task-record/blocks/7b84fd4d-e947-4ec7-8535-05ede5f8aa9d
```
响应示例:
```json
{
"code": 200,
"message": "成功获取任务记录 7b84fd4d-e947-4ec7-8535-05ede5f8aa9d 的块运行情况",
"data": [
{
"id": "b5410c81-99b3-4d61-bb79-e54292d012d4",
"block_name": "-1",
"block_id": "-1",
"status": 1000,
"started_on": "2025-04-30T17:28:19.105648",
"ended_on": "2025-04-30T17:28:19.601597",
"ended_reason": "执行成功",
"block_execute_name": "RootBp",
"block_input_params_value": {},
"block_out_params_value": null,
"remark": "执行成功"
},
{
"id": "ee29eccd-11e8-490b-ac24-81f243771dda",
"block_name": "b1",
"block_id": "1",
"status": 1000,
"started_on": "2025-04-30T17:28:19.149185",
"ended_on": "2025-04-30T17:28:19.576944",
"ended_reason": "执行成功",
"block_execute_name": "IterateListBp",
"block_input_params_value": {
"list": "[1,2,3,4,5]"
},
"block_out_params_value": {
"index": 4,
"item": 5
},
"remark": "执行成功"
},
{
"id": "c944c7df-329c-468e-90ed-9e064ddccdbc",
"block_name": "b2",
"block_id": "2",
"status": 1000,
"started_on": "2025-04-30T17:28:19.457166",
"ended_on": "2025-04-30T17:28:19.488009",
"ended_reason": "执行成功",
"block_execute_name": "PrintBp",
"block_input_params_value": {
"message": "blocks.b1.item"
},
"block_out_params_value": null,
"remark": "执行成功"
}
]
}
```
### 2. 获取块记录详情
#### 接口说明
获取指定块记录的详细信息,包括完整的输入输出参数、内部变量等数据。
#### 请求路径
```
GET /api/vwed-task-record/block/{block_record_id}
```
#### 路径参数
| 参数名 | 类型 | 是否必须 | 描述 |
| --- | --- | --- | --- |
| block_record_id | string | 是 | 块记录ID |
#### 响应结果
成功响应:
```json
{
"code": 200,
"message": "成功获取块记录详情",
"data": {
"id": "块记录ID",
"block_name": "块名称",
"block_id": "块ID",
"block_config_id": "块配置ID",
"block_input_params": {
"参数名": {
"type": "参数类型",
"value": "参数默认值",
"required": true/false
}
},
"block_input_params_value": {
"参数名": "参数值"
},
"block_out_params_value": {
"参数名": "参数值"
},
"block_internal_variables": {
"变量名": "变量值"
},
"block_execute_name": "块执行名称",
"task_id": "任务定义ID",
"task_record_id": "任务记录ID",
"started_on": "开始时间",
"ended_on": "结束时间",
"ended_reason": "结束原因",
"status": 块执行状态码,
"ctrl_status": 控制状态码,
"input_params": {
"参数名": {
"type": "参数类型",
"value": "参数默认值",
"required": true/false
}
},
"internal_variables": {
"变量名": "变量值"
},
"output_params": {
"参数名": "参数值"
},
"version": 版本号,
"remark": "备注"
}
}
```
失败响应:
```json
{
"code": 404,
"message": "未找到ID为 {block_record_id} 的块记录"
}
```
#### 响应字段说明
| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| id | string | 块记录ID |
| block_name | string | 块名称 |
| block_id | string | 块ID |
| block_config_id | string | 块配置ID |
| block_input_params | object | 块输入参数定义 |
| block_input_params_value | object | 块输入参数值 |
| block_out_params_value | object | 块输出参数值 |
| block_internal_variables | object | 块内部变量 |
| block_execute_name | string | 块执行名称 |
| task_id | string | 任务定义ID |
| task_record_id | string | 任务记录ID |
| started_on | string | 开始时间ISO 8601格式 |
| ended_on | string | 结束时间ISO 8601格式 |
| ended_reason | string | 结束原因 |
| status | integer | 块执行状态1000:执行成功1001:执行中1002:未执行2000:执行失败2002:取消 |
| ctrl_status | integer | 控制状态 |
| input_params | object | 输入参数 |
| internal_variables | object | 内部变量 |
| output_params | object | 输出参数 |
| version | integer | 版本号 |
| remark | string | 备注 |
#### 示例
请求示例:
```
GET /api/vwed-task-record/block/00b7dc0d-7c23-4dce-ae95-3618f2cad202
```
响应示例:
```json
{
"code": 200,
"message": "成功获取块记录详情",
"data": {
"id": "00b7dc0d-7c23-4dce-ae95-3618f2cad202",
"block_name": "b1",
"block_id": "1",
"block_config_id": "",
"block_input_params": {
"keyRoute": {
"type": "Simple",
"value": "TK01",
"required": true
}
},
"block_input_params_value": {
"keyRoute": "TK01"
},
"block_out_params_value": null,
"block_internal_variables": {},
"block_execute_name": "CSelectAgvBp",
"task_id": "3273c7cb-b4bb-47df-9d47-17f96bc401fc",
"task_record_id": "5ce20794-2b45-4031-8de0-9df922f91bd1",
"started_on": "2025-04-30T08:36:37.847431",
"ended_on": "2025-04-30T08:36:37.959064",
"ended_reason": "选择执行机器人失败: 执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等",
"status": 2000,
"ctrl_status": null,
"input_params": {
"keyRoute": {
"type": "Simple",
"value": "TK01",
"required": true
}
},
"internal_variables": {},
"output_params": {
"blocks": {
"b1": null
}
},
"version": 1,
"remark": "选择执行机器人失败: 执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等"
}
}
```
### 3. 终止任务
#### 接口说明
停止指定任务记录下的所有运行任务实例,同时禁用定时任务。
#### 请求路径
```
POST /api/vwed-task-record/stop/{task_record_id}
```
#### 路径参数
| 参数名 | 类型 | 是否必须 | 描述 |
| --- | --- | --- | --- |
| task_record_id | string | 是 | 任务记录ID |
#### 响应结果
成功响应:
```json
{
"code": 200,
"message": "任务终止成功",
"data": {
"task_record_id": "任务记录ID",
"status": 任务状态码,
"ended_on": "结束时间",
"ended_reason": "结束原因"
}
}
```
失败响应:
```json
{
"code": 400,
"message": "任务终止失败: {错误信息}"
}
```
```json
{
"code": 500,
"message": "任务记录终止失败: {错误信息}"
}
```
#### 响应字段说明
| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| task_record_id | string | 任务记录ID |
| status | integer | 任务状态码 |
| ended_on | string | 结束时间ISO 8601格式 |
| ended_reason | string | 结束原因 |
#### 示例
请求示例:
```
POST /api/vwed-task-record/stop/7b84fd4d-e947-4ec7-8535-05ede5f8aa9d
```
响应示例:
```json
{
"code": 200,
"message": "任务终止成功",
"data": {
"task_record_id": "7b84fd4d-e947-4ec7-8535-05ede5f8aa9d",
"status": 2002,
"ended_on": "2025-04-30T17:35:42.105648",
"ended_reason": "任务终止"
}
}
```
### 4. 获取任务执行结果
#### 接口说明
获取指定任务记录的执行结果,包括任务的输出参数和执行状态等信息。
#### 请求路径
```
GET /api/vwed-task-record/execution/block/results/{task_record_id}
```
#### 路径参数
| 参数名 | 类型 | 是否必须 | 描述 |
| --- | --- | --- | --- |
| task_record_id | string | 是 | 任务记录ID |
#### 响应结果
成功响应:
```json
{
"code": 200,
"message": "成功获取任务记录执行结果",
"data": [
{
"created_at": "2025-05-09T10:17:48.447047",
"context": "[CacheDataBp] 数据缓存成功: test",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.407731",
"context": "[RootBp] c1973f22-b098-47f7-80ae-97e9df1644ae",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.611951",
"context": "[PrintBp] 打印成功@{'cache_data': 1}",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.518772",
"context": "[GetCacheDataBp] 获取缓存数据成功: test",
"status": 1000
}
]
}
```
失败响应:
```json
{
"code": 404,
"message": "未找到ID为 {task_record_id} 的任务记录"
}
```
```json
{
"code": 500,
"message": "获取任务记录执行结果失败: {错误信息}"
}
```
#### 响应字段说明
| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| created_at | string | 记录创建时间ISO 8601格式 |
| context | string | 执行上下文信息,包含块名称和执行结果 |
| status | integer | 执行状态码1000:执行成功1001:执行中1002:未执行2000:执行失败2002:取消 |
#### 示例
请求示例:
```
GET /api/vwed-task-record/execution/block/results/7b84fd4d-e947-4ec7-8535-05ede5f8aa9d
```
响应示例:
```json
{
"code": 200,
"message": "成功获取任务记录执行结果",
"data": [
{
"created_at": "2025-05-09T10:17:48.447047",
"context": "[CacheDataBp] 数据缓存成功: test",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.407731",
"context": "[RootBp] c1973f22-b098-47f7-80ae-97e9df1644ae",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.611951",
"context": "[PrintBp] 打印成功@{'cache_data': 1}",
"status": 1000
},
{
"created_at": "2025-05-09T10:17:48.518772",
"context": "[GetCacheDataBp] 获取缓存数据成功: test",
"status": 1000
}
]
}
```
### 5. 获取任务记录详情
#### 接口说明
获取指定任务记录的详细信息,包括任务的基本信息、执行状态、开始结束时间等。
#### 请求路径
```
GET /api/vwed-task-record/detail/{task_record_id}
```
#### 路径参数
| 参数名 | 类型 | 是否必须 | 描述 |
| --- | --- | --- | --- |
| task_record_id | string | 是 | 任务记录ID |
#### 响应结果
成功响应:
```json
{
"code": 200,
"message": "成功获取任务记录详情",
"data": {
"id": "任务记录ID",
"task_id": "任务定义ID",
"task_name": "任务名称",
"task_version": 任务版本,
"status": 任务状态码,
"input_params": {
"参数名": "参数值"
},
"started_on": "开始时间",
"ended_on": "结束时间",
"ended_reason": "结束原因",
"execution_time": 执行时长(毫秒),
"created_at": "创建时间",
"updated_at": "更新时间",
"agv_id": "执行任务的AGV设备ID",
"parent_task_record_id": "父任务记录ID",
"root_task_record_id": "根任务记录ID",
"state_description": "状态描述",
"if_have_child_task": 是否有子任务,
"periodic_task": 是否为周期任务,
"priority": 优先级,
"work_stations": "工作站",
"work_types": "工作类型",
"variables": {
"变量名": "变量值"
},
"source_type": 任务来源类型,
"source_system": "来源系统标识",
"source_user": "下达任务的用户ID或账号",
"source_device": "下达任务的硬件设备标识",
"source_ip": "下达任务的IP地址",
"source_time": "任务下达时间",
"source_client_info": "客户端设备信息",
"source_remarks": "任务来源备注信息"
}
}
```
失败响应:
```json
{
"code": 404,
"message": "未找到ID为 {task_record_id} 的任务记录"
}
```
```json
{
"code": 500,
"message": "获取任务记录详情失败: {错误信息}"
}
```
#### 响应字段说明
| 字段名 | 类型 | 描述 |
| --- | --- | --- |
| id | string | 任务记录ID |
| task_id | string | 任务定义ID对应def_id字段 |
| task_name | string | 任务名称对应def_label字段 |
| task_version | integer | 任务定义版本对应def_version字段 |
| status | integer | 任务状态码1000:执行成功1001:执行中1002:队列中2000:失败2001:取消2002:暂停 |
| input_params | object | 输入参数JSON格式 |
| started_on | string | 开始时间对应first_executor_time字段ISO 8601格式 |
| ended_on | string | 结束时间ISO 8601格式 |
| ended_reason | string | 结束原因 |
| execution_time | integer | 执行时长(毫秒)根据开始和结束时间计算或executor_time字段值 |
| created_at | string | 创建时间ISO 8601格式 |
| updated_at | string | 更新时间ISO 8601格式 |
| agv_id | string | 执行任务的AGV设备ID |
| parent_task_record_id | string | 父任务记录ID |
| root_task_record_id | string | 根任务记录ID |
| state_description | string | 状态描述 |
| if_have_child_task | boolean | 是否有子任务 |
| periodic_task | integer | 是否为周期任务0:否1:是 |
| priority | integer | 优先级,数值越大优先级越高 |
| work_stations | string | 工作站 |
| work_types | string | 工作类型 |
| variables | object | 变量信息JSON格式 |
| source_type | integer | 任务来源类型1:系统调度2:呼叫机3:第三方系统4:手持电脑) |
| source_system | string | 来源系统标识WMS、MES等系统编号 |
| source_user | string | 下达任务的用户ID或账号 |
| source_device | string | 下达任务的硬件设备标识设备ID、MAC地址等 |
| source_ip | string | 下达任务的IP地址 |
| source_time | string | 任务下达时间ISO 8601格式 |
| source_client_info | string | 客户端设备信息(用户代理、浏览器、操作系统等) |
| source_remarks | string | 任务来源备注信息 |
#### 示例
请求示例:
```
GET /api/vwed-task-record/detail/7b84fd4d-e947-4ec7-8535-05ede5f8aa9d
```
响应示例:
```json
{
"code": 200,
"message": "成功获取任务记录详情",
"data": {
"id": "7b84fd4d-e947-4ec7-8535-05ede5f8aa9d",
"task_id": "3273c7cb-b4bb-47df-9d47-17f96bc401fc",
"task_name": "示例任务",
"task_version": 2,
"status": 1000,
"input_params": {
"from": "A",
"to": "B"
},
"started_on": "2025-04-30T17:28:19.105648",
"ended_on": "2025-04-30T17:28:20.601597",
"ended_reason": "执行成功",
"execution_time": 1496,
"created_at": "2025-04-30T17:28:19.100000",
"updated_at": "2025-04-30T17:28:20.610000",
"agv_id": "AGV001",
"parent_task_record_id": null,
"root_task_record_id": "7b84fd4d-e947-4ec7-8535-05ede5f8aa9d",
"state_description": "任务已完成",
"if_have_child_task": false,
"periodic_task": 0,
"priority": 1,
"work_stations": "WS001",
"work_types": "运输任务",
"variables": {
"position": {"x": 100, "y": 200}
},
"source_type": 1,
"source_system": "WMS",
"source_user": "admin",
"source_device": "PC-001",
"source_ip": "192.168.1.100",
"source_time": "2025-04-30T17:28:18.000000",
"source_client_info": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"source_remarks": "测试任务"
}
}
```