import pandas as pd import datetime import pymysql import log from LIB.BACKEND import DBManager, Log from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload if __name__ == "__main__": 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') start_time = pd.to_datetime('2021-09-01 12:00:00',format='%Y-%m-%d %H:%M:%S') end_time = pd.to_datetime('2021-11-01 12:00:00',format='%Y-%m-%d %H:%M:%S') excelpath=r'D:\Develop\User\Liuzhongxiao\data_analyze_platform\USER\01算法开发\00项目sn号\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_U7255, SNnums_6040 + SNnums_4840 + SNnums_6060 SNnums=['PK504B00100004003'] # SNnums_data = pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\增加波峰高度与峰谷比计算结果\SNnums_C7255析锂情况析锂排序.csv',encoding='GB18030') # SNnums_len = len(SNnums_data) # SNnums = SNnums_data['sn'][SNnums_len-11:SNnums_len] #log信息配置 mylog=log.Mylog('log.txt','error') mylog.logcfg() # df_li_plated = pd.DataFrame(columns = ['sn','time','liplated','liplated_amount']) k = 1 for sn in SNnums: try: # celltype=4 # sn=SNnums[2] print('下载数据中,第' + str(k) + '个:' + sn) #下载数据库.......................................................................................................................................... # host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com' # port=3306 # db='qx_cas' # user='qx_algo_readonly' # password='qx@123456' # mode = 2 # tablename='cellstateestimation_soh' # DBRead=DBDownload.DBDownload(host, port, db, user, password, mode) # with DBRead as DBRead: # df_cell_soh=DBRead.getdata(param='sn,time_sp,soh,cellsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time) # # df_li_plated = df_li_plated.append(df_cell_li_plated) # if not df_cell_soh.empty: # df_cell_soh.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\增加波峰高度与峰谷比计算结果\析锂排序后10模组的soh\\'+ sn + '.csv', encoding='GB18030') #下载原始数据------------------------------------------------------------------------------------------------------------------------------------ start_time = '2021-11-01 00:00:00' end_time = '2021-12-04 00:00:00' 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.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\01下载数据\金茂\原始数据\\'+sn+'.csv', encoding='GB18030') df_bms.to_csv(r'D:\Develop\User\Liuzhongxiao\data_analyze_platform\USER\02问题查询\PK504B\PK504B00100004003.csv', encoding='GB18030') k = k + 1 # if not df_bms.empty: # BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms) # df_res=BatInterShort.intershort() #df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\04didi\99Result\\'+'CBMS_InterShort'+sn[3:10]+'.xlsx') # print(sn,'done!!!') print(sn) except IndexError as e: print(repr(e)) mylog.logopt(sn,e) pass # df_li_plated.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\析锂状态.csv', encoding='GB18030')