updateDragDropItem.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from .flightDB import flightDB
  2. import datetime
  3. from unitls.LogerinTxt import app_logger
  4. from unitls.StaticDataclass import get_dic
  5. def updateDragDropItem(fdb:flightDB,column,text,flightid,displayMode,flighttype,selectedtime):
  6. try:
  7. rowlistLabel=get_dic('rowlistLabelA') if displayMode =="A" else get_dic('rowlistLabel')
  8. flightid_new=""
  9. if displayMode =="A":
  10. if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
  11. flightid_new=flightid+"-1"+"-A"
  12. flightid_other=flightid+"-2"+"-A"
  13. elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
  14. flightid_new = flightid + "-2" + "-A"
  15. flightid_other=flightid+"-1"+"-A"
  16. elif displayMode =="B":
  17. if flighttype =="短停" or flighttype =="航后" or flighttype =="特后前" or flighttype =="停场":
  18. flightid_new=flightid+"-1"+"-B"
  19. elif flighttype =="航前":
  20. flightid_new = flightid + "-2" + "-B"
  21. nowDay = datetime.datetime.now().strftime("%Y%m%d")
  22. flightids_in_peopleSchedule=fdb.getSingledata("编号","peopleSchedule{}".format(selectedtime))
  23. newdic = {}
  24. if str(flightid_new) not in str(flightids_in_peopleSchedule) and str(flightid_new) !="":
  25. newdic={"编号":flightid_new,"航班编号":flightid,"显示模式":displayMode}
  26. for i in rowlistLabel.keys():
  27. if i == int(column):
  28. if text != "清空项目12345678987654321":
  29. newdic[rowlistLabel[i]] = text
  30. else:
  31. newdic[rowlistLabel[i]] = ""
  32. else:
  33. newdic[rowlistLabel[i]] = ""
  34. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  35. if flighttype[-1] in ["接","送"] and column =="31":
  36. newdic["编号"]=flightid_other
  37. fdb.insertData("peopleSchedule{}".format(selectedtime),newdic)
  38. else:
  39. if text != "清空项目12345678987654321":
  40. newdic[rowlistLabel[int(column)]]="'%s'"%text
  41. else:
  42. newdic[rowlistLabel[int(column)]]="''"
  43. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
  44. if flighttype[-1] in ["接","送"] and column =="31":
  45. fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_other)
  46. except Exception as e:
  47. app_logger.log_error(e)