To execute a report, use the command report/exec_report:
svc=report/exec_report¶ms={"reportResourceId":<long>, "reportTemplateId":<long>, "reportObjectId":<long>, "reportObjectSecId":<long>, "interval":{ "from":<uint>, "to":<uint>, "flags":<uint> }, "reportTemplate":<object>}
Attention! There can be only one report in a session at the same time. Therefore if a session already has some report results, they must be cleared before executing a new report – with the command report/cleanup_result. Also current request can’t be executed simultaneously with following requests:
- report/export_result,
- report/get_result_chart,
- report/get_result_map,
- messages/load_interval,
- render/create_messages_layer,
- unit/get_trips,
- resource/get_driver_bindings,
- resource/get_trailer_bindings,
- all requests from chapter Export and import,
- account/get_account_history.
You can find an example of this request in the sample Reports.
Parameters
Name | Description |
---|---|
reportResourceId | resource ID |
reportTemplateId | template ID |
reportObjectId | item ID |
reportObjectSecId | subitem ID (like driver, trailer or their groups), 0 – if the item has no subitems |
interval | report interval settings |
from | interval beginning, UNIX-time |
to | interval end, UNIX-time |
flags | interval flags |
reportTemplate | JSON of report template, which you can get from get_report_data request (optional parameter, used only if reportTemplateId equals 0) |
reportResourceId is required parameter, report will be executed as creator of this resource if reportTemplateId equals 0.
Interval flags:
Flag | Description |
---|---|
0x00 | specified interval |
0x01 | starts ‘From’ until today |
0x02 | for previous n days |
0x04 | for previous n weeks |
0x08 | for previous n month |
0x10 | for previous n years |
0x20 | including current |
0x40 | for previous n hours |
0x40 | for previous n minutes |
Response
{ "reportResult":{ /* report execution result */ "msgsRendered":<int>, /* messages loaded: 0 - no, 1 - yes */ "stats":[ /* array of statistics parameters */ [<text>,<text>] /* [parameter name, value] */ ], "tables":[ /* array of tables */ { "name":<text>, /* table type */ "label":<text>, /* name */ "grouping": { "type":<text> /* grouping type */ }, "flags":<uint>, /* table flags (see below) */ "rows":<uint>, /* quantity of lines */ "level":<uint>, /* max level in table */ "columns":<uint>, /* columns count */ "header":[ <text> /* array of table headers */ ], "total":[ /* total */ <text> /* array of cells */ ] } ], "attachments":[ /* attachments array (charts, photos) */ { /* for charts */ "name":<text>, /* name */ "type":<text>, /* type: chart, photo */ "datasets":[<text>] /* array with names of chart's curved lines */ }, { /* 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>, /* index of the same-type attachments registered simultaneously */ "lat":<text>, /* latitude */ "lon":<text>, /* longitude */ "type":<text> /* attachment type */ } ] }, "reportLayer":{ /* graphic layer */ "name":<text>, /* layer name */ "bounds":[ <double>, /* minimal latitude */ <double>, /* minimal longitude */ <double>, /* maximal latitude */ <double> /* maximal longitude */ ] }, "layerCount":<uint> /* quantity of layers to be merged in report layer */ }
To get all available types of tables, make the request report/get_report_tables.
Table flags:
Flag | Description |
---|---|
0x1 | Group by: days |
0x2 | Time limitation |
0x4 | Group by: weeks |
0x8 | Group by: months |
0x10 | Total |
0x20 | Charts: split sensors |
0x100 | Detalization: partial |
0x200 | Charts: count from zero |
0x800 | Detalization: full |
0x1000 | Row numbering |
0x200000 | Group by: trips |
0x400000 | Group by: violation type |