Тема: Remote API: Выполнение отчета по шаблону
Здравствуйте!
Столкнулись с такой проблемой:
Нужно получить моточасы техники (общее время, общие моточасы, моточасы на стоянке) в разрезе водителей.
Пришли к выводу, что одним отчетом эти данные не достать - сделали два шаблона:
Получение общего времени и моточасов по технике, без водителей:
{"id":6,"n":"Сводный по объекту","ct":"avl_unit","p":"{\"bind\":null}","tbl":[{"n":"unit_stops","l":"","c":"","cl":"","s":"[\"chart_stops_regions\"]","sl":"","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_conn_quality","l":"","c":"","cl":"","s":"[\"chart_conn_quality_regions\"]","sl":"","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stays","l":"","c":"","cl":"","s":"[\"chart_stays_regions\"]","sl":"","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_trips","l":"","c":"","cl":"","s":"[\"chart_trips_regions\"]","sl":"","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stats","l":"Статистика","c":"","cl":"","s":"[\"address_format\",\"time_format\",\"us_units\"]","sl":"[\"Address\",\"Time Format\"]","p":"{\"address_format\":\"1255211008_10_5\",\"time_format\":\"%Y-%m-%E_%H:%M:%S\",\"us_units\":0}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_generic","l":"Сводка","c":"[\"mileage\",\"avg_speed\",\"max_speed\",\"in_motion\",\"eh\",\"sensor_duration\",\"duration_stay\",\"fuel_consumption_fls\",\"avg_fuel_consumption_fls\",\"fuel_level_begin\",\"fuel_level_end\",\"fillings_count\",\"thefts_count\",\"filled\",\"thefted\"]","cl":"[\"Пробег в поездках\",\"Ср. скорость\",\"Макс. скорость\",\"Время в движении\",\"Моточасы\",\"Длительность полезной работы\",\"Стоянки\",\"Потрачено по ДУТ\",\"Ср. расход по ДУТ\",\"Нач. уровень\",\"Конеч. уровень\",\"Всего заправок\",\"Всего сливов\",\"Заправлено\",\"Слито\"]","s":"","sl":"","p":"{\"grouping\":\"{\\\"type\\\":\\\"day\\\"}\",\"fillings_params\":{},\"thefts_params\":{},\"sensors_params\":{},\"custom_interval\":{\"type\":\"0\"}}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":4369},{"n":"unit_chart","l":"График уровня топлива","c":"[\"voltage_sensors_base\",\"fuel_level\",\"fuel_level_proc_inline\"]","cl":"[\"Напряжение\",\"Уровень топлива\",\"Обработанный уровень топлива\"]","s":"","sl":"","p":"{\"sensor_mask\":\"*\",\"chart_regions\":[{\"id\":\"chart_stops_regions\",\"color\":14413564,\"priority\":5,\"name\":\"Stops\"},{\"id\":\"chart_conn_quality_regions\",\"color\":14474460,\"priority\":3,\"name\":\"Connection loss\"},{\"id\":\"chart_stays_regions\",\"color\":16773056,\"priority\":2,\"name\":\"Parkings\"},{\"id\":\"chart_trips_regions\",\"color\":16766408,\"priority\":1,\"name\":\"Trips\"}]}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_chart","l":"Графики ДУТ раздельно","c":"[\"custom_sensors_base\",\"custom_sensors_smooth\"]","cl":"[\"Произвольные датчики\",\"Произвольные датчики (сглаж.)\"]","s":"","sl":"","p":"{\"sensor_mask\":\"*\",\"chart_regions\":[{\"id\":\"chart_stops_regions\",\"color\":14413564,\"priority\":5,\"name\":\"Stops\"},{\"id\":\"chart_stays_regions\",\"color\":16773056,\"priority\":2,\"name\":\"Parkings\"},{\"id\":\"chart_trips_regions\",\"color\":16766408,\"priority\":1,\"name\":\"Trips\"}]}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0}]}
И второй для получения информации по поездкам водителей:
{"id":4,"n":"Комплексный по ТС","ct":"avl_unit","p":"{\"bind\":null}","tbl":[{"n":"unit_fillings","l":"Заправки","c":"","cl":"","s":"[\"render_filling_markers\"]","sl":"[\"Маркеры заправок\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stops","l":"Остановки","c":"","cl":"","s":"[\"render_stops_markers\",\"chart_stops_regions\"]","sl":"[\"Маркеры остановок\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_thefts","l":"Сливы","c":"","cl":"","s":"[\"render_theft_markers\"]","sl":"[\"Маркеры сливов\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stays","l":"Стоянки","c":"","cl":"","s":"[\"render_stays_markers\",\"chart_stays_regions\"]","sl":"[\"Маркеры стоянок\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_trips","l":"Поездки","c":"","cl":"","s":"[\"render_trips\",\"chart_trips_regions\"]","sl":"[\"Треки поездок\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stats","l":"Статистика","c":"","cl":"","s":"[\"address_format\",\"time_format\",\"us_units\"]","sl":"[\"Address\",\"Time Format\"]","p":"{\"address_format\":\"1255211008_10_5\",\"time_format\":\"%Y-%m-%E_%H:%M:%S\",\"us_units\":0}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_stats","l":"Статистика","c":"","cl":"","s":"[\"report_name\",\"unit_name\",\"time_begin\",\"time_end\",\"fuel_consumption_fls\",\"fuel_consumption_all\",\"fuel_level_begin\",\"fuel_level_end\",\"fuel_level_max\",\"fuel_level_min\"]","sl":"[\"Отчет\",\"Объект\",\"Начало интервала\",\"Конец интервала\",\"Потрачено по ДУТ\",\"Потрачено\",\"Нач. уровень\",\"Конеч. уровень\",\"Макс. уровень топлива\",\"Мин. уровень топлива\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_fillings","l":"Заправки","c":"","cl":"","s":"[\"filled\"]","sl":"[\"Всего заправлено\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_thefts","l":"Сливы","c":"","cl":"","s":"[\"thefted\"]","sl":"[\"Всего топлива слито\"]","p":"","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_trips","l":"Поездки","c":"[\"time_begin\",\"location_begin\",\"time_end\",\"location_end\",\"driver\",\"duration\",\"mileage\",\"avg_speed\",\"max_speed\",\"trips_count\",\"fuel_consumption_fls\",\"avg_fuel_consumption_fls\",\"fuel_level_begin\",\"fuel_level_end\",\"fuel_level_max\",\"fuel_level_min\",\"trailer\"]","cl":"[\"Начало\",\"Нач. положение\",\"Конец\",\"Конеч. положение\",\"Водитель\",\"Длительность\",\"Пробег\",\"Ср. скорость\",\"Макс. скорость\",\"Количество поездок\",\"Потрачено по ДУТ\",\"Ср. расход по ДУТ\",\"Нач. уровень\",\"Конеч. уровень\",\"Макс. уровень топлива\",\"Мин. уровень топлива\",\"Прицеп\"]","s":"","sl":"","p":"{\"grouping\":\"{\\\"type\\\":\\\"day\\\"}\"}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":4368},{"n":"unit_stays","l":"Стоянки","c":"[\"time_begin\",\"time_end\",\"duration\",\"location\",\"driver\",\"stays_count\"]","cl":"[\"Начало\",\"Конец\",\"Длительность\",\"Положение\",\"Водитель\",\"Количество\"]","s":"","sl":"","p":"{\"grouping\":\"{\\\"type\\\":\\\"day\\\"}\"}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":4368},{"n":"unit_fillings","l":"Заправки","c":"[\"time_end\",\"location_end\",\"fuel_level_begin\",\"fuel_level_filled\",\"filled\",\"sensor_name\",\"driver\",\"count\"]","cl":"[\"Время\",\"Положение\",\"Нач. уровень\",\"Конеч. уровень\",\"Заправлено\",\"Имя датчика\",\"Водитель\",\"Количество\"]","s":"","sl":"","p":"{\"grouping\":\"{\\\"type\\\":\\\"day\\\"}\",\"fillings_params\":{},\"thefts_params\":{},\"sensors_params\":{}}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":4368},{"n":"unit_thefts","l":"Сливы","c":"[\"time_begin\",\"location_begin\",\"time_end\",\"location_end\",\"fuel_level_begin\",\"thefted\",\"fuel_level_thefted\",\"sensor_name\",\"driver\",\"count\"]","cl":"[\"Начало\",\"Нач. положение\",\"Время\",\"Конеч. положение\",\"Нач. уровень\",\"Слито\",\"Конеч. уровень\",\"Имя датчика\",\"Водитель\",\"Количество\"]","s":"","sl":"","p":"{\"grouping\":\"{\\\"type\\\":\\\"day\\\"}\",\"fillings_params\":{},\"thefts_params\":{},\"sensors_params\":{}}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":4368},{"n":"unit_chart","l":"График уровня топлива","c":"[\"fuel_level\",\"fuel_level_proc_inline\",\"voltage_sensors_smooth\"]","cl":"[\"Уровень топлива\",\"Обработанный уровень топлива\",\"Напряжение (сглаж.)\"]","s":"","sl":"","p":"{\"sensor_mask\":\"*\",\"chart_regions\":[{\"id\":\"chart_stops_regions\",\"color\":14413564,\"priority\":5,\"name\":\"Stops\"},{\"id\":\"chart_stays_regions\",\"color\":16773056,\"priority\":4,\"name\":\"Parkings\"},{\"id\":\"chart_trips_regions\",\"color\":16766408,\"priority\":3,\"name\":\"Trips\"}]}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0},{"n":"unit_chart","l":"График ДУТ раздельно","c":"[\"custom_sensors_base\",\"custom_sensors_smooth\"]","cl":"[\"Произвольные датчики\",\"Произвольные датчики (сглаж.)\"]","s":"","sl":"","p":"{\"sensor_mask\":\"*\",\"chart_regions\":[{\"id\":\"chart_stops_regions\",\"color\":14413564,\"priority\":5,\"name\":\"Stops\"},{\"id\":\"chart_stays_regions\",\"color\":16773056,\"priority\":2,\"name\":\"Parkings\"},{\"id\":\"chart_trips_regions\",\"color\":16766408,\"priority\":1,\"name\":\"Trips\"}]}","sch":{"f1":0,"f2":0,"t1":0,"t2":0,"m":0,"y":0,"w":0,"fl":0},"f":0}]}
Через интерфейс отчеты отрабатывают.
По идеи, если как-то вручную слепить результаты этих отчетов, то можно получить желаемое..
Значит, их нужно дернуть через RemoteAPI, причем желательно по один раз настроенным отчетам, что бы не волноваться об их изменении или возможном переносе на Local.
Как их можно выполнить имея приведенные шаблоны (были получены через функцию report/get_report_data) ?
Подставляю шаблоны в приведенном виде в параметр reportTemplate метода report/exec_report при reportTemplateId=0 и reportResourceId=user.bact из ответа token/login получаю ошибку 4!
В чем проблема?
Как правильно выполнить отчет по шаблону?
PS
Я видел пример для JavaScript API, но непонятно что не так для Remote API.