Exemplo n.º 1
0
def main(ide, flag):
    wialon = Wialon()
    try:
        login = wialon.token_login(token='5ed8fe38981e59aa088f19b358849ddc3FD03E8E9549E2CB60A4380A13FC1AB97ECBB73C')
    except WialonError as e:
        print(e)
        return
    wialon.sid = login['eid']

    parm = {
        "id": ide
        # "itemsType": "avl_unit",
        # "propName": "id",
        # "propValueMask": f"{valuemask}",
        # "sortType": "sys_name",
        # "propType": "sys_name, sys_unique_id",
    }
    interval = {"from": 0, "to": 0}
    try:
        units = wialon.core_search_items(, force=1, flags=flag, **interval)
    except WialonError as e:
        print(e)
        return

    return units
Exemplo n.º 2
0
def get_data_cars(carid, dtfrom, dtto):
    wialon = Wialon()
    array = []
    params = params_get_report(carid, dtfrom, dtto)
    # print(params)
    try:
        login = wialon.token_login(token=TOKEN)
    except WialonError as e:
        print("Error while login:"******"Error while execturing report:", e)

    # logout is necessary, for preventing error with a lot of session from one ip
    try:
        wialon.core_logout()
    except WialonError as e:
        print("Error while logout")
Exemplo n.º 3
0
def get_drivers():
    wialon = Wialon()
    array = []

    try:
        login = wialon.token_login(token=TOKEN)
    except WialonError as e:
        print("Error while login:"******"Error while execturing report:", e)

    # logout is necessary, for preventing error with a lot of session from one ip
    try:
        wialon.core_logout()
    except WialonError as e:
        print("Error while logout")
Exemplo n.º 4
0
def test(requestbot):
    req_b = str(requestbot)
    token, ID, TimeFrom, TimeTo = req_b.split(';')
    if token == 'db1cee3b1f964df20f8d163a1423b6c6286A919144720D152383E5DD77C6113AD31CDC9A':
        token = 'db1cee3b1f964df20f8d163a1423b6c67D562ED72C4E60F2797A1247C61C9B977DBC7DCA'
    y, m, d, h, min, s = TimeFrom.split('-')
    y1, m1, d1, h1, min1, s1 = TimeTo.split('-')
    t1 = datetime.datetime(int(y), int(m), int(d), int(h), int(min), int(s))
    from_time = int(str(time.mktime(t1.timetuple()))[:-2]) - 25200
    t2 = datetime.datetime(int(y1), int(m1), int(d1), int(h1), int(min1), int(s1))
    to_time = int(str(time.mktime(t2.timetuple()))[:-2]) - 25200
    wialon = Wialon()

    try:
        login = wialon.token_login(token=str(token))
    except WialonError as e:
        return ('Error while login')

    wialon.sid = login['eid']
    res_id = api_wialon_dwnData(wialon)

    if res_id:
        calb1, pr_count, pr_dist, units4, units5 = execute_report(res_id, wialon, ID, from_time, to_time)
    else:
        return 'No API resourses'

    milleage = int(str(calb1[1][1])[:calb1[1][1].find("."):])

    callback_retr = ''
    callback_retr += str(calb1[1][1])[:calb1[1][1].find(" "):] + ';'
    probeg = calb1[1][1].replace("km", 'км.')
    callback_retr += str(calb1[2][1]) + ';'
    motoh = calb1[2][1]
    callback_retr += str(calb1[4][1])[:calb1[4][1].find(" "):] + ';'
    start_fuel = calb1[4][1].replace("l", 'л.')

    callback_retr += str(calb1[3][1])[:calb1[3][1].find(" "):] + ';'
    end_fuel = calb1[3][1].replace("l", 'л.')

    callback_retr += str(calb1[5][1])[:calb1[5][1].find(" "):] + ';'
    fuel_up = calb1[5][1].replace("l", 'л.')
    callback_retr += str(calb1[6][1])[:calb1[6][1].find(" "):] + ';'
    fuel_down = calb1[6][1].replace("l", 'л.')
    callback = handler1(calb1, milleage, pr_count, pr_dist, from_time, to_time, wialon, units4, units5, res_id, ID)

    callback_retr += str(callback.data_status) + ';' + str(callback.track_status) \
                     + ';' + str(callback.dut_status) + ';' + str(callback.ign_status) + ';'

    data_obj = wialon.core_search_item({"id": ID, "flags": 0x00000001})
    name_obj = data_obj['item']['nm']
    start_period = "{}.{}.{}. {}:{}:{}".format(d, m, y, h, min, s)
    end_period = '{}.{}.{}. {}:{}:{}'.format(d1, m1, y1, h1, min1, s1)

    return render_template('test_first.html', name=name_obj, probeg=probeg, motoh=motoh, start_fuel=start_fuel,
                           end_fuel=end_fuel, fuel_up=fuel_up, fuel_down=fuel_down, start_period=start_period,
                           end_period=end_period, data_status=callback.data_status, data_info=callback.data_info,
                           track_status=callback.track_status, track_info=callback.track_info,
                           dut_status=callback.dut_info, ign_status=callback.ign_info, callback=callback_retr)
