tableWidgetDispaly.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. from unitls.baseFunction import TuplefindInList
  2. from .flightDB import flightDB
  3. from unitls.LogerinTxt import app_logger
  4. from .getSortFlightdata import getSortFlightdata
  5. from .waringMessageID import waringMessageID
  6. import concurrent.futures
  7. def tableWidgetDispaly(fdb:flightDB,selectedtime,date):#1,昨天。2今天3明天4其他
  8. try:
  9. #t1 = datetime.datetime.now()
  10. tableWidgetDispalydata = {}
  11. nowDayStr = selectedtime
  12. sorttable = getSortFlightdata(fdb, selectedtime, "sortFlight")
  13. #t2 = datetime.datetime.now()
  14. #print(f'【航班刷新】【数据库1】:{t2 - t1}')
  15. TaskFlightinfoAlldata = fdb.getAlldata('TaskFlightinfo{}'.format(nowDayStr))
  16. #t3 = datetime.datetime.now()
  17. #print(f'【航班刷新】【数据库2】:{t3 - t2}')
  18. #flightInfoDataAll = fdb.getAlldata('flightinfo{}'.format(nowDayStr))
  19. #t4 = datetime.datetime.now()
  20. #print(f'【航班刷新】【数据库3】:{t4 - t3}')
  21. flightStsDataAll = fdb.getAlldata('flightsts{}'.format(nowDayStr))
  22. #t5 = datetime.datetime.now()
  23. #print(f'【航班刷新】【数据库4】:{t5 - t4}')
  24. peopleScheduleDataAll = fdb.getAlldata("peopleSchedule{}".format(nowDayStr))
  25. #t6 = datetime.datetime.now()
  26. #print(f'【航班刷新】【数据库5】:{t6 - t5}')
  27. workjobDataAll = fdb.getAlldata('workjob')
  28. #t7 = datetime.datetime.now()
  29. #print(f'【航班刷新】【数据库6】:{t7 - t6}')
  30. #print(f'【航班刷新】【数据库ALL】:{t7 - t1}')
  31. waringMessageIDs = waringMessageID(fdb)
  32. executor = concurrent.futures.ThreadPoolExecutor()
  33. all_task = []
  34. for i in range(len(sorttable)):
  35. #all_task.append(executor.submit(functionDisaplay, sorttable[i],i, TaskFlightinfoAlldata,workjobDataAll,flightInfoDataAll, flightStsDataAll,peopleScheduleDataAll,waringMessageIDs))
  36. all_task.append(executor.submit(functionDisaplay, sorttable[i],i, TaskFlightinfoAlldata,workjobDataAll, flightStsDataAll,peopleScheduleDataAll,waringMessageIDs))
  37. for future in concurrent.futures.as_completed(all_task):
  38. data = future.result()
  39. tableWidgetDispalydata.update(data)
  40. #t8 = datetime.datetime.now()
  41. #print(f'【航班刷新】【处理数据】:{t8 - t7}')
  42. newdic = {"A": '"{}"'.format(tableWidgetDispalydata)}
  43. if date == "1":
  44. fdb.upDateItem("display", newdic, "ID = '1'")
  45. elif date == "2":
  46. fdb.upDateItem("display", newdic, "ID = '2'")
  47. elif date == "3":
  48. fdb.upDateItem("display", newdic, "ID = '3'")
  49. #t9 = datetime.datetime.now()
  50. #print(f'【航班刷新】【保存数据】:{t9 - t8}')
  51. #print(f'【航班刷新】【总时间】:{t9 - t1}')
  52. return tableWidgetDispalydata
  53. except Exception as e:
  54. #dingding_alert(traceback.format_exc())
  55. app_logger.log_error(e)
  56. def functionDisaplay(row,rowNum,TaskFlightinfoAlldata, workjobDataAll, flightStsDataAll,peopleScheduleDataAll, waringMessageID):
  57. #print("kaishi")
  58. TaskFlightinfo = TuplefindInList(TaskFlightinfoAlldata,row[1])
  59. #print(TaskFlightinfo)
  60. # print(row)
  61. e = ""
  62. F = ""
  63. g = ""
  64. if TaskFlightinfo != None and TaskFlightinfo[16] != "":
  65. e = "保留"
  66. if TaskFlightinfo != None :
  67. takinfo = TuplefindInList(workjobDataAll, TaskFlightinfo[21])
  68. JWA = TaskFlightinfo[10]
  69. JWB = TaskFlightinfo[11]
  70. if JWA =="" and JWB !="":
  71. JWA=JWB
  72. elif JWB =="" and JWA !="":
  73. JWB=JWA
  74. if TaskFlightinfo[18] != "":
  75. #takinfo = fdb.queryTabel('workjob', '*', "任务编号= '%s'" % TaskFlightinfo[0][21])
  76. F = "工作包无法正常获取请通过AMRO人工查询"
  77. if takinfo != None and takinfo[4] != "":
  78. F = takinfo[4] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[6] + "\n<+++++++++++++++++++++++++++++++++++++++++>\n" + takinfo[7]
  79. elif takinfo != None:
  80. F = "工作包暂未获取请点击右键工作包查询后即可随意查看"
  81. else:
  82. JWA =""
  83. JWB =""
  84. if TaskFlightinfo != None and TaskFlightinfo[21] != "":
  85. g = TaskFlightinfo[21]
  86. #print("tttt:{}".format(g))
  87. wx_people = ""
  88. fx_people = ""
  89. ecsj_people = ""
  90. ta_td = ""
  91. type31 = ""
  92. if TaskFlightinfo != None:
  93. wx_people = TaskFlightinfo[12]
  94. fx_people = TaskFlightinfo[13]
  95. ecsj_people = TaskFlightinfo[19]
  96. ta_td = TaskFlightinfo[9]
  97. type31 = TaskFlightinfo[3]
  98. # print(row[1])
  99. # print(fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1])))
  100. #flightinfodata = TuplefindInList(flightInfoDataAll,row[1])
  101. #flightinfodata = fdb.queryTabel('flightinfo{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0]
  102. flightstsdata = TuplefindInList(flightStsDataAll, row[1]) if TuplefindInList(flightStsDataAll, row[1]) != None else ["", "","", "", "", "","", "", "", "","", "", "", ""]
  103. # flightstsdata = fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))[0] if \
  104. # len(fdb.queryTabel('flightsts{}'.format(nowDayStr), '*', "航班编号='{}'".format(row[1]))) != 0 else ["", "",
  105. # "", "", "", "",
  106. # "", "", "", "",
  107. # "", "", "", ""]
  108. jjdw = "√" if flightstsdata[3] != "" else ""
  109. FX = "√" if flightstsdata[4] != "" else ""
  110. XJ = "√" if flightstsdata[5] != "" else ""
  111. ESDW = "√" if flightstsdata[7] != "" else ""
  112. if TaskFlightinfo[3] == "AF":
  113. postion = str(TaskFlightinfo[23]).split("</br>")[0]
  114. elif TaskFlightinfo[3] == "TR" or TaskFlightinfo[3] == "TAF":
  115. postion = str(TaskFlightinfo[23]).replace("</br>天府","")
  116. elif "</br>" in str(TaskFlightinfo[23]):
  117. postion = str(TaskFlightinfo[23]).split("</br>")[1]
  118. else:
  119. postion = "无信息"
  120. if TaskFlightinfo[4] != "" and (TaskFlightinfo[8] == "" or TaskFlightinfo[30] == ""): #如果sta不为空,且eta或flying为空,显示sta
  121. a = TaskFlightinfo[4][-8:-3]
  122. else:
  123. a=""
  124. if TaskFlightinfo[6] != "" : #当ata不为空显示ata,eta不为空显示eta否则为空
  125. b = TaskFlightinfo[6][-8:-3]
  126. elif TaskFlightinfo[8] != "":
  127. b = TaskFlightinfo[8][-8:-3]
  128. else:
  129. b = ''
  130. if TaskFlightinfo[7] != "" :
  131. c = '[实]' + TaskFlightinfo[7][-8:-3]
  132. elif TaskFlightinfo[5] != "":
  133. c = '[预]' + TaskFlightinfo[5][-8:-3]
  134. else:
  135. c = ''
  136. d = TaskFlightinfo[15] if "随机" in str(TaskFlightinfo[15]) else ""
  137. QColorList = ['black', 'white', '#F3ECD9', '#BAD1D1', '#DDE2E3', '#647277', 'red', 'blue']
  138. waringMessageIDs = waringMessageID
  139. if str(row[1]) in str(waringMessageIDs["通用警告"]):
  140. color_code = QColorList[6]
  141. color_code1 = QColorList[1]
  142. color_code2 = QColorList[1]
  143. color_code3 = QColorList[1]
  144. elif row[3] == "短停接" and (
  145. str(row[1]) in str(waringMessageIDs["到位警告"]) or str(row[1]) in str(waringMessageIDs["ETA"]) or str(
  146. row[1]) in str(waringMessageIDs["BAY_2"])):
  147. color_code = QColorList[6]
  148. color_code1 = QColorList[1]
  149. color_code2 = QColorList[1]
  150. color_code3 = QColorList[1]
  151. elif row[3] == "短停送" and (
  152. str(row[1]) in str(waringMessageIDs["二送警告"]) or str(row[1]) in str(waringMessageIDs["TD"])):
  153. color_code = QColorList[6]
  154. color_code1 = QColorList[1]
  155. color_code2 = QColorList[1]
  156. color_code3 = QColorList[1]
  157. elif row[5] == "4":
  158. color_code = QColorList[5]
  159. color_code1 = QColorList[1]
  160. color_code2 = QColorList[1]
  161. color_code3 = QColorList[1]
  162. elif row[5] == "3":
  163. color_code = QColorList[3]
  164. color_code1 = QColorList[0]
  165. color_code2 = QColorList[0]
  166. color_code3 = QColorList[0]
  167. elif row[5] == "2":
  168. color_code = QColorList[2]
  169. color_code1 = QColorList[0]
  170. color_code2 = QColorList[0]
  171. color_code3 = QColorList[0]
  172. elif row[5] == "1":
  173. if (rowNum + 2) % 2 == 0:
  174. color_code = QColorList[4]
  175. else:
  176. color_code = QColorList[1]
  177. color_code1 = QColorList[0]
  178. color_code2 = QColorList[6]
  179. color_code3 = QColorList[7]
  180. findid = row[0] + "-A"
  181. peopleSchedule = TuplefindInList(peopleScheduleDataAll,findid)
  182. if peopleSchedule != None:
  183. fx = peopleSchedule[3]
  184. qw1 = peopleSchedule[4]
  185. qw2 = peopleSchedule[5]
  186. g1 = peopleSchedule[6]
  187. g2 = peopleSchedule[7]
  188. g3 = peopleSchedule[8]
  189. fj = str(peopleSchedule[9])
  190. else:
  191. fx = ""
  192. qw1 = ""
  193. qw2 = ""
  194. g1 = ""
  195. g2 = ""
  196. g3 = ""
  197. fj = ""
  198. if "随机离港" in str(fj):
  199. SJDW = "√" if flightstsdata[6] != "" else ""
  200. else:
  201. SJDW ="--"
  202. if TaskFlightinfo[3] == "AF":
  203. item_dic = {"0": rowNum,
  204. "1": TaskFlightinfo[1],
  205. "2": TaskFlightinfo[26],
  206. "3": TaskFlightinfo[25],
  207. "4": TaskFlightinfo[21],
  208. "5": a,
  209. "6": b,
  210. "7": "--",
  211. "8": JWA,
  212. "9": row[3],
  213. "10": fx,
  214. "11": qw1,
  215. "12": qw2,
  216. "13": g1,
  217. "14": g2,
  218. "15": g3,
  219. "16": jjdw,
  220. "17": "--",
  221. "18": "--",
  222. "19": d,
  223. "20": "--",
  224. "21": e,
  225. "22": F,
  226. "23": postion,
  227. "24": wx_people, # flightinfodata[22],
  228. "25": fx_people, # flightinfodata[23],
  229. "26": row[1],
  230. "27": g,
  231. "28": ta_td,
  232. "29": type31,
  233. "30": fj,
  234. "99": color_code,
  235. "101": color_code1,
  236. "102": color_code2,
  237. "103": color_code3,
  238. "109": row[5]
  239. }
  240. elif TaskFlightinfo[3] == "停场":
  241. item_dic = {"0": rowNum,
  242. "1": TaskFlightinfo[1],
  243. "2": TaskFlightinfo[26],
  244. "3": TaskFlightinfo[25],
  245. "4": "--",
  246. "5": a,
  247. "6": "--",
  248. "7": "--",
  249. "8": TaskFlightinfo[10],
  250. "9": row[3],
  251. "10": fx,
  252. "11": qw1,
  253. "12": qw2,
  254. "13": g1,
  255. "14": g2,
  256. "15": g3,
  257. "16": "--",
  258. "17": "--",
  259. "18": "--",
  260. "19": "--",
  261. "20": "--",
  262. "21": "--",
  263. "22": "--",
  264. "23": "--",
  265. "24": "--", # flightinfodata[22],
  266. "25": "--", # flightinfodata[23],
  267. "26": row[1],
  268. "27": "TSK",
  269. "28": "--",
  270. "29": "--",
  271. "30": fj,
  272. "99": color_code,
  273. "101": color_code1,
  274. "102": color_code2,
  275. "103": color_code3,
  276. "109": row[5]
  277. }
  278. elif TaskFlightinfo[3] == "AP":
  279. item_dic = {"0": rowNum,
  280. "1": TaskFlightinfo[1],
  281. "2": TaskFlightinfo[26],
  282. "3": TaskFlightinfo[25],
  283. "4": TaskFlightinfo[21],
  284. "5": "",
  285. "6": "",
  286. "7": c,
  287. "8": JWB,
  288. "9": row[3],
  289. "10": fx,
  290. "11": qw1,
  291. "12": qw2,
  292. "13": g1,
  293. "14": g2,
  294. "15": g3,
  295. "16": jjdw,
  296. "17": FX,
  297. "18": XJ,
  298. "19": d,
  299. "20": SJDW,
  300. "21": e,
  301. "22": F,
  302. "23": postion,
  303. "24": wx_people, # flightinfodata[22],
  304. "25": fx_people, # flightinfodata[23],
  305. "26": row[1],
  306. "27": g,
  307. "28": ta_td,
  308. "29": type31,
  309. "30": fj,
  310. "99": color_code,
  311. "101": color_code1,
  312. "102": color_code2,
  313. "103": color_code3,
  314. "109": row[5]
  315. }
  316. elif (TaskFlightinfo[3] == "TR" or TaskFlightinfo[3] == "TAF") and (row[3] == "短停接" or row[3] == "特后前接"):
  317. item_dic = {"0": rowNum,
  318. "1": TaskFlightinfo[1],
  319. "2": TaskFlightinfo[26],
  320. "3": TaskFlightinfo[25],
  321. "4": TaskFlightinfo[21],
  322. "5": a,
  323. "6": b,
  324. "7": c,
  325. "8": JWA,
  326. "9": row[3],
  327. "10": fx,
  328. "11": qw1,
  329. "12": qw2,
  330. "13": g1,
  331. "14": g2,
  332. "15": g3,
  333. "16": jjdw,
  334. "17": FX,
  335. "18": "--",
  336. "19": d,
  337. "20": SJDW,
  338. "21": e,
  339. "22": F,
  340. "23": postion,
  341. "24": wx_people, # flightinfodata[22],
  342. "25": fx_people, # flightinfodata[23],
  343. "26": row[1],
  344. "27": g,
  345. "28": ta_td,
  346. "29": type31,
  347. "30": fj,
  348. "99": color_code,
  349. "101": color_code1,
  350. "102": color_code2,
  351. "103": color_code3,
  352. "109": row[5]
  353. }
  354. elif (TaskFlightinfo[3] == "TR" or TaskFlightinfo[3] == "TAF") and (row[3] == "短停送" or row[3] == "特后前送"):
  355. item_dic = {"0": rowNum,
  356. "1": TaskFlightinfo[1],
  357. "2": TaskFlightinfo[26],
  358. "3": TaskFlightinfo[25],
  359. "4": TaskFlightinfo[21],
  360. "5": a,
  361. "6": b,
  362. "7": c,
  363. "8": JWA,
  364. "9": row[3],
  365. "10": fx,
  366. "11": qw1,
  367. "12": qw2,
  368. "13": g1,
  369. "14": g2,
  370. "15": g3,
  371. "16": ESDW,
  372. "17": FX,
  373. "18": "--",
  374. "19": d,
  375. "20": SJDW,
  376. "21": e,
  377. "22": F,
  378. "23": postion,
  379. "24": ecsj_people, # flightinfodata[22],
  380. "25": fx_people, # flightinfodata[23],
  381. "26": row[1],
  382. "27": g,
  383. "28": ta_td,
  384. "29": type31,
  385. "30": fj,
  386. "99": color_code,
  387. "101": color_code1,
  388. "102": color_code2,
  389. "103": color_code3,
  390. "109": row[5]
  391. }
  392. else:
  393. item_dic = {"0": rowNum,
  394. "1": TaskFlightinfo[1],
  395. "2": TaskFlightinfo[26],
  396. "3": TaskFlightinfo[25],
  397. "4": TaskFlightinfo[21],
  398. "5": a,
  399. "6": b,
  400. "7": c,
  401. "8": JWA,
  402. "9": row[3],
  403. "10": fx,
  404. "11": qw1,
  405. "12": qw2,
  406. "13": g1,
  407. "14": g2,
  408. "15": g3,
  409. "16": jjdw,
  410. "17": FX,
  411. "18": "--",
  412. "19": d,
  413. "20": SJDW,
  414. "21": e,
  415. "22": F,
  416. "23": postion,
  417. "24": wx_people, # flightinfodata[22],
  418. "25": fx_people, # flightinfodata[23],
  419. "26": row[1],
  420. "27": g,
  421. "28": ta_td,
  422. "29": type31,
  423. "30": fj,
  424. "99": color_code,
  425. "101": color_code1,
  426. "102": color_code2,
  427. "103": color_code3,
  428. "109": row[5]
  429. }
  430. #tableWidgetDispalydata[rowNum] = item_dic
  431. #rowNum += 1
  432. # print(rowNum)
  433. # print(item_dic)
  434. # print({rowNum:item_dic})
  435. return {rowNum:item_dic}