checkFlightAlert.py 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  123. WarningInsert(database, i[0], "请确认%s/%s/%s到位情况!"%(a, b, c), "到位警告")
  124. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  125. print(datetime.datetime.now(),"航后推送个人到位信息")
  126. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  127. noteInsert(database,i[0],"%s/%s/%s航后推送个人到位信息"%(a,b,c),"到位个人提示推送")
  128. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  129. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  130. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  131. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  132. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  133. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  134. # 短停15min 检查到位情况,推送准备组,推送个人每2min,直到点击到位
  135. # 短停落地30min,且满足距离起飞时间小于50min检查放行情况,推送个人,3min间隔,落地30min,且满足距离起飞时间小于40min,推送准备组,直到点击放行
  136. # 短停落地25min,且满足距离起飞时间小于25min,推送个人,2min间隔,落地30min,且满足距离起飞时间小于25min,推送准备组,直到点击二送到位
  137. elif b == "短停" and eta != "" and flying != "":
  138. ETA_15_str=eta
  139. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=15)
  140. ETA_40 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=55)
  141. ATA = baseFunction.TuplefindInList3(datas, i[0], 0, 6)
  142. if ATA != "":
  143. ATA_time_25 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=25)
  144. ATA_time_30 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  145. ATA_time_3H = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S")+datetime.timedelta(minutes=180)
  146. else:
  147. ATA_time_30 = ""
  148. ATA_time_25 = ""
  149. ATA_time_3H = ""
  150. TD = std
  151. TD_time_50 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=50)
  152. TD_time_40 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=40)
  153. TD_time_25 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=25)
  154. TD_time_120 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  155. TD_time = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")
  156. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  157. WarningInsert(database,i[0],"请确认%s/%s/%s到位情况!"%(a,b,c),"到位警告")
  158. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  159. print(datetime.datetime.now(),"短停推送个人到位信息")
  160. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  161. noteInsert(database,i[0],"%s/%s/%s短停推送个人到位信息"%(a,b,c),"到位个人提示推送")
  162. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_40 < now and "已放行" not in str(fx) and "放行警告" not in str(singlelogs):
  163. WarningInsert(database,i[0],"请确认%s/%s/%s放行情况!"%(a,b,c), "放行警告")
  164. 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:
  165. print(datetime.datetime.now(),"短停放行个人提示推送")
  166. getpeopleinfo(fxry,peoplesinfo_today,peoplesinfo_yes)
  167. noteInsert(database,i[0],"%s/%s/%s短停放行个人提示推送"%(a,b,c),"放行个人提示推送")
  168. 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):
  169. WarningInsert(database,i[0],"请确认%s/%s/%s二送到位情况!"%(a,b,c), "二送警告")
  170. 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:
  171. print(datetime.datetime.now(),"短停二送到位个人提示推送")
  172. getpeopleinfo(ecsj,peoplesinfo_today,peoplesinfo_yes)
  173. noteInsert(database,i[0],"%s/%s/%s短停二送到位个人提示推送"%(a,b,c),"二送到位个人提示推送")
  174. 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)):
  175. WarningInsert(database,i[0],"请确认安排%s/%s/%s长短停上电人员!" % (a, b, c),"长短停到位提示")
  176. if ATA_time_3H !="" and ATA_time_3H < TD_time and "长短停值守提示" not in str(baseFunction.TuplefindInList33(logsall, i[0], 1, 8)):
  177. WarningInsert(database,i[0],"请注意安排%s %s长短停值守,如无需则忽略!" % (a,c),"长短停值守提示")
  178. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  179. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  180. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  181. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  182. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  183. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  184. # 特后前15min 检查到位情况,推送准备组,推送个人每2min,直到点击到位
  185. # 特后前落地30min,且满足距离起飞时间小于50min检查放行情况,推送个人,3min间隔,落地30min,且满足距离起飞时间小于40min,推送准备组,直到点击放行
  186. # 特后前落地25min,且满足距离起飞时间小于25min,推送个人,2min间隔,落地30min,且满足距离起飞时间小于25min,推送准备组,直到点击二送到位
  187. elif b!="短停" and b!="航后" and b!="航前" and b!="未显示" and eta != "":
  188. ETA_15_str = eta
  189. ETA_15 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes = 15)
  190. ETA_40 = datetime.datetime.strptime(ETA_15_str, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes = 55)
  191. ATA = baseFunction.TuplefindInList3(datas, i[0], 0, 6)
  192. if ATA!= "":
  193. ATA_time_25 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=25)
  194. ATA_time_30 = datetime.datetime.strptime(ATA, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(minutes=30)
  195. else:
  196. ATA_time_25=""
  197. ATA_time_30 = ""
  198. TD = std
  199. TD_time_50 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S")- datetime.timedelta(minutes=50)
  200. TD_time_40 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=40)
  201. TD_time_25 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=25)
  202. if ETA_15 < now and "已到位" not in str(jjdw) and "到位警告" not in str(singlelogs):
  203. WarningInsert(database,i[0],"请确认%s/%s/%s到位情况!"%(a,b,c),"到位警告")
  204. if ETA_15 < now and "已到位" not in str(jjdw) and judgeFunction(singlelogsall1,"到位个人提示推送",2) and singlePeopleNotice and "【交班航班】" not in fj:
  205. print(datetime.datetime.now(),"短停推送个人到位信息")
  206. getpeopleinfo(wxry,peoplesinfo_today,peoplesinfo_yes)
  207. noteInsert(database,i[0],"%s/%s/%s短停推送个人到位信息"%(a,b,c),"到位个人提示推送")
  208. if ATA_time_30 != "" and ATA_time_30 < now and TD_time_40 < now and "已放行" not in str(fx) and "放行警告" not in str(singlelogs):
  209. WarningInsert(database,i[0],"请确认%s/%s/%s放行情况!"%(a,b,c),"放行警告")
  210. 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:
  211. print(datetime.datetime.now(),"短停放行个人提示推送")
  212. getpeopleinfo(fxry,peoplesinfo_today,peoplesinfo_yes)
  213. noteInsert(database,i[0],"%s/%s/%s短停放行个人提示推送"%(a,b,c),"放行个人提示推送")
  214. 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):
  215. WarningInsert(database,i[0],"请确认%s/%s/%s二送到位情况!"%(a,b,c), "二送警告")
  216. 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:
  217. print(datetime.datetime.now(),"短停二送到位个人提示推送")
  218. getpeopleinfo(ecsj,peoplesinfo_today,peoplesinfo_yes)
  219. noteInsert(database,i[0],"%s/%s/%s短停二送到位个人提示推送"%(a,b,c),"二送到位个人提示推送")
  220. if ETA_40 < now and BAY_A == "" and "机位未出提醒" not in str(singlelogsall):
  221. WarningInsert(database,i[0],"[机位未出提醒]请确认%s/%s机位情况!"%(a,b),"机位警告")
  222. elif BAY_A != "" and "机位未出提醒" in str(singlelogstext):
  223. mesg="[机位未出提醒]请确认%s/%s机位情况!"%(a,b)
  224. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  225. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  226. #航前 起飞前 100min,没有确认任务,推送准备组, 二送起飞前40min没有确认任务推送准备组 105 和 45 min 2min 个人推送一次?
  227. #短停 特后前 预计到达前40min没有确认任务推送准备组,短停特后前 预计起飞前40min没有确认任务推送准备组 45min 2min 个人推送一次?
  228. #航后 预计到达前40min没有确认任务推送准备组 45min 2min 个人推送一次?
  229. if b == "航前":
  230. bztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APZBZ)
  231. esbztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESZBZ)
  232. bztztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APGR)
  233. estzbztime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESGR)
  234. pgtime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=APPG)
  235. espgtime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  236. elif b == "短停":
  237. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)#40
  238. esbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESZBZ)#40
  239. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  240. estzbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESGR)#45通知
  241. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  242. espgtime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  243. elif b == "特后前":
  244. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)
  245. esbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESZBZ)
  246. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  247. estzbztime = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=ESGR)
  248. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  249. espgtime=datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=ESPG)
  250. else:
  251. bztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJZBZ)
  252. esbztime=""
  253. bztztime=datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJGR)
  254. estzbztime=""
  255. pgtime = datetime.datetime.strptime(eta, "%Y-%m-%d %H:%M:%S")-datetime.timedelta(minutes=JJPG)
  256. espgtime=""
  257. if (wxry != "" or fxry != "") and bztztime < now and judgeFunction(singlelogsall1,"航前或接机任务接送通知",2) and singlePeopleNotice and "【交班航班】" not in fj:
  258. peoples = ""
  259. res = wxry.split(",") + fxry.split(",")
  260. for l in res:
  261. if "√" not in l:
  262. peoples=peoples+","+l if peoples != "" else l
  263. if peoples != "":
  264. getpeopleinfo(peoples,peoplesinfo_today,peoplesinfo_yes)
  265. print(datetime.datetime.now(),"航前或接机任务接送通知")
  266. noteInsert(database,i[0],"%s/%s/%s航前或接机任务接送通知"%(a,b,c),"航前或接机任务接送通知")
  267. if (wxry != "" or fxry != "") and bztime < now:
  268. res = wxry.split(",")+fxry.split(",")
  269. for l in res:
  270. if "√" not in l:
  271. mesg = "请确认%s/%s/%s/%s人员任务接收情况!" % (a, b, c, l)
  272. if mesg not in str(singlelogsall):
  273. WarningInsert(database, i[0], mesg, "任务接收监控")
  274. else:
  275. mesg = "请确认%s/%s/%s/%s人员任务接收情况!" % (a, b, c, l.replace("√",""))
  276. if mesg in str(singlelogstext):
  277. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  278. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  279. if ecsj != "" and estzbztime != "" and estzbztime < now and judgeFunction(singlelogsall1,"航前或接机任务接送通知",2) and singlePeopleNotice and "【交班航班】" not in fj:
  280. peoples = ""
  281. res = ecsj.split(",")
  282. for l in res:
  283. if "√" not in l:
  284. peoples = peoples + "," + l if peoples != "" else l
  285. if peoples != "":
  286. getpeopleinfo(peoples, peoplesinfo_today, peoplesinfo_yes)
  287. print(datetime.datetime.now(), "二送任务接送通知")
  288. noteInsert(database, i[0], "%s/%s/%s二送任务接送通知" % (a, b, c), "二送任务接送通知")
  289. if ecsj != "" and esbztime != "" and esbztime < now: #and "任务执行情况" not in str(singlelogsall):
  290. res = ecsj.split(",")
  291. for l in res:
  292. if "√" not in l:
  293. mesg = "请确认%s/%s/%s/%s人员二送任务接收情况!" % (a, b, c, l)
  294. if mesg not in str(singlelogsall):
  295. WarningInsert(database, i[0], mesg, "任务接收监控")
  296. else:
  297. mesg = "请确认%s/%s/%s/%s人员二送任务接收情况!" % (a, b, c, l.replace("√",""))
  298. if mesg in str(singlelogstext):
  299. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  300. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  301. if wxry == "" and pgtime < now:
  302. mesg = "请及时安排%s/%s/%s保障人员并派工!" % (a, b, c)
  303. if mesg not in str(singlelogsall):
  304. WarningInsert(database, i[0], mesg, "任务安排监控")
  305. elif wxry != "":
  306. mesg = "请及时安排%s/%s/%s保障人员并派工!" % (a, b, c)
  307. if mesg in str(singlelogstext):
  308. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  309. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  310. if fxry == "" and pgtime < now:
  311. mesg = "请及时安排%s/%s/%s放行人员并派工!" % (a, b, c)
  312. if mesg not in str(singlelogsall):
  313. WarningInsert(database, i[0], mesg, "任务安排监控")
  314. elif fxry != "":
  315. mesg = "请及时安排%s/%s/%s放行人员并派工!" % (a, b, c)
  316. if mesg in str(singlelogstext):
  317. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  318. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  319. if ecsj == "" and b != "航前" and espgtime != "" and espgtime < now:
  320. mesg = "请及时安排%s/%s/%s二送保障人员并派工!" % (a, b, c)
  321. if mesg not in str(singlelogsall):
  322. WarningInsert(database, i[0], mesg, "任务安排监控")
  323. elif ecsj != "" and b != "航前" :
  324. mesg = "请及时安排%s/%s/%s二送保障人员并派工!" % (a, b, c)
  325. if mesg in str(singlelogstext):
  326. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  327. database.lazyUpdateItem('logs', newdic, "航班编号='%s' and 警告信息='%s'" % (i[0],mesg))
  328. for i in flightcheck2:
  329. data2 = baseFunction.TuplefindInList1(datas, i[0], 0)
  330. if data2 and data2[0][3] != "停场":
  331. a = data2[0][1]
  332. b = get_dic("taskType")[data2[0][3]]
  333. std= data2[0][5]
  334. fj=baseFunction.TuplefindInList3(peopleschedule, i[0], 1, 9)
  335. sjry_str = data2[0][15]
  336. flightno = data2[0][21]
  337. singlelogsall=baseFunction.TuplefindInList33(logsall, i[0], 1, 2) #所有警告信息
  338. singlelogs=baseFunction.TuplefindInList33(logs, i[0], 1, 2) #未确认所有警告信息
  339. sjdw=baseFunction.TuplefindInList3(flightsts, i[0], 0, 6)
  340. if b == "航前":
  341. c = data2[0][11]
  342. else:
  343. c = data2[0][10]
  344. if b=="航前" and std != "":
  345. STD = std
  346. STD_120 = datetime.datetime.strptime(STD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 120)
  347. STD_60 = datetime.datetime.strptime(STD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes= 60)
  348. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and STD_120 < now:
  349. sjry = sjry_str.split(" ")[1]
  350. WarningInsert(database, i[0], "[随机2H提醒]%s/%s/%s/%s"% (a, flightno, c, sjry),"随机2H提醒")
  351. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and STD_60 < now and "已到位" not in str(sjdw):
  352. sjry = sjry_str.split("随机离港 ")[1]
  353. WarningInsert(database, i[0], "[随机到位确认]%s/%s/%s/%s"% (a, flightno, c, sjry),"随机到位警告")
  354. elif b=="短停" :
  355. TD = std
  356. TD_time_120 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  357. TD_time_60 = datetime.datetime.strptime(TD, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=60)
  358. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and TD_time_120 < now and sjry_str != "":
  359. sjry = sjry_str.split(" ")[1]
  360. WarningInsert(database,i[0],"[随机2H提醒]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机2H提醒")
  361. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and TD_time_60 < now and "已到位" not in str(sjdw):
  362. sjry = sjry_str.split(" ")[1]
  363. WarningInsert(database,i[0], "[随机到位确认]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机到位警告")
  364. elif b != "短停" and b != "航后" and b != "航前" and b != "未显示" and b != "停场" :
  365. TD_time_120= datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=120)
  366. TD_time_60 = datetime.datetime.strptime(std, "%Y-%m-%d %H:%M:%S") - datetime.timedelta(minutes=60)
  367. if "随机离港" in str(fj) and "随机2H提醒" not in str(singlelogsall) and TD_time_120 < now:
  368. sjry=sjry_str.split(" ")[1]
  369. WarningInsert(database,i[0],"[随机2H提醒]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机2H提醒")
  370. if "随机离港" in str(fj) and "随机到位确认" not in str(singlelogs) and TD_time_60 < now and "已到位" not in str(sjdw):
  371. sjry=sjry_str.split("随机离港 ")[1]
  372. WarningInsert(database,i[0],"[随机到位确认]%s/%s/%s/%s"%(a,flightno,c,sjry),"随机到位警告")
  373. database.FunctionCommit()
  374. waringIDs=database.queryTabel('logs',"*","变更字段 like '%警告%' and 处理时间 =''")
  375. flightstsids=database.getSingledata("航班编号",'flightsts{}'.format(nowDayStr))
  376. for waringID in waringIDs:
  377. if str(waringID[1]) in str(flightstsids):
  378. waringIDstsNow=database.queryTabel('flightsts{}'.format(nowDayStr),"*","航班编号 ='%s'"%waringID[1])
  379. if waringID[8] == "到位警告" and waringIDstsNow[0][3] == "已到位":
  380. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  381. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  382. if waringID[8] == "放行警告" and waringIDstsNow[0][4] == "已放行":
  383. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  384. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  385. if waringID[8] == "二送警告" and waringIDstsNow[0][7] == "已到位":
  386. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  387. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  388. if waringID[8] == "销夹警告" and waringIDstsNow[0][5] == "已取下":
  389. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  390. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  391. if waringID[8] == "随机到位警告" and waringIDstsNow[0][6] == "已到位":
  392. newdic = {"处理人": "'系统确认状态'", "处理时间": "'%s'" % now}
  393. database.lazyUpdateItem('logs', newdic, "编号='%s'" % waringID[0])
  394. database.FunctionCommit()
  395. except Exception as e:
  396. database.FunctionCommit()
  397. app_logger.log_error(e)