Parcourir la source

BMS上传故障增加故障说明和处理建议

Eric412V il y a 2 ans
Parent
commit
5a2da7af92
1 fichiers modifiés avec 14 ajouts et 2 suppressions
  1. 14 2
      LIB/MIDDLE/SaftyCenter/DataDiag_Static/SC_BMSUploadError.py

+ 14 - 2
LIB/MIDDLE/SaftyCenter/DataDiag_Static/SC_BMSUploadError.py

@@ -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='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