exec_report
The exec_report method is used to execute a report.
A session stores one report result. Each new
exec_reportrequest replaces the previous result, so you don’t have to clear it first. To clear the result and remove the report layers from the map, use the report/cleanup_result method.The result of an asynchronous report (see the
remoteExecparameter) is stored separately. Executing another report or callingreport/cleanup_resultdoesn’t remove it. Only report/apply_report_result does.You can’t execute this request simultaneously with the following requests:
Endpoint
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>
}
Parameters
The request can contain the following parameters. The required parameters are marked with an asterisk (*).
| Name | Description |
|---|---|
| reportResourceId* | Resource ID. 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. If from is greater than to, the report is executed without an error, but it contains no tables. |
| 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 "remoteExec":1, it means the server has accepted the report for processing, and the execution timeout is 5 minutes.Specify 0 or omit this parameter to execute the report on the Web server. In this case, the execution timeout is 2 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. The tbl array of the template must contain at least one table. |
Interval flags
| Flag | Description | The value of the from parameter |
The value of the to parameter |
Comments |
|---|---|---|---|---|
| 0x00 (0) | Specified interval. | Timestamp value in seconds. | Timestamp value in seconds. | |
| 0x01 (1) | Starts from the specified time until today. | Timestamp value in seconds. | 0 | Any value introduced in the parameter is replaced with the current server time. |
| 0x02 (2) | 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 (4) | For previous n weeks. | 0 | The number of weeks. | |
| 0x08 (8) | For previous n months. | 0 | The number of months. | |
| 0x10 (16) | For previous n years. | 0 | The number of years. | |
| 0x20 (32) | Including current. | |||
| 0x40 (64) | For previous n hours. | 0 | The number of hours. | |
| 0x80 (128) | For previous n minutes. | 0 | The number of minutes. |
Returned result
{
"reportResult": { /* report execution result */
"msgsRendered": <int>, /* messages loaded: 0 for no, 1 for 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": { /* grouping settings of the table from the template; can be empty */
"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; only if the table has the 0x10 flag */
"<text>" /* the array of cells */
],
"header_type": ["<text>"], /* the array of table header types */
"totalRaw": [ /* the array of values of the line "Total"; only if the table has the 0x10 flag */
{
"v": <double>, /* original cell value */
"vt": <uint> /* value type */
},
...
]
}
],
"attachments": [ /* the array of attachments (charts, photos) */
{ /* for charts */
"name": "<text>", /* name */
"type": "<text>", /* type: chart, photo */
"c": "<text>", /* chart columns, JSON string */
"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 */
],
"units": [ /* units whose tracks are in the layer */
{
"id": <long>, /* unit ID */
"msgs": {
"count": <uint>, /* number of messages */
"first": { /* first message with a location */
"time": <uint>, /* message time, Unix time */
"lat": <double>, /* latitude */
"lon": <double> /* longitude */
},
"last": {...} /* last message with a location, same format */
},
"mileage": <double>, /* mileage */
"max_speed": <double>, /* maximum speed */
"trips": [ /* trips; only if the track is split into trips */
{
"first": {...}, /* first message of the trip, same format */
"last": {...}, /* last message of the trip, same format */
"mileage": <double>,
"max_speed": <double>,
"color": "<text>" /* trip color, #RRGGBB */
}
]
}
]
},
"layerCount": <uint> /* the number of layers to be merged in the report layer */
}
In Wialon Local, the c field of a chart is available starting from version 2404.
To get all available table types, use the report/get_report_tables method.
For the zone field details, see the resource/get_zone_data page.
For the tags field details, see the resource/update_tag page.
Table flags
| Flag | Description |
|---|---|
| 0x1 (1) | Grouping by days. |
| 0x2 (2) | Time limitation. |
| 0x4 (4) | Grouping by weeks. |
| 0x8 (8) | Grouping by months. |
| 0x10 (16) | Total. |
| 0x20 (32) | Charts: split sensors. |
| 0x100 (256) | Detalization: partial. |
| 0x200 (512) | Charts: count from zero. |
| 0x400 (1024) | Accumulate intervals. |
| 0x800 (2048) | Detalization: full. |
| 0x1000 (4096) | Row numbering. |
| 0x2000 (8192) | Execute table only by report item (not subitems). |
| 0x4000 (16384) | Group records into shifts. |
| 0x8000 (32768) | Cut intervals in the table. |
| 0x200000 (2097152) | Grouping by trips. |
| 0x400000 (4194304) | Grouping by violation type. |
| 0x10000000 (268435456) | Grouping by the day of the week. |
| 0x20000000 (536870912) | Grouping by day of the month. |
| 0x40000000 (1073741824) | Grouping by years. |
Chart flags
| Flag | Additional flag | Description |
|---|---|---|
| 0x4 (4) | Correct maximum for the Y axis. | |
| 0x10 (16) | The format specified in the template settings. | |
| 0x1 (1) | Additional for 0x10 (Set format to “H:M:S”). | |
| 0x2 (2) | Additional for 0x10 (Set format to “Y-m-E”). | |
| 0x80 (128) | Generic type. | |
| 0x100 (256) | 24-hour format. | |
| 0x20 (32) | 24-hour format (additional for 0x100). | |
| 0x2 (2) | 12-hour format (additional for 0x20). | |
| 0x40 (64) | Display days of the week (additional for 0x100). |
Error codes
| Code | Description |
|---|---|
| 4 | Wrong input parameters: a required parameter is missing, the template with the specified reportTemplateId doesn’t exist, or reportTemplateId is 0 and the reportTemplate parameter is missing or its tbl array is empty. A template must contain at least one table. |
| 6 | Undefined error. |
| 7 | One of the following errors:
|