Exemplo n.º 5
0
def get_id_report():
    wialon = Wialon()
    array = []

    params_getid_report = {
        "spec": {
            "itemsType": "avl_resource",
            "propName": "reporttemplates",
            "propValueMask": "*",
            "sortType": "reporttemplates"
        },
        "force": 1,
        "flags": "0x00002001",
        "from": 0,
        "to": 0
    }

    try:
        login = wialon.token_login(token=TOKEN)
    except WialonError as e:
        print("Error while login:"******"Error while execturing report:", e)

    # logout is necessary, for preventing error with a lot of session from one ip
    try:
        wialon.core_logout()
    except WialonError as e:
        print("Error while logout")
Exemplo n.º 6
0
def index(requestbot):
    req_b = str(requestbot)
    token, ID, TimeFrom, TimeTo = req_b.split(';')
    if token == 'db1cee3b1f964df20f8d163a1423b6c6286A919144720D152383E5DD77C6113AD31CDC9A':
        token = 'db1cee3b1f964df20f8d163a1423b6c67D562ED72C4E60F2797A1247C61C9B977DBC7DCA'
    y, m, d, h, min, s = TimeFrom.split('-')
    y1, m1, d1, h1, min1, s1 = TimeTo.split('-')
    t1 = datetime.datetime(int(y), int(m), int(d), int(h), int(min), int(s))
    from_time = int(str(time.mktime(t1.timetuple()))[:-2]) - 25200
    t2 = datetime.datetime(int(y1), int(m1), int(d1), int(h1), int(min1), int(s1))
    to_time = int(str(time.mktime(t2.timetuple()))[:-2]) - 25200

    wialon = Wialon()
    login = None
    try:
        login = wialon.token_login(token=str(token))
    except WialonError as e:
        return ('Error while login')
    wialon.sid = login['eid']
    res_id = api_wialon_dwnData(wialon)

    if res_id:
        calb1, pr_count, pr_dist, units4, units5 = execute_report(res_id, wialon, ID, from_time, to_time)
    else:
        return 'No API resourses'

    milleage = int(str(calb1[1][1])[:calb1[1][1].find("."):])

    callback_retr = ''
    callback_retr += str(calb1[1][1])[:calb1[1][1].find(" "):] + ';'
    callback_retr += str(calb1[2][1]) + ';'
    callback_retr += str(calb1[4][1])[:calb1[4][1].find(" "):] + ';'
    callback_retr += str(calb1[3][1])[:calb1[3][1].find(" "):] + ';'
    callback_retr += str(calb1[5][1])[:calb1[5][1].find(" "):] + ';'
    callback_retr += str(calb1[6][1])[:calb1[6][1].find(" "):] + ';'
    callback = handler1(calb1, milleage, pr_count, pr_dist, from_time, to_time, wialon, units4, units5, res_id, ID)

    callback_retr += str(callback.data_status) + ';' + str(callback.track_status) \
                     + ';' + str(callback.dut_status) + ';' + str(callback.ign_status) + ';'

    return callback_retr
Exemplo n.º 7
0
def logon_session():
    wialon = Wialon()
    try:
        login = wialon.token_login(token=TOKEN)
    except WialonError as e:
        print("Error while login:"******"Error while execturing report:", e)

    # logout is necessary, for preventing error with a lot of session from one ip
    try:
        wialon.core_logout()
    except WialonError as e:
        print("Error while logout")
