checkFlightAlert.py 36 KB

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