main_1.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #coding=utf-8
  2. # 计算里程
  3. from math import radians, cos, sin, asin, sqrt
  4. import pandas as pd
  5. import numpy as np
  6. from datetime import datetime
  7. from datetime import timedelta
  8. from GpsRank import *
  9. from ProcessDfBms import *
  10. from ProcessDfGps import *
  11. from LIB.MIDDLE.odo.CalDist import *
  12. from LIB.BACKEND import DBManager
  13. import pdb
  14. asset_table_path='asset_table.xlsx'
  15. # drive_info_path='D:\\work\\Qixiang\\data_analyze_platform\\pengmin\\AllCarDist\\drive_info.xlsx'
  16. asset_sheet_num=1
  17. usecols_list=[4,5]
  18. asset_table=pd.read_excel(asset_table_path,sheet_name=asset_sheet_num,skiprows=1,usecols=usecols_list)
  19. SN_list=asset_table['SN号'].values.tolist()
  20. print('从6060sheet读取到:'+str(len(SN_list))+'行')
  21. asset_table=asset_table.rename(columns={'SN号':'SN','状态':'state'})
  22. asset_table.set_index(["SN"],inplace=True)
  23. col_name=asset_table.columns.tolist()
  24. col_name.extend(['range','accum_soc','day_start_soc','day_end_soc','day_start_time','day_end_time'])
  25. asset_table=asset_table.reindex(columns=col_name)
  26. start_hour='00:00:00'#每日查询最早时间
  27. end_hour='23:59:00'#每日查询最晚时间
  28. date_index=pd.date_range('2021-07-31','2021-07-31')
  29. for date in date_index:
  30. '''遍历日期'''
  31. str_date=str(date)[:10]
  32. input_starttime=str_date+' '+start_hour
  33. input_endtime=str_date+' '+end_hour
  34. test_day=str_date[5:10]#月-日,用于建立sheet
  35. drive_info_path='6060\\drive_info'+test_day+'_50_end_'+'.xlsx'
  36. print(input_starttime)
  37. drive_info_aday=pd.DataFrame()
  38. SN_list_short=SN_list#先选择了0:50,50:end
  39. for SN in SN_list_short:
  40. '''遍历SN号'''
  41. SN=SN.strip('\t')
  42. SN=SN.strip('\n')
  43. try:
  44. range=GetDistInfo(SN,input_starttime,input_endtime)
  45. range_df=pd.DataFrame([range])
  46. drive_info_aday=pd.concat([drive_info_aday,range_df],axis=0)
  47. except:
  48. print(SN+' '+test_day+'fail')
  49. else:
  50. pass
  51. #print(SN+' '+test_day+'success')
  52. drive_info_aday.to_excel(drive_info_path,sheet_name=test_day)#sheet名称为testday