Exemplo n.º 8
0
def norm(requesthandler):
    req_b = str(requesthandler)

    token, ID, TimeFrom, TimeTo, start_fuel_n, consumption_n, fuel_up = req_b.split(';')
    if token == 'db1cee3b1f964df20f8d163a1423b6c6286A919144720D152383E5DD77C6113AD31CDC9A':
        token = 'db1cee3b1f964df20f8d163a1423b6c67D562ED72C4E60F2797A1247C61C9B977DBC7DCA'
    start_fuel_n.replace(',', '.')
    consumption_n.replace(',', '.')
    fuel_up.replace(',', '.')

    start_fuel_n, consumption_n, fuel_up = float(start_fuel_n), float(consumption_n), float(fuel_up)

    y, m, d, h, min, s = TimeFrom.split('-')
    y1, m1, d1, h1, min1, s1 = TimeTo.split('-')
    t1 = datetime.datetime(int(y), int(m), int(d), int(h), int(min), int(s))
    from_time = int(str(time.mktime(t1.timetuple()))[:-2]) - 25200
    t2 = datetime.datetime(int(y1), int(m1), int(d1), int(h1), int(min1), int(s1))
    to_time = int(str(time.mktime(t2.timetuple()))[:-2]) - 25200
    callback_consum_info = ""

    wialon = Wialon()
    login = None
    try:
        login = wialon.token_login(token=str(token))
    except WialonError as e:
        return ('Error while login')
    wialon.sid = login['eid']
    res_id = api_wialon_dwnData(wialon)

    if res_id:
        volume_tank, end_fuel_f, fuel_up_f, fuel_down, start_fuel_f = execute_report2(res_id, wialon, ID, from_time,
                                                                                      to_time)
    else:
        return 'No API resourses'

    consum_f = round(start_fuel_n + fuel_up - end_fuel_f, 2)

    callback = handler2(volume_tank, consum_f, fuel_up_f, fuel_down, fuel_up, consumption_n, start_fuel_n, start_fuel_f)
    callback_retr = ''

    if callback.fuel_up:
        callback_retr += "Заправка не сходится:" + str(round(fuel_up_f - fuel_up, 2)) + ";"
        callback_consum_info += "Заправка не сходится:" + str(round(fuel_up_f - fuel_up, 2)) + '\n'
    elif callback.nedoliv:
        callback_retr += "Недолив:" + str(round((fuel_up - fuel_up_f), 2)) + ";"
        callback_consum_info += "Недолив:" + str(round((fuel_up - fuel_up_f), 2)) + '\n'
    else:
        callback_retr += "Ok;"  # Заправка ОК

    if callback.fuel_down:
        callback_retr += str(round(fuel_down, 2)) + ";"
    else:
        callback_retr += "0;"  # Слив ОК

    if callback.fuel_start:
        callback_retr += "Нач ур. не сходится!;"
        callback_consum_info += "Нач ур. не сходится! \n"

    else:
        callback_retr += "Ok;"  # Нач ур. ОК

    """Дальше один из 4 вариантов"""
    if callback.short:
        callback_retr += "Короткая поездка, списание по норме;"
        callback_consum_info += "Короткая поездка, списание по норме \n"

    elif callback.perejog:
        callback_retr += "Пережог топлива:" + str(round(consum_f - consumption_n, 2)) + ", списание по факту;"
        callback_consum_info += "Пережог топлива:" + str(round(consum_f - consumption_n, 2)) + ", списание по факту"

    elif callback.economy:
        callback_retr += "Экономия топлива:" + str(round(consumption_n - consum_f, 2)) + ", списание по факту;"
        callback_consum_info += "Экономия топлива:" + str(round(consumption_n - consum_f, 2)) + ", списание по факту"

    else:
        callback_retr += "Расход сходится;"
        callback_consum_info += "Расход сходится"

    callback_retr += str(consum_f) + ';'
    end_fuel_n = float(start_fuel_n) - float(consumption_n) + float(fuel_up)
    data_obj = wialon.core_search_item({"id": ID, "flags": 0x00000001})
    name_obj = data_obj['item']['nm']
    start_period = '{}.{}.{}. {}:{}:{}'.format(d, m, y, h, min, s)
    end_period = '{}.{}.{}. {}:{}:{}'.format(d1, m1, y1, h1, min1, s1)
    consum_smt = float(start_fuel_f) + (fuel_up_f) - (end_fuel_f)
    consum_smt = round(consum_smt, 2)

    write_db(ID, name_obj, start_period, end_period, start_fuel_n, start_fuel_f,
             end_fuel_n, end_fuel_f, fuel_up, fuel_up_f, fuel_down, consumption_n, consum_smt, consum_f,
             callback_consum_info)

    return callback_retr
