lmstack пре 3 година
родитељ
комит
b2c9d42bfe

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

@@ -0,0 +1,46 @@
+'''
+定义表的结构,并在数据库中创建对应的数据表
+'''
+__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)

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

@@ -0,0 +1,50 @@
+'''
+定义表的结构,并在数据库中创建对应的数据表
+'''
+__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)

+ 59 - 16
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy.py

@@ -12,6 +12,8 @@ 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
 
@@ -25,6 +27,8 @@ def saftywarning_cal():
     global df_warning_ram2
     global df_warning_ram3
     global df_lfp_ram
+    global df_lfp_ram1
+
     
     
     # 读取结果数据库
@@ -38,7 +42,10 @@ def saftywarning_cal():
         "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
             user2, parse.quote_plus(password2), host2, port2, db2
         ))
-    conn = pymysql.connect(host=host2, port=port2, user=user2, password=password2, database=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'
@@ -50,8 +57,8 @@ def saftywarning_cal():
             user, parse.quote_plus(password), host, port, db
         ))
     
-    conn = pymysql.connect(host=host2, port=port2, user=user2, password=password2, database=db2)
-    cursor = conn.cursor()
+    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 where factory = '{}'".format('骑享'), db_safety_platform_engine)
     result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
@@ -61,8 +68,12 @@ def saftywarning_cal():
     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_time3=now_time-datetime.timedelta(days=3)
+
     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)):
@@ -86,7 +97,9 @@ def saftywarning_cal():
 
             # 读取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'])
@@ -104,18 +117,41 @@ def saftywarning_cal():
                 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'])
+                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)
+                
+                #电压离群.....................................................................................................................................................
+                OutLineVol=VoltStray.main(sn,df_bms,celltype)
+                if not OutLineVol.empty:
+                    df_voltsigma=OutLineVol
+                    OutLineVol.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)
@@ -131,44 +167,49 @@ def saftywarning_cal():
                 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,cellmin_num from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time1,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_liplated,df_uniform)
+                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_voltsigma)
                 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",con=conn, if_exists="append",index=False)
-                    conn.commit()
+                    df_warning_res.to_sql("all_fault_info",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()>24*3600:   #df_warning_end历史故障筛选并更改数据库故障结束时间
+                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 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.commit()
+                        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.close()
-    conn.close()
+    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()))
@@ -246,8 +287,10 @@ if __name__ == "__main__":
     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'])
+    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()

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

@@ -0,0 +1,305 @@
+
+__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=12)
+    start_time1=now_time-datetime.timedelta(days=7)
+    start_time2=now_time-datetime.timedelta(days=90)
+    start_time3=now_time-datetime.timedelta(days=3)
+
+    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)
+                
+                #电压离群.....................................................................................................................................................
+                OutLineVol=VoltStray.main(sn,df_bms,celltype)
+                if not OutLineVol.empty:
+                    df_voltsigma=OutLineVol
+                    OutLineVol.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_liplated,df_uniform,df_voltsigma)
+                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)
+            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', seconds=12*3600, id='saftywarning_cal')
+
+    try:  
+        scheduler.start()
+    except Exception as e:
+        scheduler.shutdown()
+        logger.error(str(e))
+    

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

@@ -0,0 +1,4 @@
+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_test.py
+pause

+ 11 - 11
LIB/FRONTEND/SaftyCenter/DataDiag_Static/deploy.py

@@ -241,7 +241,7 @@ def DaTa_Sta_Week_Task():
             all_period_fault_info.loc[j,'solve_rate']=FltAlarmInfo.loc[0,'OprationManageRate']
             all_period_fault_info.fillna(0,inplace=False)
             if not all_period_fault_info.empty:
-                all_period_fault_info.to_sql('all_period_fault_info', db_engine, if_exists='append', index=False)
+                all_period_fault_info.loc[j].to_sql('all_period_fault_info', db_engine, if_exists='append', index=False)
             
             logger.info("DaTa_Sta_Week_Task DONE!")
     except Exception as e:
