main.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import CBMSBatUniform
  2. import log
  3. #coding=utf-8
  4. import os
  5. import sys
  6. import datetime
  7. import pandas as pd
  8. from LIB.BACKEND import DBManager, Log
  9. # from LIB.MIDDLE import SignalMonitor
  10. from sqlalchemy import create_engine
  11. from sqlalchemy.orm import sessionmaker
  12. import time, datetime
  13. from LIB.MIDDLE.soh import NCMSoh_20210716 as NCMSoh
  14. from LIB.MIDDLE.soh import LFPSoh_20210711 as LFPSoh
  15. from urllib import parse
  16. dbManager = DBManager.DBManager()
  17. if __name__ == "__main__":
  18. SNdata_6040 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
  19. SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
  20. SNdata_4840 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='4840骑享')
  21. SNdata_7250 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='7250')
  22. SNnums_6060=SNdata_6060['SN号']
  23. SNnums_6040=SNdata_6040['SN号']
  24. SNnums_4840=SNdata_4840['SN号']
  25. SNnums_7250=SNdata_7250['SN号']
  26. SNnums=SNnums_6040.tolist()+SNnums_6060.tolist()+SNnums_4840.tolist()+SNnums_7250.tolist()
  27. now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  28. now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
  29. start_time=now_time-datetime.timedelta(days=5)
  30. end_time=str(now_time)
  31. start_time=str(start_time)
  32. #log信息配置
  33. mylog=log.Mylog('log.txt','error')
  34. mylog.logcfg()
  35. for sn in SNnums:
  36. try:
  37. if 'PK500' in sn:
  38. celltype=1 #6040三元电芯
  39. elif 'PK502' in sn:
  40. celltype=2 #4840三元电芯
  41. elif 'PK504' in sn:
  42. celltype=99 #60ah林磷酸铁锂电芯
  43. elif 'MGMLXN750' in sn:
  44. celltype=3 #力信50ah三元电芯
  45. elif 'MGMCLN750' in sn:
  46. celltype=4 #CATL 50ah三元电芯
  47. else:
  48. print('未找到对应电池编号!!!')
  49. sys.exit()
  50. # sn='PK50001A100000035'
  51. # start_time='2021-08-10 9:49:37'
  52. # end_time='2021-08-29 19:49:37'
  53. dbManager = DBManager.DBManager()
  54. df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
  55. df_bms = df_data['bms']
  56. # df_bms.to_csv('BMS_'+sn+'.csv',encoding='GB18030')
  57. BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms)
  58. df_res=BatUniform.batuniform()
  59. df_res.to_csv('CBMS_Uniform_'+sn+'.csv',encoding='GB18030')
  60. except IndexError as e:
  61. print(repr(e))
  62. mylog.logopt(sn,e)
  63. pass