checkFlightAlert.py 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. from .flightDB import flightDB
  2. import datetime
  3. from unitls.LogerinTxt import app_logger
  4. import unitls.baseFunction as baseFunction
  5. from unitls.StaticDataclass import get_dic
  6. from unitls.settings import MesgTime
  7. APZBZ, JJZBZ, ESZBZ, APGR, JJGR, ESGR,APPG,JJPG,ESPG=MesgTime()
  8. def WarningInsert(database, taskid, mesg, types):
  9. newdic = {"航班编号": "%s" % taskid, "警告信息": mesg, "信息状态": "",
  10. "提示信息": "", "产生时间": "%s" % datetime.datetime.now(), "处理人": "", "处理时间": "", "变更字段": types, "显示对象": "", "提示内容": ""}
  11. database.lazyInsertData('logs', newdic)
  12. def noteInsert(database, taskid, mesg, types):
  13. newdic = {"航班编号": "%s" % taskid, "警告信息": '', "信息状态": "",
  14. "提示信息": mesg, "产生时间": "%s" % datetime.datetime.now(), "处理人": "", "处理时间": "", "变更字段": types, "显示对象": "", "提示内容": ""}
  15. database.lazyInsertData('logs', newdic)
  16. def judgeFunction(datas,key,numb): #numb 警告时间间隔
  17. now=datetime.datetime.now()
  18. time_str = baseFunction.TuplefindInList3(datas, key, 8, 5) #变更字段为key的最近的一次时间
  19. if time_str == "":
  20. time1 = now - datetime.timedelta(minutes=numb)
  21. else:
  22. time1 = datetime.datetime.strptime(time_str.split(".")[0], "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=numb)
  23. if now > time1:
  24. return True
  25. else:
  26. return False
  27. def getpeopleinfo(names,data,data1):
  28. res = []
  29. success = []
  30. fail = []
  31. names = names.replace("√","")
  32. names_list = names.split(",")
  33. for name in names_list:
  34. worknum = baseFunction.TuplefindInList3(data, name, 0, 1) if data else ""
  35. if worknum == "":
  36. worknum=baseFunction.TuplefindInList3(data1, name, 0, 1)
  37. if worknum != "":
  38. res.append(worknum)
  39. success.append(name)
  40. else:
  41. fail.append(name)
  42. #int("success",success)
  43. #print("fail",fail)
  44. #print("res",res)
  45. return {"success":success,"fail":fail,"worknums":res}
  46. def checkFlightAlert(database:flightDB, singlePeopleNotice):
  47. try:
  48. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  49. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  50. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  51. now = datetime.datetime.now()
  52. now_20=(datetime.datetime.now()+ datetime.timedelta(minutes=120)).strftime("%Y%m%d")
  53. if now_20 == nowDay:
  54. day=[nowDay,nowDay_1]
  55. else:
  56. day = [nowDay,nowDay_1,nowDay_2]
  57. for nowDayStr in day:
  58. flightcheck=database.queryTabel("sortFlight{}".format(nowDayStr),"航班编号","CAST(级别 AS integer) = 1" )
  59. flightcheck2 = database.queryTabel("sortFlight{}".format(nowDayStr), "航班编号", "CAST(级别 AS integer) != 4")
  60. datas=database.queryTabel("TaskFlightinfo{}".format(nowDayStr),"*","航班编号 !=''")
  61. flightsts=database.queryTabel("flightsts{}".format(nowDayStr),"*","航班编号 !=''")
  62. logs=database.queryTabel("logs","*","处理时间= '' and 警告信息 !=''")
  63. logsall=database.queryTabel("logs","*","警告信息 !=''")
  64. logsall1=database.sort_queryTable("*","logs", "提示信息 !=''", "产生时间", "desc") #所有提示信息
  65. peopleschedule=database.queryTabel("peopleSchedule{}".format(nowDayStr),"*","航班编号 !=''")
  66. peoplesinfo_today=database.queryTabel("pglist{}".format(nowDay),"*","姓名!=''")
  67. peoplesinfo_yes=database.queryTabel("pglist{}".format(nowDay_1),"*","姓名!=''")
  68. if datas and flightcheck:
  69. for i in flightcheck:
  70. data=baseFunction.TuplefindInList1(datas, i[0], 0)
  71. if data and data[0][3] != "停场":
  72. a = data[0][1]
  73. b = get_dic("taskType")[data[0][3]]
  74. std=data[0][5]
  75. singlelogs=baseFunction.TuplefindInList33(logs,i[0],1,8)#未处理的警告信息
  76. singlelogstext=baseFunction.TuplefindInList33(logs,i[0],1,2)#未处理的警告信息
  77. singlelogsall=baseFunction.TuplefindInList33(logsall, i[0], 1, 2) #所有警告信息
  78. singlelogsall1=baseFunction.TuplefindInList11(logsall1, i[0], 1) #所有和这个id相关的提示信息
  79. jjdw=baseFunction.TuplefindInList3(flightsts,i[0],0,3)
  80. fx=baseFunction.TuplefindInList3(flightsts,i[0],0,4)
  81. eta=data[0][8]
  82. flying=data[0][30]
  83. BAY_A=data[0][10]#进港机位
  84. wxry=data[0][12]
  85. fxry=data[0][13]
  86. ecsj=data[0][19]
  87. fj=baseFunction.TuplefindInList3(peopleschedule, i[0], 1, 9)
  88. #航前90min 检查到位情况,推送准备组,推送个人没2min,直到点击到位
  89. #起飞前40min 检查放行情况,推送个人,3min间隔,起飞前30min推送准备组,直到放行点击
  90. #起飞前50min 检查销子夹板取下情况,推送个人,3min间隔,起飞前40min推送准备组,直到上报销子夹板
  91. if b == "航前":
  92. c = baseFunction.TuplefindInList3(datas, i[0], 0, 11)
  93. else:
  94. c = baseFunction.TuplefindInList3(datas, i[0], 0, 10)
  95. if b == "航前" and std != "":
  96. STD_90 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=90)
  97. STD_50 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=50)
  98. STD_40 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=40)
  99. STD_30 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=30)
  100. if STD_90 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  101. WarningInsert(database,i[0],"请确认%s/%s/%s到位情况!"%(a,b,c),"到位警告")
  102. if STD_90 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  103. print(datetime.datetime.now(),"航前推送个人到位信息") ###要加维修人员是否为空
  104. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  105. noteInsert(database,i[0],"%s/%s/%s航前推送个人到位信息"%(a,b,c),"到位个人提示推送")
  106. if STD_30 < now and "已放行" not in str(fx) and "放行警告" not in str(singlelogs):
  107. WarningInsert(database,i[0],"请确认%s/%s/%s放行情况!"%(a,b,c),"放行警告")
  108. if STD_40 < now and "已放行" not in str(fx) and judgeFunction(singlelogsall1,"放行个人提示推送",3) and singlePeopleNotice and "【交班航班】" not in fj:
  109. print(datetime.datetime.now(),"航前推送放行确认信息")
  110. getpeopleinfo(fxry, peoplesinfo_today, peoplesinfo_yes)
  111. noteInsert(database,i[0],"%s/%s/%s航前推送放行确认信息"%(a,b,c),"放行个人提示推送")
  112. if STD_40 < now and "已取下" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,5)) and "销夹警告" not in str(singlelogs):
  113. WarningInsert(database,i[0],"请确认%s/%s/%s销夹取下情况!"%(a,b,c), "销夹警告")
  114. if STD_50 < now and "已取下" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,5)) and judgeFunction(singlelogsall1,"销夹个人提示推送",3) and singlePeopleNotice and "【交班航班】" not in fj:
  115. print(datetime.datetime.now(),"航前推送销夹取下信息")
  116. noteInsert(database,i[0],"%s/%s/%s航前推送销夹取下信息"%(a,b,c),"销夹个人提示推送")
  117. # 航后15min 检查到位情况,推送准备组,推送个人每2min,直到点击到位
  118. elif b == "航后" and eta != "" and flying != "":
  119. ETA_15_str = eta
  120. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 15)
  121. ETA_40 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 55)
  122. ETA = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")
  123. NXTSTD = datetime.datetime.strptime(data[0][32], "%Y-%m-%d %H:%M:%S") if data[0][32] != "" else ""
  124. if NXTSTD != "" and abs((NXTSTD-ETA).total_seconds()) < 3 * 3600:
  125. WarningInsert(database, i[0], "%s/%s/%s预计落地和预计起飞时间相差小于3H,请结合手册判断是否符合特后前签署条件,如需签署特后前注意通报72!"%(a, b, c), "到位警告")
  126. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  127. WarningInsert(database, i[0], "请确认%s/%s/%s到位情况!"%(a, b, c), "到位警告")
  128. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  129. print(datetime.datetime.now(),"航后推送个人到位信息")
  130. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  131. noteInsert(database,i[0],"%s/%s/%s航后推送个人到位信息"%(a,b,c),"到位个人提示推送")
  132. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  133. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  134. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  135. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  136. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  137. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  138. # 短停15min 检查到位情况,推送准备组,推送个人每2min,直到点击到位
  139. # 短停落地30min,且满足距离起飞时间小于50min检查放行情况,推送个人,3min间隔,落地30min,且满足距离起飞时间小于40min,推送准备组,直到点击放行
  140. # 短停落地25min,且满足距离起飞时间小于25min,推送个人,2min间隔,落地30min,且满足距离起飞时间小于25min,推送准备组,直到点击二送到位
  141. elif b == "短停" and eta != "" and flying != "":
  142. ETA_15_str=eta
  143. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  144. ETA_40 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=55)
  145. ATA = baseFunction.TuplefindInList3(datas, i[0], 0, 6)
  146. if ATA != "":
  147. ATA_time_25 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=25)
  148. ATA_time_30 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  149. ATA_time_3H = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S")+datetime.timedelta(minutes=180)
  150. else:
  151. ATA_time_30 = ""
  152. ATA_time_25 = ""
  153. ATA_time_3H = ""
  154. TD = std
  155. TD_time_50 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=50)
  156. TD_time_40 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=40)
  157. TD_time_25 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=25)
  158. TD_time_120 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  159. TD_time = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")
  160. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  161. WarningInsert(database,i[0],"请确认%s/%s/%s到位情况!"%(a,b,c),"到位警告")
  162. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  163. print(datetime.datetime.now(),"短停推送个人到位信息")
  164. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  165. noteInsert(database,i[0],"%s/%s/%s短停推送个人到位信息"%(a,b,c),"到位个人提示推送")
  166. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_40 < now and "已放行" not in str(fx) and "放行警告" not in str(singlelogs):
  167. WarningInsert(database,i[0],"请确认%s/%s/%s放行情况!"%(a,b,c), "放行警告")
  168. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_50 < now and "已放行" not in str(fx) and judgeFunction(singlelogsall1,"放行个人提示推送",3) and singlePeopleNotice and "【交班航班】" not in fj:
  169. print(datetime.datetime.now(),"短停放行个人提示推送")
  170. getpeopleinfo(fxry,peoplesinfo_today,peoplesinfo_yes)
  171. noteInsert(database,i[0],"%s/%s/%s短停放行个人提示推送"%(a,b,c),"放行个人提示推送")
  172. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已到位" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,7)) and "二送警告" not in str(singlelogs):
  173. WarningInsert(database,i[0],"请确认%s/%s/%s二送到位情况!"%(a,b,c), "二送警告")
  174. if ATA_time_25 != "" and ATA_time_25 < now and TD_time_25 < now and "已到位" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,7)) and judgeFunction(singlelogsall1,"二送到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  175. print(datetime.datetime.now(),"短停二送到位个人提示推送")
  176. getpeopleinfo(ecsj,peoplesinfo_today,peoplesinfo_yes)
  177. noteInsert(database,i[0],"%s/%s/%s短停二送到位个人提示推送"%(a,b,c),"二送到位个人提示推送")
  178. if ATA_time_3H !="" and ATA_time_3H < TD_time and TD_time_120 < now and "长短停到位提示" not in str(baseFunction.TuplefindInList33(logsall, i[0], 1, 8)):
  179. WarningInsert(database,i[0],"请确认安排%s/%s/%s长短停上电人员!" % (a, b, c),"长短停到位提示")
  180. if ATA_time_3H !="" and ATA_time_3H < TD_time and "长短停值守提示" not in str(baseFunction.TuplefindInList33(logsall, i[0], 1, 8)):
  181. WarningInsert(database,i[0],"请注意安排%s %s长短停值守,如无需则忽略!" % (a,c),"长短停值守提示")
  182. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  183. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  184. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  185. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  186. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  187. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  188. # 特后前15min 检查到位情况,推送准备组,推送个人每2min,直到点击到位
  189. # 特后前落地30min,且满足距离起飞时间小于50min检查放行情况,推送个人,3min间隔,落地30min,且满足距离起飞时间小于40min,推送准备组,直到点击放行
  190. # 特后前落地25min,且满足距离起飞时间小于25min,推送个人,2min间隔,落地30min,且满足距离起飞时间小于25min,推送准备组,直到点击二送到位
  191. elif b!="短停" and b!="航后" and b!="航前" and b!="未显示" and eta != "":
  192. ETA_15_str = eta
  193. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes = 15)
  194. ETA_40 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes = 55)
  195. ATA = baseFunction.TuplefindInList3(datas, i[0], 0, 6)
  196. if ATA!= "":
  197. ATA_time_25 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=25)
  198. ATA_time_30 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  199. else:
  200. ATA_time_25=""
  201. ATA_time_30 = ""
  202. TD = std
  203. TD_time_50 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=50)
  204. TD_time_40 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=40)
  205. TD_time_25 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=25)
  206. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  207. WarningInsert(database,i[0],"请确认%s/%s/%s到位情况!"%(a,b,c),"到位警告")
  208. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  209. print(datetime.datetime.now(),"短停推送个人到位信息")
  210. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  211. noteInsert(database,i[0],"%s/%s/%s短停推送个人到位信息"%(a,b,c),"到位个人提示推送")
  212. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_40 < now and "已放行" not in str(fx) and "放行警告" not in str(singlelogs):
  213. WarningInsert(database,i[0],"请确认%s/%s/%s放行情况!"%(a,b,c),"放行警告")
  214. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_50 < now and "已放行" not in str(fx) and judgeFunction(singlelogsall1,"放行个人提示推送",3) and singlePeopleNotice and "【交班航班】" not in fj:
  215. print(datetime.datetime.now(),"短停放行个人提示推送")
  216. getpeopleinfo(fxry,peoplesinfo_today,peoplesinfo_yes)
  217. noteInsert(database,i[0],"%s/%s/%s短停放行个人提示推送"%(a,b,c),"放行个人提示推送")
  218. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_25 < now and "已到位" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,7)) and "二送警告" not in str(singlelogs):
  219. WarningInsert(database,i[0],"请确认%s/%s/%s二送到位情况!"%(a,b,c), "二送警告")
  220. if ATA_time_25 != "" and ATA_time_25 < now and TD_time_25 < now and "已到位" not in str(baseFunction.TuplefindInList3(flightsts,i[0],0,7)) and judgeFunction(singlelogsall1,"二送到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  221. print(datetime.datetime.now(),"短停二送到位个人提示推送")
  222. getpeopleinfo(ecsj,peoplesinfo_today,peoplesinfo_yes)
  223. noteInsert(database,i[0],"%s/%s/%s短停二送到位个人提示推送"%(a,b,c),"二送到位个人提示推送")
  224. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  225. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  226. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  227. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  228. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  229. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  230. #航前 起飞前 100min,没有确认任务,推送准备组, 二送起飞前40min没有确认任务推送准备组 105 和 45 min 2min 个人推送一次?
  231. #短停 特后前 预计到达前40min没有确认任务推送准备组,短停特后前 预计起飞前40min没有确认任务推送准备组 45min 2min 个人推送一次?
  232. #航后 预计到达前40min没有确认任务推送准备组 45min 2min 个人推送一次?
  233. if b == "航前":
  234. bztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APZBZ)
  235. esbztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESZBZ)
  236. bztztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APGR)
  237. estzbztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESGR)
  238. pgtime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APPG)
  239. espgtime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  240. elif b == "短停":
  241. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)#40
  242. esbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESZBZ)#40
  243. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  244. estzbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESGR)#45通知
  245. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  246. espgtime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  247. elif b == "特后前":
  248. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)
  249. esbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESZBZ)
  250. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  251. estzbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESGR)
  252. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  253. espgtime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  254. else:
  255. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)
  256. esbztime=""
  257. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  258. estzbztime=""
  259. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  260. espgtime=""
  261. if (wxry != "" or fxry != "") and bztztime < now and judgeFunction(singlelogsall1,"航前或接机任务接送通知",2) and singlePeopleNotice and "【交班航班】" not in fj:
  262. peoples = ""
  263. res = wxry.split(",") + fxry.split(",")
  264. for l in res:
  265. if "√" not in l:
  266. peoples=peoples+","+l if peoples != "" else l
  267. if peoples != "":
  268. getpeopleinfo(peoples,peoplesinfo_today,peoplesinfo_yes)
  269. print(datetime.datetime.now(),"航前或接机任务接送通知")
  270. noteInsert(database,i[0],"%s/%s/%s航前或接机任务接送通知"%(a,b,c),"航前或接机任务接送通知")
  271. if (wxry != "" or fxry != "") and bztime < now:
  272. res = wxry.split(",")+fxry.split(",")
  273. for l in res:
  274. if "√" not in l:
  275. mesg = "请确认%s/%s/%s/%s人员任务接收情况!" % (a, b, c, l)
  276. if mesg not in str(singlelogsall):
  277. WarningInsert(database, i[0], mesg, "任务接收监控")
  278. else:
  279. mesg = "请确认%s/%s/%s/%s人员任务接收情况!" % (a, b, c, l.replace("√",""))
  280. if mesg in str(singlelogstext):
  281. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  282. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  283. if ecsj != "" and estzbztime != "" and estzbztime < now and judgeFunction(singlelogsall1,"航前或接机任务接送通知",2) and singlePeopleNotice and "【交班航班】" not in fj:
  284. peoples = ""
  285. res = ecsj.split(",")
  286. for l in res:
  287. if "√" not in l:
  288. peoples = peoples + "," + l if peoples != "" else l
  289. if peoples != "":
  290. getpeopleinfo(peoples, peoplesinfo_today, peoplesinfo_yes)
  291. print(datetime.datetime.now(), "二送任务接送通知")
  292. noteInsert(database, i[0], "%s/%s/%s二送任务接送通知" % (a, b, c), "二送任务接送通知")
  293. if ecsj != "" and esbztime != "" and esbztime < now: #and "任务执行情况" not in str(singlelogsall):
  294. res = ecsj.split(",")
  295. for l in res:
  296. if "√" not in l:
  297. mesg = "请确认%s/%s/%s/%s人员二送任务接收情况!" % (a, b, c, l)
  298. if mesg not in str(singlelogsall):
  299. WarningInsert(database, i[0], mesg, "任务接收监控")
  300. else:
  301. mesg = "请确认%s/%s/%s/%s人员二送任务接收情况!" % (a, b, c, l.replace("√",""))
  302. if mesg in str(singlelogstext):
  303. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  304. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  305. if wxry == "" and pgtime < now:
  306. mesg = "请及时安排%s/%s/%s保障人员并派工!" % (a, b, c)
  307. if mesg not in str(singlelogsall):
  308. WarningInsert(database, i[0], mesg, "任务安排监控")
  309. elif wxry != "":
  310. mesg = "请及时安排%s/%s/%s保障人员并派工!" % (a, b, c)
  311. if mesg in str(singlelogstext):
  312. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  313. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  314. if fxry == "" and pgtime < now:
  315. mesg = "请及时安排%s/%s/%s放行人员并派工!" % (a, b, c)
  316. if mesg not in str(singlelogsall):
  317. WarningInsert(database, i[0], mesg, "任务安排监控")
  318. elif fxry != "":
  319. mesg = "请及时安排%s/%s/%s放行人员并派工!" % (a, b, c)
  320. if mesg in str(singlelogstext):
  321. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  322. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  323. if ecsj == "" and b != "航前" and espgtime != "" and espgtime < now:
  324. mesg = "请及时安排%s/%s/%s二送保障人员并派工!" % (a, b, c)
  325. if mesg not in str(singlelogsall):
  326. WarningInsert(database, i[0], mesg, "任务安排监控")
  327. elif ecsj != "" and b != "航前" :
  328. mesg = "请及时安排%s/%s/%s二送保障人员并派工!" % (a, b, c)
  329. if mesg in str(singlelogstext):
  330. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  331. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  332. for i in flightcheck2:
  333. data2 = baseFunction.TuplefindInList1(datas, i[0], 0)
  334. if data2 and data2[0][3] != "停场":
  335. a = data2[0][1]
  336. b = get_dic("taskType")[data2[0][3]]
  337. std= data2[0][5]
  338. fj=baseFunction.TuplefindInList3(peopleschedule, i[0], 1, 9)
  339. sjry_str = data2[0][15]
  340. flightno = data2[0][21]
  341. singlelogsall=baseFunction.TuplefindInList33(logsall, i[0], 1, 2) #所有警告信息
  342. singlelogs=baseFunction.TuplefindInList33(logs, i[0], 1, 2) #未确认所有警告信息
  343. sjdw=baseFunction.TuplefindInList3(flightsts, i[0], 0, 6)
  344. if b == "航前":
  345. c = data2[0][11]
  346. else:
  347. c = data2[0][10]
  348. if b=="航前" and std != "":
  349. STD = std
  350. STD_120 = datetime.datetime.strptime(STD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 120)
  351. STD_60 = datetime.datetime.strptime(STD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 60)
  352. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and STD_120 < now:
  353. sjry = sjry_str.split(" ")[1]
  354. WarningInsert(database, i[0], "[随机2H提醒]%s/%s/%s/%s"% (a, flightno, c, sjry),"随机2H提醒")
  355. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and STD_60 < now and "已到位" not in str(sjdw):
  356. sjry = sjry_str.split("随机离港 ")[1]
  357. WarningInsert(database, i[0], "[随机到位确认]%s/%s/%s/%s"% (a, flightno, c, sjry),"随机到位警告")
  358. elif b=="短停" :
  359. TD = std
  360. TD_time_120 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  361. TD_time_60 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=60)
  362. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and TD_time_120 < now and sjry_str != "":
  363. sjry = sjry_str.split(" ")[1]
  364. WarningInsert(database,i[0],"[随机2H提醒]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机2H提醒")
  365. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and TD_time_60 < now and "已到位" not in str(sjdw):
  366. sjry = sjry_str.split(" ")[1]
  367. WarningInsert(database,i[0], "[随机到位确认]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机到位警告")
  368. elif b != "短停" and b != "航后" and b != "航前" and b != "未显示" and b != "停场" :
  369. TD_time_120= datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  370. TD_time_60 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=60)
  371. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and TD_time_120 < now:
  372. sjry=sjry_str.split(" ")[1]
  373. WarningInsert(database,i[0],"[随机2H提醒]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机2H提醒")
  374. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and TD_time_60 < now and "已到位" not in str(sjdw):
  375. sjry=sjry_str.split("随机离港 ")[1]
  376. WarningInsert(database,i[0],"[随机到位确认]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机到位警告")
  377. database.FunctionCommit()
  378. waringIDs=database.queryTabel('logs',"*","变更字段 like '%警告%' and 处理时间 =''")
  379. flightstsids=database.getSingledata("航班编号",'flightsts{}'.format(nowDayStr))
  380. for waringID in waringIDs:
  381. if str(waringID[1]) in str(flightstsids):
  382. waringIDstsNow=database.queryTabel('flightsts{}'.format(nowDayStr),"*","航班编号 ='%s'"%waringID[1])
  383. if waringID[8] == "到位警告" and waringIDstsNow[0][3] == "已到位":
  384. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  385. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  386. if waringID[8] == "放行警告" and waringIDstsNow[0][4] == "已放行":
  387. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  388. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  389. if waringID[8] == "二送警告" and waringIDstsNow[0][7] == "已到位":
  390. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  391. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  392. if waringID[8] == "销夹警告" and waringIDstsNow[0][5] == "已取下":
  393. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  394. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  395. if waringID[8] == "随机到位警告" and waringIDstsNow[0][6] == "已到位":
  396. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  397. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  398. database.FunctionCommit()
  399. except Exception as e:
  400. database.FunctionCommit()
  401. app_logger.log_error(e)