@@ -359,20 +359,20 @@ def DaTa_Sta_Minutes_Task():
                         cell_type_count='{}',cell_safety_risk_count={}, data_safety_risk_count={},status_safety_risk_count={},hv_safety_risk_count={},
                         system_safety_risk_count={},sample_safety_risk_count={},controller_safety_risk_count={},design_safety_risk_count={}
                         where factory='{}' 
-                        '''.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), all_statistic_info.loc[0,'total_alarm'], all_statistic_info.loc[0,'alarm_total_today'],all_statistic_info.loc[0,'alarm_close_today'],
-                                all_statistic_info.loc[0,'alarm_not_close_today'],all_statistic_info.loc[0,'alarm_uregent_total_today'],all_statistic_info.loc[0,'alarm_uregent_close_today'],
-                                all_statistic_info.loc[0,'alarm_uregent_not_close_today'],all_statistic_info.loc[0,'run_time_total'],all_statistic_info.loc[0,'dischrg_total'],
-                                all_statistic_info.loc[0,'odo_total'],all_statistic_info.loc[0,'max_dischrg_one'],all_statistic_info.loc[0,'max_runtime_one'],
-                                all_statistic_info.loc[0,'max_cycle_one'],all_statistic_info.loc[0,'max_odo_one'],all_statistic_info.loc[0,'alarm_close_total'],
-                                all_statistic_info.loc[0,'alarm_total'],all_statistic_info.loc[0,'cell_type'],all_statistic_info.loc[0,'cell_type_count'],
-                                all_statistic_info.loc[0,'cell_safety_risk_count'],all_statistic_info.loc[0,'data_safety_risk_count'],all_statistic_info.loc[0,'status_safety_risk_count'],
-                                all_statistic_info.loc[0,'hv_safety_risk_count'],all_statistic_info.loc[0,'system_safety_risk_count'],all_statistic_info.loc[0,'sample_safety_risk_count'],
-                                    all_statistic_info.loc[0,'controller_safety_risk_count'],all_statistic_info.loc[0,'design_safety_risk_count'],all_statistic_info.loc[j,'factory'])
+                        '''.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), all_statistic_info.loc[j,'total_alarm'], all_statistic_info.loc[j,'alarm_total_today'],all_statistic_info.loc[j,'alarm_close_today'],
+                                all_statistic_info.loc[j,'alarm_not_close_today'],all_statistic_info.loc[j,'alarm_uregent_total_today'],all_statistic_info.loc[j,'alarm_uregent_close_today'],
+                                all_statistic_info.loc[j,'alarm_uregent_not_close_today'],all_statistic_info.loc[j,'run_time_total'],all_statistic_info.loc[j,'dischrg_total'],
+                                all_statistic_info.loc[j,'odo_total'],all_statistic_info.loc[j,'max_dischrg_one'],all_statistic_info.loc[j,'max_runtime_one'],
+                                all_statistic_info.loc[j,'max_cycle_one'],all_statistic_info.loc[j,'max_odo_one'],all_statistic_info.loc[j,'alarm_close_total'],
+                                all_statistic_info.loc[j,'alarm_total'],all_statistic_info.loc[j,'cell_type'],all_statistic_info.loc[j,'cell_type_count'],
+                                all_statistic_info.loc[j,'cell_safety_risk_count'],all_statistic_info.loc[j,'data_safety_risk_count'],all_statistic_info.loc[j,'status_safety_risk_count'],
+                                all_statistic_info.loc[j,'hv_safety_risk_count'],all_statistic_info.loc[j,'system_safety_risk_count'],all_statistic_info.loc[j,'sample_safety_risk_count'],
+                                    all_statistic_info.loc[j,'controller_safety_risk_count'],all_statistic_info.loc[j,'design_safety_risk_count'],all_statistic_info.loc[j,'factory'])
             cursor.execute(sql)
             conn.commit()
             # 更新故障位置信息
             if not all_location_info.empty:
-                sql = "delete from all_fault_location_info where factory='骑享'"
+                sql = "delete from all_fault_location_info where factory='{}'".format(all_statistic_info.loc[j,'factory'])
                 cursor.execute(sql)
                 all_location_info.to_sql('all_fault_location_info', db_engine, if_exists='append', index=False)
                 conn.commit()

+ 4 - 4
LIB/FRONTEND/SaftyCenter/Liplated/create_table.py

@@ -10,8 +10,8 @@ Base = declarative_base()
 
 
 class ConsistencyDeltaSoc(Base):
-    __tablename__ = "mechanism_liplated"
-    __table_args__ = ({'comment': '析锂检测'})  # 添加索引和表注释
+    __tablename__ = "mechanism_volsorout"
+    __table_args__ = ({'comment': '电压内阻偏离检测'})  # 添加索引和表注释
 
     id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
     add_time = Column(TIMESTAMP(True), comment='记录创建时间') # 创建时间
@@ -20,8 +20,8 @@ class ConsistencyDeltaSoc(Base):
     sn = Column(String(64), comment="sn")
     time = Column(TIMESTAMP(True), comment="计算时间")
 
-    liplated = Column(Text, comment="析锂状态(1析锂,0未析锂)")
-    liplated_amount = Column(Text, comment="析锂量")
+    volsorout_confr = Column(Text, comment="电压内阻偏离状态(1析锂,0未析锂)")
+    volsorout_amplt = Column(Text, comment="电压内阻偏离量")
 
 
     # def __init__(self, sn, current, time_stamp, pack_state, line_state):

+ 36 - 4
LIB/FRONTEND/SaftyCenter/Liplated/deploy.py

@@ -18,9 +18,11 @@ from LIB.MIDDLE.SaftyCenter.Common import QX_BatteryParam
 
 import datacompy
 from LIB.MIDDLE.SaftyCenter.Liplated import Li_plated
+from LIB.MIDDLE.SaftyCenter.Liplated import vol_sor_est
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
 
-def cell_platd_test(df_sn):
+def cell_platd_sorvol_test(df_sn):
     # 读取结果数据库
     host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
     port2=3306
@@ -39,7 +41,7 @@ def cell_platd_test(df_sn):
     start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
     end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
     logger.info("cycle start !!!!!!!!!!!!!!!!!!!!")
-    
+
     
     for i in range(0, len(df_sn)):
         try:
@@ -69,17 +71,47 @@ def cell_platd_test(df_sn):
             df_Diag_lipltd = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
 
             df_Diag_lipltd_add = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
+            df_diag_sor = pd.DataFrame(columns = ['sn','time','sorout_confr', 'sorout_amplt'])
+            df_diag_vol = pd.DataFrame(columns = ['sn','time','volout_confr', 'volout_amplt'])
+            df_diag_volsor = pd.DataFrame(columns = ['sn','time','volsorout_confr', 'volsorout_amplt'])
 
             #析锂诊断................................................................................................................................................................
             if not df_bms.empty:
                 Diag_lipltd_temp = Li_plated.Liplated_test(sn,celltype,df_bms)#析锂检测
-                df_Diag_lipltd_add = Diag_lipltd_temp.liplated_detect()        
+                df_Diag_lipltd_add = Diag_lipltd_temp.liplated_detect()    
+                # Diag_sorvol_temp = vol_sor_est.vol_sor_est(sn,celltype,df_bms)#电压内阻估计
+                # [df_diag_sor_add, df_diag_vol_add, df_diag_sorvol_add] = Diag_sorvol_temp.volsor_cal()       
             if not df_Diag_lipltd_add.empty:
                 df_Diag_lipltd_temp = df_Diag_lipltd.append(df_Diag_lipltd_add)
                 df_Diag_lipltd = df_Diag_lipltd_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                df_Diag_lipltd.reset_index(drop = True)
                 df_Diag_lipltd.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
                 df_Diag_lipltd['add_time'] = datetime.datetime.now()
                 df_Diag_lipltd.to_sql("mechanism_liplated",con=db_engine, if_exists="append",index=False)
+            # if not df_diag_sor_add.empty:
+            #     df_diag_sor_temp = df_diag_sor.append(df_diag_sor_add)
+            #     df_diag_sor = df_diag_sor_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_sor.reset_index(drop = True)
+            #     df_diag_sor.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_sor['add_time'] = datetime.datetime.now()
+            #     df_diag_sor.to_sql("mechanism_sorout",con=db_engine, if_exists="append",index=False)
+                
+            # if not df_diag_vol_add.empty:
+            #     df_diag_vol_temp = df_diag_vol.append(df_diag_vol_add)
+            #     df_diag_vol = df_diag_vol_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_vol.reset_index(drop = True)
+            #     df_diag_vol.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_vol['add_time'] = datetime.datetime.now()
+            #     df_diag_vol.to_sql("mechanism_volout",con=db_engine, if_exists="append",index=False)
+        
+                            
+            # if not df_diag_sorvol_add.empty:
+            #     df_diag_volsor_temp = df_diag_volsor.append(df_diag_sorvol_add)
+            #     df_diag_volsor = df_diag_volsor_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_volsor.reset_index(drop = True)
+            #     df_diag_volsor.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_volsor['add_time'] = datetime.datetime.now()
+            #     df_diag_volsor.to_sql("mechanism_volsorout",con=db_engine, if_exists="append",index=False)
                 
                 logger.info("pid-{} celltype-{} SN: {} DONE!".format(os.getpid(), celltype, sn))
         except:
@@ -158,7 +190,7 @@ if __name__ == "__main__":
 
 
     #定时任务.......................................................................................................................................................................
-    cell_platd_test(df_sn)
+    cell_platd_sorvol_test(df_sn)
     # scheduler = BlockingScheduler()
 
     # scheduler.add_job(fun, 'interval', seconds=600, id='diag_job')

+ 1 - 1
LIB/FRONTEND/SaftyCenter/Liplated/deploy_7255.py

@@ -147,7 +147,7 @@ if __name__ == "__main__":
     
     # 日志配置
     now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/' + now_str
+    log_path = 'log7255/' + now_str
     if not os.path.exists(log_path):
         os.makedirs(log_path)
     log = Log.Mylog(log_name='saftyCenter_liplated7255', log_level = 'info')

+ 41 - 7
LIB/FRONTEND/SaftyCenter/Liplated/deploy_7255_other.py

@@ -23,6 +23,8 @@ from apscheduler.schedulers.blocking import BlockingScheduler
 import datacompy
 from LIB.MIDDLE.SaftyCenter.Liplated import Li_plated
 from LIB.MIDDLE.SaftyCenter.diagfault.SC_SamplingSafty import SamplingSafty
+from LIB.MIDDLE.SaftyCenter.Liplated import vol_sor_est
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
 def cell_platd_test(df_sn, df_first_data_time):
     # 读取结果数据库
@@ -55,8 +57,8 @@ def cell_platd_test(df_sn, df_first_data_time):
                 celltype=99 # 6060锂电芯
             elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                 celltype=3 #力信 50ah三元电芯
-            # if 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: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
@@ -70,20 +72,52 @@ def cell_platd_test(df_sn, df_first_data_time):
             df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
             df_bms = df_data['bms']
      
-            df_Diag_lipltd = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
+            # df_Diag_lipltd = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
 
-            df_Diag_lipltd_add = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
+            # df_Diag_lipltd_add = pd.DataFrame(columns = ['sn','time','liplated', 'liplated_amount'])
+
+            df_diag_sor = pd.DataFrame(columns = ['sn','time','sorout_confr', 'sorout_amplt'])
+            df_diag_vol = pd.DataFrame(columns = ['sn','time','volout_confr', 'volout_amplt'])
+            df_diag_volsor = pd.DataFrame(columns = ['sn','time','volsorout_confr', 'volsorout_amplt'])
 
             #析锂诊断................................................................................................................................................................
             if not df_bms.empty:
                 Diag_lipltd_temp = Li_plated.Liplated_test(sn,celltype,df_bms)#析锂检测
