import datetime import pandas as pd import datetime from USER.SPF.alibaba.Common import DBDownload from USER.SPF.alibaba.Common import log import CBMSBatSoh if __name__ == "__main__": SNnums= ['LISHEN01'] end_time=datetime.datetime.now()-datetime.timedelta(seconds=10) start_time=end_time-datetime.timedelta(seconds=12000) start_time=start_time.strftime('%Y-%m-%d %H:%M:%S') end_time=end_time.strftime('%Y-%m-%d %H:%M:%S') #log信息配置............................................................................................................................................................................ mylog=log.Mylog('log_soh.txt','error') mylog.logcfg() for sn in SNnums: try: # if 'PK500' in sn: # celltype=1 #6040三元电芯 # elif 'PK502' in sn: # celltype=2 #4840三元电芯 # elif 'PK504' in sn: # celltype=99 #60ah林磷酸铁锂电芯 # elif 'MGMLXN750' in sn: # celltype=3 #力信50ah三元电芯 # elif 'MGMCLN750' in sn: # celltype=4 #CATL 50ah三元电芯 # else: # print('未找到对应电池编号!!!\n',sn) # # sys.exit() celltype=99 #............................................................读取原始数据库数据........................................................................... df_bms= pd.read_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\alibaba\98Download\力神40Ah-SOH原始数据.xlsx') #............................................................读取结果数据库数据......................................................................... 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,packsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time) df_soh=pd.DataFrame() # print(df_soh) #.................................................................计算soh................................................................................... BatSoh=CBMSBatSoh.BatSoh(sn,celltype,df_bms,df_soh) df_res=BatSoh.batsoh() df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\alibaba\99Result\\'+'CBMS_SOH_'+sn+'.xlsx') # print('done!!!') except Exception as e: print(repr(e)) mylog.logopt(sn,e) pass