Browse Source

涵盖机型风险提示,计算中心修订

maohu 1 week ago
parent
commit
002fecf4be
4 changed files with 58 additions and 34 deletions
  1. 3 0
      Functions/DButilsFunction/calltry.py
  2. 48 29
      Functions/DataComputer.py
  3. 2 2
      Functions/utils.py
  4. 5 3
      SeverStart.py

+ 3 - 0
Functions/DButilsFunction/calltry.py

@@ -24,8 +24,11 @@ def calltry(fdb:flightDB,ip,token):
                     "Cookie": token
                 }
                 requests.post(url="http://%s/contacts.htm" % ip, data=data, headers=header)
+                return phone_num
             except Exception as e:
                 app_logger.log_error(e)
                 print(datetime.datetime.now(),"[数据中心]拨号失败")
+                return "fail"
     except Exception as e:
         app_logger.log_error(e)
+        return "fail"

+ 48 - 29
Functions/DataComputer.py

@@ -310,8 +310,10 @@ def mytask():
 
     alldata=DataDBUtilsgetData("sortFlight%s" % nowDay, "*", "编号 != ''")
     Yalldata=DataDBUtilsgetData("sortFlight%s" % nowDay_1, "*", "编号 != ''")
+    alldata_task=DataDBUtilsgetData("TaskFlightinfo%s" % nowDay, "*", "航班编号 != ''")
+    Yalldata_task=DataDBUtilsgetData("TaskFlightinfo%s" % nowDay_1, "*", "航班编号 != ''")
     try:
-        mytask1 = function1(alldata,Yalldata)
+        mytask1 = function1(alldata_task,Yalldata_task)
         finishdeTask=finishdeTask+"task1/"
     except:
         mytask1=[]