-                df_Diag_lipltd_add = Diag_lipltd_temp.liplated_detect()        
+                df_Diag_lipltd_add = Diag_lipltd_temp.liplated_detect()   
+
+                # Diag_sorvol_temp = vol_sor_est.vol_sor_est(sn,celltype,df_bms)#电压内阻估计
+                # [df_diag_sor_add, df_diag_vol_add, df_diag_sorvol_add] = Diag_sorvol_temp.volsor_cal()       
             if not df_Diag_lipltd_add.empty:
                 df_Diag_lipltd_temp = df_Diag_lipltd.append(df_Diag_lipltd_add)
                 df_Diag_lipltd = df_Diag_lipltd_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                df_Diag_lipltd.reset_index(drop = True)
                 df_Diag_lipltd.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
                 df_Diag_lipltd['add_time'] = datetime.datetime.now()
                 df_Diag_lipltd.to_sql("mechanism_liplated",con=db_engine, if_exists="append",index=False)
+            # if not df_diag_sor_add.empty:
+            #     df_diag_sor_temp = df_diag_sor.append(df_diag_sor_add)
+            #     df_diag_sor = df_diag_sor_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_sor.reset_index(drop = True)
+            #     df_diag_sor.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_sor['add_time'] = datetime.datetime.now()
+            #     df_diag_sor.to_sql("mechanism_sorout",con=db_engine, if_exists="append",index=False)
+                
+            # if not df_diag_vol_add.empty:
+            #     df_diag_vol_temp = df_diag_vol.append(df_diag_vol_add)
+            #     df_diag_vol = df_diag_vol_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_vol.reset_index(drop = True)
+            #     df_diag_vol.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_vol['add_time'] = datetime.datetime.now()
+            #     df_diag_vol.to_sql("mechanism_volout",con=db_engine, if_exists="append",index=False)
+        
+                            
+            # if not df_diag_sorvol_add.empty:
+            #     df_diag_volsor_temp = df_diag_volsor.append(df_diag_sorvol_add)
+            #     df_diag_volsor = df_diag_volsor_temp.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+            #     df_diag_volsor.reset_index(drop = True)
+            #     df_diag_volsor.sort_values(by = ['sn'], axis = 0, ascending=True,inplace=True)#对故障信息按照时间进行排序
+            #     df_diag_volsor['add_time'] = datetime.datetime.now()
+            #     df_diag_volsor.to_sql("mechanism_volsorout",con=db_engine, if_exists="append",index=False)
 
                 logger.info("pid-{} celltype-{} SN: {} DONE!".format(os.getpid(), celltype, sn))
         except:
@@ -137,10 +171,10 @@ if __name__ == "__main__":
     
     # 日志配置
     now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/' + now_str
+    log_path = 'log_3month/' + now_str
     if not os.path.exists(log_path):
         os.makedirs(log_path)
-    log = Log.Mylog(log_name='saftyCenter_liplated7255_other', log_level = 'info')
+    log = Log.Mylog(log_name='saftyCenter_liplatedAll', 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()

+ 1 - 2
LIB/FRONTEND/SaftyCenter/Liplated/run.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Liplated
 title cal_saftyCenter_lipated
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Liplated\deploy.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Liplated\deploy.py

+ 1 - 2
LIB/FRONTEND/SaftyCenter/LowSocAlarm/run.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm
 title cal_saftyCenter_LowSocAlarm
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm\deploy.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm\deploy.py

+ 1 - 2
LIB/FRONTEND/SaftyCenter/LowSocAlarm/run_sta.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm
 title cal_saftyCenter_LowSocAlarmSta
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm\deploy_sta.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\LowSocAlarm\deploy_sta.py

+ 1 - 2
LIB/FRONTEND/SaftyCenter/Offline/run.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline
 title cal_saftyCenter_Offline
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline\deploy.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline\deploy.py

+ 1 - 2
LIB/FRONTEND/SaftyCenter/Offline/run_sta.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline
 title cal_saftyCenter_Offline
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline\deploy_sta.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Offline\deploy_sta.py

+ 1 - 2
LIB/FRONTEND/SaftyCenter/status_sta/run.bat

@@ -1,4 +1,3 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\status_sta
 title cal_saftyCenter_status_sta
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\status_sta\deploy.py
-pause
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\status_sta\deploy.py