Browse Source

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

lmstack 3 năm trước cách đây
mục cha
commit
3fc4142808

+ 15 - 3
LIB/MIDDLE/SaftyCenter/DataDiag_Static/SC_BMSUploadError.py

@@ -18,7 +18,7 @@ from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker
 from urllib import parse
 import pymysql
-
+from urllib import parse
 class BMSReportError:
     def __init__(self):
         pass
@@ -88,16 +88,26 @@ class BMSReportError:
                         
                              
                         code = newCode[j] # 终端故障码
-                        platform_code = errorcode_map[(errorcode_map['protocol']==FactoryType)&(errorcode_map['end_errorcode']==str(code))]['platform_errorcode']                   
+                        platform_code = errorcode_map[(errorcode_map['protocol']==FactoryType)&(errorcode_map['end_errorcode']==str(code))]['platform_errorcode']
 
                         # db_engine.dispose()
                         if len(platform_code) == 0:
                             pass
                         else:                       
+                            host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
+                            port=3306
+                            db='qx_cas'
+                            user='qx_algo_readonly'
+                            password = parse.quote_plus('qx@123456')                   
+                            db_engine_1 = create_engine("mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(user, password, host, port, db))
+                            df_fidinfo = pd.read_sql("select * from fid_info ", db_engine_1)
+                            faltinfo=df_fidinfo[df_fidinfo['errCode']==platform_code.values[0]]['errChinese'].values[0]
+                            faltsugst=df_fidinfo[df_fidinfo['errCode']==platform_code.values[0]]['treatment'].values[0]
+                                                  
                             newCode_total.append(platform_code.values[0])
                             newCode[j]=platform_code.values[0]
                             if not platform_code.values[0] in df_Diag_Ram_BMS['code'].values.tolist():
-                                df_Diag_Ram_BMS.loc[len(df_Diag_Ram_BMS)]=[df_bms.loc[i,'时间戳'],'0000-00-00 00:00:00',sn,platform_code.values[0],df_bms.loc[i,'故障等级'],'','']
+                                df_Diag_Ram_BMS.loc[len(df_Diag_Ram_BMS)]=[df_bms.loc[i,'时间戳'],'0000-00-00 00:00:00',sn,platform_code.values[0],df_bms.loc[i,'故障等级'],faltinfo,faltsugst]
                             else:
                                 pass
         if len(df_Diag_Ram_BMS):
@@ -112,4 +122,6 @@ class BMSReportError:
                     pass
         df_Diag_Ram=df_Diag_Ram_BMS.append(df_Diag_Ram_Cloud)
         df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)
+        if len(df_Diag_Ram):
+            print(df_Diag_Ram)
         return df_Diag_Ram

+ 43 - 43
LIB/MIDDLE/SaftyCenter/DataDiag_Static/SC_SamplingSafty.py

@@ -65,49 +65,49 @@ class SamplingSafty:
             AvgVol=CellVoltage.mean()
         #—————————————————————————————电压无效和断线判断———————————————————————
         if len(InVMaxBatNo):
-            if len(InVMinBatNo):
-                QuitErrCount[10]=0
-                if not 'C310' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C310',3,'电池电压采样断线,最高电压为{:.2f}V,电池编号为{},最低电压为{:.2f}V,电池编号为{}'.format(MaxVolt,InVMaxBatNo.values,MinVolt,InVMinBatNo.values),'返厂维修']
-                    ErrorFlg=1  
-                else:#如果故障发生当前故障中有该故障,则不进行操作
-                    pass                 
-            else:#如果没有故障,并且当前故障表中有该故障,则判断故障是否结束
-                QuitErrCount[50]=0
-                if 'C310' in df_Diag_Ram['code'].values.tolist():
-                    QuitErrCount[10]=QuitErrCount[10]+1
-                    if QuitErrCount[10]>3:
-                        QuitErrCount[10]=4
-                        end_time=datetime.datetime.now()
-                        end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
-                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C310'].index,['end_time']]=end_time
-                    else:
-                        pass
-                else:
-                    pass
-                if not 'C350' in df_Diag_Ram['code'].values.tolist():
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C350',3,str(InVMaxBatNo.values)+'号电压大于{:.2f}V,采样无效'.format(param.CellOVlmt),'返厂维修']
-                    ErrorFlg=1
-                else:
-                    pass
-        elif len(InVMinBatNo):
-            QuitErrCount[50]=0
-            if not 'C350' in df_Diag_Ram['code'].values.tolist():
-                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C350',3,str(InVMinBatNo.values)+'号电压小于{:.2f}V,采样无效'.format(param.CellUVlmt),'返厂维修']
-                ErrorFlg=1
-            else:
-                pass
-        else:
-            if 'C350' in df_Diag_Ram['code'].values.tolist():
-                QuitErrCount[50]=QuitErrCount[50]+1
-                if QuitErrCount[50]>3:
-                    QuitErrCount[50]=4
-                    end_time=datetime.datetime.now()
-                    end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
-                    df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']==50].index,['end_time']]=end_time                   
-                else:
-                    pass
-            else:
+        #     if len(InVMinBatNo):
+        #         QuitErrCount[10]=0
+        #         if not 'C310' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+        #             df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C310',3,'电池电压采样断线,最高电压为{:.2f}V,电池编号为{},最低电压为{:.2f}V,电池编号为{}'.format(MaxVolt,InVMaxBatNo.values,MinVolt,InVMinBatNo.values),'返厂维修']
+        #             ErrorFlg=1  
+        #         else:#如果故障发生当前故障中有该故障,则不进行操作
+        #             pass                 
+        #     else:#如果没有故障,并且当前故障表中有该故障,则判断故障是否结束
+        #         QuitErrCount[50]=0
+        #         if 'C310' in df_Diag_Ram['code'].values.tolist():
+        #             QuitErrCount[10]=QuitErrCount[10]+1
+        #             if QuitErrCount[10]>3:
+        #                 QuitErrCount[10]=4
+        #                 end_time=datetime.datetime.now()
+        #                 end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
+        #                 df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C310'].index,['end_time']]=end_time
+        #             else:
+        #                 pass
+        #         else:
+        #             pass
+        #         if not 'C350' in df_Diag_Ram['code'].values.tolist():
+        #             df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C350',3,str(InVMaxBatNo.values)+'号电压大于{:.2f}V,采样无效'.format(param.CellOVlmt),'返厂维修']
+        #             ErrorFlg=1
+        #         else:
+        #             pass
+        # elif len(InVMinBatNo):
+        #     QuitErrCount[50]=0
+        #     if not 'C350' in df_Diag_Ram['code'].values.tolist():
+        #         df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C350',3,str(InVMinBatNo.values)+'号电压小于{:.2f}V,采样无效'.format(param.CellUVlmt),'返厂维修']
+        #         ErrorFlg=1
+        #     else:
+        #         pass
+        # else:
+        #     if 'C350' in df_Diag_Ram['code'].values.tolist():
+        #         QuitErrCount[50]=QuitErrCount[50]+1
+        #         if QuitErrCount[50]>3:
+        #             QuitErrCount[50]=4
+        #             end_time=datetime.datetime.now()
+        #             end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
+        #             df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']==50].index,['end_time']]=end_time                   
+        #         else:
+        #             pass
+        #     else:
                 pass                                      
        #——————————————————————————————————电压卡滞和离群判断—————————————————————————
         if ErrorFlg==0: