1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import CBMSBatInterShort
- #coding=utf-8
- import sys
- import datetime
- import pandas as pd
- from LIB.BACKEND import DBManager, Log
- from sqlalchemy import create_engine
- import time, datetime
- from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload
- from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import log
- dbManager = DBManager.DBManager()
- if __name__ == "__main__":
- excelpath=r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\sn-20210903.xlsx'
- SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
- SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
- SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
- SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
- SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
- SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
- SNnums_6060=SNdata_6060['SN号'].tolist()
- SNnums_6040=SNdata_6040['SN号'].tolist()
- SNnums_4840=SNdata_4840['SN号'].tolist()
- SNnums_L7255=SNdata_L7255['SN号'].tolist()
- SNnums_C7255=SNdata_C7255['SN号'].tolist()
- SNnums_U7255=SNdata_U7255['SN号'].tolist()
- SNnums= SNnums_6060 + SNnums_L7255 + SNnums_C7255 + SNnums_6040 + SNnums_4840 + SNnums_U7255
- SNnums=['TJMCL120502305038','TJMCL120502305032','TJMCL120502305022','TJMCL120502305026','TJMCL120502305032','TJMCL120502305044','TJMCL120502305048','TJMCL120502305012','TJMCL120502305010']
-
- now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
- start_time=now_time-datetime.timedelta(days=30)
- end_time=str(now_time)
- start_time=str(start_time)
- start_time='2021-11-17 00:00:00'
- end_time='2021-11-23 00:00:00'
- #log信息配置
- mylog=log.Mylog('log_short.txt','error')
- mylog.logcfg()
- for sn in SNnums:
- try:
- if 'PK500' in sn:
- celltype=1 #6040三元电芯
- elif 'PK502' in sn:
- celltype=2 #4840三元电芯
- elif 'K504B' in sn:
- celltype=99 #60ah林磷酸铁锂电芯
- elif 'MGMLXN750' in sn:
- celltype=3 #力信50ah三元电芯
- elif ('MGMCLN750' or 'UD') in sn:
- celltype=4 #CATL 50ah三元电芯
- else:
- celltype=100
- print('SN:{},未找到对应电池类型!!!'.format(sn))
- # continue
- # sys.exit()
-
- # df_bms= pd.read_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\98Download\\'+'BMS_'+sn+'.csv',encoding='GB18030')
- #......................................................................读取原始数据库数据..................................................................................
- dbManager = DBManager.DBManager()
- df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
- df_bms = df_data['bms']
- df_bms=df_bms.dropna(subset=['总电流[A]'])
- df_bms.reset_index(inplace=True,drop=True) #重置索引
- df_bms.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\98Download\\'+'BMS_'+sn+'.csv',encoding='GB18030')
- #.....................................................................读取结果数据库数据.............................................................................
- host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
- port=3306
- db='qx_cas'
- user='qx_read'
- password='Qx@123456'
- mode=1
- tablename='cellstateestimation_soh'
- DBRead=DBDownload.DBDownload(host, port, db, user, password, mode)
- with DBRead as DBRead:
- df_soh=DBRead.getdata(param='time_st,time_sp,sn,method,soh,cellsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time)
-
- #...........................................................................计算漏电流............................................................................
- BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh)
- df_res=BatInterShort.intershort()
- df_res.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\99Result\\'+'CBMS_Short_1_'+sn+'.csv',encoding='GB18030')
- # print('done!!!')
-
- except Exception as e:
- print(repr(e))
- mylog.logopt(sn,e)
- pass
|