from static_data_process import *
from settings import *
import numpy as np

from data.dispatchInfo import DispatchInfo
from bidict import bidict
from alg.algorithm import AlgorithmBase

if __name__ == '__main__':
    # dynamic_excavator_set = set(update_autodisp_excavator())
    # dynamic_excavator_num = len(dynamic_excavator_set)
    #
    # dynamic_dump_set = set(update_autodisp_dump())
    # dynamic_dump_num = len(dynamic_dump_set)
    #
    # dynamic_excavator_list = []
    # for item in (
    #         session_mysql.query(Dispatch).filter_by(isdeleted=0, isauto=1).all()
    # ):
    #     dynamic_excavator_list.append(item.exactor_id)
    # if len(dynamic_excavator_list) < 1:
    #     raise Exception("无动态派车计划可用-动态派车挖机/卸载设备集合读取异常")

    # 更新数据库缓存
    DispatchInfo.renew_set()

    DispatchInfo.update_device_group_structure()

    DispatchInfo.update_route_distance()

    DispatchInfo.update_group_mode()

    a = DispatchInfo.get_group_mode('9bb14655-4fd5-49da-a31a-13f6ced88d6c')
    a_excavator = DispatchInfo.get_excavator('9bb14655-4fd5-49da-a31a-13f6ced88d6c')
    a_dump = DispatchInfo.get_dump('9bb14655-4fd5-49da-a31a-13f6ced88d6c')
    a_truck = DispatchInfo.get_truck_set('9bb14655-4fd5-49da-a31a-13f6ced88d6c')
    # bb = DispatchInfo.get_to_excavator_distance('9bb14655-4fd5-49da-a31a-13f6ced88d6c')
    # cc = DispatchInfo.get_to_dump_distance('9bb14655-4fd5-49da-a31a-13f6ced88d6c')

    print(a_excavator)
    print(a_dump)
    print(a_truck)




