main.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import CBMSBatInterShort
  2. import log
  3. #coding=utf-8
  4. import sys
  5. import datetime
  6. import pandas as pd
  7. from LIB.BACKEND import DBManager, Log
  8. from sqlalchemy import create_engine
  9. import time, datetime
  10. host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  11. port=3306
  12. db='qx_cas'
  13. user='qx_read'
  14. password='Qx@123456'
  15. tablename='soh_result'
  16. dbManager = DBManager.DBManager()
  17. if __name__ == "__main__":
  18. excelpath=r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\sn-20210903.xlsx'
  19. SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
  20. SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
  21. SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
  22. SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
  23. SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
  24. SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
  25. SNnums_6060=SNdata_6060['SN号'].tolist()
  26. SNnums_6040=SNdata_6040['SN号'].tolist()
  27. SNnums_4840=SNdata_4840['SN号'].tolist()
  28. SNnums_L7255=SNdata_L7255['SN号'].tolist()
  29. SNnums_C7255=SNdata_C7255['SN号'].tolist()
  30. SNnums_U7255=SNdata_U7255['SN号'].tolist()
  31. SNnums= SNnums_L7255 + SNnums_C7255 + SNnums_6040 + SNnums_4840 + SNnums_6060 + SNnums_U7255
  32. now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  33. now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
  34. start_time=now_time-datetime.timedelta(days=30)
  35. end_time=str(now_time)
  36. start_time=str(start_time)
  37. #log信息配置
  38. mylog=log.Mylog('log.txt','error')
  39. mylog.logcfg()
  40. for sn in SNnums:
  41. try:
  42. if 'PK500' in sn:
  43. celltype=1 #6040三元电芯
  44. elif 'PK502' in sn:
  45. celltype=2 #4840三元电芯
  46. elif 'K504B' in sn:
  47. celltype=99 #60ah林磷酸铁锂电芯
  48. elif 'MGMLXN750' in sn:
  49. celltype=3 #力信50ah三元电芯
  50. elif 'MGMCLN750' or 'UD' in sn:
  51. celltype=4 #CATL 50ah三元电芯
  52. else:
  53. print('SN:{},未找到对应电池类型!!!'.format(sn))
  54. continue
  55. # sys.exit()
  56. # sn='MGMCLN750N215H001'
  57. # celltype=2
  58. start_time='2021-08-02 09:12:26'
  59. end_time='2021-09-03 19:12:26'
  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\99Result\\''BMS_'+sn+'.csv',encoding='GB18030')
  64. BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,host, port, db, user, password, tablename)
  65. df_res=BatInterShort.intershort()
  66. df_res.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\99Result\\'+'CBMS_Short_'+sn+'_1.csv',encoding='GB18030')
  67. except Exception as e:
  68. print(repr(e))
  69. mylog.logopt(sn,e)
  70. pass