Browse Source

R17.0.1 修复数据传输和请求报错

maohu 3 weeks ago
parent
commit
95e5fb5ee9

+ 2 - 2
Functions/DBUtils4PG_old.py

@@ -859,11 +859,11 @@ def postgresql_local(local:flightDB,host_online, port_online, user_online, passw
 
     table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
                    "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
-                   "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
+                   "sortFlight%s"%today:sortLabel,"sortFlight%s"%yesterday:sortLabel,"sortFlight%s"%tomorrow:sortLabel,
                    "display":displayLabel}
     dbtables=["flightinfo%s"%today,"flightinfo%s"%yesterday,"flightinfo%s"%tomorrow,
               "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
-              "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
+              "sortFlight%s"%today,"sortFlight%s"%yesterday,"sortFlight%s"%tomorrow,"display"]
     try:
         tablesok=""
         tablenum=0

+ 2 - 2
Functions/DBUtils4PG_oldtry.py

@@ -614,11 +614,11 @@ def postgresql_local(local:flightDB,host_online, port_online, user_online, passw
 
     table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
                    "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
-                   "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
+                   "sortFlight%s"%today:sortLabel,"sortFlight%s"%yesterday:sortLabel,"sortFlight%s"%tomorrow:sortLabel,
                    "display":displayLabel}
     dbtables=["flightinfo%s"%today,"flightinfo%s"%yesterday,"flightinfo%s"%tomorrow,
               "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
-              "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
+              "sortFlight%s"%today,"sortFlight%s"%yesterday,"sortFlight%s"%tomorrow,"display"]
     try:
         tablesok=""
         tablenum=0

+ 5 - 2
Functions/DButilsFunction/get_dic.py

@@ -45,13 +45,16 @@ def get_dic(database:flightDB, fileName):
                         IDSNOW.append(mydics0["工号"])
                 #print(1)
             fdb.FunctionCommit()
-            return 1
+            return "ok"
         except Exception as e:
             print(datetime.datetime.now(),'[数据库操作]数据库获取错误!!检查通讯录文件!人员显示功能失效!!')
+            print(e)
             app_logger.log_error(e)
             # 需要QT输出警告弹框信息
             fdb.FunctionCommit()
-            return 0
+            return "fail"
 
     except Exception as e:
         app_logger.log_error(e)
+        return "fail"
+

+ 10 - 36
Functions/DButilsFunction/get_empNos.py

@@ -8,13 +8,10 @@ def get_empNos(database:flightDB,dict:dict):
         bc = judge_bc()["bc"]
         faillist=[]
         WXempNos = ""
-        ESempNos = ""
         FXempNos = ""
         WX = ""
-        ES = ""
         FX = ""
         wxkey = ["工1", "工2", "工3", "工4"]
-        eskey = ["工1", "工2", "工3", "工4"]
         for i in wxkey:
             if dict[i] != "":
                 aa = []
@@ -23,45 +20,22 @@ def get_empNos(database:flightDB,dict:dict):
                 elif bc == "B":
                     aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
                 if len(aa) != 0 and WXempNos == "":
-                   if  aa[0][0] !="":
+                    if aa[0][0] !="":
                         WXempNos = str(aa[0][0])
-                   else:
+                    else:
                        faillist.append(dict[i])
-                elif  len(aa) != 0 and WXempNos != "":
+                elif len(aa) != 0 and WXempNos != "":
                     if aa[0][0] != "":
                         WXempNos =WXempNos+","+str(aa[0][0])
                     else:
                         faillist.append(dict[i])
-                elif len(aa) == 0:
+                else:
                     faillist.append(dict[i])
                 if dict[i] != "" and WX == "":
                     WX=dict[i]
                 elif dict[i] != "" and WX != "":
                     WX=WX+","+dict[i]
 
-        for i in eskey:
-            if dict[i] != "":
-                aa = []
-                if bc == "A":
-                    aa = database.queryTabel("pglist{}".format(date), "工号", "班次='A' and 姓名='%s'" % dict[i])
-                elif bc == "B":
-                    aa = database.queryTabel("pglist{}".format(date), "工号", "班次='B' and 姓名='%s'" % dict[i])
-                if len(aa) != 0 and ESempNos == "":
-                   if  aa[0][0] !="":
-                        ESempNos = str(aa[0][0])
-                   else:
-                       faillist.append(dict[i])
-                elif  len(aa) != 0 and ESempNos != "":
-                    if aa[0][0] != "":
-                        ESempNos =ESempNos+","+str(aa[0][0])
-                    else:
-                        faillist.append(dict[i])
-                elif len(aa) == 0:
-                    faillist.append(dict[i])
-                if dict[i] != "" and ES == "":
-                    ES=dict[i]
-                elif dict[i] != "" and ES != "":
-                    ES=ES+","+dict[i]
 
         if dict["放行"] != "":
             aa = []
