|
@@ -15,6 +15,7 @@ import numpy as np
|
|
|
import pdb
|
|
|
from numba import jit
|
|
|
from LIB.BACKEND import Tools
|
|
|
+from LIB.BACKEND.OPENAPI import OpenApi
|
|
|
|
|
|
class DataPreProcess:
|
|
|
def __init__(self):
|
|
@@ -486,4 +487,45 @@ class DataPreProcess:
|
|
|
if len(set(df_bms[df_bms['data_status_after_combine']=='charge']['data_split_by_status_after_combine'])) > 0 :
|
|
|
res_record['charge'] = (res_record['charge'])/len(set(df_bms[df_bms['data_status_after_combine']=='charge']['data_split_by_status_after_combine']))
|
|
|
return df_bms, df_gps, res_record
|
|
|
-
|
|
|
+
|
|
|
+ '''
|
|
|
+ 为故障数据打标签
|
|
|
+ sn: 电池编码
|
|
|
+ df_bms: 本电池编码对应的bms数据
|
|
|
+ '''
|
|
|
+ def data_fault_tag(self, sn='', df_bms=pd.DataFrame()):
|
|
|
+ if sn =='':
|
|
|
+ raise Exception("请输入sn")
|
|
|
+ o = OpenApi.OpenApi()
|
|
|
+ df_fault = o.get_omp_fatult_tag(sn=sn)
|
|
|
+ df_data = df_bms.copy()
|
|
|
+ df_data['fault_tag'] = None
|
|
|
+ if len(df_fault) > 0:
|
|
|
+ # 遍历本sn的故障
|
|
|
+ for index in df_fault.index:
|
|
|
+ startT = df_fault.loc[index, 'faultTime']
|
|
|
+ endT = df_fault.loc[index, 'endTime']
|
|
|
+ tagTypeText = df_fault.loc[index, 'tagTypeText']
|
|
|
+ childTagText = df_fault.loc[index, 'childTagText']
|
|
|
+ tagType = df_fault.loc[index, 'tagType']
|
|
|
+ childTag = df_fault.loc[index, 'childTag']
|
|
|
+ # 故障标签拼接
|
|
|
+ new_tag = []
|
|
|
+ if pd.isnull(tagType) or len(tagTypeText) <= 0:
|
|
|
+ continue
|
|
|
+ elif pd.isnull(childTag) or len(childTagText) <= 0:
|
|
|
+ new_tag.append(tagTypeText)
|
|
|
+ else:
|
|
|
+ for child in childTagText.split(";"):
|
|
|
+ new_tag.append(tagTypeText+':' + child)
|
|
|
+
|
|
|
+ # 原始数据对应故障时间的index
|
|
|
+ for index2 in df_data[(df_data['时间戳']>=startT) & (df_data['时间戳']<endT)].index:
|
|
|
+ old_tag = df_data.loc[index2, 'fault_tag']
|
|
|
+ if pd.isnull(old_tag) or len(old_tag) <= 0:
|
|
|
+ df_data.loc[index2,'fault_tag'] = ';'.join(new_tag)
|
|
|
+ else:
|
|
|
+ tag = old_tag.split(";")
|
|
|
+ tag.extend(new_tag)
|
|
|
+ df_data.loc[index2,'fault_tag'] = ';'.join(list(set(tag)))
|
|
|
+ return df_data
|