Exemplo n.º 9
0
def test_norm(requesthandler):
    req_b = str(requesthandler)
    token, ID, TimeFrom, TimeTo, start_fuel_n, consumption_n, fuel_up = req_b.split(';')
    if token == 'db1cee3b1f964df20f8d163a1423b6c6286A919144720D152383E5DD77C6113AD31CDC9A':
        token = 'db1cee3b1f964df20f8d163a1423b6c67D562ED72C4E60F2797A1247C61C9B977DBC7DCA'
    start_fuel_n.replace(',', '.')
    consumption_n.replace(',', '.')
    fuel_up.replace(',', '.')

    start_fuel_n, consumption_n, fuel_up = float(start_fuel_n), float(consumption_n), float(fuel_up)

    y, m, d, h, min, s = TimeFrom.split('-')
    y1, m1, d1, h1, min1, s1 = TimeTo.split('-')
    t1 = datetime.datetime(int(y), int(m), int(d), int(h), int(min), int(s))
    from_time = int(str(time.mktime(t1.timetuple()))[:-2]) - 25200
    t2 = datetime.datetime(int(y1), int(m1), int(d1), int(h1), int(min1), int(s1))
    to_time = int(str(time.mktime(t2.timetuple()))[:-2]) - 25200

    wialon = Wialon()
    login = None
    try:
        login = wialon.token_login(token=str(token))
    except WialonError as e:
        return ('Error while login')

    wialon.sid = login['eid']
    res_id = api_wialon_dwnData(wialon)

    if res_id:
        volume_tank, end_fuel_f, fuel_up_f, fuel_down, start_fuel_f = execute_report2(res_id, wialon, ID, from_time,
                                                                                      to_time)
    else:
        return 'No API resourses'

    consum_f = round(start_fuel_n + fuel_up - end_fuel_f, 2)

    callback = handler2(volume_tank, consum_f, fuel_up_f, fuel_down, fuel_up, consumption_n, start_fuel_n, start_fuel_f)
    callback_retr = ''

    if callback.fuel_up:
        diff = round(fuel_up_f - fuel_up, 2)
        callback_retr += "Заправка не сходится:" + str(round(fuel_up_f - fuel_up, 2)) + ";"
        callback_fuel_info = "Заправка не сходится, разница = {}".format(diff)

    elif callback.nedoliv:
        diff = round((fuel_up - fuel_up_f), 2)
        callback_retr += "Недолив:" + str(round((fuel_up - fuel_up_f), 2)) + ";"
        callback_fuel_info = "Недолив, объемом = {}".format(diff)
    else:
        callback_retr += "Ok;"  # Заправка ОК
        callback_fuel_info = "Заправка ОК"

    if callback.fuel_down:
        callback_retr += str(round(fuel_down, 2)) + ";"
    else:
        callback_retr += "0;"  # Слив ОК
    diff_start = round(float(start_fuel_n) - float(start_fuel_f))
    if callback.fuel_start:
        callback_retr += "Нач ур. не сходится!;"
        callback_start_info = "Нач ур. не сходится! Разница в {} л.".format(diff_start)
    else:
        callback_retr += "Ok;"  # Нач ур. ОК
        callback_start_info = "Нач. уровень сходится"

    """Дальше один из 4 вариантов"""
    if callback.short:
        pr_volume_consum = round((float(consumption_n) / float(volume_tank)) * 100, 2)
        callback_retr += "Короткая поездка, списание по норме;"
        callback_consum_info = "Короткая поездка, потрачено {}% от бака, списание по норме".format(pr_volume_consum)

    elif callback.perejog:
        diff = round(consum_f - consumption_n, 2)
        callback_retr += "Пережог топлива:" + str(round(consum_f - consumption_n, 2)) + ", списание по факту;"
        callback_consum_info = "Пережог топлива, объем = {}, списание по факту".format(diff)

    elif callback.economy and not callback.nedoliv and not callback.fuel_down:
        diff = round(consumption_n - consum_f, 2)
        callback_retr += "Экономия топлива:" + str(round(consumption_n - consum_f, 2)) + ", списание по факту;"
        callback_consum_info = "Экономия топлива, объем = {}, списание по факту".format(diff)

    else:
        callback_retr += "Расход сходится"
        callback_consum_info = 'Расход сходится (В пределах погрешности)'

    if float(fuel_down) > 0:
        fuel_down_info = 'Слито {}! Необходимо провести служебное расследование'.format(fuel_down)
    else:
        fuel_down_info = 'Cливов не зафиксировано'

    end_fuel_n = float(start_fuel_n) - float(consumption_n) + float(fuel_up)
    data_obj = wialon.core_search_item({"id": ID, "flags": 0x00000001})
    name_obj = data_obj['item']['nm']
    start_period = '{}.{}.{}. {}:{}:{}'.format(d, m, y, h, min, s)
    end_period = '{}.{}.{}. {}:{}:{}'.format(d1, m1, y1, h1, min1, s1)
    consum_smt = float(start_fuel_f) + (fuel_up_f) - (end_fuel_f)
    consum_smt = round(consum_smt, 2)

    write_db(ID, name_obj, start_period, end_period, start_fuel_n, start_fuel_f,
             end_fuel_n, end_fuel_f, fuel_up, fuel_up_f, fuel_down, consumption_n,
             consum_smt, consum_f, callback_consum_info, Test=True)

    return render_template('test_norm.html', name=name_obj, start_p=start_period,
                           end_period=end_period, start_fuel_n=start_fuel_n,
                           start_fuel_f=start_fuel_f, consumption_n=consumption_n, consum_f=consum_f, fuel_up=fuel_up,
                           fuel_up_f=fuel_up_f, fuel_down=fuel_down, callback=callback_retr,
                           callback_fuel_info=callback_fuel_info, callback_consum_info=callback_consum_info,
                           volume_tank=volume_tank, end_fuel_n=end_fuel_n, end_fuel_f=end_fuel_f,
                           callback_start_info=callback_start_info, fuel_down_info=fuel_down_info,
                           consum_smt=consum_smt)
