from unitls.LogerinTxt import app_logger
from .flightDB import flightDB


def waringMessageID(database:flightDB):
    try:
        waringMessageID1_arr=[]
        waringMessageID2_arr = []
        waringMessageID3_arr = []
        waringMessageID4_arr = []
        waringMessageID5_arr = []
        waringMessageID6_arr = []
        waringMessageID0_arr = []
        waringMessageID_arrs={}
        waringMessageIDs=database.queryTabel('logs',"*","警告信息 !='' and 处理时间 =''")
        if len(waringMessageIDs) != 0:
            for i in waringMessageIDs:
                waringMessageID0_arr.append(i[1])
                if i[8] == "到位警告":
                    waringMessageID1_arr.append(i[1])
                elif i[8] == "二送警告":
                    waringMessageID2_arr.append(i[1])
                elif i[8] == "非航前预计到达":
                    waringMessageID3_arr.append(i[1])
                elif i[8] == "非航前进港机位":
                    waringMessageID4_arr.append(i[1])
                elif i[8] == "非航前预计起飞":
                    waringMessageID5_arr.append(i[1])
                else:
                    waringMessageID6_arr.append(i[1])
        waringMessageID_arrs["到位警告"]=waringMessageID1_arr
        waringMessageID_arrs["二送警告"] = waringMessageID2_arr
        waringMessageID_arrs["ETA"] = waringMessageID3_arr
        waringMessageID_arrs["BAY_2"] = waringMessageID4_arr
        waringMessageID_arrs["TD"] = waringMessageID5_arr
        waringMessageID_arrs["通用警告"] = waringMessageID6_arr
        waringMessageID_arrs["全部警告"] = waringMessageID0_arr
        return waringMessageID_arrs
    except Exception as e:
        app_logger.log_error(e)