@@ -329,30 +331,34 @@ def mytask():
     ystartTime = (now - datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
     tstartTime = (now + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
 
-    taskMainData=getData("taskMain", "*", "'%s' < 任务开始时间 and 任务开始时间 <'%s'"%(startTime,tstartTime))
-    YtaskMainData = getData("taskMain", "*", "'%s' < 任务开始时间 and 任务开始时间 <'%s'" % (ystartTime, startTime))
+    taskMainData=getData_online("taskMain", "*", "'%s' < 任务开始时间 and 任务开始时间 <'%s'"%(startTime,tstartTime))
+    YtaskMainData = getData_online("taskMain", "*", "'%s' < 任务开始时间 and 任务开始时间 <'%s'" % (ystartTime, startTime))
 
     try:
         mytask3 = function4(taskMainData,YtaskMainData)
         finishdeTask=finishdeTask+"task3/"
-    except:
+    except  Exception as e:
+        print(e)
         mytask3=[]
         pass
 
     try:
         mytask4 = function5()
         finishdeTask=finishdeTask+"task4/"
-    except:
+    except  Exception as e:
+        print(e)
         pass
     try:
         mytask5 = function7()
         finishdeTask=finishdeTask+"task5/"
-    except:
+    except  Exception as e:
+        print(e)
         pass
     try:
         mytask6 = function9()
         finishdeTask=finishdeTask+"task6/"
-    except:
+    except  Exception as e:
+        print(e)
         pass
 
     nowday=datetime.date.today()
@@ -421,6 +427,7 @@ def mytask():
         fdb.lazyInsertData("dataList{}".format(nowDay_1), newdic)
 
         #航材工具配送
+
         for i in mytask5[0].keys():
             newdic={"类型":'%s配送'%mytask5[0][i]["类型"],"时间":mytask5[0][i]['配送发起时间'],"数据1":mytask5[0][i]['机位'],"数据2":mytask5[0][i]['耗时'],'唯一序列':mytask5[0][i]['任务号'],'备1':mytask5[0][i]['任务级别'],'备2':"",'备3':"",'备4':"",'备5':"",'备6':""}
             fdb.lazyInsertData("dataList{}".format(nowDay), newdic)
@@ -472,6 +479,18 @@ def CountInList(lists: list, args, numb):  # 返回列表
         return res
     except:
         return res
+def CountInListor(lists: list, args, args1,numb):  # 返回列表
+    res = 0
+    try:
+        for l in lists:
+            if args not in l[numb] and args1 not in l[numb]:
+                if l[3] == 'TR' or l[3] == 'TAF':
+                    res+=2
+                else:
+                    res+=1
+        return res
+    except:
+        return res
 def CountInListNot(lists: list, args, numb):  # 返回列表
     res = 0
     try:
@@ -493,21 +512,21 @@ def CountFinshed(lists: list):  # 返回列表
         return res
 
 def function1(alldata,Yalldata):   #查询每日航班的分布
-    resTR=CountInList(alldata, "短停", 3)
-    resPEF=CountInList(alldata, "航前", 3)
-    resPOF=CountInList(alldata, "航后", 3)
-    resTAF=CountInList(alldata, "特后前", 3)
+    resTR=CountInList(alldata, "TR", 3) * 2
+    resPEF=CountInList(alldata, "AP", 3)
+    resPOF=CountInList(alldata, "AF", 3)
+    resTAF=CountInList(alldata, "TAF", 3)*2
     resST=CountInList(alldata, "停场", 3)
     resAll=resTR+resPEF+resPOF+resTAF
     resfinsh=CountFinshed(alldata)
-    YresTR=CountInList(Yalldata, "短停", 3)
-    YresPEF=CountInList(Yalldata, "航前", 3)
-    YresPOF=CountInList(Yalldata, "航后", 3)
-    YresTAF=CountInList(Yalldata, "特后前", 3)
+    YresTR=CountInList(Yalldata, "TR", 3)*2
+    YresPEF=CountInList(Yalldata, "AP", 3)
+    YresPOF=CountInList(Yalldata, "AF", 3)
+    YresTAF=CountInList(Yalldata, "TAF", 3)*2
     YresST=CountInList(Yalldata, "停场", 3)
     YreAll=YresTR+YresPEF+YresPOF+YresTAF
-    ww=CountInList(alldata, "PB", 0)
-    yww=CountInList(Yalldata, "PB", 0)
+    ww=CountInListor(alldata, "3U",'CSC', 21)
+    yww=CountInListor(Yalldata, "3U",'CSC', 21)
     ch=resAll-ww
     Ych=YreAll-yww
     Yresfinsh=CountFinshed(Yalldata)
@@ -534,7 +553,7 @@ def function3(startTime,res):
     list=[]
     ress={}
     aa=30#准备时间
-    bb=25#收尾时间
+    bb=15#收尾时间
     if len(res) !=0 and res !=None:
         for i in res:
             #print(i)
@@ -617,8 +636,8 @@ def function7():#航材工具
     startTime = now.replace(hour=0, minute=0, second=0, microsecond=0)
     ystartTime = (now - datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
     tstartTime = (now + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
-    resALL=getData("sendTaskList",'*',"'%s' < 配送发起时间 and 配送发起时间 <'%s'"%(startTime,tstartTime))
-    yresALL = getData("sendTaskList", '*', "'%s' < 配送发起时间 and 配送发起时间 <'%s'" % (ystartTime, startTime))
+    resALL=getData_online("sendtasklist",'*',"'%s' < 配送发起时间 and 配送发起时间 <'%s'"%(startTime,tstartTime))
+    yresALL = getData_online("sendtasklist", '*', "'%s' < 配送发起时间 and 配送发起时间 <'%s'" % (ystartTime, startTime))
     res=function8(resALL)
     yres = function8(yresALL)
     return(res,yres)
@@ -627,8 +646,8 @@ def function8(res):
     ress={}
     if res !=None and len(res) !=0:
         for i in res:
-            if i[23] == "" and i[6] != "":
-                costtime= math.ceil((datetime.datetime.strptime(i[23].split(".")[0], "%Y-%m-%d %H:%M:%S")- datetime.datetime.strptime(i[6].split(".")[0], "%Y-%m-%d %H:%M:%S")).total_seconds()/60)
+            if i[23] != "" and i[6] != "":
+                costtime= math.ceil((datetime.datetime.strptime(i[23].split(".")[0], "%Y-%m-%d %H:%M:%S") - datetime.datetime.strptime(i[6].split(".")[0], "%Y-%m-%d %H:%M:%S")).total_seconds()/60)
             else:
                 costtime=""
 
@@ -641,16 +660,16 @@ def function9():#二拖
     ystartTime = (now - datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
     tstartTime = (now + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
 
-    resALL = getData("towbarMain", '*', "'%s' < 创建时间 and 创建时间 <'%s'" % (startTime, tstartTime))
-    yresALL = getData("towbarMain", '*', "'%s' < 创建时间 and 创建时间 <'%s'" % (ystartTime, startTime))
+    resALL = getData_online("towbarmain", '*', "'%s' < 创建时间 and 创建时间 <'%s'" % (startTime, tstartTime))
+    yresALL = getData_online("towbarmain", '*', "'%s' < 创建时间 and 创建时间 <'%s'" % (ystartTime, startTime))
     res=function10(resALL)
     yres = function10(yresALL)
     return(res,yres)
 def function10(res):
     ress={}
-    if res !=None and len(res) !=0:
+    if res and res !=None and len(res) !=0:
         for i in res:
-            if i[11] !="":
+            if i[11] !="" and i[9] !="":
                 costtime= math.ceil((datetime.datetime.strptime(i[11].split(".")[0], "%Y-%m-%d %H:%M:%S")- datetime.datetime.strptime(i[9].split(".")[0], "%Y-%m-%d %H:%M:%S")).total_seconds()/60)
             else:
                 costtime=""
@@ -676,9 +695,9 @@ def initFlightDatabase1(datatime):
         database.close()
         print(traceback.format_exc())
 
-def getData(tablename, data, key):
-    fdb = flightDB(host=host,
-                   port=port,
+def getData_online(tablename, data, key):
+    fdb = flightDB(host=online_host,
+                   port=online_port,
                    user=user1,
                    password=password,
                    database=databasefileDB

+ 2 - 2
Functions/utils.py

@@ -347,8 +347,8 @@ class flight_list(object):
                 "tasktype": "",
                 "notView": "",
                 "isThird":"Y",
-                "actype1": "(21N|319|320|321|32N|332|738|73G|A21N|A319|A319|A320|A321|A32N|A738|A73G|AZZZ|B737|C919)",
-                "actype": "B737NG,B737MAX,A319,A320,A321,C919"
+                "actype1": "(21N|319|320|321|32N|332|738|73G|A21N|A319|A319|A320|A321|A32N|A738|A73G|AZZZ|B737|C919|ARJ21)",
+                "actype": "B737NG,B737MAX,A319,A320,A321,C919,ARJ21"
                 #"actype": "A319%2CA320%2CA321%2CB737MAX%2CB737NG"
                 }
         header = {"Accept": "application/json, text/javascript, */*; q=0.01",

+ 5 - 3
SeverStart.py

@@ -69,7 +69,6 @@ def check_a_availability():
     """检查A服务器的可用性"""
     try:
         ip = "http://" + mainseverip + ":7162/static/health"
-        #ip = "http://" + "192.168.2.65" + ":7162/static/health"
         response = requests.get(ip, timeout=5)
         return response.status_code != 200  #看是否连接成功
     except Exception as e:
@@ -646,8 +645,11 @@ def calltry():
         fdb = flightDB(host=dbhost,port=dbport,user=dbuser,password=dbpassword,database=databaseDB4)
         A=Calltry(fdb, ip,token)
         fdb.close()
-        res = {"返回值": "ok"}
-        print(datetime.datetime.now(),"[%s]尝试自动拨打请求"%remote_addr)
+        if A != "fail":
+            res = {"返回值": "ok"}
+            print(datetime.datetime.now(),"[%s]尝试自动拨打请求%s"%(remote_addr,A))
+        else:
+            res = { "返回值" : "fail" }
     else:
         res = {"返回值": "fail"}
     return res