@@ -82,12 +56,12 @@ def get_empNos(database:flightDB,dict:dict):
             elif len(aa) == 0:
                 faillist.append(dict["放行"])
             FX=dict["放行"]
-        if WXempNos =="" and FXempNos=="" and ESempNos=="":
-            dict1={"code":"fail","WXempNos":"","FXempNos":"","ESempNos":"","faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
-        elif faillist=="":
-            dict1 = {"code": "ok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
-        elif faillist !="":
-            dict1 = {"code": "justok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": ESempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":ES}
+        if (WXempNos != "" or FXempNos != "") and faillist=="":
+            dict1 = {"code": "ok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": WXempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":WX}
+        elif (WXempNos != "" or FXempNos != "") and faillist !="":
+            dict1 = {"code": "justok", "WXempNos": WXempNos, "FXempNos": FXempNos, "ESempNos": WXempNos, "faillist":faillist,"date":date_str,"bc":bc,"WX":WX,"FX":FX,"ES":WX}
+        else:
+            dict1 = { "code" : "fail" , "WXempNos" : "" , "FXempNos" : "" , "ESempNos" : "" , "faillist" : faillist , "date" : date_str , "bc" : bc , "WX" : WX , "FX" : FX , "ES" : WX }
         return dict1
     except Exception as e:
         app_logger.log_error(e)

+ 1 - 1
Functions/DButilsFunction/infoConfirm.py

@@ -16,7 +16,7 @@ def infoConfirm(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
         peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
         newdic={}
         if len(peopleSchedule_sts) != 0:
-            for i in range(3,9):
+            for i in range(3,8):
                 if "√" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
                     newitem=peopleSchedule_sts[0][i]+"√"
                     newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem

+ 1 - 1
Functions/DButilsFunction/infoConfirm2.py

@@ -18,7 +18,7 @@ def infoConfirm2(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
         peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
         newdic={}
         if len(peopleSchedule_sts) != 0:
-            for i in range(3,9):
+            for i in range(3,8):
                 if "!" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
                     newitem="!"+peopleSchedule_sts[0][i]
                     newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem

+ 1 - 1
Functions/DButilsFunction/infoConfirm3.py

@@ -16,7 +16,7 @@ def infoConfirm3(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
         peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
         newdic={}
         if len(peopleSchedule_sts) != 0:
-            for i in range(3,9):
+            for i in range(3,8):
                 if "*" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
                     newitem=peopleSchedule_sts[0][i]+"*"
                     newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem

+ 22 - 4
Functions/DButilsFunction/postgresql_backup.py

@@ -16,11 +16,18 @@ def postgresql_bakup(bakcup:flightDB,main:flightDB,type):
                    'risktable':get_dic('RiskLabel'),'workerinfo':get_dic('workerinfoLabel'),'pglist%s'%today:get_dic('pglistLabel'),'pglist%s'%yesterday:get_dic('pglistLabel'),
                    'logs':get_dic('logsLabel'),'taskauto':get_dic('taskLabel'),'calllist':get_dic('CalllistLabel'),
                    'flightsts%s'%today:get_dic('flightstsLabel'),'flightsts%s'%yesterday:get_dic('flightstsLabel'),
-                   'logintoken':logintoken_dic,'loginsts':loginsts_dic,'logintable':logintable_dic}
+                   'logintoken':logintoken_dic,'loginsts':loginsts_dic,'logintable':logintable_dic,
+                   "TaskFlightinfo%s"%today:get_dic('TaskflightinfoLabel'),"TaskFlightinfo%s"%yesterday:get_dic('TaskflightinfoLabel'),"TaskFlightinfo%s"%tomorrow:get_dic('TaskflightinfoLabel'),
+                   "flightsearch%s"%today:get_dic('flightsearchLabel'),"flightsearch%s"%yesterday:get_dic('flightsearchLabel'),"flightsearch%s"%tomorrow:get_dic('flightsearchLabel'),
+                   "sortFlight%s"%today:get_dic('sortLabel'),"sortFlight%s"%yesterday:get_dic('sortLabel'),"sortFlight%s"%tomorrow:get_dic('sortLabel'),"display":get_dic('displayLabel'),
+                   }
     if type == 1:
         dbtables=["peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,'risktable',
                   'workerinfo','pglist%s'%today,'pglist%s'%yesterday,'taskauto','calllist',
-                  'flightsts%s'%today,'flightsts%s'%yesterday]#logs太大无法同步
+                  'flightsts%s'%today,'flightsts%s'%yesterday,
+                  "TaskFlightinfo%s"%today,"TaskFlightinfo%s"%yesterday,"TaskFlightinfo%s"%tomorrow,
+                  "flightsearch%s"%today,"flightsearch%s"%yesterday,"flightsearch%s"%tomorrow,
+                  "sortFlight%s"%today,"sortFlight%s"%yesterday,"sortFlight%s"%tomorrow,"display"]#logs太大无法同步
     elif type == 2:
         dbtables=['logintable']
     elif type == 3:
@@ -39,8 +46,19 @@ def postgresql_bakup(bakcup:flightDB,main:flightDB,type):
                 all_source_data=bakcup.getAlldata(dbtable)
                 if len(all_source_data)!=0:
                     main.lazydeleteTable(dbtable)
-                    for row in all_source_data:
-                        main.lazyInsertData2(dbtable,', '.join(table_colmuns[dbtable]),row)
+                    if dbtable=="display":
+                        dispaly_res=main.getSingledata("A", 'display')
+                        if dispaly_res == None or len(dispaly_res) == 0:
+                            main.insertData('display', {'ID': 1, 'A': '{}', 'B': '{}'})
+                            main.insertData('display', {'ID': 2, 'A': '{}', 'B': '{}'})
+                            main.insertData('display', {'ID': 3, 'A': '{}', 'B': '{}'})
+                        for row in all_source_data:
+                            newdic = {"A": '"{}"'.format(row[1]),"B": '"{}"'.format(row[2])}
+                            main.lazyUpdateItem(dbtable, newdic, "ID = '%s'"%row[0])
+                        #online.FunctionCommit()
+                    else:
+                        for row in all_source_data:
+                            main.lazyInsertData2(dbtable,', '.join(table_colmuns[dbtable]),row)
                     main.FunctionCommit()
                 tablesok=tablesok+dbtable+"/"
                 tablenum+=1

+ 3 - 3
Functions/DButilsFunction/postgresql_local.py

@@ -14,17 +14,17 @@ def postgresql_local(local:flightDB,host_online, port_online, user_online, passw
     '''
     table_colmuns={"flightinfo%s"%today:flightinfoLabel,"flightinfo%s"%yesterday:flightinfoLabel,"flightinfo%s"%tomorrow:flightinfoLabel,
                    "peopleschedule%s"%today:peopleScheduleLabel,"peopleschedule%s"%yesterday:peopleScheduleLabel,"peopleschedule%s"%tomorrow:peopleScheduleLabel,
-                   "sortflight%s"%today:sortLabel,"sortflight%s"%yesterday:sortLabel,"sortflight%s"%tomorrow:sortLabel,
+                   "sortFlight%s"%today:sortLabel,"sortFlight%s"%yesterday:sortLabel,"sortFlight%s"%tomorrow:sortLabel,
                    "display":displayLabel}
     '''
     table_colmuns={"TaskFlightinfo%s"%today:get_dic("TaskflightinfoLabel"),"TaskFlightinfo%s"%yesterday:get_dic("TaskflightinfoLabel"),"TaskFlightinfo%s"%tomorrow:get_dic("TaskflightinfoLabel"),
                    "peopleschedule%s"%today:get_dic('peopleScheduleLabel'),"peopleschedule%s"%yesterday:get_dic('peopleScheduleLabel'),"peopleschedule%s"%tomorrow:get_dic('peopleScheduleLabel'),
-                   "sortflight%s"%today:get_dic('sortLabel'),"sortflight%s"%yesterday:get_dic("sortLabel"),"sortflight%s"%tomorrow:get_dic("sortLabel"),
+                   "sortFlight%s"%today:get_dic('sortLabel'),"sortFlight%s"%yesterday:get_dic("sortLabel"),"sortFlight%s"%tomorrow:get_dic("sortLabel"),
                    "display":get_dic("displayLabel"),"flightsearch%s"%today:get_dic("flightsearchLabel"),"flightsearch%s"%yesterday:get_dic("flightsearchLabel"),"flightsearch%s"%tomorrow:get_dic("flightsearchLabel"),}
     dbtables=["TaskFlightinfo%s"%today,"TaskFlightinfo%s"%yesterday,"TaskFlightinfo%s"%tomorrow,
               "peopleschedule%s"%today,"peopleschedule%s"%yesterday,"peopleschedule%s"%tomorrow,
               "flightsearch%s"%today,"flightsearch%s"%yesterday,"flightsearch%s"%tomorrow,
-              "sortflight%s"%today,"sortflight%s"%yesterday,"sortflight%s"%tomorrow,"display"]
+              "sortFlight%s"%today,"sortFlight%s"%yesterday,"sortFlight%s"%tomorrow,"display"]
     try:
         tablesok=""
         tablenum=0

+ 1 - 0
Functions/DataComputer.py

@@ -306,6 +306,7 @@ def mytask():
     nowDay_2 = (datetime.date.today() - datetime.timedelta(days=2)).strftime("%Y%m%d").replace("-", "")
     initFlightDatabase1(nowDay)
     initFlightDatabase1(nowDay_1)
+    initFlightDatabase1(nowDay_2)
 
     alldata=DataDBUtilsgetData("sortFlight%s" % nowDay, "*", "编号 != ''")
     Yalldata=DataDBUtilsgetData("sortFlight%s" % nowDay_1, "*", "编号 != ''")

+ 18 - 7
SeverStart.py

@@ -31,6 +31,8 @@ from Functions.DButilsFunction import flightDB, judge_bc as Judge_bc, initFlight
     calltry as Calltry, callon as Callon,get_empNos_phoone as Get_empNos_phoone,FlightSearchInsert,TaskListInsert,checkWorkerlaod_new,\
     GetPglistInDatabase,Getworkload ,HandoverStsChange,ManCahangeWorkload,UpdateNoteItem,postgresql_bakup
 
+from urllib3.exceptions import InsecureRequestWarning
+requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 
 app = Flask(__name__)
 dir = os.getcwd()
@@ -48,6 +50,9 @@ ServerClas = Server_Class()
 severVersion = "17.0.1"
 displayVersion = "17.0.0"
 print(f"当前客户端版本:{severVersion}/白板版本:{displayVersion}")
+print(f"当前服务器为:【{ServerClas}】")
+print(f"当前服务器航班数据传输模式为:【{flightDataTransfer}】")
+print(f"当前服务器显示计算请求模式为:【{displayDataTransfer}】")
 
 # 获取本地IP地址
 def get_local_ip():
@@ -271,15 +276,20 @@ def postgresql():
         if displayDataTransfer == 1:
             res= DataComputer.mytask()
             if res == "ok":
-                url = "https://"+online_host+":5070/computerDispalydata"
+                url = "https://"+online_host+":7162/computerDispalydata"
+                #url = "https://192.168.2.87:5070/computerDispalydata"
                 try:
-                    ress=requests.get(url, verify=False).json()
-                    #ress=requests.get(url, verify='D:\\flightinfo\\DATABASE\\secret.pem').json()
-                    if ress == "ok":
+                    ress=requests.get(url, verify=False)
+                    ress.raise_for_status()  # 检查HTTP状态码是否为成功
+                    data = ress.json()
+                    #ress=requests.post(url, cert=('D:\\flightinfo\\DATABASE\\sichuanair.com.pem','D:\\flightinfo\\DATABASE\\sichuanair.com.key')).json()
+                    if data == "ok":
+                    #if data.get("result") == "ok":
                         print(datetime.datetime.now(), "远端显示中心计算请求成功")
                     else:
                         print(datetime.datetime.now(), "[返回为fail]远端显示中心计算请求失败")
-                except:
+                except Exception as e:
+                    print(e)
                     print(datetime.datetime.now(), "[请求被拒绝]远端显示中心计算请求失败")
         return "ok"
     except:
@@ -1214,9 +1224,9 @@ def get_dic():
     remote_addr = request.remote_addr
     data = json.loads(request.get_data())
     fdb = flightDB(host=dbhost,port=dbport,user=dbuser,password=dbpassword,database=databaseDB4)
-    Get_dic(fdb,data["fileName"])
+    ress=Get_dic(fdb,data["fileName"])
     fdb.close()
-    res = {"返回值": "ok"}
+    res = {"返回值": ress}
     print(datetime.datetime.now(),"[%s]获取人员信息EXCEL表格"%remote_addr)
     return res
 @app.route('/static/handovechange',methods=["GET","POST"])
@@ -1356,6 +1366,7 @@ def init():
     fl = utils.flight_list()
     si = ipcall.searchinfo()
     loaclseverip = get_local_ip()
+    print(f"当前服务器IP:{loaclseverip}")
     singlePeopleNotice = initialize_file('D:\\flightinfo\\DATABASE\\singlepoeple_notice.txt',False)
 if __name__ == '__main__':
     serve(app, host='0.0.0.0',port=7162, threads=20)

+ 1 - 1
templates/index.html

@@ -138,7 +138,7 @@
               var table
               var loginsts
               setInterval("backupdata()",300000)
-              setInterval("postgresql()",300000)
+              setInterval("postgresql()",60000)
               setInterval("getflightdata()",30000)
               setInterval("updatatable()",60000)