1313 lines
34 KiB
Markdown
1313 lines
34 KiB
Markdown
# 任务编辑接口文档
|
||
|
||
## 三、任务编辑模块接口
|
||
|
||
### 1. 获取块数据
|
||
|
||
#### 接口描述
|
||
获取系统中所有可用的块数据,包括各类组件类型及其对应的组件列表,用于任务编辑页面左侧的组件面板显示。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/block`
|
||
|
||
#### 请求参数
|
||
无
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"msg": "Success",
|
||
"data": [
|
||
{
|
||
"label": "脚本",
|
||
"order": 0,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "ScriptBp",
|
||
"label": "运行脚本",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "functionName",
|
||
"type": "String",
|
||
"label": "函数名",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "functionArgs",
|
||
"type": "Any",
|
||
"label": "函数参数",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
},
|
||
{
|
||
"type": "All",
|
||
"name": "SetTaskVariablesBp",
|
||
"label": "设置任务变量",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "script",
|
||
"type": "String",
|
||
"label": "脚本代码",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "HTTP请求",
|
||
"order": 1,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "HttpGetBp",
|
||
"label": "HTTP GET请求",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "url",
|
||
"type": "String",
|
||
"label": "请求URL",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "headers",
|
||
"type": "Object",
|
||
"label": "请求头",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": {},
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "timeout",
|
||
"type": "Number",
|
||
"label": "超时时间(ms)",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": 30000,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
},
|
||
{
|
||
"type": "All",
|
||
"name": "HttpPostBp",
|
||
"label": "HTTP POST请求",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "url",
|
||
"type": "String",
|
||
"label": "请求URL",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "data",
|
||
"type": "Object",
|
||
"label": "请求数据",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": {},
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "headers",
|
||
"type": "Object",
|
||
"label": "请求头",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": {},
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "contentType",
|
||
"type": "String",
|
||
"label": "内容类型",
|
||
"description": "",
|
||
"required": false,
|
||
"defaultValue": "application/json",
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "任务",
|
||
"order": 2,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "PrintBp",
|
||
"label": "打印",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "message",
|
||
"type": "String",
|
||
"label": "消息内容",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "流程",
|
||
"order": 3,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "IfBp",
|
||
"label": "条件判断",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "condition",
|
||
"type": "Expression",
|
||
"label": "条件表达式",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
},
|
||
{
|
||
"type": "All",
|
||
"name": "WhileBp",
|
||
"label": "循环",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "condition",
|
||
"type": "Expression",
|
||
"label": "循环条件",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "基础",
|
||
"order": 4,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "WaitBp",
|
||
"label": "等待",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "timeout",
|
||
"type": "Number",
|
||
"label": "等待时间(ms)",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": 1000,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "库位",
|
||
"order": 5,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "GetSiteBp",
|
||
"label": "获取库位信息",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "siteId",
|
||
"type": "String",
|
||
"label": "库位ID",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "仿真",
|
||
"order": 6,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "SimulateBp",
|
||
"label": "仿真操作",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "action",
|
||
"type": "String",
|
||
"label": "仿真动作",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "机器人调度",
|
||
"order": 7,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "MoveRobotBp",
|
||
"label": "移动机器人",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "robotId",
|
||
"type": "String",
|
||
"label": "机器人ID",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "targetPosition",
|
||
"type": "Object",
|
||
"label": "目标位置",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"label": "设备",
|
||
"order": 8,
|
||
"blocks": [
|
||
{
|
||
"type": "All",
|
||
"name": "ControlDeviceBp",
|
||
"label": "控制设备",
|
||
"description": "",
|
||
"inputParams": [
|
||
{
|
||
"name": "deviceId",
|
||
"type": "String",
|
||
"label": "设备ID",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
},
|
||
{
|
||
"name": "command",
|
||
"type": "String",
|
||
"label": "控制命令",
|
||
"description": "",
|
||
"required": true,
|
||
"defaultValue": null,
|
||
"options": []
|
||
}
|
||
],
|
||
"extraInputParamsFunc": "",
|
||
"outputParams": {}
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### 2. 获取任务源码
|
||
|
||
#### 接口描述
|
||
获取指定任务的源码详情数据,直接返回vwed_taskdef表中的详细定义,用于任务编辑页面加载已有任务的详细配置信息。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/source/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID,路径参数 |
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "操作成功",
|
||
"data": {
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"label": "test1",
|
||
"version": 3,
|
||
"createDate": "2023-05-10 14:30:22",
|
||
"modifyDate": "2023-05-10 15:30:22",
|
||
"templateName": "userTemplate",
|
||
"periodicTask": 0,
|
||
"ifEnable": 0,
|
||
"status": 0,
|
||
"detail": {
|
||
"inputParams": [
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"remark": "",
|
||
"defaultValue": "",
|
||
"required": false
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"remark": "",
|
||
"defaultValue": "",
|
||
"required": false
|
||
}
|
||
],
|
||
"outputParams": [],
|
||
"rootBlock": {
|
||
"id": -1,
|
||
"name": "-1",
|
||
"blockType": "RootBp",
|
||
"inputParams": {},
|
||
"children": {
|
||
"default": [
|
||
{
|
||
"id": 5,
|
||
"name": "b5",
|
||
"blockType": "IfBp",
|
||
"children": {},
|
||
"inputParams": {
|
||
"condition": {
|
||
"type": "Expression",
|
||
"value": "taskInputs.from",
|
||
"required": true
|
||
}
|
||
},
|
||
"refTaskDefId": "",
|
||
"selected": false,
|
||
"expanded": true
|
||
},
|
||
{
|
||
"id": 6,
|
||
"name": "b6",
|
||
"blockType": "PrintBp",
|
||
"children": {},
|
||
"inputParams": {
|
||
"message": {
|
||
"type": "Simple",
|
||
"value": "111111"
|
||
}
|
||
},
|
||
"refTaskDefId": "",
|
||
"selected": false,
|
||
"expanded": true
|
||
}
|
||
]
|
||
},
|
||
"selected": false,
|
||
"refTaskDefId": "",
|
||
"expanded": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
#### 错误响应
|
||
|
||
1. 任务不存在时:
|
||
```json
|
||
{
|
||
"code": 404,
|
||
"message": "任务不存在"
|
||
}
|
||
```
|
||
|
||
2. 系统错误:
|
||
```json
|
||
{
|
||
"code": 500,
|
||
"message": "获取任务源码详情失败: [详细错误信息]"
|
||
}
|
||
```
|
||
|
||
### 3. 保存任务编辑数据
|
||
|
||
#### 接口描述
|
||
保存任务的编辑数据,包括任务的详细定义、输入参数配置、组件配置和连接关系等。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: POST
|
||
- **接口路径**: `/api/vwed-task-edit/save`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID |
|
||
| detail | Object | 是 | 任务详细定义,包含输入参数、根块配置等 |
|
||
|
||
#### 请求示例
|
||
|
||
```json
|
||
{
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"label": "test1",
|
||
"detail": {
|
||
"inputParams": [
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"remark": "",
|
||
"defaultValue": "",
|
||
"required": false
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"remark": "",
|
||
"defaultValue": "",
|
||
"required": false
|
||
}
|
||
],
|
||
"outputParams": [],
|
||
"rootBlock": {
|
||
"id": -1,
|
||
"name": "-1",
|
||
"blockType": "RootBp",
|
||
"inputParams": {},
|
||
"children": {
|
||
"default": [
|
||
{
|
||
"id": 5,
|
||
"name": "b5",
|
||
"blockType": "IfBp",
|
||
"children": {},
|
||
"inputParams": {
|
||
"condition": {
|
||
"type": "Expression",
|
||
"value": "taskInputs.from",
|
||
"required": true
|
||
}
|
||
},
|
||
"refTaskDefId": "",
|
||
"selected": false,
|
||
"expanded": true
|
||
},
|
||
{
|
||
"id": 6,
|
||
"name": "b6",
|
||
"blockType": "PrintBp",
|
||
"children": {},
|
||
"inputParams": {
|
||
"message": {
|
||
"type": "Simple",
|
||
"value": "111111"
|
||
}
|
||
},
|
||
"refTaskDefId": "",
|
||
"selected": false,
|
||
"expanded": true
|
||
}
|
||
]
|
||
},
|
||
"selected": false,
|
||
"refTaskDefId": "",
|
||
"expanded": true
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "保存成功",
|
||
"data": {
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"version": 3,
|
||
"updateTime": "2023-05-10 15:30:22"
|
||
}
|
||
}
|
||
```
|
||
|
||
### 4. 备份任务
|
||
|
||
#### 接口描述
|
||
创建指定任务的备份副本。系统会从vwed_taskdef表中复制原任务的所有信息(包括任务定义、详细配置、输入参数等),并在同一张表中生成一个新的任务记录。新任务名称默认为原任务名称加上"-备份"后缀,用户可以修改备份名称和添加备注信息。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: POST
|
||
- **接口路径**: `/api/vwed-task-edit/backup/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 要备份的任务ID,路径参数 |
|
||
| backupName | String | 否 | 备份后的任务名称,不提供则默认为"原任务名-备份" |
|
||
| remark | String | 否 | 备份任务的备注信息 |
|
||
|
||
#### 请求示例
|
||
|
||
```json
|
||
{
|
||
"backupName": "test1-备份",
|
||
"remark": "这是一个备份任务"
|
||
}
|
||
```
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "备份成功",
|
||
"data": {
|
||
"id": "7c6aac36-652b-4314-9433-f5788e9e7adb",
|
||
"label": "test1-备份",
|
||
"version": 1,
|
||
"templateName": "userTemplate",
|
||
"periodicTask": 0,
|
||
"ifEnable": 0,
|
||
"status": 0,
|
||
"createDate": "2023-05-16 11:22:36",
|
||
"sourceTaskId": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"remark": "这是一个备份任务"
|
||
}
|
||
}
|
||
```
|
||
|
||
### 5. 获取子任务列表
|
||
|
||
#### 接口描述
|
||
获取可以被引用的子任务列表,用于子任务组件的配置。数据来源是vwed_taskdef表中的现有任务定义,任何定义好的任务都可以作为其他任务的子任务使用(除了任务自身)。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/subtasks/list`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| page | Integer | 否 | 页码,默认为1 |
|
||
| pageSize | Integer | 否 | 每页记录数,默认为100 |
|
||
| keyword | String | 否 | 搜索关键词,用于筛选子任务 |
|
||
| excludeId | String | 否 | 要排除的任务ID,通常是当前正在编辑的任务ID |
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "操作成功",
|
||
"data": {
|
||
"total": 10,
|
||
"list": [
|
||
{
|
||
"id": "231f8412-fa0d-4b6d-9648-70bceacd1111",
|
||
"label": "test1",
|
||
"version": 3,
|
||
"templateName": "userTemplate",
|
||
"remark": "测试子任务1",
|
||
"createDate": "2023-05-10 14:30:22",
|
||
"createdBy": "admin",
|
||
"status": 0,
|
||
"inputParams": [
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"required": false
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"required": false
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"id": "231f8412-fa0d-4b6d-9648-70bceacd2222",
|
||
"label": "测试_cc",
|
||
"version": 2,
|
||
"templateName": "userTemplate",
|
||
"remark": "测试子任务2",
|
||
"createDate": "2023-05-12 10:20:15",
|
||
"createdBy": "admin",
|
||
"status": 0,
|
||
"inputParams": [
|
||
{
|
||
"name": "agvId",
|
||
"type": "String",
|
||
"label": "机器人ID",
|
||
"required": true
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
### 8. 运行任务
|
||
|
||
#### 接口描述
|
||
直接执行指定的任务,并传入任务输入参数,用于在任务编辑页面上直接启动任务。与测试执行不同,此接口将真实运行任务并影响系统数据。如果任务输入参数中有必填字段,则必须在请求中提供对应字段,否则会返回400错误。系统还会检查设备是否有正在运行的相同任务,根据配置决定是否允许重新启动。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: POST
|
||
- **接口路径**: `/api/vwed-task-edit/run`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| taskId | String | 是 | 要运行的任务ID |
|
||
| params | Array<TaskInputParamNew> | 否 | 任务运行参数数组,根据任务定义中的inputParams字段确定 |
|
||
| source_system | String | 否 | 请求来源系统标识(如:WMS、MES等系统编号) |
|
||
| source_device | String | 否 | 下达任务的硬件设备标识(设备ID、MAC地址等) |
|
||
| source_type | Integer | 否 | 来源类型(1: 系统调度, 2: 呼叫机, 3: 第三方系统, 4: 手持电脑)|
|
||
|
||
##### TaskInputParamNew参数结构
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| name | String | 是 | 参数名称 |
|
||
| type | String | 是 | 参数类型(STRING、BOOLEAN、INTEGER、FLOAT、OBJECT、ARRAY) |
|
||
| label | String | 是 | 参数显示名称 |
|
||
| required | Boolean | 否 | 是否必填,默认为false |
|
||
| defaultValue | String | 是 | 默认值 |
|
||
| remark | String | 否 | 参数说明,默认为空字符串 |
|
||
|
||
#### 请求示例
|
||
|
||
```json
|
||
{
|
||
"taskId": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"params": [
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"required": false,
|
||
"defaultValue": "WH-01",
|
||
"remark": "起始位置"
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"required": true,
|
||
"defaultValue": "PKG-02",
|
||
"remark": "目标位置"
|
||
}
|
||
],
|
||
"source_system": "web_editor",
|
||
"source_device": "device_001",
|
||
"source_type": 1
|
||
}
|
||
```
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "任务启动成功",
|
||
"data": {
|
||
"taskRecordId": "a52c6b91-de78-4fd2-9d18-5f79ba8e7c1d",
|
||
"status": 1001,
|
||
"createTime": "2023-05-18 15:20:36"
|
||
}
|
||
}
|
||
```
|
||
|
||
#### 错误响应
|
||
|
||
1. 缺少必填参数时:
|
||
```json
|
||
{
|
||
"code": 400,
|
||
"message": "缺少必填参数"
|
||
}
|
||
```
|
||
|
||
2. 设备已有相同任务运行且不允许重启时:
|
||
```json
|
||
{
|
||
"code": 409,
|
||
"message": "相同设备已有此任务正在运行中,请等待任务完成后再次启动"
|
||
}
|
||
```
|
||
|
||
3. 任务不存在时:
|
||
```json
|
||
{
|
||
"code": 404,
|
||
"message": "任务不存在"
|
||
}
|
||
```
|
||
|
||
4. 其他服务器错误:
|
||
```json
|
||
{
|
||
"code": 500,
|
||
"message": "任务启动失败"
|
||
}
|
||
```
|
||
|
||
### 9. 获取任务输入参数配置
|
||
|
||
#### 接口描述
|
||
获取指定任务的输入参数配置信息,用于编辑任务时展示当前任务已配置的输入参数。同时返回任务基本信息和可用的参数类型,方便前端一次性获取所需信息。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/input-params/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID,路径参数 |
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "操作成功",
|
||
"data": {
|
||
"inputParams": [
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"required": false,
|
||
"defaultValue": "",
|
||
"remark": "起始位置"
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"required": true,
|
||
"defaultValue": "",
|
||
"remark": "目标位置"
|
||
}
|
||
],
|
||
"taskInfo": {
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"label": "test1",
|
||
"version": 3,
|
||
"remark": "测试任务",
|
||
"templateName": "userTemplate"
|
||
},
|
||
"paramTypes": [
|
||
{
|
||
"code": "STRING",
|
||
"label": "字符串",
|
||
"description": "文本类型数据"
|
||
},
|
||
{
|
||
"code": "BOOLEAN",
|
||
"label": "布尔",
|
||
"description": "布尔类型,值为true或false"
|
||
},
|
||
{
|
||
"code": "INTEGER",
|
||
"label": "整数",
|
||
"description": "整数类型"
|
||
},
|
||
{
|
||
"code": "FLOAT",
|
||
"label": "浮点数",
|
||
"description": "浮点数类型"
|
||
},
|
||
{
|
||
"code": "OBJECT",
|
||
"label": "JSON对象",
|
||
"description": "JSON对象类型,如{\"key\":\"value\"}"
|
||
},
|
||
{
|
||
"code": "ARRAY",
|
||
"label": "JSON数组",
|
||
"description": "JSON数组类型,如[\"item1\",\"item2\"]"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
### 10. 保存任务输入参数配置
|
||
|
||
#### 接口描述
|
||
保存指定任务的输入参数配置信息。系统支持根据获取可用输入参数类型接口返回的字段动态配置参数。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: POST
|
||
- **接口路径**: `/api/vwed-task-edit/input-params/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID,路径参数 |
|
||
| inputParams | Array | 是 | 输入参数配置数组 |
|
||
|
||
#### 请求示例
|
||
|
||
```json
|
||
{
|
||
"inputParams": [
|
||
{
|
||
"name": "test",
|
||
"type": "Number",
|
||
"label": "test",
|
||
"required": false,
|
||
"defaultValue": "",
|
||
"remark": ""
|
||
},
|
||
{
|
||
"name": "from",
|
||
"type": "String",
|
||
"label": "起点",
|
||
"required": false,
|
||
"defaultValue": "",
|
||
"remark": "起始位置"
|
||
},
|
||
{
|
||
"name": "to",
|
||
"type": "String",
|
||
"label": "终点",
|
||
"required": true,
|
||
"defaultValue": "",
|
||
"remark": "目标位置"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "保存成功",
|
||
"data": null
|
||
}
|
||
```
|
||
|
||
### 11. 获取任务基本设置
|
||
|
||
#### 接口描述
|
||
获取任务的基本信息设置,包括任务名称、备注、是否在任务异常结束或终止时解锁库位等配置。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/basic-settings/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID,路径参数 |
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "操作成功",
|
||
"data": {
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"label": "test1",
|
||
"remark": "测试任务基本设置",
|
||
"releaseSites": true,
|
||
"version": 3,
|
||
"createDate": "2023-05-10 14:30:22"
|
||
}
|
||
}
|
||
```
|
||
|
||
### 12. 保存任务基本设置
|
||
|
||
#### 接口描述
|
||
保存任务的基本信息设置,包括任务名称、备注、是否在任务异常结束或终止时解锁库位等配置。此接口修改的是vwed_taskdef表中的数据。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: POST
|
||
- **接口路径**: `/api/vwed-task-edit/basic-settings/{id}`
|
||
|
||
#### 请求参数
|
||
|
||
| 参数名 | 类型 | 必填 | 描述 |
|
||
|-------|------|-----|------|
|
||
| id | String | 是 | 任务ID,路径参数 |
|
||
| label | String | 是 | 任务名称 |
|
||
| remark | String | 否 | 备注信息 |
|
||
| releaseSites | Boolean | 否 | 任务异常结束/终止时是否解锁库位,默认为true |
|
||
|
||
#### 请求示例
|
||
|
||
```json
|
||
{
|
||
"label": "test1",
|
||
"remark": "测试任务基本设置",
|
||
"releaseSites": true
|
||
}
|
||
```
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "保存成功",
|
||
"data": {
|
||
"id": "193f8412-fa0d-4b6d-9648-70bceacd6629",
|
||
"label": "test1",
|
||
"remark": "测试任务基本设置",
|
||
"releaseSites": true,
|
||
"updateTime": "2023-05-10 16:30:22"
|
||
}
|
||
}
|
||
```
|
||
|
||
### 13. 获取常用参数字段
|
||
|
||
#### 接口描述
|
||
获取常用参数的展示字段和字段值类型,用于任务编辑页面中间部分上侧的常用字段展示区域。
|
||
|
||
#### 请求方式
|
||
- **HTTP方法**: GET
|
||
- **接口路径**: `/api/vwed-task-edit/common-params`
|
||
|
||
#### 请求参数
|
||
无
|
||
|
||
#### 响应参数
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"message": "操作成功",
|
||
"data": [
|
||
{
|
||
"id": "robotId",
|
||
"label": "机器人id",
|
||
"type": "String",
|
||
"description": "机器人唯一标识",
|
||
"example": "robot_001",
|
||
"placeholder": "机器人ID",
|
||
"order": 1,
|
||
"values": [
|
||
{"id": "robot_001", "name": "AGV-001", "description": "1号AGV机器人"},
|
||
{"id": "robot_002", "name": "AGV-002", "description": "2号AGV机器人"},
|
||
{"id": "robot_003", "name": "AGV-003", "description": "3号AGV机器人"}
|
||
]
|
||
},
|
||
{
|
||
"id": "robotGroup",
|
||
"label": "机器人组",
|
||
"type": "Array",
|
||
"description": "机器人分组信息",
|
||
"example": "['group1', 'group2']",
|
||
"placeholder": "机器人组",
|
||
"order": 2,
|
||
"values": [
|
||
{"id": "group1", "name": "分拣组", "description": "负责物品分拣的机器人组"},
|
||
{"id": "group2", "name": "运输组", "description": "负责物品运输的机器人组"},
|
||
{"id": "group3", "name": "装配组", "description": "负责物品装配的机器人组"}
|
||
]
|
||
},
|
||
{
|
||
"id": "robotTag",
|
||
"label": "机器人标签",
|
||
"type": "String",
|
||
"description": "机器人标签信息",
|
||
"example": "delivery",
|
||
"placeholder": "机器人标签",
|
||
"order": 3,
|
||
"values": [
|
||
{"id": "delivery", "name": "配送", "description": "配送类机器人"},
|
||
{"id": "picking", "name": "拣货", "description": "拣货类机器人"},
|
||
{"id": "cleaning", "name": "清洁", "description": "清洁类机器人"}
|
||
]
|
||
},
|
||
{
|
||
"id": "siteId",
|
||
"label": "库位id",
|
||
"type": "String",
|
||
"description": "库位唯一标识",
|
||
"example": "site_001",
|
||
"placeholder": "库位ID",
|
||
"order": 4,
|
||
"values": [
|
||
{"id": "site_001", "name": "A01", "description": "A区1号库位"},
|
||
{"id": "site_002", "name": "A02", "description": "A区2号库位"},
|
||
{"id": "site_003", "name": "B01", "description": "B区1号库位"}
|
||
]
|
||
},
|
||
{
|
||
"id": "area",
|
||
"label": "库区",
|
||
"type": "String",
|
||
"description": "库区信息",
|
||
"example": "A区",
|
||
"placeholder": "库区",
|
||
"order": 5,
|
||
"values": [
|
||
{"id": "area_A", "name": "A区", "description": "A区储存区"},
|
||
{"id": "area_B", "name": "B区", "description": "B区储存区"},
|
||
{"id": "area_C", "name": "C区", "description": "C区装配区"}
|
||
]
|
||
},
|
||
{
|
||
"id": "station",
|
||
"label": "站点",
|
||
"type": "String",
|
||
"description": "站点信息",
|
||
"example": "station_001",
|
||
"placeholder": "站点",
|
||
"order": 6,
|
||
"values": [
|
||
{"id": "station_001", "name": "入库站", "description": "物品入库站点"},
|
||
{"id": "station_002", "name": "出库站", "description": "物品出库站点"},
|
||
{"id": "station_003", "name": "检验站", "description": "物品质检站点"}
|
||
]
|
||
},
|
||
{
|
||
"id": "binTask",
|
||
"label": "binTask",
|
||
"type": "Object",
|
||
"description": "bin任务相关信息",
|
||
"example": "{\"id\": \"bin_001\"}",
|
||
"placeholder": "binTask",
|
||
"order": 7,
|
||
"values": [
|
||
{"id": "bin_001", "name": "分拣任务", "description": "物品分拣任务"},
|
||
{"id": "bin_002", "name": "装箱任务", "description": "物品装箱任务"},
|
||
{"id": "bin_003", "name": "码垛任务", "description": "物品码垛任务"}
|
||
]
|
||
},
|
||
{
|
||
"id": "workstation",
|
||
"label": "工位",
|
||
"type": "String",
|
||
"description": "工位信息",
|
||
"example": "ws_001",
|
||
"placeholder": "工位",
|
||
"order": 8,
|
||
"values": [
|
||
{"id": "ws_001", "name": "装配工位1", "description": "1号装配工位"},
|
||
{"id": "ws_002", "name": "装配工位2", "description": "2号装配工位"},
|
||
{"id": "ws_003", "name": "测试工位", "description": "产品测试工位"}
|
||
]
|
||
},
|
||
{
|
||
"id": "position",
|
||
"label": "岗位",
|
||
"type": "String",
|
||
"description": "岗位信息",
|
||
"example": "operator",
|
||
"placeholder": "岗位",
|
||
"order": 9,
|
||
"values": [
|
||
{"id": "operator", "name": "操作员", "description": "设备操作人员"},
|
||
{"id": "inspector", "name": "检验员", "description": "质量检验人员"},
|
||
{"id": "manager", "name": "管理员", "description": "区域管理人员"}
|
||
]
|
||
},
|
||
{
|
||
"id": "user",
|
||
"label": "用户",
|
||
"type": "Object",
|
||
"description": "用户信息",
|
||
"example": "{\"id\": \"user_001\", \"name\": \"张三\"}",
|
||
"placeholder": "用户",
|
||
"order": 10,
|
||
"values": [
|
||
{"id": "user_001", "name": "张三", "description": "系统操作员"},
|
||
{"id": "user_002", "name": "李四", "description": "系统管理员"},
|
||
{"id": "user_003", "name": "王五", "description": "系统维护员"}
|
||
]
|
||
},
|
||
{
|
||
"id": "cache",
|
||
"label": "缓存",
|
||
"type": "Object",
|
||
"description": "缓存数据",
|
||
"example": "{\"key\": \"value\"}",
|
||
"placeholder": "缓存",
|
||
"order": 11,
|
||
"values": [
|
||
{"id": "cache_task", "name": "任务缓存", "description": "任务相关的缓存数据"},
|
||
{"id": "cache_user", "name": "用户缓存", "description": "用户相关的缓存数据"},
|
||
{"id": "cache_system", "name": "系统缓存", "description": "系统相关的缓存数据"}
|
||
]
|
||
},
|
||
{
|
||
"id": "builtInFunction",
|
||
"label": "内置函数",
|
||
"type": "Function",
|
||
"description": "系统内置函数",
|
||
"example": "getCurrentTime()",
|
||
"placeholder": "内置函数",
|
||
"order": 12,
|
||
"values": [
|
||
{"id": "getCurrentTime", "name": "获取当前时间", "description": "返回系统当前时间", "syntax": "getCurrentTime()"},
|
||
{"id": "formatDate", "name": "格式化日期", "description": "将日期格式化为指定格式", "syntax": "formatDate(date, format)"},
|
||
{"id": "generateUUID", "name": "生成UUID", "description": "生成唯一标识符", "syntax": "generateUUID()"}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 四、组件相关数据结构
|
||
|
||
### 1. 组件类型说明
|
||
|
||
任务编辑中的组件类型主要分为以下几类:
|
||
|
||
| 类别ID | 类别名称 | 描述 |
|
||
|-------|---------|------|
|
||
| subtask | 子任务 | 用于创建和管理子任务,支持任务的层级结构和模块化 |
|
||
| script | 脚本 | 支持编写自定义脚本,实现复杂的业务逻辑 |
|
||
| http | HTTP请求 | 用于与外部系统进行通信,发送HTTP请求并处理响应 |
|
||
| task | 任务 | 基本任务单元,包含任务的核心属性和行为 |
|
||
| flow | 流程 | 控制任务执行流程,如条件判断、循环等 |
|
||
| base | 基础 | 提供基础功能,如变量操作、数据转换等 |
|
||
| site | 库位 | 与工位或库位相关的组件,用于定位和操作 |
|
||
| robot | 机器人 | 控制和管理机器人的调度和执行 |
|
||
| device | 设备 | 与外部设备交互的组件 |
|
||
|
||
### 2. 任务详情结构说明
|
||
|
||
任务详情(detail)字段是一个JSON对象,包含以下主要部分:
|
||
|
||
| 属性名 | 类型 | 描述 |
|
||
|-------|------|------|
|
||
| inputParams | Array | 任务输入参数定义数组 |
|
||
| outputParams | Array | 任务输出参数定义数组(可能为空) |
|
||
| rootBlock | Object | 任务根块配置,包含所有子组件和连接关系 |
|
||
|
||
#### 输入参数对象结构
|
||
|
||
| 属性名 | 类型 | 描述 |
|
||
|-------|------|------|
|
||
| name | String | 参数名称,用于代码中引用 |
|
||
| type | String | 参数类型(String、Number、Boolean、Object等) |
|
||
| label | String | 参数显示名称 |
|
||
| remark | String | 参数说明 |
|
||
| defaultValue | String | 参数默认值 |
|
||
| required | Boolean | 是否必填 |
|
||
|
||
#### 根块对象结构
|
||
|
||
| 属性名 | 类型 | 描述 |
|
||
|-------|------|------|
|
||
| id | Number/String | 块ID,根块固定为-1 |
|
||
| name | String | 块名称 |
|
||
| blockType | String | 块类型,根块固定为RootBp |
|
||
| inputParams | Object | 块输入参数配置 |
|
||
| children | Object | 子块配置,包含default属性下的子块数组 |
|
||
| selected | Boolean | 是否被选中(编辑状态) |
|
||
| expanded | Boolean | 是否被展开(编辑状态) |
|
||
|
||
#### 子块对象结构
|
||
|
||
| 属性名 | 类型 | 描述 |
|
||
|-------|------|------|
|
||
| id | Number | 块ID,唯一标识 |
|
||
| name | String | 块名称 |
|
||
| blockType | String | 块类型,对应组件类型 |
|
||
| children | Object | 子块配置,根据块类型不同可能有不同的属性 |
|
||
| inputParams | Object | 块输入参数配置 |
|
||
| refTaskDefId | String | 引用的任务定义ID(子任务类型使用) |
|
||
| selected | Boolean | 是否被选中(编辑状态) |
|
||
| expanded | Boolean | 是否被展开(编辑状态) |
|
||
|
||
### 3. 参数值类型
|
||
|
||
组件参数值支持以下几种类型:
|
||
|
||
| 类型 | 描述 |
|
||
|-----|------|
|
||
| Simple | 简单值,直接输入的固定值 |
|
||
| Expression | 表达式,使用${变量名}语法引用变量 |
|
||
| JSON | JSON格式,用于复杂数据结构 | |