Selaa lähdekoodia

Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev

qingfeng 2 vuotta sitten
vanhempi
commit
2f14c6d532

+ 0 - 46
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/create_table.py

@@ -1,46 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func, Text
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "outlier_voltchangeratio"
-    __table_args__ = ({'comment': '电压变化率离群度'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), comment='记录创建时间') # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now(), comment='记录更新时间') # 更新时间
-    
-    sn = Column(String(64), comment="sn")
-    time = Column(TIMESTAMP(True), comment="计算时间")
-
-    VolOl_Uni = Column(Text, comment="电芯电压离群度")
-    VolChng_Uni = Column(Text, comment="电芯电压变化率")
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 50
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/create_table_uniform.py

@@ -1,50 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func, Text
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "cellstateestimation_uniform"
-    __table_args__ = ({'comment': '一致性'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), comment='记录创建时间') # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now(), comment='记录更新时间') # 更新时间
-    
-    sn = Column(String(64), comment="sn")
-    time = Column(TIMESTAMP(True), comment="计算时间")
-
-    cellsoc_diff = Column(FLOAT, comment="soc差")
-    cellvolt_diff = Column(FLOAT, comment="电压差")
-    cellmin_num = Column(Integer, comment="最小电压编号")
-    cellmax_num = Column(FLOAT, comment="最大电压编号")
-    cellvolt_rank = Column(Text, comment="电芯静置电压排名")
-
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 325
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy.py

@@ -1,325 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import datetime
-import traceback
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSSafetyWarning
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatInterShort
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatUniform
-# from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import VoltStray
-from urllib import parse
-import pymysql
-import logging
-import logging.handlers
-import re
-from apscheduler.schedulers.blocking import BlockingScheduler
-
-#...................................电池包电芯安全诊断函数......................................................................................................................
-def saftywarning_cal():
-    global df_sn
-    global df_warning_ram
-    global df_warning_ram1
-    global df_warning_ram2
-    global df_warning_ram3
-    global df_lfp_ram
-    global df_lfp_ram1
-    global df_chrgvolt_ram
-    
-    
-    # 读取结果数据库
-    host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port2=3306
-    db2='safety_platform'
-    user2='qx_algo_rw'
-    password2='qx@123456'
-    
-    db_safety_platform_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user2, parse.quote_plus(password2), host2, port2, db2
-        ))
-    conn_platform = pymysql.connect(host=host2, port=port2, user=user2, password=password2, database=db2)
-    cursor_platform = conn_platform.cursor()
-
-    
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qx_cas'
-    user='qx_algo_rw'
-    password='qx@123456'
-    
-    db_qxcas_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, parse.quote_plus(password), host, port, db
-        ))
-    
-    conn_cas = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor_cas = conn_cas.cursor()
-    
-    df_fault_ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info where end_time={} and code={}".format('0000-00-00 00:00:00','C490'), db_safety_platform_engine)
-    # result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
-    # df_fault_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']=='C490')]
-    
-    now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=6)
-    start_time1=now_time-datetime.timedelta(days=7)
-    start_time2=now_time-datetime.timedelta(days=3)
-    start_time3=now_time-datetime.timedelta(days=1)
-
-    start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
-    start_time1=start_time1.strftime('%Y-%m-%d %H:%M:%S')
-    start_time2=start_time2.strftime('%Y-%m-%d %H:%M:%S')
-    start_time3=start_time3.strftime('%Y-%m-%d %H:%M:%S')
-    end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
-
-    for i in range(0, len(df_sn)):
-        factory = "骑享"
-        try:
-            sn = df_sn.loc[i, 'sn']
-            if df_sn.loc[i, 'imei'][5:9] == 'N640':
-                celltype=1 #6040三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'N440':
-                celltype=2 #4840三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'L660':
-                celltype=99 # 6060锂电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
-                celltype=3 #力信 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
-                celltype=4 #CATL 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
-                celltype=100 # 重卡
-                factory = "金茂换电"
-            else:
-                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
-                continue
-            
-            
-            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
-
-            # 读取soh数据
-            df_soh = pd.read_sql("select time_st,sn,soh,cellsoh from cellstateestimation_soh where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
-            df_uniform.loc[0,'cellvolt_rank']=str([1]*20)
-            # df_voltsigma=pd.DataFrame()
-            #读取原始数据库数据................................................................................id........................................................................
-            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']
-            # print(df_bms)
-
-            #电池诊断................................................................................................................................................................
-            if not df_bms.empty:
-                 #电池内短路计算................................................................................................................................................................
-                df_warning_ram_sn=df_warning_ram[df_warning_ram['sn']==sn]
-                df_warning_ram_sn1=df_warning_ram1[df_warning_ram1['sn']==sn]
-                df_warning_ram_sn2=df_warning_ram2[df_warning_ram2['sn']==sn]
-                df_warning_ram_sn3=df_warning_ram3[df_warning_ram3['sn']==sn]
-                df_chrgvolt_ram_sn=df_chrgvolt_ram[df_chrgvolt_ram['sn']==sn]
-                df_warning_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn2.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn3.reset_index(inplace=True,drop=True)     #重置索引
-                if not df_lfp_ram.empty:
-                    df_lfp_ram_sn=df_lfp_ram[df_lfp_ram['sn']==sn]
-                    df_lfp_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-                else:
-                    df_lfp_ram_sn=pd.DataFrame()
-                    df_lfp_ram=pd.DataFrame(columns=df_bms.columns.tolist()+['sn'])
-                    
-                if celltype>50 and (not df_lfp_ram1.empty):
-                    df_lfp_ram_sn1=df_lfp_ram1[df_lfp_ram1['sn']==sn]
-                    df_lfp_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
-                else:
-                    df_lfp_ram_sn1=pd.DataFrame()
-                    df_lfp_ram1=pd.DataFrame(columns=df_bms.columns.tolist()+['sn'])
-                
-                #内短路计算..................................................................................................................................................
-                BatShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh,df_warning_ram_sn,df_warning_ram_sn1,df_warning_ram_sn2,df_warning_ram_sn3,df_lfp_ram_sn,df_chrgvolt_ram_sn)
-                df_short_res, df_ram_res, df_ram_res1, df_ram_res2, df_ram_res3, df_ram_res4, df_chrgvolt_ram_sn=BatShort.intershort() 
-
-                if not df_short_res.empty:
-                    df_short_res.columns = ['time_st', 'time_sp', 'sn', 'method', 'short_current', 'baltime']
-                    df_short_res.to_sql("cellStateEstimation_interShort",con=db_qxcas_engine, if_exists="append",index=False)
-                    
-                #静置电压排名..................................................................................................................................................
-                BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms,df_uniform,df_ram_res3,df_lfp_ram_sn1)
-                df_rank_res, df_ram_res3, df_ram_res5=BatUniform.batuniform()
-                if not df_rank_res.empty:
-                    df_uniform=df_rank_res
-                    df_rank_res.to_sql("cellstateestimation_uniform_socvoltdiff",con=db_qxcas_engine, if_exists="append",index=False)
-                
-                #电压离群.....................................................................................................................................................
-                # df_voltsigma=VoltStray.main(sn,df_bms,celltype)
-                # if not df_voltsigma.empty:
-                #     df_voltsigma.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
-
-
-                #内短路ram处理.........................................................
-                df_warning_ram=df_warning_ram.drop(df_warning_ram[df_warning_ram.sn==sn].index)
-                df_warning_ram1=df_warning_ram1.drop(df_warning_ram1[df_warning_ram1.sn==sn].index)
-                df_warning_ram2=df_warning_ram2.drop(df_warning_ram2[df_warning_ram2.sn==sn].index)
-                df_warning_ram3=df_warning_ram3.drop(df_warning_ram3[df_warning_ram3.sn==sn].index)
-                df_chrgvolt_ram=df_chrgvolt_ram.drop(df_chrgvolt_ram[df_chrgvolt_ram.sn==sn].index)
-
-                df_warning_ram=pd.concat([df_warning_ram,df_ram_res],ignore_index=True)
-                df_warning_ram1=pd.concat([df_warning_ram1,df_ram_res1],ignore_index=True)
-                df_warning_ram2=pd.concat([df_warning_ram2,df_ram_res2],ignore_index=True)
-                df_warning_ram3=pd.concat([df_warning_ram3,df_ram_res3],ignore_index=True)
-                df_chrgvolt_ram=pd.concat([df_chrgvolt_ram,df_chrgvolt_ram_sn],ignore_index=True)
-
-                df_lfp_ram=df_lfp_ram.drop(df_lfp_ram[df_lfp_ram.sn==sn].index)
-                df_lfp_ram=pd.concat([df_lfp_ram,df_ram_res4],ignore_index=True)
-                
-                if celltype>50:
-                    df_lfp_ram1=df_lfp_ram1.drop(df_lfp_ram1[df_lfp_ram1.sn==sn].index)
-                    df_lfp_ram1=pd.concat([df_lfp_ram1,df_ram_res5],ignore_index=True)
-                    
-            #电池热安全预警..............................................................................................................................................................
-            #读取内短路、析锂和一致性结果数据库数据
-            df_short = pd.read_sql("select time_sp,sn,short_current from cellstateestimation_intershort where sn = '{}' and time_sp between '{}' and '{}'".format(sn,start_time1,end_time), db_qxcas_engine)
-            # df_liplated = pd.read_sql("select time,sn,liplated,liplated_amount from mechanism_liplated where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
-            # df_voltsigma = pd.read_sql("select time,sn,VolOl_Uni,VolChng_Uni from outlier_voltchangeratio where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
-
-            #获取sn的故障RAM
-            df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
-            df_fault_ram_sn.reset_index(inplace=True, drop=True)
-            
-            #热安全预警
-            BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_soh,df_fault_ram_sn)
-            df_res_new, df_res_chg=BatWarning.diag()
-            #新增内短路故障写入数据库
-            if not df_res_new.empty:
-                df_res_new['add_time'] = datetime.datetime.now()
-                df_res_new['factory'] = factory
-                df_res_new.to_sql("all_fault_info",con=db_safety_platform_engine, if_exists="append",index=False)
-                conn_platform.commit()
-            #内短路结束故障更新数据库
-            if not df_res_chg.empty:
-                df_res_chg['Batpos']=1
-                cursor_platform.execute('''
-                        update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00'
-                        '''.format(datetime.datetime.now(), df_res_chg.iloc[-1]['end_time'], df_res_chg.iloc[-1]['Batpos'],sn, 'C490'))
-                conn_platform.commit()
-        except Exception as e:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-    cursor_platform.close()
-    conn_platform.close()
-    cursor_cas.close()
-    conn_cas.close()
-    db_qxcas_engine.dispose()
-    db_safety_platform_engine.dispose()
-    logger.info("pid-{} Done!".format(os.getpid()))
-
-#...................................................主进程...........................................................................................................
-if __name__ == "__main__":
-
-     # 日志
-    log_path = 'log/'
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    logger = logging.getLogger("main")
-    logger.setLevel(logging.DEBUG)
-    
-     # 根据日期滚动(每天产生1个文件)
-    fh = logging.handlers.TimedRotatingFileHandler(filename='{}/main_info.log'.format(log_path), when="D", interval=1, backupCount=30,
-                                                    encoding="utf-8")
-    formatter = logging.Formatter("%(asctime)s - %(name)s-%(levelname)s %(message)s")
-    fh.suffix = "%Y-%m-%d_%H-%M-%S"
-    fh.extMatch = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}")
-    fh.setFormatter(formatter)
-    fh.setLevel(logging.INFO)
-    logger.addHandler(fh)
-
-    fh = logging.handlers.TimedRotatingFileHandler(filename='{}/main_error.log'.format(log_path), when="D", interval=1, backupCount=30,
-                                                    encoding="utf-8")
-    formatter = logging.Formatter("%(asctime)s - %(name)s-%(levelname)s %(message)s")
-    fh.suffix = "%Y-%m-%d_%H-%M-%S"
-    fh.extMatch = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}")
-    fh.setFormatter(formatter)
-    fh.setLevel(logging.ERROR)
-    logger.addHandler(fh)
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-    # 时间设置
-    # now_time = datetime.datetime.now()
-    # pre_time = now_time + dateutil.relativedelta.relativedelta(days=-1)# 前一日
-    # end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 00:00:00")
-    # start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 00:00:00")
-    
-    history_run_flag = False # 历史数据运行标志
-    
-
-    # # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device where status in (1,2,3)")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 运行历史数据配置
-    
-    df_first_data_time = pd.read_sql("select * from bat_first_data_time", db_engine)
-    
-    # 算法参数
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='safety_platform'
-    user='qx_read'
-    password=parse.quote_plus('Qx@123456')
-    tablename='all_fault_info'
-    db_res_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, db
-        ))
-
-        
-    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................
-    df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
-    df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
-    df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
-    df_warning_ram3=pd.DataFrame(columns=['sn','time3','standingtime','standingtime1','standingtime2'])
-    df_lfp_ram=pd.DataFrame()
-    df_lfp_ram1=pd.DataFrame()
-    df_chrgvolt_ram=pd.DataFrame(columns=['sn','time','deltvolt','packcrnt_avg','temp_avg'])
-
-    # now_time='2021-10-15 00:00:00'
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    saftywarning_cal()
-    #定时任务.......................................................................................................................................................................
-    scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', hours=6, id='saftywarning_cal')
-
-    try:  
-        scheduler.start()
-    except Exception as e:
-        scheduler.shutdown()
-        logger.error(str(e))
-    

+ 0 - 305
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy_test.py

@@ -1,305 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-import traceback
-from LIB.MIDDLE.CellStateEstimation.Common import log
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSSafetyWarning
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatInterShort
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import CBMSBatUniform
-from LIB.MIDDLE.CellStateEstimation.BatSafetyWarning.V1_0_1 import VoltStray
-from urllib import parse
-import pymysql
-
-from apscheduler.schedulers.blocking import BlockingScheduler
-
-#...................................电池包电芯安全诊断函数......................................................................................................................
-def saftywarning_cal():
-    global df_sn
-    global df_warning_ram
-    global df_warning_ram1
-    global df_warning_ram2
-    global df_warning_ram3
-    global df_lfp_ram
-    global df_lfp_ram1
-
-    
-    
-    # 读取结果数据库
-    host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port2=3306
-    db2='safety_platform'
-    user2='qx_algo_rw'
-    password2='qx@123456'
-    
-    db_safety_platform_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user2, parse.quote_plus(password2), host2, port2, db2
-        ))
-    conn_platform = pymysql.connect(host=host2, port=port2, user=user2, password=password2, database=db2)
-    cursor_platform = conn_platform.cursor()
-
-    
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qx_cas'
-    user='qx_algo_rw'
-    password='qx@123456'
-    
-    db_qxcas_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, parse.quote_plus(password), host, port, db
-        ))
-    
-    conn_cas = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor_cas = conn_cas.cursor()
-    
-    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info_copy where factory = '{}'".format('骑享'), db_safety_platform_engine)
-    result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
-    df_fault_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']==110)]
-    
-    now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=6)
-    start_time1=now_time-datetime.timedelta(days=7)
-    start_time2=now_time-datetime.timedelta(days=3)
-    start_time3=now_time-datetime.timedelta(days=1)
-
-    start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
-    start_time1=start_time1.strftime('%Y-%m-%d %H:%M:%S')
-    start_time2=start_time2.strftime('%Y-%m-%d %H:%M:%S')
-    start_time3=start_time3.strftime('%Y-%m-%d %H:%M:%S')
-    end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][5:9] == 'N640':
-                celltype=1 #6040三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'N440':
-                celltype=2 #4840三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'L660':
-                celltype=99 # 6060锂电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
-                celltype=3 #力信 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
-                celltype=4 #CATL 50ah三元电芯
-            else:
-                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
-                continue
-            sn = df_sn.loc[i, 'sn']
-            
-            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
-
-            # 读取soh数据
-            df_soh = pd.read_sql("select time_st,sn,soh,cellsoh from cellstateestimation_soh where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num from cellstateestimation_uniform_socvoltdiff where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
-            df_uniform.loc[0,'cellvolt_rank']=str([1]*20)
-            df_voltsigma=pd.DataFrame()
-            #读取原始数据库数据................................................................................id........................................................................
-            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']
-            # print(df_bms)
-
-            #电池诊断................................................................................................................................................................
-            if not df_bms.empty:
-                 #电池内短路计算................................................................................................................................................................
-                df_warning_ram_sn=df_warning_ram[df_warning_ram['sn']==sn]
-                df_warning_ram_sn1=df_warning_ram1[df_warning_ram1['sn']==sn]
-                df_warning_ram_sn2=df_warning_ram2[df_warning_ram2['sn']==sn]
-                df_warning_ram_sn3=df_warning_ram3[df_warning_ram3['sn']==sn]
-                df_warning_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn2.reset_index(inplace=True,drop=True)     #重置索引
-                df_warning_ram_sn3.reset_index(inplace=True,drop=True)     #重置索引
-                if celltype>50 and (not df_lfp_ram.empty):
-                    df_lfp_ram_sn=df_lfp_ram[df_lfp_ram['sn']==sn]
-                    df_lfp_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-                else:
-                    df_lfp_ram_sn=pd.DataFrame()
-                    df_lfp_ram=pd.DataFrame(columns=df_bms.columns.tolist()+['sn'])
-                    
-                if celltype>50 and (not df_lfp_ram1.empty):
-                    df_lfp_ram_sn1=df_lfp_ram1[df_lfp_ram1['sn']==sn]
-                    df_lfp_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
-                else:
-                    df_lfp_ram_sn1=pd.DataFrame()
-                    df_lfp_ram1=pd.DataFrame(columns=df_bms.columns.tolist()+['sn'])
-                
-                #内短路计算..................................................................................................................................................
-                BatShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh,df_warning_ram_sn,df_warning_ram_sn1,df_warning_ram_sn2,df_warning_ram_sn3,df_lfp_ram_sn)
-                df_short_res, df_ram_res, df_ram_res1, df_ram_res2, df_ram_res3, df_ram_res4=BatShort.intershort() 
-
-                if not df_short_res.empty:
-                    df_short_res.columns = ['time_st', 'time_sp', 'sn', 'method', 'short_current', 'baltime']
-                    df_short_res.to_sql("cellStateEstimation_interShort",con=db_qxcas_engine, if_exists="append",index=False)
-                    
-                #静置电压排名..................................................................................................................................................
-                BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms,df_uniform,df_ram_res3,df_lfp_ram_sn1)
-                df_rank_res, df_ram_res3, df_ram_res5=BatUniform.batuniform()
-                if not df_rank_res.empty:
-                    df_uniform=df_rank_res
-                    df_rank_res.to_sql("cellstateestimation_uniform_socvoltdiff",con=db_qxcas_engine, if_exists="append",index=False)
-                
-                #电压离群.....................................................................................................................................................
-                df_voltsigma=VoltStray.main(sn,df_bms,celltype)
-                if not df_voltsigma.empty:
-                    df_voltsigma.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
-
-
-                #内短路ram处理.........................................................
-                df_warning_ram=df_warning_ram.drop(df_warning_ram[df_warning_ram.sn==sn].index)
-                df_warning_ram1=df_warning_ram1.drop(df_warning_ram1[df_warning_ram1.sn==sn].index)
-                df_warning_ram2=df_warning_ram2.drop(df_warning_ram2[df_warning_ram2.sn==sn].index)
-                df_warning_ram3=df_warning_ram3.drop(df_warning_ram3[df_warning_ram3.sn==sn].index)
-
-                df_warning_ram=pd.concat([df_warning_ram,df_ram_res],ignore_index=True)
-                df_warning_ram1=pd.concat([df_warning_ram1,df_ram_res1],ignore_index=True)
-                df_warning_ram2=pd.concat([df_warning_ram2,df_ram_res2],ignore_index=True)
-                df_warning_ram3=pd.concat([df_warning_ram3,df_ram_res3],ignore_index=True)
-                
-                if celltype>50:
-                    df_lfp_ram=df_lfp_ram.drop(df_lfp_ram[df_lfp_ram.sn==sn].index)
-                    df_lfp_ram=pd.concat([df_lfp_ram,df_ram_res4],ignore_index=True)
-                    df_lfp_ram1=df_lfp_ram1.drop(df_lfp_ram1[df_lfp_ram1.sn==sn].index)
-                    df_lfp_ram1=pd.concat([df_lfp_ram1,df_ram_res5],ignore_index=True)
-                    
-            #电池热安全预警..............................................................................................................................................................
-            #读取内短路、析锂和一致性结果数据库数据
-            df_short = pd.read_sql("select time_sp,sn,short_current from cellstateestimation_intershort where sn = '{}' and time_sp between '{}' and '{}'".format(sn,start_time1,end_time), db_qxcas_engine)
-            # df_liplated = pd.read_sql("select time,sn,liplated,liplated_amount from mechanism_liplated where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
-            df_voltsigma = pd.read_sql("select time,sn,VolOl_Uni,VolChng_Uni from outlier_voltchangeratio where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
-
-            #获取sn的故障RAM
-            df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
-            
-            #热安全预警
-            if df_fault_ram_sn.empty:
-                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_voltsigma,df_soh)
-                df_warning_res=BatWarning.diag()
-                #当前热失控故障写入数据库
-                if not df_warning_res.empty:
-                    df_warning_res['add_time'] = datetime.datetime.now()
-                    df_warning_res['factory'] = '骑享'
-                    df_warning_res.to_sql("all_fault_info_copy",con=db_safety_platform_engine, if_exists="append",index=False)
-                    conn_platform.commit()
-            else:
-                fault_time=datetime.datetime.strptime(df_fault_ram_sn.iloc[-1]['start_time'], '%Y-%m-%d %H:%M:%S')
-                if (now_time-fault_time).total_seconds()>3*24*3600:   #df_warning_end历史故障筛选并更改数据库故障结束时间
-                    df_fault_ram_sn['end_time']=end_time
-                    df_fault_ram_sn['Batpos']=1
-                    try:
-                        cursor.execute('''
-                                update all_fault_info_copy set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00' and factory='骑享'
-                                '''.format(datetime.datetime.now(), df_fault_ram_sn.loc[0,'end_time'], df_fault_ram_sn.loc[0,'Batpos'],sn, 110))
-                        conn_platform.commit()
-                    except:
-                        logger.error(traceback.format_exc)
-                        logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-    cursor_platform.close()
-    conn_platform.close()
-    cursor_cas.close()
-    conn_cas.close()
-    db_qxcas_engine.dispose()
-    db_safety_platform_engine.dispose()
-    logger.info("pid-{} Done!".format(os.getpid()))
-
-#...................................................主进程...........................................................................................................
-if __name__ == "__main__":
-    
-    # 时间设置
-    # now_time = datetime.datetime.now()
-    # pre_time = now_time + dateutil.relativedelta.relativedelta(days=-1)# 前一日
-    # end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 00:00:00")
-    # start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 00:00:00")
-    
-    history_run_flag = False # 历史数据运行标志
-    
-
-    # # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 运行历史数据配置
-    
-    df_first_data_time = pd.read_sql("select * from bat_first_data_time", db_engine)
-
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log_test/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='batsafetyWarning', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-    # 算法参数
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='safety_platform'
-    user='qx_read'
-    password=parse.quote_plus('Qx@123456')
-    tablename='all_fault_info_copy'
-    db_res_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, db
-        ))
-
-        
-    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................
-    df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
-    df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
-    df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
-    df_warning_ram3=pd.DataFrame(columns=['sn','time3','standingtime','standingtime1','standingtime2'])
-    df_lfp_ram=pd.DataFrame()
-    df_lfp_ram1=pd.DataFrame()
-
-    # now_time='2021-10-15 00:00:00'
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    saftywarning_cal()
-    #定时任务.......................................................................................................................................................................
-    scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', hours=6, id='saftywarning_cal')
-
-    try:  
-        scheduler.start()
-    except Exception as e:
-        scheduler.shutdown()
-        logger.error(str(e))
-    

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 88059
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/log/2022-03-06 17_16_40/info.log.1


+ 0 - 186
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/main.py

@@ -1,186 +0,0 @@
-import pandas as pd
-import pymysql
-from LIB.BACKEND import DBManager, Log
-from apscheduler.schedulers.blocking import BlockingScheduler
-import time, datetime
-from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload
-from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import log
-import CBMSBatInterShort
-import CBMSSafetyWarning
-
-#电池热安全预警核心算法函数......................................................................................................................
-def saftywarning_cal():
-    global SNnums
-    global df_warning_ram
-    global df_warning_ram1
-    global df_warning_ram2
-    global df_warning_ram3
-    global df_lfp_ram
-    
-    now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=12)
-    start_time1=now_time-datetime.timedelta(days=7)
-    start_time2=now_time-datetime.timedelta(days=90)
-    start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
-    start_time1=start_time1.strftime('%Y-%m-%d %H:%M:%S')
-    end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
-
-    #数据库配置
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    user='qx_read'
-    password='Qx@123456'
-
-    #读取故障结果库中code==110且end_time='0000-00-00 00:00:00'...............................
-    db='safety_platform'
-    mysql = pymysql.connect (host=host, user=user, password=password, port=port, database=db)
-    cursor = mysql.cursor()
-    param='start_time,end_time,product_id,code,level,info,advice'
-    tablename='all_fault_info'
-    sql =  "select %s from %s where code=110 and end_time='0000-00-00 00:00:00'" %(param,tablename)
-    cursor.execute(sql)
-    res = cursor.fetchall()
-    df_fault_ram= pd.DataFrame(res,columns=param.split(','))
-    cursor.close()
-    mysql.close()
-
-    for sn in SNnums:
-        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:
-            print('SN:{},未找到对应电池类型!!!'.format(sn))
-            continue
-            # sys.exit()
-
-        #读取原始数据库数据........................................................................................................................................................
-        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']
-        # tim=start_time.replace(':','_')
-        # df_bms.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\98Download\\'+sn+'_BMS_'+tim+'.csv',encoding='GB18030')
-
-        #读取结果数据库数据........................................................................................................................................................
-        db='qx_cas'
-        mode=1
-        tablename='cellstateestimation_soh'
-        DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
-        with DBRead as DBRead:
-            df_soh=DBRead.getdata('time_st,sn,soh,cellsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time)
-
-        if not df_bms.empty:
-            #电池内短路计算................................................................................................................................................................
-            df_warning_ram_sn=df_warning_ram[df_warning_ram['sn']==sn]
-            df_warning_ram_sn1=df_warning_ram1[df_warning_ram1['sn']==sn]
-            df_warning_ram_sn2=df_warning_ram2[df_warning_ram2['sn']==sn]
-            df_warning_ram_sn3=df_warning_ram3[df_warning_ram3['sn']==sn]
-            df_warning_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-            df_warning_ram_sn1.reset_index(inplace=True,drop=True)     #重置索引
-            df_warning_ram_sn2.reset_index(inplace=True,drop=True)     #重置索引
-            df_warning_ram_sn3.reset_index(inplace=True,drop=True)     #重置索引
-            if celltype>50:
-                df_lfp_ram=df_lfp_ram.reindex(columns=df_bms.columns.tolist()+['sn'])
-                df_lfp_ram_sn=df_lfp_ram[df_lfp_ram['sn']==sn]
-                df_lfp_ram_sn.reset_index(inplace=True,drop=True)     #重置索引
-            else:
-                df_lfp_ram_sn=pd.DataFrame()
-
-            BatShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_soh,df_warning_ram_sn,df_warning_ram_sn1,df_warning_ram_sn2,df_warning_ram_sn3,df_lfp_ram_sn)
-            df_short_res, df_ram_res, df_ram_res1, df_ram_res2, df_ram_res3, df_ram_res4=BatShort.intershort() 
-
-            if not df_short_res.empty:
-                with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\内短路.txt','a') as file:
-                    file.write(str(df_short_res)+'\n')
-
-            #内短路ram处理.........................................................
-            df_warning_ram=df_warning_ram.drop(df_warning_ram[df_warning_ram.sn==sn].index)
-            df_warning_ram1=df_warning_ram1.drop(df_warning_ram1[df_warning_ram1.sn==sn].index)
-            df_warning_ram2=df_warning_ram2.drop(df_warning_ram2[df_warning_ram2.sn==sn].index)
-            df_warning_ram3=df_warning_ram3.drop(df_warning_ram3[df_warning_ram3.sn==sn].index)
-
-            df_warning_ram=pd.concat([df_warning_ram,df_ram_res],ignore_index=True)
-            df_warning_ram1=pd.concat([df_warning_ram1,df_ram_res1],ignore_index=True)
-            df_warning_ram2=pd.concat([df_warning_ram2,df_ram_res2],ignore_index=True)
-            df_warning_ram3=pd.concat([df_warning_ram3,df_ram_res3],ignore_index=True)
-            
-            if celltype>50:
-                df_lfp_ram=df_lfp_ram.drop(df_lfp_ram[df_lfp_ram.sn==sn].index)
-                df_lfp_ram=pd.concat([df_lfp_ram,df_ram_res4],ignore_index=True)
-            
-
-        #电池热安全预警..............................................................................................................................................................
-        #读取内短路、析锂和一致性结果数据库数据
-        db='qx_cas'
-        mode=2
-        tablename1='cellstateestimation_intershort'
-        tablename2=''   #析锂表单
-        tablename3='cellstateestimation_uniform_socvoltdiff'
-        DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
-        with DBRead as DBRead:
-            df_short=DBRead.getdata('time_sp,sn,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
-            # df_liplated=DBRead.getdata('time,sn,liplated,lipltd_amount', tablename=tablename2, sn=sn, timename='time_sp', st=start_time2, sp=end_time)
-            df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellmin_num', tablename=tablename3, sn=sn, timename='time', st=start_time1, sp=end_time)
-            df_liplated=pd.DataFrame()
-        
-        #获取sn的故障RAM
-        df_fault_ram_sn=df_fault_ram[df_fault_ram['product_id']==sn]
-        
-        #热安全预警
-        BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_fault_ram_sn)
-        df_warning_res=BatWarning.diag()
-
-        df_warning_end=df_warning_res[df_warning_res['end_time'] != '0000-00-00 00:00:00']
-        if not df_warning_end.empty:    #df_warning_end历史故障筛选并更改数据库故障结束时间
-            pass   
-        elif df_fault_ram_sn.empty and (not df_warning_res.empty):
-            with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a') as file:
-                file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
-        else:
-            pass
-
-#...............................................主函数起定时作用.......................................................................................................................
-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_L7255 + SNnums_C7255 + SNnums_U7255, SNnums_6040 + SNnums_4840 + SNnums_6060
-    SNnums=['MGMCLN750N215N099','PK504B10100004425']
-    
-    mylog=log.Mylog('log_warning.txt','error')
-    mylog.logcfg()
-
-    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取...................................
-    df_warning_ram=pd.DataFrame(columns=['sn','time','deltsoc','cellsoc'])
-    df_warning_ram1=pd.DataFrame(columns=['sn','time1','deltsoc1'])
-    df_warning_ram2=pd.DataFrame(columns=['sn','time2','deltAs2'])
-    df_warning_ram3=pd.DataFrame(columns=['sn','standingtime','standingtime1'])
-    df_lfp_ram=pd.DataFrame()
-
-    #定时任务.......................................................................................................................................................................
-    scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', seconds=5)
-
-    try:  
-        scheduler.start()
-    except Exception as e:
-        scheduler.shutdown()
-        print(repr(e))
-        mylog.logopt(e)

