Bladeren bron

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

shangguanlie23 3 jaren geleden
bovenliggende
commit
35891dba68

+ 2 - 3
LIB/BACKEND/DBManager.py

@@ -174,9 +174,9 @@ class DBManager():
             if data['info']['subType'] == 1:
                 data_block = np.array([data['info']['obdTime'],data['ffGps']['locationType'], data['ffGps']['satellites'],
                                        data['ffGps']['latitude'],data['ffGps']['longitude'],data['ffGps']['speed'], 
-                                       data['ffGps']['altitude'], data['ffGps']['direction']]).reshape(1,8)
+                                       data['ffGps']['altitude'], data['ffGps']['direction'], data['ffGps']['mileage']]).reshape(1,9)
                 df = pd.DataFrame(
-                    columns=['时间戳','定位类型', '卫星数','纬度','经度','速度[km/h]','海拔','航向'],data=data_block)
+                    columns=['时间戳','定位类型', '卫星数','纬度','经度','速度[km/h]','海拔','航向', '里程/m'],data=data_block)
             elif data['info']['subType'] == 2:
                 df = pd.DataFrame(
                     columns=['时间戳','定位类型', '卫星数','纬度','经度','速度[km/h]','海拔','航向'])
@@ -251,7 +251,6 @@ class DBManager():
                 temp = len(line['ffBatteryStatus'].get('otherTempList', []))
                 if (temp > OtherTNum):
                     OtherTNum = temp
-            
             data_blocks = pd.DataFrame()
             for line in data:
                 et = time.time()

+ 16 - 0
LIB/MIDDLE/CellStateEstimation/Common/BatParam.py

@@ -112,6 +112,22 @@ class BatParam:
             self.BalCurrent=0.015
             self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
             self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
+
+            
+            
+            self.CellOvLv1=3.75
+            self.CellOvLv2=3.8
+            self.CellUvLv1=2.3
+            self.CellUvLv2=2.2
+            self.CellVoltDiffLv1=0.6
+            self.CellVoltDiffLv2=1
+            self.PackVoltOvLv1=self.CellOvLv1*self.CellVoltNums/2
+            self.PackVoltOvLv2=self.CellOvLv2*self.CellVoltNums/2
+            self.PackVoltUvLv1=self.CellUvLv1*self.CellVoltNums/2
+            self.PackVoltUvLv2=self.CellUvLv2*self.CellVoltNums/2
+
+            self.PackChgOc=-800
+            self.PackDisOc=800        
         else:
             print('未找到对应电池编号!!!')
             # sys.exit()

+ 49 - 49
LIB/MIDDLE/CellStateEstimation/Common/V1_0_1/BatParam.py

@@ -67,7 +67,7 @@ class BatParam:
             self.PackDisOc=200
 
             self.LeakCurrentLv1=-10
-            self.LeakCurrentLv2=-20
+            self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
             self.CellTempHighLv2=50
@@ -104,7 +104,7 @@ class BatParam:
             self.PackDisOc=200
 
             self.LeakCurrentLv1=-10
-            self.LeakCurrentLv2=-20
+            self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
             self.CellTempHighLv2=50
@@ -141,7 +141,7 @@ class BatParam:
             self.PackDisOc=200
 
             self.LeakCurrentLv1=-10
-            self.LeakCurrentLv2=-20
+            self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
             self.CellTempHighLv2=50
@@ -179,7 +179,7 @@ class BatParam:
             self.PackDisOc=200
 
             self.LeakCurrentLv1=-10
-            self.LeakCurrentLv2=-20
+            self.LeakCurrentLv2=-15
             self.LeakCurrentLv3=-50
             self.CellTempHighLv1=45
             self.CellTempHighLv2=50
@@ -200,7 +200,7 @@ class BatParam:
             self.SocInflexion2=60
             self.SocInflexion3=70
             self.CellVoltNums=20
-            self.CellTempNums=4
+            self.CellTempNums=3
             self.OtherTempNums=5
             self.FullChrgSoc=98
             self.PeakSoc=59
@@ -223,11 +223,11 @@ class BatParam:
             self.PackVoltUvLv1=self.CellUvLv1*self.CellVoltNums
             self.PackVoltUvLv2=self.CellUvLv2*self.CellVoltNums
 
-            self.PackChgOc=-600
-            self.PackDisOc=600
+            self.PackChgOc=-60
+            self.PackDisOc=200
 
             self.LeakCurrentLv1=-20
-            self.LeakCurrentLv2=-50
+            self.LeakCurrentLv2=-30
             self.LeakCurrentLv3=-100
             self.CellTempHighLv1=45
             self.CellTempHighLv2=50
@@ -236,49 +236,49 @@ class BatParam:
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15                       
         elif celltype==100:
