update_Pglist.py 1.0 KB

12345678910111213141516171819202122232425
  1. from .flightDB import flightDB
  2. from unitls.LogerinTxt import app_logger
  3. from unitls.StaticDataclass import get_dic
  4. def update_Pglist(database:flightDB,datatime: str,bc:str,jsonData):
  5. try:
  6. nowDayStr = datatime
  7. newdic={}
  8. database.deleteSingledata("pglist{}".format(nowDayStr), "班次='%s'" % bc)
  9. names=[]
  10. pglistLabel2en=get_dic('pglistLabel2en')
  11. pglistLabel=get_dic('pglistLabel')
  12. for row in jsonData:
  13. if "SHIFT" in row.keys() and row["SHIFT"] == bc and row["NAME"] not in names:
  14. for col in row:
  15. if col in pglistLabel2en.keys():
  16. newdic[pglistLabel2en[col]]=row[col]
  17. for col in pglistLabel:
  18. if col not in newdic.keys():
  19. newdic[col] = ''
  20. database.lazyInsertData("pglist{}".format(nowDayStr),newdic)
  21. names = row["NAME"]
  22. database.FunctionCommit()
  23. except Exception as e:
  24. database.FunctionCommit()
  25. app_logger.log_error(e)