main_daily_mileage.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from LIB.BACKEND import DBManager
  2. import mileage
  3. from LIB.MIDDLE.CellStateEstimation.Common import log
  4. import datetime
  5. import pandas as pd
  6. dbManager = DBManager.DBManager()
  7. now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') #type: str
  8. now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S') #type: datetime
  9. start_time=now_time-datetime.timedelta(days=1)
  10. end_time=str(now_time)
  11. start_time=str(start_time)
  12. dataSOH = pd.read_excel('sn-20210903.xlsx',sheet_name='sn-20210903')
  13. fileNames = dataSOH['sn']
  14. fileNames = list(fileNames)
  15. l = len(fileNames)
  16. #log信息配置
  17. mylog=log.Mylog('log.txt','error')
  18. mylog.logcfg()
  19. for k in range(l):
  20. try:
  21. sn = fileNames[k]
  22. df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms','gps'])
  23. data_bms = df_data['bms']
  24. data_gps = df_data['gps']
  25. #...............每日累积里程............................................................................
  26. if len(data_bms['时间戳'])>0:
  27. df_res = mileage.cal_mileage(sn,data_gps,data_bms)
  28. df_res.to_csv('Mileage_'+sn+'.csv')
  29. except Exception as e:
  30. print(repr(e))
  31. mylog.logopt(sn,e)
  32. pass