-                self.Capacity = 228*2
-                self.PackFullChrgVolt=3.65*192
-                self.CellFullChrgVolt=3.5
-                self.OcvInflexionBelow=3.285
-                self.OcvInflexion2=3.296
-                self.OcvInflexion3=3.328
-                self.OcvInflexionAbove=3.4
-                self.CellVoltNums=384
-                self.CellTempNums=64
-                self.FullChrgSoc=98
-                self.PeakSoc=59
-                self.PeakVoltLowLmt=3.35
-                self.PeakVoltUpLmt=3.4
-                self.PeakCellVolt=[3.362,3.363,3.365,3.366,3.367]
-                self.PackCrntDec=1
-                self.BalCurrent=0.015
-                self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
-                self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
-                
-                self.CellOvLv1=3.75
-                self.CellOvLv2=3.8
-                
-                self.CellUvLv1=2.3
-                self.CellUvLv2=2.2
-                self.CellVoltDiffLv1=0.6
-                self.CellVoltDiffLv2=1
-                self.PackVoltOvLv1=self.CellOvLv1*self.CellVoltNums
-                self.PackVoltOvLv2=self.CellOvLv2*self.CellVoltNums
-                self.PackVoltUvLv1=self.CellUvLv1*self.CellVoltNums
-                self.PackVoltUvLv2=self.CellUvLv2*self.CellVoltNums
+            self.Capacity = 228*2
+            self.PackFullChrgVolt=3.65*192
+            self.CellFullChrgVolt=3.5
+            self.OcvInflexionBelow=3.285
+            self.OcvInflexion2=3.296
+            self.OcvInflexion3=3.328
+            self.OcvInflexionAbove=3.4
+            self.CellVoltNums=384
+            self.CellTempNums=64
+            self.FullChrgSoc=98
+            self.PeakSoc=59
+            self.PeakVoltLowLmt=3.35
+            self.PeakVoltUpLmt=3.4
+            self.PeakCellVolt=[3.362,3.363,3.365,3.366,3.367]
+            self.PackCrntDec=1
+            self.BalCurrent=0.015
+            self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
+            self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
+            
+            self.CellOvLv1=3.75
+            self.CellOvLv2=3.8
+            
+            self.CellUvLv1=2.3
+            self.CellUvLv2=2.2
+            self.CellVoltDiffLv1=0.6
+            self.CellVoltDiffLv2=1
+            self.PackVoltOvLv1=self.CellOvLv1*self.CellVoltNums/2
+            self.PackVoltOvLv2=self.CellOvLv2*self.CellVoltNums/2
+            self.PackVoltUvLv1=self.CellUvLv1*self.CellVoltNums/2
+            self.PackVoltUvLv2=self.CellUvLv2*self.CellVoltNums/2
 
-                self.PackChgOc=-600
-                self.PackDisOc=600
+            self.PackChgOc=-800
+            self.PackDisOc=800
 
-                self.LeakCurrentLv1=-20
-                self.LeakCurrentLv2=-50
-                self.LeakCurrentLv3=-100
-                self.CellTempHighLv1=65
-                self.CellTempHighLv2=67
-                self.CellTempLowLv1=-30
-                self.CellTempLowLv2=-35
-                self.CellTempDiffLv1=28
-                self.CellTempDiffLv2=32                            
+            self.LeakCurrentLv1=-20
+            self.LeakCurrentLv2=-50
+            self.LeakCurrentLv3=-100
+            self.CellTempHighLv1=65
+            self.CellTempHighLv2=67
+            self.CellTempLowLv1=-30
+            self.CellTempLowLv2=-35
+            self.CellTempDiffLv1=28
+            self.CellTempDiffLv2=32                            
             
         else:
             print('未找到对应电池编号!!!')

+ 1 - 1
LIB/MIDDLE/CellStateEstimation/Common/V1_0_1/log.py

@@ -17,7 +17,7 @@ class Mylog:
                 Level=logging.WARNING
             else:
                 Level=logging.ERROR
-        logging.basicConfig(filename=r'D:\ZLWORK\code\data_analyze_platform\USER\eric\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s')
+        logging.basicConfig(filename=r'D:\Platform\platform_python\data_analyze_platform\USER\spf\101log\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s')
 
 
     def logopt(self,*info):

+ 6 - 1
LIB/MIDDLE/SaftyCenter/Common/QX_BatteryParam.py

@@ -123,6 +123,7 @@ class BatteryInfo():
             self.OcvInflexionAbove=3.4
             self.CellVoltNums=384
             self.CellTempNums=64
+            self.OtherTempNums=0
             self.FullChrgSoc=98
             self.PeakSoc=59
             self.PeakVoltLowLmt=3.35
@@ -132,7 +133,11 @@ class BatteryInfo():
             self.BalCurrent=0.015
             self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
             self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
-
+            self.DifVolGap = 3
+            self.CellOVlmt=4
+            self.CellUVlmt=2
+            self.CantChrgVol=2.6
+ 
 
         else:
             print('未找到对应电池编号!!!')

+ 145 - 74
LIB/MIDDLE/SaftyCenter/DataDiag_Static/DataStatistics.py

@@ -10,52 +10,100 @@ from apscheduler.schedulers.blocking import BlockingScheduler
 class DataSta():
     def __init__(self) -> None:
         pass
