checkFlightAlert.py 40 KB

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