Exemplo n.º 10
0
from pprint import pprint

from wialon import Wialon, WialonError, flags

wialon = Wialon()
login = None
token = 'cc06cce5395ef07d3e3407ae05e79a9808EC7AC81B47A18DA69B534A43958D265B22FB46'

try:
    login = wialon.token_login(token=token)
except WialonError as e:
    print("Error while login")

wialon.sid = login['eid']


def api_wialon_dwnObj(name):

    custom_flag = flags.ITEM_DATAFLAG_BASE

    spec = {
        'itemsType': 'avl_unit',
        'propName': 'sys_name',
        'propValueMask': '*' + name + '*',
        'sortType': 'sys_name'
    }
    interval = {"from": 0, "to": 0}

    units = wialon.core_search_items(spec=spec,
                                     force=1,
                                     flags=custom_flag,
Exemplo n.º 11
0
def get_engine_hours(reportResourceId=14587158,
                     reportTemplateId=29,
                     start_timestamp=1604174400,
                     end_timestamp=1604519999,
                     reportObjectId=15021052):
    try:
        logger.debug('Creating wialon instance')
        wialon_api = Wialon()
        # old username and password login is deprecated, use token login
        result = wialon_api.token_login(
            token=
            '8ad9141cc16c305ffa5f0fff9df4e273BFE4CB6398F53061F6315C002FAD111C8271BD93'
        )
        wialon_api.sid = result['eid']

        result = wialon_api.avl_evts()

        logger.debug('Eval events %s', result)
        # exit()
        result = wialon_api.report_cleanup_result({})
        logger.debug('report_cleanup_result %s', result)
        result = wialon_api.report_exec_report({
            "reportResourceId": reportResourceId,
            "reportTemplateId": reportTemplateId,
            "reportTemplate": None,
            "reportObjectId": reportObjectId,
            "reportObjectSecId": 0,
            "interval": {
                "flags": 117440512,
                "from": start_timestamp,
                "to": end_timestamp
            },
            "remoteExec": 1,
            "reportObjectIdList": []
        })

        # print("report_exec_report ", result)  # {"remoteExec":1}
        logger.debug('report_exec_report %s', result)

        all_units_rows = []

        if result.get('remoteExec') == 1:
            """ Wait until result response comes back to you """
            while True:
                result = wialon_api.report_get_report_status({})
                # print("report_get_report_status", result)
                logger.debug('report_get_report_status %s', result)
                if result.get('status') == "4":
                    result = wialon_api.report_apply_report_result({})
                    logger.debug('report_apply_report_result %s', result)
                    # print("report_apply_report_result", result)

                    break
            result = wialon_api.report_select_result_rows({
                "tableIndex": 0,
                "config": {
                    "type": "range",
                    "data": {
                        "from": 0,
                        "to": 0xfffff,
                        "level": 0,
                        "unitInfo": 1
                    }
                }
            })
            # print("Select Top Level: ", result)
            logger.debug('report_select_result_rows %s', result)

            index = 0
            batch_rows = []
            for r in result:
                # print("Top Level Rows: ", r)
                batch_rows.append({
                    "svc": "report/select_result_rows",
                    "params": {
                        "tableIndex": 0,
                        "config": {
                            "type": "row",
                            "data": {
                                "rows": [f"{index}"],
                                "level": 0,
                                "unitInfo": 1
                            }
                        }
                    }
                })
                index += 1

            # print("core/batch", batch_rows)
            unit_rows = wialon_api.core_batch(batch_rows)
            # logger.debug('core_batch %s', len(unit_rows))
            for unit_data in unit_rows:
                all_units_rows += unit_data
            logger.debug('All Rows:  %s', len(all_units_rows))
            # print("All Rows: ", len(all_units_rows))
        wialon_api.core_logout()

        return all_units_rows
    except WialonError as e:
        logger.error('Wialon Error %s', e)
        return []
Exemplo n.º 12
0
def main():
    """
        Main Execution Loop
    """

    global wln_handle
    wln_handle = Wialon()

    print('-- Login and set SID --')
    res = login()
    wln_handle.sid = res['eid']
    wln_handle.avl_evts()

    print('-- Set session flags --')
    print('------ Set avl_resource flag ')
    # reports resource
    avl_resource = wln_handle.core_update_data_flags(
        spec=[{
            'type': 'type',
            'data': 'avl_resource',
            'mode': 1,
            'flags': flags.ITEM_RESOURCE_DATAFLAG_REPORTS
        }])

    print('------ Set avl_unit_group ')
    # unit group info
    avl_u_groups = wln_handle.core_update_data_flags(spec=[{
        'type':
        'type',
        'data':
        'avl_unit_group',
        'mode':
        1,
        'flags':
        flags.ITEM_RESOURCE_DATAFLAG_REPORTS | flags.ITEM_DATAFLAG_BASE
    }])

    print('------ Set avl_unit ')
    # unit info
    avl_unit_res = wln_handle.core_update_data_flags(spec=[{
        'type':
        'type',
        'data':
        'avl_unit',
        'mode':
        1,
        'flags':
        flags.ITEM_RESOURCE_DATAFLAG_REPORTS | flags.ITEM_DATAFLAG_BASE
    }])

    # TODO : need set date interval by days
    #st_range = 1421002800
    #fin_range = 1421089140
    report_running_date = datetime.strptime(sys.argv[1], "%d/%m/%y %H:%M")
    st_range = int(mktime(report_running_date.timetuple()) + cl_tmz_offset_req)
    fin_range = int(
        mktime(datetime.strptime(sys.argv[2], "%d/%m/%y %H:%M").timetuple()) +
        cl_tmz_offset_req)

    print('-- Report run : ' + sys.argv[1] + " : " + sys.argv[2])
    rep_exec = wln_handle.report_exec_report(reportResourceId=12122660,
                                             reportTemplateId=1,
                                             reportObjectId=12244464,
                                             reportObjectSecId=0,
                                             interval={
                                                 'from': st_range,
                                                 'to': fin_range,
                                                 'flags': 0
                                             })

    report_table_list = list()
    i = 0
    for tab in rep_exec['reportResult']['tables']:
        report_table_list.append(
            dict(tabIndex=i, lbl=tab['label'], rows=tab['rows']))
        i = i + 1

    report_table_data = list()
    for t_rec in report_table_list:
        res = wln_handle.report_get_result_rows(tableIndex=t_rec['tabIndex'],
                                                indexFrom=0,
                                                indexTo=t_rec['rows'])
        report_table_data.append(dict(tabIndex=t_rec['tabIndex'], data=res))

    # get 'moto_rashod_virobotka'
    for i in report_table_data:
        if 0 == i['tabIndex']:
            refills = i['data']

        if 1 == i['tabIndex']:
            moto_rate = i['data']

        if 2 == i['tabIndex']:
            remain_fuel = i['data']

        if 3 == i['tabIndex']:
            q_table = i['data']

    # list of units of unit group with description and id, fuel_in, fuel_start_per and fuel_end_per
    u_of_group = dict()
    for u in avl_u_groups[1]['d']['u']:

        d = ''
        f_in = ''
        r_fl_st = ''
        r_fl_fn = ''
        q_start = ''
        q_end = ''

        # find WLN_ID, WLN_UNIT_NAME by unit id's list from unit_group
        for i in avl_unit_res:
            if u == i['d']['id']:
                d = i['d']['nm']

                # find FUEL_IN param by unit NAME in Zapravki table resul
                for k in refills:
                    if d == k['c'][1]:
                        f_in = k['c'][3].replace(' lt', '')
                        break

                # find FUEL_START_PREIOD and FUELD_END_PERIOD by unit NAME
                for x in remain_fuel:
                    if d == x['c'][1]:
                        r_fl_st = x['c'][3].replace(' lt', '')
                        r_fl_fn = x['c'][4].replace(' lt', '')
                        break

                # find Q_START and Q_END
                for z in q_table:
                    if d == z['c'][1]:
                        q_start = z['c'][3]
                        q_end = z['c'][4]

                break

        u_of_group[d] = [str(u), f_in, [r_fl_st, r_fl_fn], [q_start, q_end]]

    # create a result records list to save in database
    db_table = list()
    for rec in moto_rate:
        if rec['c'][2] == '':
            rec['c'][2] = report_running_date.strftime('%Y-%m-%d')
        db_rec = dict(
            place_work=avl_u_groups[1]['d']['nm'],
            date=rec['c'][2],
            object_name=rec['c'][1],
            object_type='',  # non fill
            object_wln_id=u_of_group.get(rec['c'][1])[0],
            start_time_int=str(int(rec['t1']) + cl_tmz_offset_resp),
            end_time_int=str(int(rec['t2']) + cl_tmz_offset_resp),
            motohours=rec['c'][5],
            energy_p=rec['c'][6].replace(' km', ''),
            ph_sred='',  # non fill
            nagruzka='',  # non fill
            energy_q='',  # non fill
            fuel_density='',
            fuel_used=rec['c'][7].replace(' lt', ''),
            fuel_rate=rec['c'][8].replace(' lt/100 km', ''),
            fuel_in=u_of_group.get(rec['c'][1])[1],
            fuel_start_period=u_of_group.get(rec['c'][1])[2][0],
            fuel_end_period=u_of_group.get(rec['c'][1])[2][1],
            p_start=rec['c'][9],
            p_end=rec['c'][10],
            q_start=u_of_group.get(rec['c'][1])[3][0],
            q_end=u_of_group.get(rec['c'][1])[3][1],
            s_start='',  # non fill
            s_end='',  # non fill
            cos_fi=rec['c'][11],
            local_energy='',  # non fill
            trans_param='')  # db_rec
        db_table.append(db_rec)

    print('-- Saving results into database')
    # save into database
    db_records_saving(db_table)

    # end report session
    logout()