#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2022/9/8 9:42
# @Author : Opfer
# @Site :
# @File : util.py    
# @Software: PyCharm

import requests
from tables import *
with open(json_file) as f:
    mysql_config = json.load(f)["mysql"]


# def redispatch_request(truck_id, excavator_id, unload_area_id):
#     """
#     redispatch request.
#     :param truck_id:
#     :param excavator_id:
#     :param unload_area_id:
#     :return:
#     """
#
#     exactor_no = session_mysql.query(Equipment).filter_by(id=excavator_id).first().device_name
#     unload_area_name = session_postgre.query(DumpArea).filter_by(Id=unload_area_id).first().Name
#     truck_name = session_mysql.query(Equipment).filter_by(id=truck_id).first().device_name
#
#     real_data = {
#         "exactorId": excavator_id,
#         "exactorNo": exactor_no,
#         "id": str(uuid.uuid4()),
#         "unloadAreaId": unload_area_id,
#         "unloadAreaName": unload_area_name,
#         "truckId": truck_id,
#         "truckNo": truck_name,
#         "isauto": "true",
#         "tempChange": 1,
#         "immediateEffect": 1
#         }
#
#     return POST(real_data)


def POST(truck_id):
    """
    Post.
    :param real_data:
    :return:
    """
    url_d = "http://" + mysql_config["host"] + ":8020/ht/api/dispatch/updateTemp?truckId=" + truck_id
    res_d = requests.get(url_d)
    print(res_d.text)
    return res_d.text