tableWidgetDispaly.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. "119": row[2], #保障时间
  240. "129": row[4],#航日期
  241. "139": row[0]+"-A",#sor编号
  242. }
  243. elif TaskFlightinfo[3] == "停场":
  244. item_dic = {"0": rowNum,
  245. "1": TaskFlightinfo[1],
  246. "2": TaskFlightinfo[26],
  247. "3": TaskFlightinfo[25],
  248. "4": "--",
  249. "5": a,
  250. "6": "--",
  251. "7": "--",
  252. "8": TaskFlightinfo[10],
  253. "9": row[3],
  254. "10": fx,
  255. "11": qw1,
  256. "12": qw2,
  257. "13": g1,
  258. "14": g2,
  259. "15": g3,
  260. "16": "--",
  261. "17": "--",
  262. "18": "--",
  263. "19": "--",
  264. "20": "--",
  265. "21": "--",
  266. "22": "--",
  267. "23": "--",
  268. "24": "--", # flightinfodata[22],
  269. "25": "--", # flightinfodata[23],
  270. "26": row[1],
  271. "27": "TSK",
  272. "28": "--",
  273. "29": "--",
  274. "30": fj,
  275. "99": color_code,
  276. "101": color_code1,
  277. "102": color_code2,
  278. "103": color_code3,
  279. "109": row[5],
  280. "119": row[2], #保障时间
  281. "129": row[4],#航班日期
  282. "139":row[0]+"-A",#sor编号
  283. }
  284. elif TaskFlightinfo[3] == "AP":
  285. item_dic = {"0": rowNum,
  286. "1": TaskFlightinfo[1],
  287. "2": TaskFlightinfo[26],
  288. "3": TaskFlightinfo[25],
  289. "4": TaskFlightinfo[21],
  290. "5": "",
  291. "6": "",
  292. "7": c,
  293. "8": JWB,
  294. "9": row[3],
  295. "10": fx,
  296. "11": qw1,
  297. "12": qw2,
  298. "13": g1,
  299. "14": g2,
  300. "15": g3,
  301. "16": jjdw,
  302. "17": FX,
  303. "18": XJ,
  304. "19": d,
  305. "20": SJDW,
  306. "21": e,
  307. "22": F,
  308. "23": postion,
  309. "24": wx_people, # flightinfodata[22],
  310. "25": fx_people, # flightinfodata[23],
  311. "26": row[1],
  312. "27": g,
  313. "28": ta_td,
  314. "29": type31,
  315. "30": fj,
  316. "99": color_code,
  317. "101": color_code1,
  318. "102": color_code2,
  319. "103": color_code3,
  320. "109": row[5],
  321. "119":row[2], #保障时间
  322. "129":row[4],#航班日期
  323. "139":row[0]+"-A",#sor编号
  324. }
  325. elif (TaskFlightinfo[3] == "TR" or TaskFlightinfo[3] == "TAF") and (row[3] == "短停接" or row[3] == "特后前接"):
  326. item_dic = {"0": rowNum,
  327. "1": TaskFlightinfo[1],
  328. "2": TaskFlightinfo[26],
  329. "3": TaskFlightinfo[25],
  330. "4": TaskFlightinfo[21],
  331. "5": a,
  332. "6": b,
  333. "7": c,
  334. "8": JWA,
  335. "9": row[3],
  336. "10": fx,
  337. "11": qw1,
  338. "12": qw2,
  339. "13": g1,
  340. "14": g2,
  341. "15": g3,
  342. "16": jjdw,
  343. "17": FX,
  344. "18": "--",
  345. "19": d,
  346. "20": SJDW,
  347. "21": e,
  348. "22": F,
  349. "23": postion,
  350. "24": wx_people, # flightinfodata[22],
  351. "25": fx_people, # flightinfodata[23],
  352. "26": row[1],
  353. "27": g,
  354. "28": ta_td,
  355. "29": type31,
  356. "30": fj,
  357. "99": color_code,
  358. "101": color_code1,
  359. "102": color_code2,
  360. "103": color_code3,
  361. "109": row[5],
  362. "119":row[2], #保障时间
  363. "129":row[4],#航班日期
  364. "139":row[0]+"-A",#sor编号
  365. }
  366. elif (TaskFlightinfo[3] == "TR" or TaskFlightinfo[3] == "TAF") and (row[3] == "短停送" or row[3] == "特后前送"):
  367. item_dic = {"0": rowNum,
  368. "1": TaskFlightinfo[1],
  369. "2": TaskFlightinfo[26],
  370. "3": TaskFlightinfo[25],
  371. "4": TaskFlightinfo[21],
  372. "5": a,
  373. "6": b,
  374. "7": c,
  375. "8": JWA,
  376. "9": row[3],
  377. "10": fx,
  378. "11": qw1,
  379. "12": qw2,
  380. "13": g1,
  381. "14": g2,
  382. "15": g3,
  383. "16": ESDW,
  384. "17": FX,
  385. "18": "--",
  386. "19": d,
  387. "20": SJDW,
  388. "21": e,
  389. "22": F,
  390. "23": postion,
  391. "24": ecsj_people, # flightinfodata[22],
  392. "25": fx_people, # flightinfodata[23],
  393. "26": row[1],
  394. "27": g,
  395. "28": ta_td,
  396. "29": type31,
  397. "30": fj,
  398. "99": color_code,
  399. "101": color_code1,
  400. "102": color_code2,
  401. "103": color_code3,
  402. "109": row[5],
  403. "119":row[2], #保障时间
  404. "129":row[4],#航班日期
  405. "139":row[0]+"-A",#sor编号
  406. }
  407. else:
  408. item_dic = {"0": rowNum,
  409. "1": TaskFlightinfo[1],
  410. "2": TaskFlightinfo[26],
  411. "3": TaskFlightinfo[25],
  412. "4": TaskFlightinfo[21],
  413. "5": a,
  414. "6": b,
  415. "7": c,
  416. "8": JWA,
  417. "9": row[3],
  418. "10": fx,
  419. "11": qw1,
  420. "12": qw2,
  421. "13": g1,
  422. "14": g2,
  423. "15": g3,
  424. "16": jjdw,
  425. "17": FX,
  426. "18": "--",
  427. "19": d,
  428. "20": SJDW,
  429. "21": e,
  430. "22": F,
  431. "23": postion,
  432. "24": wx_people, # flightinfodata[22],
  433. "25": fx_people, # flightinfodata[23],
  434. "26": row[1],
  435. "27": g,
  436. "28": ta_td,
  437. "29": type31,
  438. "30": fj,
  439. "99": color_code,
  440. "101": color_code1,
  441. "102": color_code2,
  442. "103": color_code3,
  443. "109": row[5],
  444. "119": row[2], #保障时间
  445. "129": row[4],#航班日期
  446. "139": row[0]+"-A",#sor编号
  447. }
  448. #tableWidgetDispalydata[rowNum] = item_dic
  449. #rowNum += 1
  450. # print(rowNum)
  451. # print(item_dic)
  452. # print({rowNum:item_dic})
  453. return {rowNum:item_dic}