-    def SaftyWarningSta(df_fltinfo,start_time,end_time):
-        start_time=datetime.datetime.strptime(start_time, '%Y-%m-%d')
-        start_time=start_time+datetime.timedelta(days=1)
-        start_time=start_time.strftime('%Y-%m-%d')
-        SftyPlt_Data_Total=len(df_fltinfo)#总报警数
-        CS_Warning_Total_Finish=df_fltinfo[df_fltinfo['batpos']==1]
-        CS_Warning_Total_Finish_Count=len(CS_Warning_Total_Finish) #平台报警总运维数
-        SftyPlt_Data_day=len(df_fltinfo[df_fltinfo['start_time']>=start_time])#日、周总报警数
-        CS_Warning_day_Finish=CS_Warning_Total_Finish[CS_Warning_Total_Finish['start_time']>=start_time]#日/周运维数
-        CS_Warning_day_Finish_Count=len(CS_Warning_day_Finish)
-        SftyPlt_EmgcyData_day=df_fltinfo[df_fltinfo['start_time']>=start_time] #紧急报警数
-        SftyPlt_EmgcyData_day=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['level']>3]
-        SftyPlt_EmgcyData_day_Count=len(SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['level']>3])
-        SftyPlt_EmgcyData_day_Finish=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['batpos']==1]
-        SftyPlt_EmgcyData_day_Finish_Count=len(SftyPlt_EmgcyData_day_Finish)
-        if int(SftyPlt_Data_Total)>0:
-            OprationManageRate=round(float(CS_Warning_day_Finish_Count/SftyPlt_Data_day)*100,2)
+    def SaftyWarningSta(df_fltinfo,start_time,end_time,factory_info):
+        if  '骑享' in factory_info:
+            df_fltinfo=df_fltinfo[~df_fltinfo['product_id'].str.contains('TJMCL')]
+            start_time=start_time+str(' 00:00:00')
+            start_time=datetime.datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S')
+            start_time=start_time+datetime.timedelta(days=1)
+            start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
+            SftyPlt_Data_Total=len(df_fltinfo)#总报警数
+            CS_Warning_Total_Finish=df_fltinfo[df_fltinfo['batpos']==1]
+            CS_Warning_Total_Finish_Count=len(CS_Warning_Total_Finish) #平台报警总运维数
+            SftyPlt_Data_day=len(df_fltinfo[df_fltinfo['start_time']>=start_time])#日、周总报警数
+            CS_Warning_day_Finish=CS_Warning_Total_Finish[CS_Warning_Total_Finish['start_time']>=start_time]#日/周运维数
+            CS_Warning_day_Finish_Count=len(CS_Warning_day_Finish)
+            SftyPlt_EmgcyData_day=df_fltinfo[df_fltinfo['start_time']>=start_time] #紧急报警数
+            SftyPlt_EmgcyData_day=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['level']>3]
+            SftyPlt_EmgcyData_day_Count=len(SftyPlt_EmgcyData_day)
+            SftyPlt_EmgcyData_day_Finish=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['batpos']==1]
+            SftyPlt_EmgcyData_day_Finish_Count=len(SftyPlt_EmgcyData_day_Finish)
+            if int(SftyPlt_Data_day)>0:
+                OprationManageRate=round(float(CS_Warning_day_Finish_Count/SftyPlt_Data_day)*100,2)
+            else:
+                OprationManageRate=100
+            if int(SftyPlt_EmgcyData_day_Count)>0:
+                OprationManageEmgcyRate=round(float(SftyPlt_EmgcyData_day_Finish_Count/SftyPlt_EmgcyData_day_Count)*100,2)
+            else:
+                OprationManageEmgcyRate=100
+            PK504FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK504')])
+            PK502FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK502')])
+            PK500FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK500')])
+            MGMCLFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('MGMCL')])
+            MGMLXFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('MGMLX')])
+            # print('总报警数=',SftyPlt_Data_Total)
+            # print('总完成运维数=',CS_Warning_Total_Finish_Count)
+            # print('周报警数=',SftyPlt_Data_day)
+            # print('周完成运维数=',CS_Warning_day_Finish_Count)
+            # print('周紧急报警数=',SftyPlt_EmgcyData_day)
+            # print('周紧急完成运维数=',SftyPlt_EmgcyData_day_Finish_Count)
+            # print('周运维率=',OprationManageRate)
+            # print('周紧急运维率=',OprationManageEmgcyRate)
+            # print('PK504总报警=',PK504FltData_Count)
+            # print('PK502总报警=',PK502FltData_Count)
+            # print('PK500总报警=',PK500FltData_Count)
+            # print('格林美总报警=',MGMCLFltData_Count)
+            # print('自研总报警=',MGMLXFltData_Count)
+            FltAlarmInfo=DataFrame(columns=['SftyPlt_Data_Total','CS_Warning_Total_Finish_Count','SftyPlt_Data_day','CS_Warning_day_Finish_Count','SftyPlt_EmgcyData_day','SftyPlt_EmgcyData_day_Finish_Count','OprationManageRate','OprationManageEmgcyRate'])
+            Celltype=DataFrame(columns=['PK504','PK502','PK500','MGMCL','MGMLX'])
+            FltAlarmInfo.loc[0]=[SftyPlt_Data_Total,CS_Warning_Total_Finish_Count,SftyPlt_Data_day,CS_Warning_day_Finish_Count,SftyPlt_EmgcyData_day_Count,SftyPlt_EmgcyData_day_Finish_Count,OprationManageRate,OprationManageEmgcyRate]
+            Celltype.loc[0]=[PK504FltData_Count,PK502FltData_Count,PK500FltData_Count,MGMCLFltData_Count,MGMLXFltData_Count]
+        elif '金茂换电' in factory_info:
+            df_fltinfo=df_fltinfo[df_fltinfo['product_id'].str.contains('TJMCL')]
+            start_time=start_time+str(' 00:00:00')
+            start_time=datetime.datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S')
+            start_time=start_time+datetime.timedelta(days=1)
+            start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
+            SftyPlt_Data_Total=len(df_fltinfo)#总报警数
+            CS_Warning_Total_Finish=df_fltinfo[df_fltinfo['batpos']==1]
+            CS_Warning_Total_Finish_Count=len(CS_Warning_Total_Finish) #平台报警总运维数
+            SftyPlt_Data_day=len(df_fltinfo[df_fltinfo['start_time']>=start_time])#日、周总报警数
+            CS_Warning_day_Finish=CS_Warning_Total_Finish[CS_Warning_Total_Finish['start_time']>=start_time]#日/周运维数
+            CS_Warning_day_Finish_Count=len(CS_Warning_day_Finish)
+            SftyPlt_EmgcyData_day=df_fltinfo[df_fltinfo['start_time']>=start_time] #紧急报警数
+            SftyPlt_EmgcyData_day=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['level']>3]
+            SftyPlt_EmgcyData_day_Count=len(SftyPlt_EmgcyData_day)
+            SftyPlt_EmgcyData_day_Finish=SftyPlt_EmgcyData_day[SftyPlt_EmgcyData_day['batpos']==1]
+            SftyPlt_EmgcyData_day_Finish_Count=len(SftyPlt_EmgcyData_day_Finish)
+            if int(SftyPlt_Data_day)>0:
+                OprationManageRate=round(float(CS_Warning_day_Finish_Count/SftyPlt_Data_day)*100,2)
+            else:
+                OprationManageRate=100
+            if int(SftyPlt_EmgcyData_day_Count)>0:
+                OprationManageEmgcyRate=round(float(SftyPlt_EmgcyData_day_Finish_Count/SftyPlt_EmgcyData_day_Count)*100,2)
+            else:
+                OprationManageEmgcyRate=100
+            TJMCLFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('TJMCL')])
+            # print('总报警数=',SftyPlt_Data_Total)
+            # print('总完成运维数=',CS_Warning_Total_Finish_Count)
+            # print('周报警数=',SftyPlt_Data_day)
+            # print('周完成运维数=',CS_Warning_day_Finish_Count)
+            # print('周紧急报警数=',SftyPlt_EmgcyData_day)
+            # print('周紧急完成运维数=',SftyPlt_EmgcyData_day_Finish_Count)
+            # print('周运维率=',OprationManageRate)
+            # print('周紧急运维率=',OprationManageEmgcyRate)
+            # print('PK504总报警=',PK504FltData_Count)
+            # print('PK502总报警=',PK502FltData_Count)
+            # print('PK500总报警=',PK500FltData_Count)
+            # print('格林美总报警=',MGMCLFltData_Count)
+            # print('自研总报警=',MGMLXFltData_Count)
+            FltAlarmInfo=DataFrame(columns=['SftyPlt_Data_Total','CS_Warning_Total_Finish_Count','SftyPlt_Data_day','CS_Warning_day_Finish_Count','SftyPlt_EmgcyData_day','SftyPlt_EmgcyData_day_Finish_Count','OprationManageRate','OprationManageEmgcyRate'])
+            Celltype=DataFrame(columns=['TJMCL'])
+            FltAlarmInfo.loc[0]=[SftyPlt_Data_Total,CS_Warning_Total_Finish_Count,SftyPlt_Data_day,CS_Warning_day_Finish_Count,SftyPlt_EmgcyData_day_Count,SftyPlt_EmgcyData_day_Finish_Count,OprationManageRate,OprationManageEmgcyRate]
+            Celltype.loc[0]=[TJMCLFltData_Count]
         else:
-            OprationManageRate=100
-        if int(SftyPlt_EmgcyData_day_Count)>0:
-            OprationManageEmgcyRate=round(float(SftyPlt_EmgcyData_day_Finish_Count/SftyPlt_EmgcyData_day_Count)*100,2)
-        else:
-            OprationManageEmgcyRate=100
-        PK504FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK504')])
-        PK502FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK502')])
-        PK500FltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('PK500')])
-        MGMCLFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('MGMCL')])
-        MGMLXFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('MGMLX')])
-        TJMCLFltData_Count=len(df_fltinfo[df_fltinfo['product_id'].str.contains('TJMCL')])
-        # print('总报警数=',SftyPlt_Data_Total)
-        # print('总完成运维数=',CS_Warning_Total_Finish_Count)
-        # print('周报警数=',SftyPlt_Data_day)
-        # print('周完成运维数=',CS_Warning_day_Finish_Count)
-        # print('周紧急报警数=',SftyPlt_EmgcyData_day)
-        # print('周紧急完成运维数=',SftyPlt_EmgcyData_day_Finish_Count)
-        # print('周运维率=',OprationManageRate)
-        # print('周紧急运维率=',OprationManageEmgcyRate)
-        # print('PK504总报警=',PK504FltData_Count)
-        # print('PK502总报警=',PK502FltData_Count)
-        # print('PK500总报警=',PK500FltData_Count)
-        # print('格林美总报警=',MGMCLFltData_Count)
-        # print('自研总报警=',MGMLXFltData_Count)
-        FltAlarmInfo=DataFrame(columns=['SftyPlt_Data_Total','CS_Warning_Total_Finish_Count','SftyPlt_Data_day','CS_Warning_day_Finish_Count','SftyPlt_EmgcyData_day','SftyPlt_EmgcyData_day_Finish_Count','OprationManageRate','OprationManageEmgcyRate'])
-        Celltype=DataFrame(columns=['PK504','PK502','PK500','MGMCL','MGMLX','TJMCL'])
-        FltAlarmInfo.loc[0]=[SftyPlt_Data_Total,CS_Warning_Total_Finish_Count,SftyPlt_Data_day,CS_Warning_day_Finish_Count,SftyPlt_EmgcyData_day_Count,SftyPlt_EmgcyData_day_Finish_Count,OprationManageRate,OprationManageEmgcyRate]
-        Celltype.loc[0]=[PK504FltData_Count,PK502FltData_Count,PK500FltData_Count,MGMCLFltData_Count,MGMLXFltData_Count,TJMCLFltData_Count]
+            FltAlarmInfo=DataFrame(columns=['SftyPlt_Data_Total','CS_Warning_Total_Finish_Count','SftyPlt_Data_day','CS_Warning_day_Finish_Count','SftyPlt_EmgcyData_day','SftyPlt_EmgcyData_day_Finish_Count','OprationManageRate','OprationManageEmgcyRate'])
+            Celltype=DataFrame(columns=['None'])
         return FltAlarmInfo,Celltype
     def WeekInfoSta(df_fltinfo,start_time,end_time):
         df_fltinfo=df_fltinfo[df_fltinfo['start_time']>=start_time]
@@ -94,36 +142,59 @@ class DataSta():
         # print('状态安全分数为',StateSaftyCodeCount)
         # print('---------------------------------------------------------------------------')
         return SatftyCount
-    def AccumInfo(df_last_accum,df_FirstDataTime,end_time):
-        df_last_accum=df_last_accum[~df_last_accum['devcode'].str.contains('TJMCL')]
-        MaxAccumAh=df_last_accum['dsg_ahaccum'].max()
-        TotalAccumAh=df_last_accum['dsg_ahaccum'].sum()
-        PK504_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK504')]
-        PK504_Ah_Max=(PK504_Ah['dsg_ahaccum'].max())/60
-        PK502_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK502')]
-        PK502_Ah_Max=(PK502_Ah['dsg_ahaccum'].max())/40
-        PK500_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK500')]
-        PK500_Ah_Max=(PK500_Ah['dsg_ahaccum'].max())/40
-        MGMCL_Ah=df_last_accum[df_last_accum['devcode'].str.contains('MGMCL')]
-        MGMCL_Ah_Max=(MGMCL_Ah['dsg_ahaccum'].max())/50
-        MGMLX_Ah=df_last_accum[df_last_accum['devcode'].str.contains('MGMLX')]
-        MGMLX_Ah_Max=(MGMLX_Ah['dsg_ahaccum'].max())/50
-        MaxCycle=round(max(PK504_Ah_Max,PK502_Ah_Max,PK500_Ah_Max,MGMCL_Ah_Max,MGMLX_Ah_Max),0)
-        deltatimeMax=0
-        deltatime=DataFrame(columns=['runningdate'])
-        df_FirstDataTime=df_FirstDataTime.dropna(how='any')
-        df_FirstDataTime=df_FirstDataTime.reset_index(drop=False)
-        for i in range(0,len(df_FirstDataTime)):
-            End_time=datetime.datetime.now()
-            df_FirstDataTime.loc[i,'first_data_time']=df_FirstDataTime.loc[i,'first_data_time'].strftime('%Y-%m-%d')
-            df_FirstDataTime.loc[i,'first_data_time']=datetime.datetime.strptime(df_FirstDataTime.loc[i,'first_data_time'],'%Y-%m-%d')
-            deltatime.loc[i,'runningdate']=(End_time-df_FirstDataTime.loc[i,'first_data_time'])
-            deltatime.loc[i,'runningdate']= deltatime.loc[i,'runningdate'].total_seconds()/3600
-        MaxRunningHour=int(deltatime['runningdate'].max())
-        TotalRunHour=int(deltatime['runningdate'].sum())
+    def AccumInfo(df_last_accum,df_FirstDataTime,end_time,factory_info):
+        if '骑享' in factory_info:
+            df_last_accum=df_last_accum[~df_last_accum['devcode'].str.contains('TJMCL')]
+            MaxAccumAh=df_last_accum['dsg_ahaccum'].max()
+            TotalAccumAh=df_last_accum['dsg_ahaccum'].sum()
+            PK504_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK504')]
+            PK504_Ah_Max=(PK504_Ah['dsg_ahaccum'].max())/60
+            PK502_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK502')]
+            PK502_Ah_Max=(PK502_Ah['dsg_ahaccum'].max())/40
+            PK500_Ah=df_last_accum[df_last_accum['devcode'].str.contains('PK500')]
+            PK500_Ah_Max=(PK500_Ah['dsg_ahaccum'].max())/40
+            MGMCL_Ah=df_last_accum[df_last_accum['devcode'].str.contains('MGMCL')]
+            MGMCL_Ah_Max=(MGMCL_Ah['dsg_ahaccum'].max())/50
+            MGMLX_Ah=df_last_accum[df_last_accum['devcode'].str.contains('MGMLX')]
+            MGMLX_Ah_Max=(MGMLX_Ah['dsg_ahaccum'].max())/50
+            MaxCycle=round(max(PK504_Ah_Max,PK502_Ah_Max,PK500_Ah_Max,MGMCL_Ah_Max,MGMLX_Ah_Max),0)
+            deltatimeMax=0
+            deltatime=DataFrame(columns=['runningdate'])
+            df_FirstDataTime=df_FirstDataTime[~df_FirstDataTime['sn'].str.contains('TJMCL')]
+            df_FirstDataTime=df_FirstDataTime.dropna(how='any')
+            df_FirstDataTime=df_FirstDataTime.reset_index(drop=False)
+            for i in range(0,len(df_FirstDataTime)):
+                End_time=datetime.datetime.now()
+                df_FirstDataTime.loc[i,'first_data_time']=df_FirstDataTime.loc[i,'first_data_time'].strftime('%Y-%m-%d')
+                df_FirstDataTime.loc[i,'first_data_time']=datetime.datetime.strptime(df_FirstDataTime.loc[i,'first_data_time'],'%Y-%m-%d')
+                deltatime.loc[i,'runningdate']=(End_time-df_FirstDataTime.loc[i,'first_data_time'])
+                deltatime.loc[i,'runningdate']= deltatime.loc[i,'runningdate'].total_seconds()/3600
+            MaxRunningHour=int(deltatime['runningdate'].max())
+            TotalRunHour=int(deltatime['runningdate'].sum())
+        elif '金茂换电' in factory_info:
+            df_last_accum=df_last_accum[df_last_accum['devcode'].str.contains('TJMCL')]
+            df_last_accum=df_last_accum[df_last_accum['dsg_ahaccum']<429496729]
+            MaxAccumAh=df_last_accum['dsg_ahaccum'].max()
+            TotalAccumAh=df_last_accum['dsg_ahaccum'].sum()
+            TJMCL_Ah=df_last_accum[df_last_accum['devcode'].str.contains('TJMCL')]
+            TJMCL_Ah_Max=(TJMCL_Ah['dsg_ahaccum'].max())/(228*2)
+            MaxCycle=round(TJMCL_Ah_Max,0)
+            deltatimeMax=0
+            deltatime=DataFrame(columns=['runningdate'])
+            df_FirstDataTime=df_FirstDataTime[df_FirstDataTime['sn'].str.contains('TJMCL')]
+            df_FirstDataTime=df_FirstDataTime.dropna(how='any')
+            df_FirstDataTime=df_FirstDataTime.reset_index(drop=False)
+            for i in range(0,len(df_FirstDataTime)):
+                End_time=datetime.datetime.now()
+                df_FirstDataTime.loc[i,'first_data_time']=df_FirstDataTime.loc[i,'first_data_time'].strftime('%Y-%m-%d')
+                df_FirstDataTime.loc[i,'first_data_time']=datetime.datetime.strptime(df_FirstDataTime.loc[i,'first_data_time'],'%Y-%m-%d')
+                deltatime.loc[i,'runningdate']=(End_time-df_FirstDataTime.loc[i,'first_data_time'])
+                deltatime.loc[i,'runningdate']= deltatime.loc[i,'runningdate'].total_seconds()/3600
+            MaxRunningHour=int(deltatime['runningdate'].max())
+            TotalRunHour=int(deltatime['runningdate'].sum())
         return MaxAccumAh,TotalAccumAh,MaxCycle,MaxRunningHour,TotalRunHour
 
-    def FltBatPosition(df_last_pos,df_fltinfo):
+    def FltBatPosition(df_last_pos,df_fltinfo,factory_info):
         df_Diag_Ram=df_fltinfo[df_fltinfo['batpos']==0].drop_duplicates(subset=['product_id'],keep=False)
         all_location_info=DataFrame(columns=['factory','product_id','lat','lon'])
         df_last_pos.rename(columns={'devcode':'product_id'},inplace=True)
@@ -137,6 +208,6 @@ class DataSta():
                 pos_la_temp=df_last_pos[df_last_pos['product_id']==(df_Diag_Ram_Pos.loc[i,'product_id'])].reset_index(drop=True)
                 all_location_info.loc[i,'lat']=pos_la_temp.loc[0,'latitude']
                 all_location_info.loc[i,'lon']=pos_la_temp.loc[0,'longitude']
-                all_location_info.loc[i,'factory']='骑享'
+                all_location_info.loc[i,'factory']=factory_info
                 all_location_info.loc[i,'product_id']=df_Diag_Ram_Pos.loc[i,'product_id']
         return all_location_info

+ 11 - 10
LIB/MIDDLE/SaftyCenter/DataDiag_Static/main.py

@@ -40,7 +40,7 @@ def diag_cal():
     DBRead = DBDw.DBDownload(host, port, db, user, password,mode)
     with DBRead as DBRead:
         df_Diag_Ram = DBRead.getdata('start_time','end_time','product_id','code','level','info','advice','Batpos',tablename=tablename2,factory='',sn='',timename='',st='',sp='')
-    df_Diag_Ram=df_Diag_Ram.dropna(how='any')
+    df_Diag_Ram=df_Diag_Ram.dropna(axis=1,how='any')
     df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)
     
     for sn in SNnums:#SN遍历
@@ -53,7 +53,7 @@ def diag_cal():
             celltype=99    #60ah林磷酸铁锂电芯
         elif 'MGMLXN750' in sn:
             celltype=3 #力信50ah三元电芯
-        elif 'MGMCLN750' or 'UD' in sn: 
+        elif ('MGMCLN750' or 'UD') in sn: 
             celltype=4 #CATL 50ah三元电芯
         elif 'TJMCL'in sn:
             celltype=100 #CATL 50ah三元电芯
@@ -66,7 +66,9 @@ def diag_cal():
         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(how='any')
+        df_bms=df_bms.dropna(subset=['总电流[A]'])
+        df_bms=df_bms.reset_index(drop=True)
+        print(df_bms)
         #读取结果数据库数据........................................................................................................................................................
         host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
         port=3306
@@ -115,7 +117,7 @@ def diag_cal():
             df_Diag_Batdiag_update_xq2=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)
-    task_on=0
+    task_on=0        
 #.................................统计程序...............................
 def DaTa_Sta_Week_Task():
     task_on=1
@@ -141,7 +143,7 @@ def DaTa_Sta_Week_Task():
         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)
+        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:
@@ -204,10 +206,10 @@ def DaTa_Sta_Minutes_Task():
         DBRead=DBDw.DBDownload(host, port, db, user, password,mode)
         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)
+        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)
-        all_location_info=DataSta.FltBatPosition(df_last_pos,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]
@@ -246,6 +248,7 @@ def DaTa_Sta_Minutes_Task():
         #print(end-start)
         task_on=0
     print(all_statistic_info)
+    all_statistic_info.to_excel('all_statistic_info.xlsx')
 
 
 #...............................................主函数.......................................................................................................................
@@ -284,8 +287,6 @@ if __name__ == "__main__":
     DBRead = DBDw.DBDownload(host, port, db, user, password,mode)
     with DBRead as DBRead:
         df_Diag_Ram = DBRead.getdata('start_time','end_time','product_id','code','level','info','advice','Batpos','factory',tablename=tablename2,factory='',sn='',timename='',st='',sp='')
-    df_Diag_Ram=df_Diag_Ram.dropna(how='any')
-    df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)
     # result=pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\01Screen_Problem\result.csv',encoding='gbk')
 
     #定时任务.......................................................................................................................................................................

+ 50 - 0
LIB/MIDDLE/SaftyCenter/Low_Soc_Alarm/low_soc_alarm_sta.py

@@ -0,0 +1,50 @@
+import numpy as np
+import pandas as pd
+import datetime,time
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+from urllib import parse
+import pymysql
+
+def low_soc_alarm_sta(db_qxcas_engine, conn, db_sp_engine):
+    
+    cursor = conn.cursor()
+
+    sql = "select sn, DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') as time, level from lowsoc_info where add_time >DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 00:00:00')"+ \
+        " and  add_time <DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 23:59:59')"           
+    df_lowsocalarm_lastday = pd.read_sql(sql, db_qxcas_engine)
+    sn_lowsoc = df_lowsocalarm_lastday['sn'].tolist()
+
+    sql = "select sn, DATE_FORMAT(add_time, '%Y-%m-%d %H:%i:%s') as time, level, last_time from offline_info where add_time >= DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 00:00:00')"+ \
+        " and add_time <= DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 23:59:59')"           
+    df_offlinealarm_lastday = pd.read_sql(sql, db_qxcas_engine)
+    sn_offline = df_offlinealarm_lastday['sn'].tolist()
+
+    sql = "select * from all_fault_info where end_time='{}' and code={}".format('0000-00-00 00:00:00', 58)
+    df_all_alarm_info = pd.read_sql(sql, db_sp_engine)
+    sn_allalarm = df_all_alarm_info['product_id'].tolist()
+
+    # 遍历昨日报警和报警列表,如果 1:sn存在于昨日报警,但不存在与报警allinfo里,则添加一条新的报警记录到allinfo里;
+    #                           2:如果sn存在于allinfo但不存在于昨日报警,也不存在于昨日离线,则记录故障为结束;
+    #                           3: 如果sn在两个表中都存在,但级别不同,则更新级别(离线暂时不考虑级别)。
+    sn_new = list(set(sn_lowsoc)-set(sn_allalarm))
+    sn_close = list(set(sn_allalarm)-set(sn_lowsoc)-set(sn_offline))
+    # sn_cross = list(set(sn_lowsoc) & set(sn_allalarm))
+    # 新增
+    df_new = pd.DataFrame(columns=['add_time', 'product_id', 'start_time', 'end_time', 'code', 'level', 'info'])
+    now = datetime.datetime.now()
+    for sn in sn_new:
+        df = df_lowsocalarm_lastday[df_lowsocalarm_lastday['sn']==sn]
+        df_new = df_new.append({'add_time':now, 'product_id':sn, 'start_time':df['time'].values[0], 'end_time':'0000-00-00 00:00:00', 'info':"低电量报警", 'code':58, 'level':1}, ignore_index=True)
+    if not df_new.empty:
+        df_new.to_sql('all_fault_info', db_sp_engine, if_exists='append', index=False)
+
+    # 修改
+    now = datetime.datetime.now()
+    for sn in sn_close:
+        df = df_lowsocalarm_lastday[df_lowsocalarm_lastday['sn']==sn]
+        df1 = df_all_alarm_info[df_all_alarm_info['product_id']==sn]
+        sql = ''' update all_fault_info set update_time='{}', end_time='{}' where product_id = '{}' and start_time = '{}' and code = {}'''.format \
+                    (now, datetime.datetime.strftime(now,"%Y-%m-%d %H:%M:%S"), sn, pd.to_datetime(df1['start_time'].values[0]), df1['code'].values[0])
+        cursor.execute(sql)
+        conn.commit()

+ 17 - 0
LIB/MIDDLE/SaftyCenter/Offline/offline_alarm.py

@@ -0,0 +1,17 @@
+import numpy as np
+import pandas as pd
+import datetime,time
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+from urllib import parse
+
+def offline_alarm(db_iotp_engine, db_qxcas_engine):
+
+    sql = "select t2.sn, t2.status_time as last_time, t2.offline_time_hour from " + \
+        "(SELECT t.*,t1.devcode,t1.update_time,t1.status_time,TIMESTAMPDIFF(hour, status_time, now()) as offline_time_hour from operation_sn t LEFT JOIN " + \
+        "ff_battery_status t1 ON(t.sn = t1.devcode)) t2 where t2.offline_time_hour > 72 order by t2.offline_time_hour"
+    df_alarm_lastday = pd.read_sql(sql, db_iotp_engine)
+    df_alarm_lastday = df_alarm_lastday[['sn', 'last_time']]
+    df_alarm_lastday['level'] = 1
+    df_alarm_lastday['add_time'] = datetime.datetime.now()
+    df_alarm_lastday.to_sql("offline_info", db_qxcas_engine,if_exists="append", index=False)

+ 50 - 0
LIB/MIDDLE/SaftyCenter/Offline/offline_alarm_sta.py

@@ -0,0 +1,50 @@
+import numpy as np
+import pandas as pd
+import datetime,time
+from sqlalchemy import create_engine
+from sqlalchemy.orm import sessionmaker
+from urllib import parse
+import pymysql
+
+
+def offline_alarm_sta(db_iotp_engine, db_qxcas_engine, conn, db_sp_engine):
+
+    cursor = conn.cursor()
+    sql = "select sn, DATE_FORMAT(add_time, '%Y-%m-%d %H:%i:%s') as time, level, last_time from offline_info where add_time >= DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 00:00:00')"+ \
+    " and add_time <= DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 23:59:59')"           
+    df_offlinealarm_lastday = pd.read_sql(sql, db_qxcas_engine)
+    sn_offline = df_offlinealarm_lastday['sn'].tolist()
+
+    sql = "select * from all_fault_info where end_time='{}' and code={}".format('0000-00-00 00:00:00', 59)
+    df_all_alarm_info = pd.read_sql(sql, db_sp_engine)
+    sn_allalarm = df_all_alarm_info['product_id'].tolist()
+
+    # 遍历昨日报警和报警列表,如果 1:sn存在于昨日报警,但不存在与报警allinfo里,则添加一条新的报警记录到allinfo里;
+    #                           2:如果sn存在于allinfo但不存在于昨日报警,则记录故障为结束;
+    #                           3: 如果sn在两个表中都存在,但级别不同,则更新级别(离线暂时不考虑级别)。
+    sn_new = list(set(sn_offline)-set(sn_allalarm))
+    sn_close = list(set(sn_allalarm)-set(sn_offline))
+    # sn_cross = list(set(sn_offline) & set(sn_allalarm))
+
+    # 新增
+    df_new = pd.DataFrame(columns=['add_time', 'product_id', 'start_time', 'end_time', 'code', 'level', 'info'])
+    now = datetime.datetime.now()
+    for sn in sn_new:
+        df = df_offlinealarm_lastday[df_offlinealarm_lastday['sn']==sn]
+        sql = "select * from ff_battery_status where devcode = '{}'".format(sn)
+        df_on = pd.read_sql(sql, db_iotp_engine)
+        df_new = df_new.append({'add_time':now, 'product_id':sn, 'start_time':pd.to_datetime(df_on['status_time'].values[0]), 'end_time':'0000-00-00 00:00:00', 'info':'离线报警','code':59, 'level':1}, ignore_index=True)
+    if not df_new.empty:
+        df_new.to_sql('all_fault_info', db_sp_engine, if_exists='append', index=False)
+
+    # 修改
+    now = datetime.datetime.now()
+    for sn in sn_close:
+        df = df_offlinealarm_lastday[df_offlinealarm_lastday['sn']==sn]
+        df1 = df_all_alarm_info[df_all_alarm_info['product_id']==sn]
+        sql = "select * from ff_battery_status where devcode = '{}'".format(sn)
+        df_on = pd.read_sql(sql, db_iotp_engine)
+        sql = ''' update all_fault_info set update_time='{}', end_time='{}' where product_id = '{}' and start_time = '{}' and code = {}'''.format \
+                    (now, pd.to_datetime(df_on['status_time'].values[0]), sn, pd.to_datetime(df1['start_time'].values[0]), df1['code'].values[0])
+        cursor.execute(sql)
+        conn.commit()