manChangests.py 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from .flightDB import flightDB
  2. import datetime
  3. from unitls.LogerinTxt import app_logger
  4. def manChangests(database:flightDB,flight_id:str,changests_id:str,selectedtime,username):
  5. try:
  6. nowDayStr = selectedtime
  7. now = datetime.datetime.now()
  8. now11=str(now).split(".")[0]
  9. code = {"接机到位": "人工已到位", "放行": "人工已放行", "随机到位": "人工已到位", "销子夹板": "人工已取下", "二送到位": "人工已到位"}
  10. code2 = {"接机到位": "接机已到位提示", "放行": "已放行提示", "随机到位": "随机已到位提示", "销子夹板": "销子夹板已提示", "二送到位": "二送已到位提示"}
  11. flightsts_search=database.queryTabel("flightsts{}".format(nowDayStr),"%s"%changests_id,"航班编号 = '%s'"%flight_id)
  12. waringsts=database.queryTabel("logs","*","航班编号='%s' and 处理时间 =''"%flight_id)
  13. if len(flightsts_search) != 0:
  14. if flightsts_search[0][0] != "":
  15. newdic={"%s"%changests_id:"''","%s"%code2[changests_id]:"''"}
  16. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号='%s'"%flight_id)
  17. a =database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  18. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  19. "提示信息": "人工处理:%s取消%s状态!%s" % (a,changests_id,now11),
  20. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  21. database.insertData('logs', newdic)
  22. else:
  23. newdic={"%s"%changests_id:"'%s'"%code[changests_id],"%s"%code2[changests_id]:"'1'"}
  24. database.upDateItem("flightsts{}".format(nowDayStr),newdic,"航班编号 = '%s'"%flight_id)
  25. a = database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)[0][0] if len(
  26. database.queryTabel('flightsts{}'.format(nowDayStr), "机号", "航班编号='%s'" % flight_id)) != 0 else "未显示机号"
  27. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "",
  28. "提示信息": "人工处理:%s确认%s已完成!%s" % (a, changests_id,now11),
  29. "产生时间": "%s" % now, "处理人": "%s"%username, "处理时间": "%s" % now, "变更字段": "","显示对象":"","提示内容":""}
  30. database.insertData('logs', newdic)
  31. else:
  32. newdic = {"航班编号": "%s" % flight_id, "%s"%changests_id:"%s"%code[changests_id],"%s"%code2[changests_id]:"1"}
  33. for i in ["航班编号","接机到位","放行","销子夹板","随机到位","二送到位","接机已到位提示","已放行提示","销子夹板已提示","随机已到位提示","二送已到位提示","天府飞机","机号","机位"]:
  34. if i not in newdic.keys():
  35. newdic[i]=''
  36. database.insertData('flightsts{}'.format(nowDayStr), newdic)
  37. newdic = {"航班编号": "%s" % flight_id, "警告信息": "", "信息状态": "","提示信息": "人工处理[首次新建]:%s确认%s已完成!%s" % (flight_id, changests_id, now11),
  38. "产生时间": "%s" % now, "处理人": "%s" % username, "处理时间": "%s" % now, "变更字段": "", "显示对象": "","提示内容": ""}
  39. database.insertData('logs', newdic)
  40. if len(waringsts) != 0:
  41. for i in waringsts:
  42. if changests_id == "接机到位" and i[8]=="到位警告":
  43. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  44. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  45. elif changests_id == "放行" and i[8]=="放行警告":
  46. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  47. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  48. elif changests_id == "二送到位" and i[8]=="二送警告":
  49. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  50. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  51. elif changests_id == "销子夹板" and i[8]=="销夹警告":
  52. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  53. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  54. elif changests_id == "随机到位" and i[8] == "随机到位警告":
  55. newdic = {"处理人": "'%s'" % username, "处理时间": "'%s'" % now}
  56. database.upDateItem('logs', newdic, "编号='%s'" % i[0])
  57. except Exception as e:
  58. app_logger.log_error(e)