+ 0 - 4
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/run.bat

@@ -1,4 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\BatSafetyWarning
-title cal_batsafetywarning
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\BatSafetyWarning\deploy.py
-pause

+ 0 - 4
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/run_test.bat

@@ -1,4 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\BatSafetyWarning
-title cal_batsafetywarning_test
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\BatSafetyWarning\deploy_test.py
-pause

+ 0 - 47
LIB/FRONTEND/CellStateEstimation/InterShort/create_table.py

@@ -1,47 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func, Text
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "cellStateEstimation_interShort"
-    __table_args__ = ({'comment': '内短路电流'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), server_default=func.now(), comment='记录创建时间') # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now(), comment='记录更新时间') # 更新时间
-    time_st = Column(TIMESTAMP(True), comment="开始时间")
-    time_sp = Column(TIMESTAMP(True), comment="结束时间")
-    sn = Column(String(64), comment="sn")
-
-    method = Column(Integer, comment="计算方法")
-    short_current = Column(Text, comment="内短路电流/mA")
-    baltime = Column(Text, comment="均衡时间/s")
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 134
LIB/FRONTEND/CellStateEstimation/InterShort/deploy.py

@@ -1,134 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-import dateutil.relativedelta
-import traceback
-from LIB.MIDDLE.CellStateEstimation.InterShort.V1_0_0 import CBMSBatInterShort
-from LIB.MIDDLE.CellStateEstimation.Common import DBDownload
-from urllib import parse
-import pymysql
-import pdb
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(days=-8)#上个月时间
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 00:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 12:00:00")
-    
-    history_run_flag = False # 历史数据运行标志
-    
-    
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 运行历史数据配置
-    
-    df_first_data_time = pd.read_sql("select * from bat_first_data_time", db_engine)
-
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='uniform', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-
-
-    # 算法参数
-    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qx_cas'
-    user='qx_read'
-    password='Qx@123456'
-    tablename='cellStateEstimation_soh'
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][5:9] == 'N640':
-                celltype=1 #6040三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'N440':
-                celltype=2 #4840三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'L660':
-                celltype=99 # 6060锂电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
-                celltype=3 #力信 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
-                celltype=4 #CATL 50ah三元电芯
-            else:
-                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
-                continue
-            sn = df_sn.loc[i, 'sn']
-            
-            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
-            
-            DBRead=DBDownload.DBDownload(host, port, db, user, password, 1)
-            with DBRead as DBRead:
-                df_soh=DBRead.getdata('time_st','time_sp','sn','method','soh','cellsoh', tablename=tablename, sn=sn, timename='',st='',sp='')
-            dbManager = DBManager.DBManager()
-            
-            # 处理运行历史数据
-            if (history_run_flag):
-                this_sn = df_first_data_time[df_first_data_time['sn']==sn]
-                if (len(this_sn) == 0):
-                    start_time = pd.to_datetime(str(df_sn.loc[df_sn[df_sn['sn']==sn].index, 'add_time'].values[0])).strftime("%Y-%m-%d 00:00:00")
-                else:
-                    first_data_time = df_first_data_time.loc[df_first_data_time[df_first_data_time['sn']==sn].index, 'first_data_time'].values[0]
-                    if pd.isnull(first_data_time):
-                        start_time = "2018-01-01 00:00:00"
-                    else:
-                        start_time = pd.to_datetime(str(df_first_data_time.loc[df_first_data_time[df_first_data_time['sn']==sn].index, 'first_data_time'].values[0])).strftime("%Y-%m-%d 00:00:00")
-
-            df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
-            df_bms = df_data['bms']
-
-            
-            BatInterShort=CBMSBatInterShort.BatInterShort(sn, celltype, df_bms, df_soh)
-            df_res=BatInterShort.intershort()
-
-            if not df_res.empty:
-                df_res.columns = ['time_st', 'time_sp', 'sn', 'method', 'short_current', 'baltime']
-                df_res.to_sql("cellStateEstimation_interShort",con=db_engine, if_exists="append",index=False)
-            logger.info("pid-{} celltype-{} SN: {} DONE!".format(os.getpid(), celltype, sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-

+ 0 - 80
LIB/FRONTEND/CellStateEstimation/InterShort/main.py

@@ -1,80 +0,0 @@
-import CBMSBatInterShort
-import log
-
-#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
-
-host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-port=3306
-db='qx_cas'
-user='qx_read'
-password='Qx@123456'
-tablename='soh_result'
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    excelpath=r'D:\Platform\platform_python\data_analyze_platform\USER\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_L7255 + SNnums_C7255 + SNnums_6040 + SNnums_4840 + SNnums_6060 + SNnums_U7255
-    
-    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)
-
-    #log信息配置
-    mylog=log.Mylog('log.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:
-                print('SN:{},未找到对应电池类型!!!'.format(sn))
-                continue
-                # sys.exit()
-            
-            # sn='MGMCLN750N215H001'
-            # celltype=2
-            start_time='2021-08-02 09:12:26'
-            end_time='2021-09-03 19:12:26'
-
-            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:\Platform\platform_python\data_analyze_platform\USER\01qixiang\99Result\\''BMS_'+sn+'.csv',encoding='GB18030')
-            
-            BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,host, port, db, user, password, tablename)
-            df_res=BatInterShort.intershort()
-            df_res.to_csv(r'D:\Platform\platform_python\data_analyze_platform\USER\01qixiang\99Result\\'+'CBMS_Short_'+sn+'_1.csv',encoding='GB18030')
-        
-        except Exception as e:
-            print(repr(e))
-            mylog.logopt(sn,e)
-            pass

+ 0 - 4
LIB/FRONTEND/CellStateEstimation/InterShort/run.bat

@@ -1,4 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\InterShort
-title cal_intershort
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\InterShort\deploy.py
-pause

+ 0 - 48
LIB/FRONTEND/CellStateEstimation/Uniform/create_table.py

@@ -1,48 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func, Text
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "cellStateEstimation_uniform_socVoltDiff"
-    __table_args__ = ({'comment': '一致性 计算结果'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), server_default=func.now(), comment='记录创建时间') # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now(), comment='记录更新时间') # 更新时间
-    time = Column(TIMESTAMP(True), comment="时间")
-    sn = Column(String(64), comment="sn")
-    
-    cellsoc_diff = Column(FLOAT, comment="soc差")
-    cellvolt_diff = Column(FLOAT, comment="电压差")
-    cellmin_num = Column(Integer, comment="最小电压编号")
-    cellmax_num = Column(FLOAT, comment="最大电压编号")
-
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 129
LIB/FRONTEND/CellStateEstimation/Uniform/deploy.py

@@ -1,129 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-import dateutil.relativedelta
-import traceback
-from LIB.MIDDLE.CellStateEstimation.Uniform.V1_0_0 import CBMSBatUniform
-from urllib import parse
-import pymysql
-import pdb
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(days=-6)#6天前时间
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 00:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 12:00:00")
-    
-    history_run_flag = False # 历史数据运行标志
-    
-
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 运行历史数据配置
-    
-    df_first_data_time = pd.read_sql("select * from bat_first_data_time", db_engine)
-
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='uniform', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-
-
-    # 算法参数
-    # host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    # port=3306
-    # db='qx_cas'
-    # user='qx_read'
-    # password='Qx@123456'
-    # tablename='soh_result'
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][5:9] == 'N640':
-                celltype=1 #6040三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'N440':
-                celltype=2 #4840三元电芯
-            elif df_sn.loc[i, 'imei'][5:9] == 'L660':
-                celltype=99 # 6060锂电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
-                celltype=3 #力信 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
-                celltype=4 #CATL 50ah三元电芯
-            else:
-                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
-                continue
-            sn = df_sn.loc[i, 'sn']
-            
-            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
-            
-            dbManager = DBManager.DBManager()
-            
-            # 处理运行历史数据
-            if (history_run_flag):
-                this_sn = df_first_data_time[df_first_data_time['sn']==sn]
-                if (len(this_sn) == 0):
-                    start_time = pd.to_datetime(str(df_sn.loc[df_sn[df_sn['sn']==sn].index, 'add_time'].values[0])).strftime("%Y-%m-%d 00:00:00")
-                else:
-                    first_data_time = df_first_data_time.loc[df_first_data_time[df_first_data_time['sn']==sn].index, 'first_data_time'].values[0]
-                    if pd.isnull(first_data_time):
-                        start_time = "2018-01-01 00:00:00"
-                    else:
-                        start_time = pd.to_datetime(str(df_first_data_time.loc[df_first_data_time[df_first_data_time['sn']==sn].index, 'first_data_time'].values[0])).strftime("%Y-%m-%d 00:00:00")
-
-            df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
-            df_bms = df_data['bms']
-
-            BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms)
-            df_res=BatUniform.batuniform()
-
-            if not df_res.empty:
-                df_res.columns = ['time', 'sn', 'cellsoc_diff', 'cellvolt_diff', 'cellmin_num', 'cellmax_num']
-                df_res.to_sql("cellStateEstimation_uniform_socVoltDiff",con=db_engine, if_exists="append",index=False)
-            logger.info("pid-{} celltype-{} SN: {} DONE!".format(os.getpid(), celltype, sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-

+ 0 - 73
LIB/FRONTEND/CellStateEstimation/Uniform/main.py

@@ -1,73 +0,0 @@
-import CBMSBatUniform
-import log
-
-#coding=utf-8
-import os
-import sys
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-# from LIB.MIDDLE import SignalMonitor
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-from LIB.MIDDLE.soh import NCMSoh_20210716 as NCMSoh
-from LIB.MIDDLE.soh import LFPSoh_20210711 as LFPSoh
-from urllib import parse
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    SNdata_6040 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
-    SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    SNdata_4840 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='4840骑享')
-    SNdata_7250 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='7250')
-    SNnums_6060=SNdata_6060['SN号']
-    SNnums_6040=SNdata_6040['SN号']
-    SNnums_4840=SNdata_4840['SN号']
-    SNnums_7250=SNdata_7250['SN号']
-
-    SNnums=SNnums_6040.tolist()+SNnums_6060.tolist()+SNnums_4840.tolist()+SNnums_7250.tolist()
-    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=5)
-    end_time=str(now_time)
-    start_time=str(start_time)
-
-    #log信息配置
-    mylog=log.Mylog('log.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('未找到对应电池编号!!!')
-                sys.exit()
-            
-            # sn='PK50001A100000035'
-            # start_time='2021-08-10 9:49:37'
-            # end_time='2021-08-29 19:49:37'
-
-            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('BMS_'+sn+'.csv',encoding='GB18030')
-
-            BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms)
-            df_res=BatUniform.batuniform()
-            df_res.to_csv('CBMS_Uniform_'+sn+'.csv',encoding='GB18030')
-        
-        
-        except IndexError as e:
-            print(repr(e))
-            mylog.logopt(sn,e)
-            pass

+ 0 - 3
LIB/FRONTEND/CellStateEstimation/Uniform/run.bat

@@ -1,3 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\Uniform
-title cal_uniform
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\Uniform\deploy.py

+ 1 - 1
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSSafetyWarning.py

@@ -162,7 +162,7 @@ class SafetyWarning:
             if cellshortfault1==1:
                 faultcode='C490'
                 faultlv=4
-                faultinfo='电芯{}发生内短路'.format([cellshort_num])
+                faultinfo='电芯{}发生内短路00'.format([cellshort_num])
                 faultadvice='请立刻召回电池包,更换模组'
                 df_res_new.loc[0]=[time_now, end_time, self.sn, faultcode, faultlv, faultinfo, faultadvice]
             else:

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä