lmstack %!s(int64=3) %!d(string=hai) anos
pai
achega
4434b5fc5b

+ 4 - 1
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy.py

@@ -79,6 +79,7 @@ def saftywarning_cal():
     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':
@@ -87,13 +88,15 @@ def saftywarning_cal():
                 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
-            sn = df_sn.loc[i, 'sn']
+            
             
             logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
 

+ 10 - 10
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy_test.py

@@ -65,10 +65,10 @@ def saftywarning_cal():
     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_time=now_time-datetime.timedelta(hours=6)
     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_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')
@@ -147,10 +147,9 @@ def saftywarning_cal():
                     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)
+                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处理.........................................................
@@ -173,7 +172,7 @@ def saftywarning_cal():
             #电池热安全预警..............................................................................................................................................................
             #读取内短路、析锂和一致性结果数据库数据
             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_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)
 
@@ -182,13 +181,14 @@ def saftywarning_cal():
             
             #热安全预警
             if df_fault_ram_sn.empty:
-                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_voltsigma)
+                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历史故障筛选并更改数据库故障结束时间
@@ -295,7 +295,7 @@ if __name__ == "__main__":
     saftywarning_cal()
     #定时任务.......................................................................................................................................................................
     scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', seconds=12*3600, id='saftywarning_cal')
+    scheduler.add_job(saftywarning_cal, 'interval', hours=6, id='saftywarning_cal')
 
     try:  
         scheduler.start()

+ 1 - 1
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/run_test.bat

@@ -1,4 +1,4 @@
 cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\CellStateEstimation\BatSafetyWarning
-title cal_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

+ 128 - 0
LIB/FRONTEND/CellStateEstimation/SOH/deploy_hand.py

@@ -0,0 +1,128 @@
+
+__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.SOH.V1_0_0 import CBMSBatSoh
+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(months=-1, days=-1)#上个月-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 # 历史数据运行标志
+    # end_time = "2021-09-01 00:00:00"
+
+    # 更新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 from app_device")
+    res = cursor.fetchall()
+    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
+    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='soh', 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:
+            sn = df_sn.loc[i, 'sn']
+            if df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                celltype=100 # 重卡
+
+            else:
+                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
+                continue
+            
+            
+            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 = "2021-11-17 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")
+            
+            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='')
+                
+            df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms','accum'])
+            df_bms = df_data['bms']
+            df_accum=df_data['accum']
+
+            BatSoh=CBMSBatSoh.BatSoh(sn, celltype, df_bms, df_accum, df_soh)
+            df_res=BatSoh.batsoh()
+
+            if not df_res.empty:
+                df_res.columns = ['time_st', 'time_sp', 'sn', 'method', 'soh', 'cellsoh']
+                df_res.to_sql("cellStateEstimation_soh",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)
+

+ 4 - 0
LIB/FRONTEND/CellStateEstimation/SOH/run_hand.bat

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

+ 88 - 38
LIB/FRONTEND/SaftyCenter/DataDiag_Static/deploy.py

@@ -19,9 +19,10 @@ from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DataStatistics import DataSta
 from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_CtrlSafty import CtrlSafty
 from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DiagDataMerge import DiagDataMerge
 from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_SamplingSafty import SamplingSafty
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_BMSUploadError import BMSReportError
 from LIB.MIDDLE.SaftyCenter.DataDiag_Static import CBMSBatDiag
 from LIB.MIDDLE.SaftyCenter.Common import DBDownload as DBDw
-from LIB.MIDDLE.SaftyCenter.Common import QX_BatteryParam
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam as QX_BatteryParam
 from urllib import parse
 import pymysql
 
@@ -32,7 +33,35 @@ def diag_cal():
     global SNnums
     # global df_Diag_Ram
     global start
-    global df_sn
+    
+    # 更新sn列表
+    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    port=3306
+    db='qixiang_oss'
+    user='qx_algo_rw'
+    password='qx@123456'
+    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)
+    cursor.close()
+    conn.close();
+    
+    # 故障映射表
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='algo_dict'
+    user='qx_algo_rw'
+    password=parse.quote_plus('qx@123456')
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, db
+        ))
+    
+    errorcode_map = pd.read_sql("select * from faultcode_map", db_engine)
+    db_engine.dispose()
     
     # 算法参数
     host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
@@ -44,6 +73,9 @@ def diag_cal():
         "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
             user, password, host, port, db
         ))
+    
+   
+    
 
         
     #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................``
@@ -99,26 +131,34 @@ def diag_cal():
     for i in range(0, len(df_sn)):
         print(df_sn.loc[i, 'imei'])
         try:
+            sn = df_sn.loc[i, 'sn']
+            factory = "骑享"
             if df_sn.loc[i, 'imei'][5:9] == 'N640':
                 celltype=1 #6040三元电芯
+                FactoryType = 1
             elif df_sn.loc[i, 'imei'][5:9] == 'N440':
                 celltype=2 #4840三元电芯
+                FactoryType = 1
             elif df_sn.loc[i, 'imei'][5:9] == 'L660':
                 celltype=99 # 6060锂电芯
+                FactoryType = 1
             elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                 celltype=3 #力信 50ah三元电芯
+                FactoryType = 3
             elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
                 celltype=4 #CATL 50ah三元电芯
+                FactoryType = 2
             elif 'TJMCL'in sn: # 金茂
                 celltype=100 #CATL 50ah三元电芯
+                factory = "金茂换电"
+                FactoryType = 0
             else:
                 logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
                 continue
-            sn = df_sn.loc[i, 'sn']
-            factory = df_sn.loc[i, 'factory']
+            
             logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
             # sys.exit()
-            param=QX_BatteryParam.BatteryInfo(celltype)   
+            param=QX_BatteryParam.BatParam(celltype)
             #读取原始数据库数据........................................................................................................................................................
             dbManager = DBManager.DBManager()
             df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
@@ -143,6 +183,9 @@ def diag_cal():
                 df_Diag_Batdiag_update_xq2=CtrlSafty.main(sn,param,df_bms,df_Diag_Batdiag_update_xq)#控制安全
   
                 batDiag=CBMSBatDiag.BatDiag(sn,celltype,df_bms, df_soh, df_uniform, df_Diag_Batdiag_update_xq2)#鹏飞计算
+                # df_Diag_Batdiag_update2=batDiag.diag()
+                # df_Diag_Batdiag_update=BMSReportError.main(sn,df_bms,df_Diag_Batdiag_update2,FactoryType,errorcode_map)
+
                 df_Diag_Batdiag_update=batDiag.diag()
                 # df_Diag_Batdiag_update=BatDiag.diag() 
             else:
@@ -164,16 +207,18 @@ def diag_cal():
             if len(df_Diag_Ram_Update) > 0:#更改故障
                 df_Diag_Ram_Update = df_Diag_Ram_Update.reset_index(drop=True)
                 try:
-                    logger.info(df_Diag_Ram_Update)
+
                     for i in range(0,len(df_Diag_Ram_Update)):
                         sql = '''
                                     update all_fault_info set update_time='{}', end_time='{}', Batpos={} where product_id='{}' and code={} and start_time='{}'
                                     '''.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), df_Diag_Ram_Update.loc[i,'end_time'], df_Diag_Ram_Update.loc[i, 'Batpos'],
                                                df_Diag_Ram_Update.loc[i,'product_id'], df_Diag_Ram_Update.loc[i,'code'], 
                                                df_Diag_Ram_Update.loc[i,'start_time'])
+
                         cursor_platform.execute(sql)
                         conn_platform.commit()
                 except:
+                    logger.error(sql)
                     logger.error(traceback.format_exc)
                     logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
 
@@ -201,7 +246,7 @@ def DaTa_Sta_Week_Task():
 
     all_period_fault_info=DataFrame(columns=['factory','week','level1_count','level2_count','level3_count','level4_count','level5_count','solve_rate'])
     #............................获取数据................................
-    toweek='Week'+time.strftime('%W')
+
     host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
     port=3306
     db='safety_platform'
@@ -217,12 +262,18 @@ def DaTa_Sta_Week_Task():
 
     try:
         logger.info("DaTa_Sta_Week_Task START!")
-
+        df_fltinfopt=DataFrame(columns=['product_id','level','code','start_time','end_time','batpos','factory'])
         DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
-        with DBRead as DBRead:
-            df_fltinfo=DBRead.getdata('product_id','level','code','start_time','end_time','batpos','factory',tablename=tablename1,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+        for i in range (0,len(factory_info)):
+        
+            with DBRead as DBRead:
+                df_fltinfo=DBRead.getdata('product_id','level','code','start_time','end_time','batpos','factory',tablename=tablename1,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+            df_fltinfopt=df_fltinfopt.append(df_fltinfo)
+            df_fltinfopt=df_fltinfopt.reset_index(drop=True)
         for j in range(0,len(factory_info)):
-            df_fltinfo=df_fltinfo[df_fltinfo['factory']==factory_info[j]]
+            toweek='Week'+time.strftime('%W')
+            df_fltinfo=df_fltinfopt[df_fltinfopt['factory']==factory_info[j]]
+
             #............................获取时间................................      
             end_time=datetime.datetime.now()
             # end_time=datetime.datetime.strptime(end_time,'%Y-%m-%d')
@@ -240,9 +291,8 @@ def DaTa_Sta_Week_Task():
             all_period_fault_info.loc[j,'week']=toweek
             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.loc[j].to_sql('all_period_fault_info', db_engine, if_exists='append', index=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)
             logger.info("DaTa_Sta_Week_Task DONE!")
     except Exception as e:
         logger.error(traceback.format_exc)
@@ -399,31 +449,31 @@ if __name__ == "__main__":
     # history_run_flag = False # 历史数据运行标志
     
 
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qx_algo_rw'
-    password='qx@123456'
-    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)
-    cursor.close()
-    conn.close();
-    df_sn['factory'] = '骑享'
+    # # 更新sn列表
+    # host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    # port=3306
+    # db='qixiang_oss'
+    # user='qx_algo_rw'
+    # password='qx@123456'
+    # 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)
+    # cursor.close()
+    # conn.close();
+    # df_sn['factory'] = '骑享'
     
-    db = 'qx_cas'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, factory from sn_list")
-    res = cursor.fetchall()
-    df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
-    df_sn2['imei'] = ""
-    df_sn = pd.concat([df_sn, df_sn2], axis=0)
-    df_sn = df_sn.reset_index(drop=True)
+    # db = 'qx_cas'
+    # conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+    # cursor = conn.cursor()
+    # cursor.execute("select sn, factory from sn_list")
+    # res = cursor.fetchall()
+    # df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+    # df_sn2['imei'] = ""
+    # df_sn = pd.concat([df_sn, df_sn2], axis=0)
+    # df_sn = df_sn.reset_index(drop=True)
     # # 数据库配置
     # host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
     # port = 3306

+ 554 - 0
LIB/FRONTEND/SaftyCenter/DataDiag_Static/deploy_test.py

@@ -0,0 +1,554 @@
+
+__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.Common import log
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload as DBDownload
+import time, datetime
+from pandas.core.frame import DataFrame
+from apscheduler.schedulers.blocking import BlockingScheduler
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DataStatistics import DataSta
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_CtrlSafty import CtrlSafty
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DiagDataMerge import DiagDataMerge
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_SamplingSafty import SamplingSafty
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_BMSUploadError import BMSReportError
+from LIB.MIDDLE.SaftyCenter.DataDiag_Static import CBMSBatDiag
+from LIB.MIDDLE.SaftyCenter.Common import DBDownload as DBDw
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam as QX_BatteryParam
+from urllib import parse
+import pymysql
+
+
+#...................................电池包电芯安全诊断函数......................................................................................................................
+def diag_cal():
+    task_on=1
+    global SNnums
+    # global df_Diag_Ram
+    global start
+    
+    # 更新sn列表
+    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    port=3306
+    db='qixiang_oss'
+    user='qx_algo_rw'
+    password='qx@123456'
+    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)
+    cursor.close()
+    conn.close();
+    
+    # 故障映射表
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='algo_dict'
+    user='qx_algo_rw'
+    password=parse.quote_plus('qx@123456')
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, db
+        ))
+    
+    errorcode_map = pd.read_sql("select * from faultcode_map", db_engine)
+    db_engine.dispose()
+    
+    # 算法参数
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='safety_platform'
+    user='qx_algo_rw'
+    password=parse.quote_plus('qx@123456')
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, db
+        ))
+    
+   
+    
+
+        
+    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................``
+    # print("select start_time, end_time, product_id, code, level, info, advice, factory from {}".format(tablename))
+    try:
+        df_Diag_Ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice, Batpos from all_fault_info_copy where end_time='0000-00-00 00:00:00' ", db_engine)
+    finally:
+        db_engine.dispose()
+    # df_Diag_Ram=df_Diag_Ram.dropna(axis=1,how='any')
+    # df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)    
+    #读取结果数据库数据........................................................................................................................................................
+    host1='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port1=3306
+    db1='qx_cas'
+    user1='qx_algo_rw'
+    password1='qx@123456'
+    mode=1
+    tablename1='cellstateestimation_soh'
+    tablename2='cellstateestimation_uniform_socvoltdiff'       
+    DBRead=DBDownload.DBDownload(host1, port1, db1, user1, password1,mode)
+    DBRead.connect()
+
+    #读取电池当前运营状态.....................................................................................................................................................
+    host2='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    port2=3306
+    db2='qixiang_manage'
+    user2='qx_algo_rw'
+    password2='qx@123456'
+    mode=4
+    tablename3='py_battery'     
+    DBReadOpe=DBDw.DBDownload(host2, port2, db2, user2, password2,mode)
+    DBReadOpe.connect()
+    
+    host3='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port3=3306
+    db3='safety_platform'
+    user3='qx_algo_rw'
+    password3='qx@123456'
+    db_engine = create_engine(
+    "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+        user3, parse.quote_plus(password3), host3, port3, db3
+    ))
+    conn_platform = pymysql.connect(host=host3, port=port3, user=user3, password=password3, database=db3)
+    cursor_platform = conn_platform.cursor()
+    #..................................设置时间..........................................................  
+    start=time.time()
+    end_time=datetime.datetime.now()
+    start_time=end_time-datetime.timedelta(seconds=900)#15分钟跑一次,一次取15分钟数据
+    start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
+    end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
+    logger.info(" diag_cal START!")
+
+    for i in range(0, len(df_sn)):
+        try:
+            factory = "骑享"
+            sn = df_sn.loc[i, 'sn']
+            if df_sn.loc[i, 'imei'][5:9] == 'N640':
+                celltype=1 #6040三元电芯
+                FactoryType = 1
+            elif df_sn.loc[i, 'imei'][5:9] == 'N440':
+                celltype=2 #4840三元电芯
+                FactoryType = 1
+            elif df_sn.loc[i, 'imei'][5:9] == 'L660':
+                celltype=99 # 6060锂电芯
+                FactoryType = 1
+            elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
+                celltype=3 #力信 50ah三元电芯
+                FactoryType = 3
+            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
+                celltype=4 #CATL 50ah三元电芯
+                FactoryType = 2
+            elif 'TJMCL'in sn: # 金茂
+                celltype=100 #CATL 50ah三元电芯
+                factory = "金茂换电"
+                FactoryType = 0
+            else:
+                logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
+                continue
+            
+            sn = 'PK504B10100004349'
+            start_time = '2021-12-30 18:00:04'
+            end_time = '2021-12-30 18:15:04'
+            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
+            # sys.exit()
+            param=QX_BatteryParam.BatParam(celltype)
+            #读取原始数据库数据........................................................................................................................................................
+            dbManager = DBManager.DBManager()
+            df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
+            df_bms = df_data['bms']
+            df_bms=df_bms.dropna(subset=['总电流[A]'])
+            df_bms=df_bms.reset_index(drop=True)
+            # with DBRead as DBRead:
+            df_soh=DBRead.getdata('time_st,sn,soh,cellsoh', tablename=tablename1, sn=sn, timename='time_sp', st=start_time, sp=end_time)
+            df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellmin_num,cellmax_num', tablename=tablename2, sn=sn, timename='time', st=start_time, sp=end_time)
+
+
+            # with DBReadOpe as DBReadOpe:
+            df_OprtnSta=DBReadOpe.getdata('qrcode','status', tablename=tablename3, sn=sn, timename='', st='', sp='',factory='')#取最后一条运营状态
+            #电池诊断.....................................................................................................................................................................
+            CellFltInfo=DataFrame(columns=['start_time', 'end_time', 'product_id', 'code', 'level', 'info','advice'])
+            df_Diag_Ram_sn = df_Diag_Ram.loc[df_Diag_Ram['product_id']==sn]#历史故障
+            df_Diag_Ram_sn_else = df_Diag_Ram.loc[df_Diag_Ram['product_id']!=sn]#sn之外的故障
+            CellFltInfo = df_Diag_Ram_sn.drop('Batpos',axis=1)
+            #获取当前故障电池的历史故障信息↑↑↑↑↑↑↑↑↑↑↑.......................................................................................................................................
+            if not df_bms.empty:
+                df_Diag_Batdiag_update_xq=SamplingSafty.main(sn,param,df_bms,CellFltInfo)#采样安全   
+                df_Diag_Batdiag_update_xq2=CtrlSafty.main(sn,param,df_bms,df_Diag_Batdiag_update_xq)#控制安全
+  
+                batDiag=CBMSBatDiag.BatDiag(sn,celltype,df_bms, df_soh, df_uniform, df_Diag_Batdiag_update_xq2)#鹏飞计算
+                df_Diag_Batdiag_update2=batDiag.diag()
+                df_Diag_Batdiag_update=BMSReportError.main(sn,df_bms,df_Diag_Batdiag_update2,FactoryType,errorcode_map)
+
+                # df_Diag_Batdiag_update=batDiag.diag()
+                # df_Diag_Batdiag_update=BatDiag.diag() 
+            else:
+                df_Diag_Batdiag_update_xq=DataFrame(columns=['start_time','end_time','product_id','code','level','info','advice','Batpos'])
+                df_Diag_Batdiag_update_xq2=DataFrame(columns=['start_time','end_time','product_id','code','level','info','advice','Batpos'])
+                df_Diag_Batdiag_update2=DataFrame(columns=['start_time','end_time','product_id','code','level','info','advice','Batpos'])
+                df_Diag_Batdiag_update=DataFrame(columns=['start_time','end_time','product_id','code','level','info','advice','Batpos'])
+            df_Diag_Ram_add,df_Diag_Ram_Update=DiagDataMerge.DetaMerge(df_Diag_Ram_sn,df_Diag_Batdiag_update,df_OprtnSta,df_Diag_Ram_sn_else)
+            logger.error(df_Diag_Ram_add['end_time'])
+            # df_Diag_Ram.to_csv('df_Diag_Ram.csv')
+            # df_Diag_Ram_add.to_csv('df_Diag_Ram_add.csv')
+            # df_Diag_Ram_Update.to_csv('df_Diag_Ram_add.csv')
+            if len(df_Diag_Ram_add) > 0:#新增故障
+                
+                df_Diag_Ram_add.columns = ['start_time', 'end_time', 'product_id', 'code', 'level', 'info','advice', 'Batpos']
+                df_Diag_Ram_add['factory'] = factory
+                df_Diag_Ram_add['add_time'] = datetime.datetime.now()
+                df_Diag_Ram_add.to_sql("all_fault_info_copy",con=db_engine, if_exists="append",index=False)
+                # df_Diag_Ram_add.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\01Screen_Problem\result_add.csv',index=False,encoding='GB18030')
+            if len(df_Diag_Ram_Update) > 0:#更改故障
+               
+                df_Diag_Ram_Update = df_Diag_Ram_Update.reset_index(drop=True)
+                try:
+
+                    for i in range(0,len(df_Diag_Ram_Update)):
+                        sql = '''
+                                    update all_fault_info_copy set update_time='{}', end_time='{}', Batpos={} where product_id='{}' and code={} and start_time='{}'
+                                    '''.format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), df_Diag_Ram_Update.loc[i,'end_time'], df_Diag_Ram_Update.loc[i, 'Batpos'],
+                                               df_Diag_Ram_Update.loc[i,'product_id'], df_Diag_Ram_Update.loc[i,'code'], 
+                                               df_Diag_Ram_Update.loc[i,'start_time'])
+
+                        cursor_platform.execute(sql)
+                        conn_platform.commit()
+                except:
+                    logger.error(sql)
+                    logger.error(traceback.format_exc)
+                    logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
+
+                # df_Diag_Ram_Update_change.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\01Screen_Problemm\result_change.csv',index=False,encoding='GB18030')
+            end=time.time()
+            logger.info("pid-{} celltype-{} SN: {} DONE!".format(os.getpid(), celltype, sn))
+         
+        except Exception as e :
+            logger.error(traceback.format_exc)
+            logger.error(str(e))
+            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
+        break
+    
+    DBReadOpe.close()
+    DBRead.close()   
+    cursor_platform.close()
+    conn_platform.close()
+    db_engine.dispose()
+    logger.info(" diag_cal Done!")
+    task_on=0
+
+#.................................统计程序...............................
+def DaTa_Sta_Week_Task():
+    task_on=1
+    factory_info=['骑享','金茂换电']
+
+    all_period_fault_info=DataFrame(columns=['factory','week','level1_count','level2_count','level3_count','level4_count','level5_count','solve_rate'])
+    #............................获取数据................................
+
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='safety_platform'
+    user='qx_algo_rw'
+    password='qx@123456'
+    mode=2
+    tablename1='all_fault_info_copy'
+    
+    db_engine = create_engine(
+    "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+        user, parse.quote_plus(password), host, port, db
+    ))
+
+    try:
+        logger.info("DaTa_Sta_Week_Task START!")
+        df_fltinfopt=DataFrame(columns=['product_id','level','code','start_time','end_time','batpos','factory'])
+        DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
+        for i in range (0,len(factory_info)):
+        
+            with DBRead as DBRead:
+                df_fltinfo=DBRead.getdata('product_id','level','code','start_time','end_time','batpos','factory',tablename=tablename1,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+            df_fltinfopt=df_fltinfopt.append(df_fltinfo)
+            df_fltinfopt=df_fltinfopt.reset_index(drop=True)
+        for j in range(0,len(factory_info)):
+            toweek='Week'+time.strftime('%W')
+            df_fltinfo=df_fltinfopt[df_fltinfopt['factory']==factory_info[j]]
+
+            #............................获取时间................................      
+            end_time=datetime.datetime.now()
+            # end_time=datetime.datetime.strptime(end_time,'%Y-%m-%d')
+            start_time_week=end_time-datetime.timedelta(days=7)
+            start_time_week=start_time_week.strftime('%Y-%m-%d')
+            end_time=end_time.strftime('%Y-%m-%d')
+            FltAlarmInfo,Celltype=DataSta.SaftyWarningSta(df_fltinfo,start_time_week,end_time,factory_info[j])
+            FaultLvlCount=DataSta.WeekInfoSta(df_fltinfo,start_time_week,end_time)
+            for i in range(1,6):
+                if not FaultLvlCount[FaultLvlCount['level']==i]['product_id'].empty:
+                    all_period_fault_info.loc[j,'level'+str(i)+'_count']=int(FaultLvlCount[FaultLvlCount['level']==i]['product_id'].values)
+                else:
+                    all_period_fault_info.loc[j,'level'+str(i)+'_count']=int(0)
+            all_period_fault_info.loc[j,'factory']=factory_info[j]
+            all_period_fault_info.loc[j,'week']=toweek
+            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)
+            logger.info("DaTa_Sta_Week_Task DONE!")
+    except Exception as e:
+        logger.error(traceback.format_exc)
+        logger.error(u" 任务运行错误\n".format(), exc_info=True)
+    finally:
+        db_engine.dispose()
+    task_on=0
+    # all_period_fault_info.to_csv('all_period_fault_info.csv')
+    
+def DaTa_Sta_Minutes_Task():
+    task_on=1
+    factory_info=['骑享','金茂换电']
+
+    #............................获取数据................................
+    host='172.16.121.236'
+    port=3306
+    db='fastfun'
+    user='readonly'
+    password='Fast1234'
+    mode=3
+    tablename1='ff_battery_accum'
+    tablename2='ff_location'
+    DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
+    with DBRead as DBRead:
+        df_last_accum=DBRead.getdata('devcode','dsg_phaccum','dsg_ahaccum',tablename=tablename1,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+        df_last_pos=DBRead.getdata('devcode','latitude','longitude',tablename=tablename2,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+        
+        
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='qx_cas'
+    user='qx_algo_rw'
+    password='qx@123456'
+    mode=3
+    tablename2='bat_first_data_time'
+    DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
+    with DBRead as DBRead:
+        df_FirstDataTime=DBRead.getdata('sn','first_data_time',tablename=tablename2,factory='',sn='',timename='',st='',sp='')#dbdownload经过了改编
+        
+        
+    host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port=3306
+    db='safety_platform'
+    user='qx_algo_rw'
+    password='qx@123456'
+    mode=2
+    tablename1='all_fault_info_copy'
+    db_engine = create_engine(
+    "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+        user, parse.quote_plus(password), host, port, db
+    ))
+    DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
+    
+        #............................获取时间................................
+    end_time=datetime.datetime.now()
+    # end_time=datetime.datetime.strptime(end_time,'%Y-%m-%d')
+    start_time=end_time-datetime.timedelta(days=1)
+    start_time=start_time.strftime('%Y-%m-%d')
+    end_time=end_time.strftime('%Y-%m-%d')
+    #............................执行程序................................
+    all_statistic_info=DataFrame(columns=['factory','total_alarm','alarm_total_today','alarm_not_close_today','alarm_close_today','alarm_uregent_total_today','alarm_uregent_close_today','alarm_uregent_not_close_today','run_time_total','dischrg_total','odo_total','max_dischrg_one','max_runtime_one','max_cycle_one','max_odo_one','alarm_close_total','alarm_total','cell_type','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'])
+    for j in range(0,len(factory_info)):
+        with DBRead as DBRead:
+            df_fltinfo=DBRead.getdata('product_id','level','code','start_time','batpos',tablename=tablename1,factory=factory_info[j],sn='',timename='',st='',sp='')#dbdownload经过了改编
+            
+        #............................执行程序................................
+        FltAlarmInfo,Celltype=DataSta.SaftyWarningSta(df_fltinfo,start_time,end_time,factory_info[j])
+        SatftyCount=DataSta.SftyWrngClsfy(df_fltinfo)
+        MaxAccumAh,TotalAccumAh,MaxCycle,MaxRunningHour,TotalRunHour=DataSta.AccumInfo(df_last_accum,df_FirstDataTime,end_time,factory_info[j])
+        all_location_info=DataSta.FltBatPosition(df_last_pos,df_fltinfo,factory_info[j])
+
+        all_statistic_info.loc[j,'factory']=factory_info[j]
+        all_statistic_info.loc[j,'total_alarm']=FltAlarmInfo.loc[0,'SftyPlt_Data_Total']
+        all_statistic_info.loc[j,'alarm_total_today']=FltAlarmInfo.loc[0,'SftyPlt_Data_day']
+        all_statistic_info.loc[j,'alarm_close_today']=FltAlarmInfo.loc[0,'CS_Warning_day_Finish_Count']
+        all_statistic_info.loc[j,'alarm_not_close_today']=FltAlarmInfo.loc[0,'SftyPlt_Data_day']-FltAlarmInfo.loc[0,'CS_Warning_day_Finish_Count']
+        all_statistic_info.loc[j,'alarm_uregent_total_today']=FltAlarmInfo.loc[0,'SftyPlt_EmgcyData_day']
+        all_statistic_info.loc[j,'alarm_uregent_close_today']=FltAlarmInfo.loc[0,'SftyPlt_EmgcyData_day_Finish_Count']
+        all_statistic_info.loc[j,'alarm_uregent_not_close_today']=FltAlarmInfo.loc[0,'SftyPlt_EmgcyData_day']-FltAlarmInfo.loc[0,'SftyPlt_EmgcyData_day_Finish_Count']
+        all_statistic_info.loc[j,'run_time_total']=TotalRunHour
+        all_statistic_info.loc[j,'dischrg_total']=TotalAccumAh
+        all_statistic_info.loc[j,'odo_total']=0
+        all_statistic_info.loc[j,'max_dischrg_one']=MaxAccumAh
+        all_statistic_info.loc[j,'max_runtime_one']=MaxRunningHour
+        all_statistic_info.loc[j,'max_cycle_one']=MaxCycle
+        all_statistic_info.loc[j,'max_odo_one']=0
+        all_statistic_info.loc[j,'alarm_close_total']=FltAlarmInfo.loc[0,'CS_Warning_Total_Finish_Count']
+        all_statistic_info.loc[j,'alarm_total']=FltAlarmInfo.loc[0,'SftyPlt_Data_Total']
+        CellType=Celltype.columns.tolist()
+        CellType=','.join(CellType) 
+        all_statistic_info.loc[0,'cell_type']=str(CellType)
+        CellTypeCount=Celltype.loc[0].tolist()
+        CellTypeCount=[str(x) for x in CellTypeCount]
+        CellTypeCount=','.join(CellTypeCount) 
+        all_statistic_info.loc[j,'cell_type_count']=str(CellTypeCount)
+        all_statistic_info.loc[j,'cell_safety_risk_count']=SatftyCount.loc[0,'CellSaftyCount']
+        all_statistic_info.loc[j,'data_safety_risk_count']=SatftyCount.loc[0,'DataSaftyCodeCount']
+        all_statistic_info.loc[j,'status_safety_risk_count']=SatftyCount.loc[0,'StateSaftyCodeCount']
+        all_statistic_info.loc[j,'hv_safety_risk_count']=SatftyCount.loc[0,'HvSaftyCodeCount']
+        all_statistic_info.loc[j,'system_safety_risk_count']=SatftyCount.loc[0,'SysSaftyCodeCount']
+        all_statistic_info.loc[j,'sample_safety_risk_count']=SatftyCount.loc[0,'SamplingSatyCount']
+        all_statistic_info.loc[j,'controller_safety_risk_count']=SatftyCount.loc[0,'CtrlSaftyCodeCount']
+        all_statistic_info.loc[j,'design_safety_risk_count']=SatftyCount.loc[0,'DsnSaftyCodeCount']
+        # all_statistic_info.to_csv('all_statistic_info.csv')
+    #
+        try:
+            logger.info("DaTa_Sta_Minutes_Task START!")
+            # 更新统计信息
+            conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+            cursor = conn.cursor()
+            sql = ''' update all_statistic_info set update_time='{}', total_alarm={}, alarm_total_today={}, alarm_close_today={}, alarm_not_close_today={},
+                        alarm_uregent_total_today={}, alarm_uregent_close_today={},alarm_uregent_not_close_today={},run_time_total={},dischrg_total={},
+                        odo_total={},max_dischrg_one={},max_runtime_one={},max_cycle_one={},max_odo_one={},alarm_close_total={},alarm_total={},cell_type='{}',
+                        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[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='{}'".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()
+            logger.info("DaTa_Sta_Minutes_Task DONE!")
+
+        except:
+            logger.error(traceback.format_exc)
+            logger.error(u"{},{} 任务运行错误\n".format(start_time,end_time), exc_info=True)
+        finally:
+            conn.close();
+            db_engine.dispose();
+    task_on=0
+
+
+if __name__ == "__main__":
+    
+    # # 时间设置
+
+    # now_time = datetime.datetime.now()
+    # pre_time = now_time + dateutil.relativedelta.relativedelta(hours=-1)#上小时时间
+    # end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d %H:00:00")
+    # start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d %H:00:00")
+    
+    # history_run_flag = False # 历史数据运行标志
+    
+
+    # # 更新sn列表
+    # host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    # port=3306
+    # db='qixiang_oss'
+    # user='qx_algo_rw'
+    # password='qx@123456'
+    # 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)
+    # cursor.close()
+    # conn.close();
+    # df_sn['factory'] = '骑享'
+    
+    # db = 'qx_cas'
+    # conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+    # cursor = conn.cursor()
+    # cursor.execute("select sn, factory from sn_list")
+    # res = cursor.fetchall()
+    # df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+    # df_sn2['imei'] = ""
+    # df_sn = pd.concat([df_sn, df_sn2], axis=0)
+    # df_sn = df_sn.reset_index(drop=True)
+    # # 数据库配置
+    # 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='saftyCenter_DataSta&Static_test', 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_algo_rw'
+    password=parse.quote_plus('qx@123456')
+    tablename='all_fault_info_copy'
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, db
+        ))
+
+        
+    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................``
+    # print("select start_time, end_time, product_id, code, level, info, advice, factory from {}".format(tablename))
+    try:
+        df_Diag_Ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice, Batpos from all_fault_info_copy", db_engine)
+    finally:
+        db_engine.dispose()
+    # result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
+    # df_Diag_Ram=result[result['end_time']=='0000-00-00 00:00:00']
+
+    global task_on
+    
+    task_on=0
+    diag_cal()
+    # DaTa_Sta_Minutes_Task()
+    # DaTa_Sta_Week_Task()
+
+    #定时任务.......................................................................................................................................................................
+    scheduler = BlockingScheduler()
+    if task_on==0:
+        scheduler.add_job(diag_cal, 'interval', seconds=900, id='diag_job')
+        scheduler.add_job(DaTa_Sta_Week_Task, 'interval',start_date='2021-11-15 08:00:00', days=7, id='Week_Task')
+        scheduler.add_job(DaTa_Sta_Minutes_Task, 'interval', seconds=180, id='Minutes_Task')
+    try:  
+        scheduler.start()
+    except Exception as e:
+        scheduler.shutdown()
+        logger.error(str(e))
+
+    

+ 4 - 0
LIB/FRONTEND/SaftyCenter/DataDiag_Static/run_test.bat

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

+ 8 - 2
LIB/FRONTEND/SaftyCenter/Liplated/deploy_7255.py

@@ -44,10 +44,14 @@ def cell_platd_test(df_sn, df_first_data_time):
     end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
     logger.info("cycle start !!!!!!!!!!!!!!!!!!!!")
     
-
+    df_sn_done = pd.read_csv("SNnums_C7255_析锂状态.csv")
+    sn_done = list(set(df_sn_done['sn']))
     for i in range(0, len(df_sn)):
         try:
             sn = df_sn.loc[i, 'sn']
+            # if sn in sn_done:
+            #     logger.info(sn+"已计算,跳过")
+            #     continue 
             # if df_sn.loc[i, 'imei'][5:9] == 'N640':
             #     celltype=1 #6040三元电芯
             # elif df_sn.loc[i, 'imei'][5:9] == 'N440':
@@ -58,6 +62,8 @@ def cell_platd_test(df_sn, df_first_data_time):
             #     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三元电芯
+            # if df_sn.loc[i, 'imei'][3:9] == 'CLL128':
+            #     celltype=100 #CATL 50ah三元电芯
             else:
                 logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
                 continue
@@ -68,7 +74,7 @@ def cell_platd_test(df_sn, df_first_data_time):
             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"
+                    start_time = "2021-11-17 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")
             logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))

+ 5 - 6
LIB/FRONTEND/SaftyCenter/Liplated/deploy_7255_other.py

@@ -23,8 +23,7 @@ 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):
     # 读取结果数据库
@@ -57,8 +56,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三元电芯
-            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: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
@@ -72,9 +71,9 @@ 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'])

+ 27 - 1
LIB/FRONTEND/SaftyCenter/LowSocAlarm/deploy_sta.py

@@ -18,6 +18,32 @@ from LIB.BACKEND import DBManager
 
 if __name__ == "__main__":
     
+    # 更新sn列表
+    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    port=3306
+    db='qixiang_oss'
+    user='qx_algo_rw'
+    password='qx@123456'
+    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)
+    cursor.close()
+    conn.close();
+    df_sn['factory'] = '骑享'
+    
+    db = 'qx_cas'
+    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+    cursor = conn.cursor()
+    cursor.execute("select sn, factory from sn_list")
+    res = cursor.fetchall()
+    df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+    df_sn2['imei'] = ""
+    df_sn2['factory'] = '金茂换电'
+    df_sn = pd.concat([df_sn, df_sn2], axis=0)
+    df_sn = df_sn.reset_index(drop=True)
     
     # 日志配置
     now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
@@ -52,7 +78,7 @@ if __name__ == "__main__":
             ))
 
         logger.info("pid-{} START!".format(os.getpid()))
-        low_soc_alarm_sta.low_soc_alarm_sta(db_qxcas_engine, conn, db_sp_engine)
+        low_soc_alarm_sta.low_soc_alarm_sta(df_sn, db_qxcas_engine, conn, db_sp_engine)
         logger.info("pid-{} DONE!".format(os.getpid()))
                     
     except:

+ 27 - 1
LIB/FRONTEND/SaftyCenter/Offline/deploy_sta.py

@@ -18,6 +18,32 @@ from LIB.BACKEND import DBManager
 
 if __name__ == "__main__":
     
+        # 更新sn列表
+    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+    port=3306
+    db='qixiang_oss'
+    user='qx_algo_rw'
+    password='qx@123456'
+    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)
+    cursor.close()
+    conn.close();
+    df_sn['factory'] = '骑享'
+    
+    db = 'qx_cas'
+    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+    cursor = conn.cursor()
+    cursor.execute("select sn, factory from sn_list")
+    res = cursor.fetchall()
+    df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+    df_sn2['imei'] = ""
+    df_sn2['factory'] = '金茂换电'
+    df_sn = pd.concat([df_sn, df_sn2], axis=0)
+    df_sn = df_sn.reset_index(drop=True)
     
     # 日志配置
     now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
@@ -62,7 +88,7 @@ if __name__ == "__main__":
             ))
 
         logger.info("pid-{}   START!".format(os.getpid()))
-        offline_alarm_sta.offline_alarm_sta(db_iotp_engine, db_qxcas_engine, conn, db_sp_engine)
+        offline_alarm_sta.offline_alarm_sta(df_sn, db_iotp_engine, db_qxcas_engine, conn, db_sp_engine)
         logger.info("pid-{} DONE!".format(os.getpid()))
                     
     except:

+ 48 - 0
LIB/FRONTEND/SaftyCenter/Sorest/create_table.py

@@ -0,0 +1,48 @@
+'''
+定义表的结构,并在数据库中创建对应的数据表
+'''
+__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__ = "mechanism_sorout"
+    __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="计算时刻")
+    sor = Column(Text, comment="内阻")
+    sor_sigma = Column(Text, comment="内阻偏离度")
+    soc = Column(Text, comment="soc")
+    temp = Column(Text, comment="temp")
+    delta_time = 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)

+ 167 - 0
LIB/FRONTEND/SaftyCenter/Sorest/deploy.py

@@ -0,0 +1,167 @@
+
+__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.Common import log
+from pandas.core.frame import DataFrame
+from urllib import parse
+import pymysql
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
+
+import datacompy
+from LIB.MIDDLE.SaftyCenter.Sorest import sor_est
+
+
+def cell_sor_test(df_sn):
+    # 读取结果数据库
+    host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port2=3306
+    db2='qx_cas'
+    user2='qx_read'
+    password2='Qx@123456'
+    
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, database
+        ))
+        
+    start=time.time()
+    end_time=datetime.datetime.now()
+    start_time=end_time-datetime.timedelta(days=7)
+    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:
+            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:9] == 'CLL128':    
+                celltype=100 # 重卡
+            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
+            
+            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
+                
+                
+            param = BatParam.BatParam(celltype)
+            #读取原始数据库数据........................................................................................................................................................
+            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']
+     
+            if not df_bms.empty:
+                Diag_sorvol_temp = sor_est.sor_est(sn,celltype,df_bms)#电压内阻估计
+                df_sor_add = Diag_sorvol_temp.sor_cal()        
+                if not df_sor_add.empty:
+                    df_sor_add = df_sor_add.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                    df_sor_add['add_time'] = datetime.datetime.now()
+                    df_sor_add.to_sql("mechanism_sorout",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)
+    logger.info("cycle DONE !!!!!!!!!!!!!!!!!!!!")
+    db_engine.dispose()
+
+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/' + now_str
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+    log = Log.Mylog(log_name='saftyCenter_sorout', 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'
+    # db_res_engine = create_engine(
+    #     "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+    #         user, password, host, port, db
+    #     ))
+
+
+
+    #定时任务.......................................................................................................................................................................
+    cell_sor_test(df_sn)
+    # scheduler = BlockingScheduler()
+
+    # scheduler.add_job(fun, 'interval', seconds=600, id='diag_job')
+    # try:  
+    #     scheduler.start()
+    # except Exception as e:
+    #     scheduler.shutdown()
+    #     logger.error(str(e))
+    

+ 177 - 0
LIB/FRONTEND/SaftyCenter/Sorest/deploy_7255.py

@@ -0,0 +1,177 @@
+
+__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.Common import log
+from pandas.core.frame import DataFrame
+from urllib import parse
+import pymysql
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
+
+import datacompy
+from LIB.MIDDLE.SaftyCenter.Sorest import sor_est
+
+
+def cell_sor_test(df_sn,df_first_data_time):
+    global df_diag_sor
+    # 读取结果数据库
+    host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port2=3306
+    db2='qx_cas'
+    user2='qx_read'
+    password2='Qx@123456'
+    
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, database
+        ))
+        
+    start=time.time()
+    end_time=datetime.datetime.now()
+    start_time=end_time-datetime.timedelta(days=7)
+    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 !!!!!!!!!!!!!!!!!!!!")
+    start_time = '2021-10-24 00:00:00'
+    end_time = '2021-10-31 00:00:00'
+    
+    for i in range(0, len(df_sn)):
+        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:9] == 'CLL128':    
+            #     celltype=100 # 重卡
+            if 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
+            
+            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
+            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 = "2019-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")    
+                
+            param = BatParam.BatParam(celltype)
+            #读取原始数据库数据........................................................................................................................................................
+            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']
+     
+            if not df_bms.empty:
+                Diag_sorvol_temp = sor_est.sor_est(sn,celltype,df_bms)#电压内阻估计
+                df_sor_add = Diag_sorvol_temp.sor_cal()        
+                if not df_sor_add.empty:
+                    df_sor_add = df_sor_add.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                    df_sor_add['add_time'] = datetime.datetime.now()
+                    df_sor_add.to_sql("mechanism_sorout",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)
+    logger.info("cycle DONE !!!!!!!!!!!!!!!!!!!!")
+    db_engine.dispose()
+
+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_7255/' + now_str
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+    log = Log.Mylog(log_name='saftyCenter_sorout7255', 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'
+    # db_res_engine = create_engine(
+    #     "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+    #         user, password, host, port, db
+    #     ))
+
+
+
+    #定时任务.......................................................................................................................................................................
+    cell_sor_test(df_sn,df_first_data_time)
+    # scheduler = BlockingScheduler()
+
+    # scheduler.add_job(fun, 'interval', seconds=600, id='diag_job')
+    # try:  
+    #     scheduler.start()
+    # except Exception as e:
+    #     scheduler.shutdown()
+    #     logger.error(str(e))
+    

+ 177 - 0
LIB/FRONTEND/SaftyCenter/Sorest/deploy_7255_other.py

@@ -0,0 +1,177 @@
+
+__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.Common import log
+from pandas.core.frame import DataFrame
+from urllib import parse
+import pymysql
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
+
+import datacompy
+from LIB.MIDDLE.SaftyCenter.Sorest import sor_est
+
+
+def cell_sor_test(df_sn,df_first_data_time):
+    global df_diag_sor
+    # 读取结果数据库
+    host2='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+    port2=3306
+    db2='qx_cas'
+    user2='qx_read'
+    password2='Qx@123456'
+    
+    db_engine = create_engine(
+        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+            user, password, host, port, database
+        ))
+        
+    start=time.time()
+    end_time=datetime.datetime.now()
+    start_time=end_time-datetime.timedelta(days=7)
+    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 !!!!!!!!!!!!!!!!!!!!")
+    start_time = '2021-10-01 00:00:00'
+    end_time = '2021-12-31 00:00:00'
+    
+    for i in range(0, len(df_sn)):
+        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:9] == 'CLL128':    
+            #     celltype=100 # 重卡
+            # if 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
+            
+            logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
+            # 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 = "2019-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")    
+                
+            param = BatParam.BatParam(celltype)
+            #读取原始数据库数据........................................................................................................................................................
+            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']
+     
+            if not df_bms.empty:
+                Diag_sorvol_temp = sor_est.sor_est(sn,celltype,df_bms)#电压内阻估计
+                df_sor_add = Diag_sorvol_temp.sor_cal()        
+                if not df_sor_add.empty:
+                    df_sor_add = df_sor_add.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                    df_sor_add['add_time'] = datetime.datetime.now()
+                    df_sor_add.to_sql("mechanism_sorout",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)
+    logger.info("cycle DONE !!!!!!!!!!!!!!!!!!!!")
+    db_engine.dispose()
+
+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_7255_other/' + now_str
+    if not os.path.exists(log_path):
+        os.makedirs(log_path)
+    log = Log.Mylog(log_name='saftyCenter_sorout7255', 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'
+    # db_res_engine = create_engine(
+    #     "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
+    #         user, password, host, port, db
+    #     ))
+
+
+
+    #定时任务.......................................................................................................................................................................
+    cell_sor_test(df_sn,df_first_data_time)
+    # scheduler = BlockingScheduler()
+
+    # scheduler.add_job(fun, 'interval', seconds=600, id='diag_job')
+    # try:  
+    #     scheduler.start()
+    # except Exception as e:
+    #     scheduler.shutdown()
+    #     logger.error(str(e))
+    

+ 108 - 0
LIB/FRONTEND/SaftyCenter/Sorest/main.py

@@ -0,0 +1,108 @@
+import datetime
+import pandas as pd
+from LIB.BACKEND import DBManager, Log
+import time, datetime
+from apscheduler.schedulers.blocking import BlockingScheduler
+from pandas.core.frame import DataFrame
+import matplotlib as plt
+from pylab import*
+import sor_est
+from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
+import log
+
+#...................................电池包电芯安全诊断函数......................................................................................................................
+def cell_sor_test():
+    global SNnums
+    global df_diag_sor
+    start=time.time()
+    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=3)
+    end_time=str(now_time)
+    start_time=str(start_time)
+    k = 1
+    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' in sn: 
+            celltype=4 #CATL 50ah三元电芯
+        elif 'UD' in sn:
+            celltype=4 #CATL 50ah三元电芯
+        elif 'TJMCL' in sn: 
+            celltype=100 #金茂电芯
+        else:
+            print('SN:{},未找到对应电池类型!!!'.format(sn))
+            continue
+            # sys.exit()
+        print('计算的第' + str(k) + '个:' + sn)
+        k = k + 1
+        #读取原始数据库数据........................................................................................................................................................
+        start_time = '2021-10-01 00:00:00'
+        end_time = '2021-11-01 00:00:00'
+        dbManager = DBManager.DBManager()
+        df_data = dbManager.get_data(sn = sn, start_time = start_time, end_time = end_time, data_groups = ['bms'])
+        df_bms = df_data['bms']
+        # df_sor_add = pd.DataFrame()
+        param = BatParam.BatParam(celltype)#鹏飞param中为BatParam,学琦为BatteryInfo
+        #........................................................电压内阻估计.....................................................................
+        if not df_bms.empty:
+            Diag_sorvol_temp = sor_est.sor_est(sn,celltype,df_bms)#电压内阻估计
+            df_sor_add = Diag_sorvol_temp.sor_cal()        
+            if not df_sor_add.empty:
+                df_diag_sor = df_diag_sor.append(df_sor_add)
+                df_diag_sor = df_diag_sor.drop_duplicates(subset = ['sn','time'], keep = 'first', inplace = False)
+                df_diag_sor.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\05内阻及电压估计\01算法开发\内阻估计\测试结果\MGMCLN750N215N049\计算结果\内阻估计.csv',index=False,encoding='GB18030')
+        end=time.time()
+        print(end-start)
+        
+
+#...............................................主函数...............................................................................................
+if __name__ == "__main__":
+    global SNnums
+    global df_diag_sor
+    
+    excelpath=r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\00项目sn号\sn-20210903.xlsx'
+    SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
+    SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
+    SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
+    SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
+    SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
+    SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
+    SNnums_6060=SNdata_6060['SN号'].tolist()
+    SNnums_6040=SNdata_6040['SN号'].tolist()
+    SNnums_4840=SNdata_4840['SN号'].tolist()
+    SNnums_L7255=SNdata_L7255['SN号'].tolist()
+    SNnums_C7255=SNdata_C7255['SN号'].tolist()
+    SNnums_U7255=SNdata_U7255['SN号'].tolist()
+    # df_diag_sor = pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\05内阻及电压估计\01算法开发\内阻估计\测试结果\内阻估计.csv', encoding='GB18030')
+    # SNums_finish = list(df_diag_sor['sn'])
+    #SNnums=SNnums_L7255 + SNnums_C7255 + SNnums_6040 + SNnums_4840 + SNnums_U7255+ SNnums_6060
+    #SNnums=['TJMCL120502305010','TJMCL120502305012','TJMCL120502305048','TJMCL120502305044','TJMCL120502305026','TJMCL120502305022','TJMCL120502305032','TJMCL120502305038']
+    # SNnums = SNnums_U7255#['MGMCLN750N215N049'] #SNnums_6040 #SNnums_C7255 #SNnums_6040['MGMCLN750N215N049'] PK504B00100004003
+    # SNnums = pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\liplated\疑似析锂电池sn.csv',encoding='GB18030')
+    # SNnums = list(set(SNnums_U7255).difference(set(SNums_finish)))
+    SNnums = ['MGMCLN750N215N049']
+    
+    mylog=log.Mylog('log_diag.txt','error')
+    mylog.logcfg()
+    #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................
+    df_diag_sor = pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\05内阻及电压估计\01算法开发\内阻估计\测试结果\MGMCLN750N215N049\计算结果\内阻估计.csv',encoding='GB18030')
+    
+    print('----------------输入--------')
+    print('-------计算中-----------')
+    #定时任务.......................................................................................................................................................................
+    scheduler = BlockingScheduler()
+    scheduler.add_job(cell_sor_test, 'interval', seconds=10, id='diag_job')
+
+    try:  
+        scheduler.start()
+    except Exception as e:
+        scheduler.shutdown()
+        print(repr(e))
+        mylog.logopt(e)

+ 3 - 0
LIB/FRONTEND/SaftyCenter/Sorest/run.bat

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

+ 3 - 0
LIB/FRONTEND/SaftyCenter/Sorest/run_7255.bat

@@ -0,0 +1,3 @@
+cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Sorest
+title cal_saftyCenter_sorest
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Sorest\deploy_7255.py

+ 3 - 0
LIB/FRONTEND/SaftyCenter/Sorest/run_7255_other.bat

@@ -0,0 +1,3 @@
+cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Sorest
+title cal_saftyCenter_sorest_7255other
+D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\SaftyCenter\Sorest\deploy_7255_other.py