main.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 sqlalchemy import create_engine
  10. from sqlalchemy.orm import sessionmaker
  11. import time, datetime
  12. from urllib import parse
  13. from LIB.MIDDLE.CellStateEstimation.Common import DBDownload
  14. dbManager = DBManager.DBManager()
  15. if __name__ == "__main__":
  16. excelpath=r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\sn-20210903.xlsx'
  17. SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
  18. SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
  19. SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
  20. SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
  21. SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
  22. SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
  23. SNnums_6060=SNdata_6060['SN号'].tolist()
  24. SNnums_6040=SNdata_6040['SN号'].tolist()
  25. SNnums_4840=SNdata_4840['SN号'].tolist()
  26. SNnums_L7255=SNdata_L7255['SN号'].tolist()
  27. SNnums_C7255=SNdata_C7255['SN号'].tolist()
  28. SNnums_U7255=SNdata_U7255['SN号'].tolist()
  29. SNnums= SNnums_6060 + SNnums_L7255 + SNnums_C7255 + SNnums_6040 + SNnums_4840 + SNnums_U7255
  30. now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  31. now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
  32. start_time=now_time-datetime.timedelta(days=20)
  33. end_time=str(now_time)
  34. start_time=str(start_time)
  35. #log信息配置
  36. mylog=log.Mylog('log.txt','error')
  37. mylog.logcfg()
  38. for sn in SNnums:
  39. try:
  40. if 'PK500' in sn:
  41. celltype=1 #6040三元电芯
  42. elif 'PK502' in sn:
  43. celltype=2 #4840三元电芯
  44. elif 'K504B' in sn:
  45. celltype=99 #60ah林磷酸铁锂电芯
  46. elif 'MGMLXN750' in sn:
  47. celltype=3 #力信50ah三元电芯
  48. elif 'MGMCLN750' or 'UD' in sn:
  49. celltype=4 #CATL 50ah三元电芯
  50. else:
  51. print('SN:{},未找到对应电池类型!!!'.format(sn))
  52. continue
  53. # sys.exit()
  54. # sn='PK504B10100004386'
  55. # celltype=99
  56. # start_time='2021-6-21 9:49:37'
  57. # end_time='2021-6-22 19:49:37'
  58. # df_bms= pd.read_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\98Download\\'+'BMS_'+sn+'.csv',encoding='GB18030')
  59. #.....................................................................读取原始数据库数据...........................................................................
  60. dbManager = DBManager.DBManager()
  61. df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
  62. df_bms = df_data['bms']
  63. # df_bms.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\98Download\\'+'BMS_'+sn+'.csv',encoding='GB18030')
  64. #.........................................................................计算一致性..............................................................................
  65. BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms)
  66. df_res=BatUniform.batuniform()
  67. df_res.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\99Result\\'+'CBMS_Uniform'+sn+'_3.csv',encoding='GB18030')
  68. # print('done!!!')
  69. except IndexError as e:
  70. print(repr(e))
  71. mylog.logopt(sn,e)
  72. pass