BMSuploaderrortest.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. __author__ = 'lmstack'
  2. #coding=utf-8
  3. import os
  4. import datetime
  5. import pandas as pd
  6. from LIB.BACKEND import DBManager, Log
  7. from sqlalchemy import create_engine
  8. from sqlalchemy.orm import sessionmaker
  9. import time, datetime
  10. import dateutil.relativedelta
  11. import traceback
  12. from LIB.MIDDLE.CellStateEstimation.Common import log
  13. from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload as DBDownload
  14. import time, datetime
  15. from pandas.core.frame import DataFrame
  16. from apscheduler.schedulers.blocking import BlockingScheduler
  17. from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DataStatistics import DataSta
  18. from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_CtrlSafty import CtrlSafty
  19. from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DiagDataMerge import DiagDataMerge
  20. from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_SamplingSafty import SamplingSafty
  21. from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_BMSUploadError import BMSReportError
  22. from LIB.MIDDLE.SaftyCenter.DataDiag_Static import CBMSBatDiag
  23. from LIB.MIDDLE.SaftyCenter.Common import DBDownload as DBDw
  24. from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam as QX_BatteryParam
  25. from urllib import parse
  26. import pymysql
  27. # 故障映射表
  28. host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  29. port=3306
  30. db='algo_dict'
  31. user='qx_algo_rw'
  32. password=parse.quote_plus('qx@123456')
  33. db_engine = create_engine(
  34. "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
  35. user, password, host, port, db
  36. ))
  37. errorcode_map = pd.read_sql("select * from faultcode_map", db_engine)
  38. db_engine.dispose()
  39. sn = 'PK504B10100004349'
  40. start_time = '2021-12-30 18:00:04'
  41. end_time = '2021-12-30 18:15:04'
  42. dbManager = DBManager.DBManager()
  43. df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
  44. df_bms = df_data['bms']
  45. df_bms=df_bms.dropna(subset=['总电流[A]'])
  46. df_bms=df_bms.reset_index(drop=True)
  47. df_Diag_Batdiag_update=BMSReportError.main(sn,df_bms,pd.DataFrame(),1,errorcode_map)
  48. print(df_Diag_Batdiag_update)