exec_report
The exec_report function is used to execute a report.
svc=report/exec_report¶ms={"reportResourceId":<long>,
"reportTemplateId":<long>,
"reportObjectId":<long>,
"reportObjectSecId":<long>,
"reportObjectIdList":[<uint>, ...]},
"interval":{
"from":<uint>,
"to":<uint>,
"flags":<uint>
},
"remoteExec":<uint>,
"reportTemplate":<object>}
There can only be one report in a session at the same time. Therefore, if there is already some report result in a session, you should clear it before executing another one. To do this, use the **[cleanup\_result](/en/api/user-guide/api-reference/report/cleanup_result)** function.You can’t execute this request simultaneously with the following requests:
Parameters
Name | Description |
---|---|
reportResourceId | Resource ID. The parameter is required. The report is executed on behalf of the resource creator if the reportTemplateId is 0. |
reportTemplateId | Template ID. |
reportObjectId | Item ID. |
reportObjectSecId | Subitem ID (driver, trailer, or their groups); 0 if the item has no subitems. |
reportObjectIdList | The array of extra item IDs (for the report on unit groups). |
interval | The settings of report interval. |
from | The beginning of the interval, Unix time. |
to | The end of the interval, Unix time. |
flags | Interval flags. |
remoteExec | Specify 1 for this parameter to execute the report on the Webreport server. The parameter is optional and is only used if the report/get_report_status request is executed later. If the JSON response includes Specify 0 or omit this parameter to execute the report on the Web server. In this case, the execution timeout is 3 minutes. |
reportTemplate | The JSON of the report template, which you can get after the get_report_data request. The parameter is optional and only used if the reportTemplateId is 0. |
Interval flags:
Flag | Description | The value of the "from" parameter | The value of the "to" parameter | Comments |
---|---|---|---|---|
0x00 | specified interval | Timestamp value in seconds. | Timestamp value in seconds. | |
0x01 | starts 'From' until today | Timestamp value in seconds. | 0 | Any value introduced in the parameter is replaced with the current server time. |
0x02 | for previous n days | 0 | The number of days. | Any value introduced in the from parameter is replaced with the last full period or the current server time if the 0x20 flag is present. |
0x04 | for previous n weeks | 0 | The number of weeks. | |
0x08 | for previous n month | 0 | The number of months. | |
0x10 | for previous n years | 0 | The number of years. | |
0x20 | including current | |||
0x40 | for previous n hours | 0 | The number of hours. | |
0x80 | for previous n minutes | 0 | The number of minutes. |
Returned result
{
"reportResult":{ /* report execution result */
"msgsRendered":<int>, /* messages loaded: 0 — no, 1 — yes */
"stats":[ /* the array of statistics parameters */
["<text>","<text>"] /* [parameter name, value] */
],
"tables":[ /* the array of tables */
{
"name":"<text>", /* table type */
"label":"<text>", /* name */
"grouping": {
"type":"<text>" /* grouping type */
},
"flags":<uint>, /* table flags (see below) */
"rows":<uint>, /* the number of lines */
"level":<uint>, /* the maximum level in the table */
"columns":<uint>, /* columns count */
"header":["<text>"], /* the array of table headers */
"total":[ /* total */
"<text>" /* the array of cells */
],
"header_type" ["<text>"], /* the array of table header types */
"totalRaw" [ /* the array of values of the line "Total" */
{
"v":<double>, /* original cell value */
"vt":<double>, /* value type */
},
...
]
}
],
"attachments":[ /* the array of attachments (charts, photos) */
{ /* for charts */
"name":"<text>", /* name */
"type":"<text>", /* type: chart, photo */
"datasets":["<text>"] /* the array with the names of the chart's curved lines */
"axis_y": ["<text>"] /* the array with the labels of 'Y' axes */
"axis_x": "<text>", /* the name of the 'X' axis */
"flags": <uint>, /* axis format, see the description below */
"p":"<text>", /* chart settings */
},
{ /* for photo and video */
"name":"<text>", /* name and following parameters separated by ";" */
"ftm":"<text>", /* formatted date */
"uid":"<text>", /* unit ID */
"tm":"<text>", /* Unix time */
"idx":"<text>", /* the index of the same-type attachments registered simultaneously */
"lat":"<text>", /* latitude */
"lon":"<text>", /* longitude */
"type":"<text>", /* attachment type */
"zone":<JSON>, /* geofence information */
"tags":<JSON>, /* information about tags */
}
]
},
"reportLayer":{ /* graphic layer */
"name":"<text>", /* layer name */
"bounds":[
<double>, /* minimum latitude */
<double>, /* minimum longitude */
<double>, /* maximum latitude */
<double> /* maximum longitude */
]
},
"layerCount":<uint> /* the number of layers to be merged in the report layer */
}
To get all available table types, use the get_report_tables function.
For the zone field details, see the get_zone_data page.
For the tags field details, see the update_tag page.
Table flags:
Flag | Description |
---|---|
0x1 | Grouping by days. |
0x2 | Time limitation. |
0x4 | Grouping by weeks. |
0x8 | Grouping by months. |
0x10 | Total. |
0x20 | Charts: split sensors. |
0x100 | Detalization: partial. |
0x200 | Charts: count from zero. |
0x400 | Accumulate intervals. |
0x800 | Detalization: full. |
0x1000 | Row numbering. |
0x2000 | Execute table only by report item (not subitems). |
0x4000 | Group records into shifts. |
0x8000 | Cut intervals in the table. |
0x200000 | Grouping by trips. |
0x400000 | Grouping by violation type. |
0x10000000 | Grouping by the day of the week. |
0x20000000 | Grouping by day of the month. |
0x40000000 | Grouping by years. |
Chart flags:
Flag | Additional flag | Description |
---|---|---|
0x4 | Correct maximum for the Y axis. | |
0x10 | The format specified in the template settings. | |
0x1 | Additional for 0x10 (Set format to "H:M:S"). | |
0x2 | Additional for 0x10 (Set format to "Y-m-E"). | |
0x80 | Generic type. | |
0x100 | 24-hour format. | |
0x20 | 24-hour format (additional for 0x100). | |
0x2 | 12-hour format (additional for 0x20). | |
0x40 | Display days of the week (additional for 0x100). |
Possible error codes:
Code | Description |
---|---|
7 | Failed to fetch the report object and report resource with the desired ACL (ADF_ACL_ITEM_EXECUTE_REPORTS, ADF_ACL_AVL_RES_VIEW_REPORTS). |
6 | Undefined error. |
4 | Wrong input parameters. |