qtPeopleLoad.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from .flightDB import flightDB
  2. import datetime
  3. from unitls.LogerinTxt import app_logger
  4. import unitls.baseFunction as baseFunction
  5. def qtPeopleLoad(fdb:flightDB,workLoad:flightDB,bc:str,nowDaystr:str):
  6. try:
  7. qtPeopleLoad={}
  8. aa=[]
  9. selectdaystr = str(nowDaystr)[0:4] + "-" + str(nowDaystr)[4:6] + "-" + str(nowDaystr)[6:] + " 00:00:00"
  10. selectday = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S")
  11. selectday_2 = datetime.datetime.strptime(selectdaystr, "%Y-%m-%d %H:%M:%S") + datetime.timedelta(days=1)
  12. nowDay = datetime.date.today().strftime("%Y%m%d")
  13. nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
  14. nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
  15. nowtime = datetime.datetime.now()
  16. nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
  17. a_str = nowDay_str2 + " 00:00:00"
  18. b_str = nowDay_str2 + " 17:00:00"
  19. a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
  20. b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
  21. nowDayStr_search = datetime.date.today().strftime("%Y-%m-%d %H:%M:%S")
  22. tomorrow_search = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  23. yesterday_search = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
  24. if bc == "A":
  25. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  26. elif bc == "B" and nowDaystr == nowDay and a < nowtime < b:
  27. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  28. elif bc == "B" and nowDaystr == nowDay and b < nowtime:
  29. pglist_str = fdb.queryTabel("pglist{}".format(nowDay), "*", "班次='%s'" % bc)
  30. elif bc == "B" and nowDaystr == nowDay_1:
  31. pglist_str = fdb.queryTabel("pglist{}".format(nowDay_1), "*", "班次='%s'" % bc)
  32. elif bc == "B" and nowDaystr < nowDay_1:
  33. pglist_str = fdb.queryTabel("pglist{}".format(nowDaystr), "*", "班次='%s'" % bc)
  34. else:
  35. pglist_str = []
  36. diplaylist = pglist_str
  37. allpeopleinfos=fdb.queryTabel('workerinfo', "*", "姓名!=''")
  38. rowNum = 0
  39. JS = ""
  40. for row in diplaylist:
  41. singleinfo=baseFunction.TuplefindInList3(allpeopleinfos,row[0],1,8).replace("*","")
  42. sq=singleinfo if singleinfo else "未录入"
  43. if row[2] == "WX":
  44. JS = "维修员"
  45. elif row[2] == "FX":
  46. JS ="放行"
  47. col={"序号":rowNum,"姓名":row[0],"角色":JS,"授权":sq}
  48. aa.append(col)
  49. rowNum += 1
  50. if len(aa) != 0:
  51. aa.sort(key=lambda x: (x["角色"], x['授权']))
  52. rowNum1=0
  53. for i in aa:
  54. i["序号"]=rowNum1
  55. qtPeopleLoad[rowNum1]=i
  56. rowNum1 += 1
  57. return qtPeopleLoad
  58. except Exception as e:
  59. app_logger.log_error(e)