使用API请求任务细节。
如何通过API获得任务细节
对于不同的使用情况,如对检查任务的数据进行后处理。可能需要从Frontline 指挥中心请求这些数据。本页描述了如何做到这一点。
第一步是查找已经完成的任务,以便以后获得其中一个任务的细节。具体做法如下。
- 通过API登录到Frontline 指挥中心。
- 从登录响应中提取令牌,并将其作为下一次的承载令牌。
- 创建一个GET请求到https://my-address/wftasks/getTasksForDisplay
输出将看起来像这样。
{
"content": [
{
"id": 1,
"name": "test",
"team": null,
"teamId": null,
"userId": 5,
"userDisplayName": "Tester",
"createdByUserDisplayName": "Tester",
"status": "done",
"createDate": "2021-07-01T19:53:19+02:00",
"doneDate": "2021-07-01T19:53:53+02:00",
"startDate": null,
"datePlanned": "2021-07-01T19:53:19+02:00",
"changeDate": null,
"workflowDisplayName": "MyWorkflow",
"workflowId": "313a1c3b-2d84-4197-9f63-20000d1d725f",
"workflowVersion": "2",
"taskResult": null,
"version": null,
"comment": null,
"domain": "ubimax",
"externalId": null,
"commentsCount": 0,
"mediasCount": 2,
"duration": "00:34",
"pdfReportingEnabled": true,
"hideTaskDetails": false,
"containsResult": true,
"tags": []
}
],
"pageable": {
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"offset": 0,
"pageNumber": 0,
"pageSize": 20,
"unpaged": false,
"paged": true
},
"last": false,
"totalElements": 67,
"totalPages": 4,
"size": 20,
"number": 0,
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"first": true,
"numberOfElements": 20,
"empty": false
}
这是一个前20个任务的列表,也可以在https://my-address/xinspect.html#!/tasks上看到。通过在请求的URL中指定,该列表也可以被预排序。一个例子可以是这样的。
https://my-address/wftasks/getTasksForDisplay?page=0&size=20&sort=createDate,desc
现在的反应将是最后创建的20个任务。
为了获得关于特定任务的更多信息,我们需要修改请求,加入任务的ID。
https://192.168.2.116/wftasks/getTasksForDisplay?page=0&size=1&taskId=67&templates=false
回复会是这样的。
{
"content": [
{
"id": 67,
"name": "TestDetails",
"team": null,
"teamId": null,
"userId": 5,
"userDisplayName": "Tester",
"createdByUserDisplayName": "Tester",
"status": "done",
"createDate": "2021-08-12T14:17:48+02:00",
"doneDate": "2021-08-12T14:18:32+02:00",
"startDate": null,
"datePlanned": "2021-08-12T14:17:48+02:00",
"changeDate": null,
"workflowDisplayName": "ImagesTaskDetails",
"workflowId": "d0c95cb1-cadd-4518-b220-e0cdbedc8294",
"workflowVersion": "1",
"taskResult": {
"id": 67,
"workflowName": "ImagesTaskDetails",
"stepID": null,
"startTime": "2021-08-12T14:17:48+02:00",
"endTime": "2021-08-12T14:18:30+02:00",
"duration": "00:42",
"status": "done",
"workflowResultUUID": "8a7f5893-f1e3-4848-bbf0-387a26541238",
"attachments": [],
"stepResults": [
{
"id": 17971,
"stepID": "component_documentation_1628601616736:take_picture",
"name": "Documentation: Screen with camera for triggering a screenshot",
"startTime": "2021-08-12T14:17:51+02:00",
"endTime": "2021-08-12T14:18:06+02:00",
"duration": "00:09",
"status": "done",
"workflowResultUUID": null,
"attachments": [
{
"id": 72236,
"type": "history",
"changeDate": null,
"payload": "[{\"event\":\"start\",\"time\":1628770671291},{\"event\":\"stop\",\"time\":1628770675399},{\"event\":\"start\",\"time\":1628770678364},{\"event\":\"stop\",\"time\":1628770681297},{\"event\":\"start\",\"time\":1628770683973},{\"event\":\"stop\",\"time\":1628770686833}]",
"assetUri": null
},
{
"id": 72237,
"type": "visit_count",
"changeDate": null,
"payload": "3",
"assetUri": null
}
],
"imagePaths": [],
"documentationComments": [],
"comment": null,
"question": null,
"answers": null,
"questionTitle": null,
"barcodeContent": null,
"measurement": null
},
...
],
"pageable": {
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"offset": 0,
"pageNumber": 0,
"pageSize": 1,
"unpaged": false,
"paged": true
},
"last": true,
"totalElements": 1,
"totalPages": 1,
"size": 1,
"number": 0,
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"first": true,
"numberOfElements": 1,
"empty": false
}
响应还包括组件的时间,谁执行了WF,记录的号码等数据,以及更多。