main.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import datetime
  2. import pandas as pd
  3. import datetime
  4. from USER.SPF.alibaba.Common import DBDownload
  5. from USER.SPF.alibaba.Common import log
  6. import CBMSBatSoh
  7. if __name__ == "__main__":
  8. SNnums= ['LISHEN01']
  9. end_time=datetime.datetime.now()-datetime.timedelta(seconds=10)
  10. start_time=end_time-datetime.timedelta(seconds=12000)
  11. start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
  12. end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
  13. #log信息配置............................................................................................................................................................................
  14. mylog=log.Mylog('log_soh.txt','error')
  15. mylog.logcfg()
  16. for sn in SNnums:
  17. try:
  18. # if 'PK500' in sn:
  19. # celltype=1 #6040三元电芯
  20. # elif 'PK502' in sn:
  21. # celltype=2 #4840三元电芯
  22. # elif 'PK504' in sn:
  23. # celltype=99 #60ah林磷酸铁锂电芯
  24. # elif 'MGMLXN750' in sn:
  25. # celltype=3 #力信50ah三元电芯
  26. # elif 'MGMCLN750' in sn:
  27. # celltype=4 #CATL 50ah三元电芯
  28. # else:
  29. # print('未找到对应电池编号!!!\n',sn)
  30. # # sys.exit()
  31. celltype=99
  32. #............................................................读取原始数据库数据...........................................................................
  33. df_bms= pd.read_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\alibaba\98Download\力神40Ah-SOH原始数据.xlsx')
  34. #............................................................读取结果数据库数据.........................................................................
  35. host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  36. port=3306
  37. db='qx_cas'
  38. user='qx_read'
  39. password='Qx@123456'
  40. mode=1
  41. tablename='cellstateestimation_soh'
  42. DBRead=DBDownload.DBDownload(host, port, db, user, password, mode)
  43. with DBRead as DBRead:
  44. df_soh=DBRead.getdata(param='time_st,time_sp,sn,method,soh,cellsoh,packsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time)
  45. df_soh=pd.DataFrame()
  46. # print(df_soh)
  47. #.................................................................计算soh...................................................................................
  48. BatSoh=CBMSBatSoh.BatSoh(sn,celltype,df_bms,df_soh)
  49. df_res=BatSoh.batsoh()
  50. df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\alibaba\99Result\\'+'CBMS_SOH_'+sn+'.xlsx')
  51. # print('done!!!')
  52. except Exception as e:
  53. print(repr(e))
  54. mylog.logopt(sn,e)
  55. pass