sortdisplaySever.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import requests
  2. import datetime
  3. from PyQt6.QtCore import QObject
  4. from .LogerinTxt import app_logger
  5. from PyQt6 import QtCore
  6. class sortdisplaySever(QObject):
  7. sortupdate = QtCore.pyqtSignal(str, dict, list, str, str)
  8. def __init__(self, name, ip, selectedtime, text, displayMode, selectedbc, displayselect, thread):
  9. super().__init__()
  10. self.funcName = name
  11. self.ipinfo = ip
  12. self.selectedtime = selectedtime
  13. self.text = text
  14. self.displayMode = displayMode
  15. self.selectedbc = selectedbc
  16. self.displayselect_mode = displayselect
  17. self.thread = thread
  18. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  19. tomorr =(datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  20. yester =(datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  21. if self.selectedtime == nowDay:
  22. self.date = "2"
  23. elif self.selectedtime == tomorr:
  24. self.date = "3"
  25. elif self.selectedtime == yester:
  26. self.date = "1"
  27. else:
  28. self.date = "4"
  29. def run(self):
  30. try:
  31. list = []
  32. if self.funcName == "sortTableWidgetDispaly":
  33. #print("1")
  34. self.sortTableWidgetDispaly()
  35. self.sortupdate.emit("sortTableWidgetDispaly", self.sorttableWidgetDispalydata, list, self.seversts,self.displayMode)
  36. self.sortupdate.emit("sortTableWidgetDispalyALL", self.DispalydataAll, list, self.seversts,self.displayMode)
  37. if self.funcName == "sortTableWidgetDispalyALL":
  38. #print("2")
  39. self.sortTableWidgetDispalyALL()
  40. self.sortupdate.emit("sortTableWidgetDispalyALL", self.sorttableWidgetDispalydata, list, self.seversts,self.displayMode)
  41. elif self.funcName == "SearchsortTableWidgetDispaly":
  42. #print("3")
  43. self.SearchsortTableWidgetDispaly()
  44. self.sortupdate.emit("SearchsortTableWidgetDispaly", self.sorttableWidgetDispalydata, list,self.seversts,self.displayMode)
  45. elif self.funcName == "sorttableWidgetDisplayChange":
  46. #print("4")
  47. self.sorttableWidgetDisplayChange()
  48. self.sortupdate.emit("sorttableWidgetDisplayChange", self.sortlogchange, list, self.seversts,self.displayMode)
  49. elif self.funcName == "sorttableWidgetPeopleDisplay":
  50. self.sorttableWidgetPeopleDisplay()
  51. self.sortupdate.emit("sorttableWidgetPeopleDisplay", self.sortdiplaylist, self.peopleOnJob,self.seversts, self.displayMode)
  52. elif self.funcName == "sorttableWidgetLOGDispaly":
  53. self.sorttableWidgetLOGDispaly()
  54. self.sortupdate.emit("sorttableWidgetLOGDispaly", self.sortlog, list, self.seversts, self.displayMode)
  55. elif self.funcName == "sorttableWidgetPHONEDispaly":
  56. self.sorttableWidgetPHONEDispaly()
  57. self.sortupdate.emit("sorttableWidgetPHONEDispaly", self.sorttableWidgetPHONEDispalydata, list,self.seversts, "")
  58. self.thread.quit()
  59. except Exception as e:
  60. app_logger.log_error(e)
  61. self.thread.quit()
  62. def severpost_nomeassge(self, postname, postdata, postdata2, postdata3):
  63. try:
  64. ip = "http://" + str(self.ipinfo) + "/static/" + str(postname) + str(postdata) + str(postdata2) + str(postdata3)
  65. try:
  66. res = requests.get(url=ip, timeout=30).json()
  67. self.seversts = "1"
  68. return res
  69. except Exception as e:
  70. app_logger.log_error(e)
  71. app_logger.log_error("重大bug")
  72. app_logger.log_error(ip)
  73. self.seversts = "0"
  74. return []
  75. except Exception as e:
  76. app_logger.log_error(e)
  77. def sorttableWidgetPHONEDispaly(self):
  78. try:
  79. sorttableWidgetPHONEDispalydataall = self.severpost_nomeassge("getphonelist", "", "", "")
  80. self.sorttableWidgetPHONEDispalydata = {}
  81. num = 0
  82. if sorttableWidgetPHONEDispalydataall != None:
  83. if self.text != "":
  84. for i in sorttableWidgetPHONEDispalydataall.keys():
  85. if str.lower(str(self.text)) in str(sorttableWidgetPHONEDispalydataall[i]):
  86. self.sorttableWidgetPHONEDispalydata[str(num)] = sorttableWidgetPHONEDispalydataall[i]
  87. num += 1
  88. else:
  89. self.sorttableWidgetPHONEDispalydata = sorttableWidgetPHONEDispalydataall
  90. except Exception as e:
  91. app_logger.log_error(e)
  92. def checkall(self, datas, text):
  93. res = {}
  94. try:
  95. num = 0
  96. for i in datas.keys():
  97. if datas[i]["109"] != text:
  98. res[str(num)] = datas[i]
  99. num += 1
  100. except Exception as e:
  101. app_logger.log_error(e)
  102. return res
  103. def checkStrsingle(self,datas, text, text2): #单一条件筛选
  104. res = {}
  105. try:
  106. num = 0
  107. for i in datas.keys():
  108. if str(text) in str(datas[i]) and datas[i]["109"] != text2:
  109. res[str(num)] = datas[i]
  110. num += 1
  111. except Exception as e:
  112. app_logger.log_error(e)
  113. return res
  114. def checkStrTerminalAll(self,datas, text1,text2,text3,text4): #筛选航站且显示全部
  115. res = {}
  116. try:
  117. num = 0
  118. for i in datas.keys():
  119. if str(datas[i]["8"]) != "" and datas[i]["109"] != text1:
  120. if str(datas[i]["8"])[0] == text2 and str(datas[i]["8"])[0] == text3:
  121. res[str(num)] = datas[i]
  122. num += 1
  123. elif str(datas[i]["8"]) == "" and str(datas[i]["109"]) == text4:
  124. res[str(num)] = datas[i]
  125. num += 1
  126. except Exception as e:
  127. app_logger.log_error(e)
  128. return res
  129. def checkStrTerminalAll2(self,datas, text1,text2,text3,text4): #筛选航站且显示全部
  130. res = {}
  131. try:
  132. num = 0
  133. for i in datas.keys():
  134. if str(datas[i]["8"]) != "" and datas[i]["109"] != text1:
  135. if str(datas[i]["8"])[0] != text2 and str(datas[i]["8"])[0] != text3:
  136. res[str(num)] = datas[i]
  137. num += 1
  138. elif str(datas[i]["8"]) == "" and str(datas[i]["109"]) == text4:
  139. res[str(num)] = datas[i]
  140. num += 1
  141. except Exception as e:
  142. app_logger.log_error(e)
  143. return res
  144. def checkStrTerminalAll3(self,datas, text1,text2,text3,text4): #筛选航站且显示全部
  145. res = {}
  146. try:
  147. num = 0
  148. for i in datas.keys():
  149. if str(datas[i]["8"]) != "" and datas[i]["109"] == text1:
  150. if str(datas[i]["8"])[0] == text2 and str(datas[i]["8"])[0] == text3:
  151. res[str(num)] = datas[i]
  152. num += 1
  153. elif str(datas[i]["8"]) == "" and str(datas[i]["109"]) == text4:
  154. res[str(num)] = datas[i]
  155. num += 1
  156. except Exception as e:
  157. app_logger.log_error(e)
  158. return res
  159. def checkStrTerminalAll4(self,datas, text1,text2,text3,text4): #筛选航站且显示全部
  160. res = {}
  161. try:
  162. num = 0
  163. for i in datas.keys():
  164. if str(datas[i]["8"]) != "" and datas[i]["109"] == text1:
  165. if str(datas[i]["8"])[0] != text2 and str(datas[i]["8"])[0] != text3:
  166. res[str(num)] = datas[i]
  167. num += 1
  168. elif str(datas[i]["8"]) == "" and str(datas[i]["109"]) == text4:
  169. res[str(num)] = datas[i]
  170. num += 1
  171. except Exception as e:
  172. app_logger.log_error(e)
  173. return res
  174. def sortTableWidgetDispaly(self):
  175. try:
  176. text = self.text
  177. Partdisplay = self.displayselect_mode # 不显示起飞航班
  178. # print(Partdisplay)
  179. tableWidgetDispalydataAll = {}
  180. if self.displayMode == "A" and (self.selectedbc == "0" or self.date=="4"):
  181. tableWidgetDispalydataAll = self.severpost_nomeassge("tableWidgetDispaly", "/%s" % self.selectedtime,"/%s"%self.date,"")
  182. elif self.displayMode == "B"and (self.selectedbc == "0" or self.date=="4"):
  183. tableWidgetDispalydataAll = self.severpost_nomeassge("tableWidgetDispaly2", "/%s" % self.selectedtime,"/%s"%self.date,"")
  184. elif self.displayMode == "A" and self.selectedbc == "1":
  185. tableWidgetDispalydataAll = self.severpost_nomeassge("tableWidgetDispalyRead","/%s"%self.date,"","")
  186. elif self.displayMode == "B"and self.selectedbc == "1":
  187. tableWidgetDispalydataAll = self.severpost_nomeassge("tableWidgetDispalyRead2","/%s"%self.date,"","")
  188. self.DispalydataAll=tableWidgetDispalydataAll
  189. self.sorttableWidgetDispalydata = {}
  190. num = 0
  191. if tableWidgetDispalydataAll != None:
  192. if text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6" and Partdisplay == "0":
  193. self.sorttableWidgetDispalydata=self.checkStrsingle(tableWidgetDispalydataAll, text, "")
  194. elif text == "T1" and Partdisplay == "0":
  195. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "", "1", "1", "1")
  196. elif text == "T2" and Partdisplay == "0":
  197. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "", "2", "2", "2")
  198. elif text == "T2T6" and Partdisplay == "0":
  199. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "1", "1", "1")
  200. elif text == "T1T6" and Partdisplay == "0":
  201. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "2", "2", "1")
  202. elif text == "T6" and Partdisplay == "0":
  203. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "1", "2", "1")
  204. elif text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6" and Partdisplay == "1":
  205. self.sorttableWidgetDispalydata = self.checkStrsingle(tableWidgetDispalydataAll, text, "4")
  206. elif text == "T1" and Partdisplay == "1":
  207. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "4", "1", "1", "1")
  208. elif text == "T2" and Partdisplay == "1":
  209. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "4", "2", "2", "1")
  210. elif text == "T2T6" and Partdisplay == "1":
  211. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "1", "1", "1")
  212. elif text == "T1T6" and Partdisplay == "1":
  213. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "2", "2", "1")
  214. elif text == "T6" and Partdisplay == "1":
  215. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "1", "2", "1")
  216. elif text == "" and Partdisplay == "1":
  217. self.sorttableWidgetDispalydata = self.checkall(tableWidgetDispalydataAll, "4")
  218. elif text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6" and Partdisplay == "3":
  219. self.sorttableWidgetDispalydata = self.checkStrsingle(tableWidgetDispalydataAll, text, "1")
  220. elif text == "T1" and Partdisplay == "3":
  221. self.sorttableWidgetDispalydata = self.checkStrTerminalAll3(tableWidgetDispalydataAll, "1", "1", "1", "1")
  222. elif text == "T2" and Partdisplay == "3":
  223. self.sorttableWidgetDispalydata = self.checkStrTerminalAll3(tableWidgetDispalydataAll, "1", "2", "2", "1")
  224. elif text == "T2T6" and Partdisplay == "3":
  225. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "1", "1", "1")
  226. elif text == "T1T6" and Partdisplay == "3":
  227. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "2", "2", "1")
  228. elif text == "T6" and Partdisplay == "3":
  229. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "1", "2", "1")
  230. elif text == "" and Partdisplay == "3":
  231. for i in tableWidgetDispalydataAll.keys():
  232. if tableWidgetDispalydataAll[i]["109"] == '1':
  233. self.sorttableWidgetDispalydata[str(num)] = tableWidgetDispalydataAll[i]
  234. num += 1
  235. else:
  236. self.sorttableWidgetDispalydata = tableWidgetDispalydataAll
  237. except Exception as e:
  238. app_logger.log_error(e)
  239. def sortTableWidgetDispalyALL(self):
  240. try:
  241. if self.displayMode == "A" and (self.selectedbc == "0" or self.date=="4"):
  242. self.sorttableWidgetDispalydata = self.severpost_nomeassge("tableWidgetDispaly", "/%s" % self.selectedtime,"/%s"%self.date,"")
  243. elif self.displayMode == "B"and (self.selectedbc == "0" or self.date=="4"):
  244. self.sorttableWidgetDispalydata = self.severpost_nomeassge("tableWidgetDispaly2", "/%s" % self.selectedtime,"/%s"%self.date,"")
  245. elif self.displayMode == "A" and self.selectedbc == "1":
  246. self.sorttableWidgetDispalydata = self.severpost_nomeassge("tableWidgetDispalyRead","/%s"%self.date,"","")
  247. elif self.displayMode == "B"and self.selectedbc == "1":
  248. self.sorttableWidgetDispalydata = self.severpost_nomeassge("tableWidgetDispalyRead2","/%s"%self.date,"","")
  249. except Exception as e:
  250. app_logger.log_error(e)
  251. def SearchsortTableWidgetDispaly(self):
  252. try:
  253. text = self.text
  254. self.seversts = "1"
  255. Partdisplay = self.displayselect_mode # 不显示起飞航班
  256. # print(Partdisplay)
  257. tableWidgetDispalydataAll = self.selectedbc
  258. self.sorttableWidgetDispalydata = {}
  259. num = 0
  260. if tableWidgetDispalydataAll != None:
  261. if text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6"and Partdisplay == "0":
  262. self.sorttableWidgetDispalydata = self.checkStrsingle(tableWidgetDispalydataAll, text, "")
  263. elif text == "T1" and Partdisplay == "0":
  264. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "", "1", "1", "1")
  265. elif text == "T2" and Partdisplay == "0":
  266. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "", "2", "2", "1")
  267. elif text == "T2T6" and Partdisplay == "0":
  268. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "1", "1", "1")
  269. elif text == "T1T6" and Partdisplay == "0":
  270. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "2", "2", "1")
  271. elif text == "T6" and Partdisplay == "0":
  272. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "", "1", "2", "1")
  273. elif text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6" and Partdisplay == "1":
  274. self.sorttableWidgetDispalydata = self.checkStrsingle(tableWidgetDispalydataAll, text, "4")
  275. elif text == "T1" and Partdisplay == "1":
  276. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "4", "1", "1", "1")
  277. elif text == "T2" and Partdisplay == "1":
  278. self.sorttableWidgetDispalydata = self.checkStrTerminalAll(tableWidgetDispalydataAll, "4", "2", "2", "1")
  279. elif text == "T2T6" and Partdisplay == "1":
  280. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "1", "1", "1")
  281. elif text == "T1T6" and Partdisplay == "1":
  282. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "2", "2", "1")
  283. elif text == "T6" and Partdisplay == "1":
  284. self.sorttableWidgetDispalydata = self.checkStrTerminalAll2(tableWidgetDispalydataAll, "4", "1", "2", "1")
  285. elif text == "" and Partdisplay == "1":
  286. self.sorttableWidgetDispalydata = self.checkall(tableWidgetDispalydataAll, "4")
  287. elif text != "" and text != "T1" and text != "T2" and text != "T6" and text != "T2T6" and text != "T1T6" and Partdisplay == "3":
  288. for i in tableWidgetDispalydataAll.keys():
  289. if str(text) in str(tableWidgetDispalydataAll[i]) and tableWidgetDispalydataAll[i]["109"] == '1':
  290. self.sorttableWidgetDispalydata[str(num)] = tableWidgetDispalydataAll[i]
  291. num += 1
  292. elif text == "T1" and Partdisplay == "3":
  293. self.sorttableWidgetDispalydata = self.checkStrTerminalAll3(tableWidgetDispalydataAll, "1", "1", "1", "1")
  294. elif text == "T2" and Partdisplay == "3":
  295. self.sorttableWidgetDispalydata = self.checkStrTerminalAll3(tableWidgetDispalydataAll, "1", "2", "2", "1")
  296. elif text == "T2T6" and Partdisplay == "3":
  297. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "1", "1", "1")
  298. elif text == "T1T6" and Partdisplay == "3":
  299. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "2", "2", "1")
  300. elif text == "T6" and Partdisplay == "3":
  301. self.sorttableWidgetDispalydata = self.checkStrTerminalAll4(tableWidgetDispalydataAll, "1", "1", "2", "1")
  302. elif text == "" and Partdisplay == "3":
  303. for i in tableWidgetDispalydataAll.keys():
  304. if tableWidgetDispalydataAll[i]["109"] == '1':
  305. self.sorttableWidgetDispalydata[str(num)] = tableWidgetDispalydataAll[i]
  306. num += 1
  307. else:
  308. self.sorttableWidgetDispalydata = tableWidgetDispalydataAll
  309. except Exception as e:
  310. app_logger.log_error(e)
  311. def sorttableWidgetDisplayChange(self):
  312. try:
  313. text = self.text
  314. logall = self.severpost_nomeassge("tableWidgetDisplayChange", "/%s" % self.selectedtime, "", "")
  315. self.sortlogchange = {}
  316. num = 0
  317. if text != "":
  318. for i in logall.keys():
  319. if str(text) in str(logall[i]):
  320. self.sortlogchange[str(num)] = logall[i]
  321. num += 1
  322. else:
  323. self.sortlogchange = logall
  324. except Exception as e:
  325. app_logger.log_error(e)
  326. def sorttableWidgetPeopleDisplay(self):
  327. try:
  328. if self.displayselect_mode == "" or self.displayselect_mode == []:
  329. text = self.text
  330. self.peopleOnJob = [""]
  331. bc = self.selectedbc
  332. nowDaystr = self.selectedtime # 选择的日期
  333. diplaylistall = self.severpost_nomeassge("qtPeopleLoad", "/%s" % nowDaystr, "/%s" % bc, "")
  334. self.sortdiplaylist = {}
  335. num = 0
  336. if text != "":
  337. for i in diplaylistall.keys():
  338. if str(text) in str(diplaylistall[i]):
  339. self.sortdiplaylist[str(num)] = diplaylistall[i]
  340. num += 1
  341. else:
  342. self.sortdiplaylist = diplaylistall
  343. for i in self.sortdiplaylist.keys():
  344. self.peopleOnJob.append(self.sortdiplaylist[i]["姓名"])
  345. else:
  346. names = self.displayselect_mode
  347. text = self.text
  348. self.peopleOnJob = [""]
  349. bc = self.selectedbc
  350. nowDaystr = self.selectedtime # 选择的日期
  351. diplaylistall = self.severpost_nomeassge("qtPeopleLoad", "/%s" % nowDaystr, "/%s" % bc, "")
  352. self.sortdiplaylist = {}
  353. num = 0
  354. if text != "":
  355. for i in diplaylistall.keys():
  356. if str(text) in str(diplaylistall[i]):
  357. for name in names:
  358. if str(name) in str(diplaylistall[i]):
  359. self.sortdiplaylist[str(num)] = diplaylistall[i]
  360. num += 1
  361. else:
  362. for i in diplaylistall.keys():
  363. for name in names:
  364. if str(name) in str(diplaylistall[i]):
  365. self.sortdiplaylist[str(num)] = diplaylistall[i]
  366. num += 1
  367. for i in self.sortdiplaylist.keys():
  368. self.peopleOnJob.append(self.sortdiplaylist[i]["姓名"])
  369. except Exception as e:
  370. app_logger.log_error(e)
  371. def sorttableWidgetLOGDispaly(self):
  372. try:
  373. text = self.text
  374. logall = self.severpost_nomeassge("tableWidgetLOGDispaly", "/%s" % self.selectedtime, "", "")
  375. self.sortlog = {}
  376. num = 0
  377. if text != "":
  378. for i in logall.keys():
  379. if str(text) in str(logall[i]):
  380. self.sortlog[str(num)] = logall[i]
  381. num += 1
  382. else:
  383. self.sortlog = logall
  384. except Exception as e:
  385. app_logger.log_error(e)