Browse Source

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

qingfeng 2 years ago
parent
commit
38b2d06748

+ 0 - 25
.gitignore

@@ -1,25 +0,0 @@
-*.txt
-./USER
-/FILES
-/USER
-/.vscode/
-/*/__pycache__/*.*
-/*/*/__pycache__/*.pyc
-/*/*/*/__pycache__/*.pyc
-/*.ipynb
-/*.csv
-*.doc
-*.ppt
-*.tmp
-!/demo.ipynb
-!.gitignore
-# *.*
-/CONFIGURE/PathSetting.py
-*.log
-/demo.ipynb
-/*/*/deploy.py
-/*/*/*/deploy.py
-!数据分析平台手册.doc
-*.pyc
-*.csv
-

+ 2 - 0
LIB/BACKEND/DEPLOY/build.cmd

@@ -0,0 +1,2 @@
+::  本脚本用于构建测试和生产环境中的python基础镜像
+

+ 45 - 3
LIB/BACKEND/OPENAPI/OpenApi.py

@@ -13,6 +13,9 @@ class OpenApi:
     def __init__(self):
         pass
 
+    '''
+    获取 运维系统中故障相关的信息
+    '''
     def get_device_fault(self, start_time="", end_time=""):
         # start_time = "2021-12-30 00:00:00"
         # end_time = "2021-12-31 00:00:00"
@@ -24,7 +27,46 @@ class OpenApi:
         if end_time != "":
             data['endTime'] = end_time
         response = requests.post(url,  json=data, headers=headers)
-        df = pd.DataFrame(columns=['sn', 'imei','faultTime', 'updateTime', 'overTime', 'faultStatus', 'questionType', 'questionTypeText', 'childProblem','childProblemText'])
-        for d in json.loads(response.text)["data"]:
-            df = df.append(d, ignore_index=True)
+        # df = pd.DataFrame(columns=['sn', 'imei','faultTime', 'updateTime', 'overTime', 'faultStatus', 'questionType', 'questionTypeText', 'childProblem','childProblemText'])
+        df = pd.DataFrame(json.loads(response.text)["data"])
+        # for d in json.loads(response.text)["data"]:
+        #     df = df.append(d, ignore_index=True)
+        return df
+    
+    '''
+    获取 资产相关信息
+    '''
+    def get_asset(self, sn=""):
+        # start_time = "2021-12-30 00:00:00"
+        # end_time = "2021-12-31 00:00:00"
+        url = 'http://open.li-ai.com.cn/admin/v1/deviceDetailInfo'
+        headers = {'Content-Type':"application/json; charset=utf-8","token":"2A26DD0ADE53456D928562A17131A3B5"}
+        data = {"id":sn}
+        response = requests.post(url,  json=data, headers=headers)
+        # df = pd.DataFrame(columns=['sn', 'imei','faultTime', 'updateTime', 'overTime', 'faultStatus', 'questionType', 'questionTypeText', 'childProblem','childProblemText'])
+        df = pd.DataFrame(json.loads(response.text)["data"])
+        if len(df)>0:
+            df2 = pd.DataFrame(list(df['basicAssetDto']))
+            df2 = df2.drop(['imei','id', 'deviceType', 'deviceTypeText'],axis=1,errors='ignore')
+            df3 = df.drop(['basicAssetDto'],axis=1)
+            df = df2.join(df3.set_index('sn'),on='sn')      
+        return df
+    
+        '''
+    获取 iotp数据
+    '''
+    def get_last_data(self, sn=""):
+        # start_time = "2021-12-30 00:00:00"
+        # end_time = "2021-12-31 00:00:00"
+        url = 'http://open.li-ai.com.cn/admin/v1/capacityAndLocation'
+        headers = {'Content-Type':"application/json; charset=utf-8","token":"2A26DD0ADE53456D928562A17131A3B5"}
+        data = {"id":sn}
+        response = requests.post(url,  json=data, headers=headers)
+        df = pd.DataFrame(json.loads(response.text)["data"])
+        if len(df)>0:
+            df2 = pd.DataFrame(list(df['batteryLocationDto']))
+            df3 = pd.DataFrame(list(df['batteryAccumDto']))
+            df2 = df2.drop(['id','updateTime'],axis=1,errors='ignore')
+            df3 = df3.drop(['id','updateTime'],axis=1,errors='ignore')
+            df = df2.join(df3.set_index('sn'),on='sn')     
         return df

+ 37 - 0
LIB/FRONTEND/AlgoTest/Algo1/Dockerfile

@@ -0,0 +1,37 @@
+# 基础镜像
+FROM python:3.8
+
+# 作者,版本
+LABEL author="lm"  
+LABEL version="1.0.0"
+
+# 环境变量参数
+ENV TZ="Asia/Shanghai"
+ENV HOST="127.0.0.1"
+
+# 安装用到的python 第三方库
+RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple \
+    sqlalchemy \
+    pandas==1.3.4 \
+    pymysql apscheduler \
+    scipy \
+    cryptography \
+    numpy==1.20.3 \
+    requests
+
+#RUN rm -r /usr/bin
+#RUN rm -r /bin
+
+
+
+# 复制算法文件到 容器
+ARG ALGO_PATH=LIB/MIDDLE/AlgoTest/Algo1
+ARG ALGO_VERSION=V_1_0_0
+
+# 复制公共库文件到 容器
+ADD LIB/BACKEND/ /LIB/BACKEND
+ADD ${ALGO_PATH}/${ALGO_VERSION}/ /${ALGO_VERSION}/
+ADD ${ALGO_PATH}/main.py /main.py
+WORKDIR /
+
+CMD ["python", "main.py"]

+ 14 - 0
LIB/MIDDLE/AlgoTest/Algo1/V_1_0_0/core.py

@@ -0,0 +1,14 @@
+# 获取数据
+from LIB.BACKEND import DBManager
+import pandas as pd
+
+
+class CalSor:
+    
+    def __init__(self):
+        pass
+    
+    def calSor(self, df_bms, df_param):
+        i = len(df_bms)
+        j = len(df_param)
+        return pd.DataFrame({'i':[i]}), pd.DataFrame({'j':[j]})

+ 16 - 0
LIB/MIDDLE/AlgoTest/Algo1/main.py

@@ -0,0 +1,16 @@
+import pandas as pd
+from LIB.BACKEND import DBManager # 以相对路径的方式引入!!!!!
+import V_1_0_0.core as core # 以相对路径的方式引入!!!!!
+
+if __name__ == '__main__':
+    
+    sn = "PK10001A326000123"
+    st = '2021-07-06 00:00:00'
+    et = '2021-07-07 20:00:00'
+
+    dbManager = DBManager.DBManager()
+    df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms', 'gps', 'accum', 'system'])
+# 
+    df_bms = df_data['bms']
+    calSor = core.CalSor();
+    print(calSor.calSor(df_bms,df_bms))

+ 4 - 4
LIB/MIDDLE/SaftyCenter/DataDiag_Static/SC_CtrlSafty.py

@@ -53,19 +53,19 @@ class CtrlSafty:
         OtherTempMax=OtherTempMax[OtherTempMax[OtherTempNum]<(param.OtherOTlmt+5)].dropna(axis=0,how='all')
         if len(CellTempMax) and len(OtherTempMax):
             QuitErrCount[57]=0
-            if not 57 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_info.loc[len(bms_info)-1,'时间戳'],'0000-00-00 00:00:00',sn,57,4,'电芯温度高','立即联系用户确认电池状态']
+            if not 'C357' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_info.loc[len(bms_info)-1,'时间戳'],'0000-00-00 00:00:00',sn,'C357',3,'电芯温度高','立即联系用户确认电池状态']
                 ErrorFlg=1            
             else:#如果故障发生当前故障中有该故障,则不进行操作
                 pass
         else:
-            if 57 in df_Diag_Ram['code'].values.tolist():
+            if 'C357' in df_Diag_Ram['code'].values.tolist():
                 QuitErrCount[57]=QuitErrCount[57]+1
                 if QuitErrCount[57]>3:
                     QuitErrCount[57]=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']==57].index,['end_time']]=end_time
+                    df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C357'].index,['end_time']]=end_time
                 else:
                     pass
             else:

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

@@ -67,38 +67,38 @@ class SamplingSafty:
         if len(InVMaxBatNo):
             if len(InVMinBatNo):
                 QuitErrCount[10]=0
-                if not 10 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,10,2,'电池电压采样断线,最高电压为{:.2f}V,电池编号为{},最低电压为{:.2f}V,电池编号为{}'.format(MaxVolt,InVMaxBatNo.values,MinVolt,InVMinBatNo.values),'返厂维修']
+                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 10 in df_Diag_Ram['code'].values.tolist():
+                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']==10].index,['end_time']]=end_time
+                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C310'].index,['end_time']]=end_time
                     else:
                         pass
                 else:
                     pass
-                if not 50 in df_Diag_Ram['code'].values.tolist():
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,50,2,str(InVMaxBatNo.values)+'号电压大于{:.2f}V,采样无效'.format(param.CellOVlmt),'返厂维修']
+                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 50 in df_Diag_Ram['code'].values.tolist():
-                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,50,2,str(InVMinBatNo.values)+'号电压小于{:.2f}V,采样无效'.format(param.CellUVlmt),'返厂维修']
+            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 50 in df_Diag_Ram['code'].values.tolist():
+            if 'C350' in df_Diag_Ram['code'].values.tolist():
                 QuitErrCount[50]=QuitErrCount[50]+1
                 if QuitErrCount[50]>3:
                     QuitErrCount[50]=4
@@ -113,25 +113,25 @@ class SamplingSafty:
         if ErrorFlg==0:
             AvgVolGap=CellVoltage-AvgVol
             OutlierVolNo=AvgVolGap[AvgVolGap>=param.AvgVolGap].index
-            if len(OutlierVolNo) and abs(bms_infoN['总电流[A]'])<2 and not 51 in df_Diag_Ram['code']:
+            if len(OutlierVolNo) and abs(bms_infoN['总电流[A]'])<2 and not 'C251' in df_Diag_Ram['code']:
                 VolCount=VolCount+1
                 QuitErrCount[51]=0
                 if VolCount>10:
                     VolCount=11
-                    if not 51 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,51,2,str(OutlierVolNo.values)+'号电池电压离群','技术介入诊断']
+                    if not 'C251' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C251',2,str(OutlierVolNo.values)+'号电池电压离群','技术介入诊断']
                         ErrorFlg=1            
                     else:#如果故障发生当前故障中有该故障,则不进行操作
                         pass                
             else:
                 VolCount=0
-                if 51 in df_Diag_Ram['code'].values.tolist():
+                if 'C251' in df_Diag_Ram['code'].values.tolist():
                     QuitErrCount[51]=QuitErrCount[51]+1
                     if QuitErrCount[51]>3:
                         QuitErrCount[51]=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']==51].index,['end_time']]=end_time                
+                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C251'].index,['end_time']]=end_time                
                     else:
                         pass
                 else:
@@ -176,44 +176,44 @@ class SamplingSafty:
         if len(InVMaxTempBatNo):
             if len(InVMinTempBatNo):
                 QuitErrCount[53]=0
-                if not 53 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,53,2,'电池温度采样断线,最高温度为{}℃,电池编号为{},最低温度为{}℃,电池编号为{}'.format(maxCellTemp,InVMaxTempBatNo.values,minCellTemp,InVMinTempBatNo.values),'返厂维修']
+                if not 'C353' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C353',3,'电池温度采样断线,最高温度为{}℃,电池编号为{},最低温度为{}℃,电池编号为{}'.format(maxCellTemp,InVMaxTempBatNo.values,minCellTemp,InVMinTempBatNo.values),'返厂维修']
                     ErrorFlg=1 
                 else:#如果故障发生当前故障中有该故障,则不进行操作
                     pass                 
             else:#如果没有故障,并且当前故障表中有该故障,则判断故障是否结束
                 QuitErrCount[2]=0
-                if 53 in df_Diag_Ram['code'].values.tolist():
+                if 'C353' in df_Diag_Ram['code'].values.tolist():
                     QuitErrCount[53]=QuitErrCount[53]+1
                     if QuitErrCount[53]>3:
                         QuitErrCount[53]=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']==53].index,['end_time']]=end_time
+                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C353'].index,['end_time']]=end_time
                     else:
                         pass
                 else:
                     pass
-                if not 2 in df_Diag_Ram['code'].values.tolist():
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,2,2,str(InVMaxTempBatNo.values)+'号温度大于{}℃,采样无效'.format(param.PackOTlmt),'联系用户核实电池温度情况,并返厂维修']
+                if not 'C302' in df_Diag_Ram['code'].values.tolist():
+                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C302',3,str(InVMaxTempBatNo.values)+'号温度大于{}℃,采样无效'.format(param.PackOTlmt),'联系用户核实电池温度情况,并返厂维修']
                     ErrorFlg=1
                 else:
                     pass
         elif len(InVMinTempBatNo):
             QuitErrCount[2]=0
-            if not 2 in df_Diag_Ram['code'].values.tolist():
-                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,2,2,str(InVMinTempBatNo.values)+'号温度小于{}℃,采样无效'.format(param.PackUTlmt),'返厂维修']
+            if not 'C302' in df_Diag_Ram['code'].values.tolist():
+                df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C302',3,str(InVMinTempBatNo.values)+'号温度小于{}℃,采样无效'.format(param.PackUTlmt),'返厂维修']
                 ErrorFlg=1
             else:
                 pass
         else:
-            if 2 in df_Diag_Ram['code'].values.tolist():
+            if 'C302' in df_Diag_Ram['code'].values.tolist():
                 QuitErrCount[2]=QuitErrCount[2]+1
                 if QuitErrCount[2]>3:
                     QuitErrCount[2]=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']==2].index,['end_time']]=end_time                   
+                    df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C302'].index,['end_time']]=end_time                   
                 else:
                     pass
             else:
@@ -223,19 +223,19 @@ class SamplingSafty:
             OutlierTempNo=AvgCellTempGap[AvgCellTempGap>=param.AvgCellTempGap].index
             if len(OutlierTempNo):
                 QuitErrCount[8]=0
-                if not 8 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,8,2,str(OutlierTempNo.values)+'号电池异常温度离群','技术介入诊断']
+                if not 'C108' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C108',1,str(OutlierTempNo.values)+'号电池异常温度离群','技术介入诊断']
                     ErrorFlg=1            
                 else:#如果故障发生当前故障中有该故障,则不进行操作
                     pass
             else:
-                if 8 in df_Diag_Ram['code'].values.tolist():
+                if 'C108' in df_Diag_Ram['code'].values.tolist():
                     QuitErrCount[8]=QuitErrCount[8]+1
                     if QuitErrCount[8]>3:
                         QuitErrCount[8]=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']==8].index,['end_time']]=end_time
+                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C108'].index,['end_time']]=end_time
                     else:
                         pass
                 else:
@@ -263,44 +263,44 @@ class SamplingSafty:
             if len(InVMaxOtherTempBatNo):
                 if len(InVMinOtherTempBatNo):
                     QuitErrCount[54]=0
-                    if not 54 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,54,2,'其他温度采样断线,最高温度为{}℃,传感器编号为{},最低温度为{}℃,传感器编号为{}'.format(maxOtherTemp,InVMaxOtherTempBatNo.values,minOtherTemp,InVMinOtherTempBatNo.values),'返厂维修']
+                    if not 'C354' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C354',3,'其他温度采样断线,最高温度为{}℃,传感器编号为{},最低温度为{}℃,传感器编号为{}'.format(maxOtherTemp,InVMaxOtherTempBatNo.values,minOtherTemp,InVMinOtherTempBatNo.values),'返厂维修']
                         ErrorFlg=1 
                     else:#如果故障发生当前故障中有该故障,则不进行操作
                         pass                 
                 else:#如果没有故障,并且当前故障表中有该故障,则判断故障是否结束
                     QuitErrCount[55]=0
-                    if 54 in df_Diag_Ram['code'].values.tolist():
+                    if 'C354' in df_Diag_Ram['code'].values.tolist():
                         QuitErrCount[54]=QuitErrCount[54]+1
                         if QuitErrCount[54]>3:
                             QuitErrCount[54]=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']==54].index,['end_time']]=end_time
+                            df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C354'].index,['end_time']]=end_time
                         else:
                             pass
                     else:
                         pass
-                    if not 55 in df_Diag_Ram['code'].values.tolist():
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,55,2,'传感器温度大于{}℃,采样无效'.format(param.OtherOTlmt),'联系用户核实电池温度情况,并返厂维修']
+                    if not 'C355' in df_Diag_Ram['code'].values.tolist():
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C355',3,'传感器温度大于{}℃,采样无效'.format(param.OtherOTlmt),'联系用户核实电池温度情况,并返厂维修']
                         ErrorFlg=1
                     else:
                         pass
             elif len(InVMinTempBatNo):
                 QuitErrCount[55]=0
-                if not 55 in df_Diag_Ram['code'].values.tolist():
-                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,55,2,'传感器温度小于{}℃,采样无效'.format(param.OtherUTlmt),'返厂维修']
+                if not 'C355' in df_Diag_Ram['code'].values.tolist():
+                    df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C355',3,'传感器温度小于{}℃,采样无效'.format(param.OtherUTlmt),'返厂维修']
                     ErrorFlg=1
                 else:
                     pass
             else:
-                if 55 in df_Diag_Ram['code'].values.tolist():
+                if 'C355' in df_Diag_Ram['code'].values.tolist():
                     QuitErrCount[55]=QuitErrCount[55]+1
                     if QuitErrCount[55]>3:
                         QuitErrCount[55]=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']==55].index,['end_time']]=end_time                   
+                        df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C355'].index,['end_time']]=end_time                   
                     else:
                         pass
                 else:
@@ -310,19 +310,19 @@ class SamplingSafty:
                 OutlierOtherTempNo=AvgOtherTempGap[AvgOtherTempGap>=param.AvgOtherTempGap].index
                 if len(OutlierOtherTempNo):
                     QuitErrCount[56]=0
-                    if not 56 in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,56,2,'传感器温度异常离群','技术介入诊断']
+                    if not 'C156' in df_Diag_Ram['code'].values.tolist():#如果故障发生当前故障中没有该故障,则压入该故障
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C156',1,'传感器温度异常离群','技术介入诊断']
                         ErrorFlg=1            
                     else:#如果故障发生当前故障中有该故障,则不进行操作
                         pass
                 else:
-                    if 56 in df_Diag_Ram['code'].values.tolist():
+                    if 'C156' in df_Diag_Ram['code'].values.tolist():
                         QuitErrCount[56]=QuitErrCount[56]+1
                         if QuitErrCount[56]>3:
                             QuitErrCount[56]=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']==56].index,['end_time']]=end_time
+                            df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C156'].index,['end_time']]=end_time
                         else:
                             pass
                     else:
@@ -330,31 +330,31 @@ class SamplingSafty:
 
                 if (maxOtherTemp-maxCellTemp)>param.AvgOtherTempGap and  maxOtherTemp<param.OtherOTlmt and maxCellTemp<param.PackOTlmt:
                     QuitErrCount[56]=0
-                    if not 56 in df_Diag_Ram['code'].values.tolist():
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,56,2,'传感器温度异常离群','技术立即介入诊断']
+                    if not 'C156' in df_Diag_Ram['code'].values.tolist():
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C156',1,'传感器温度异常离群','技术立即介入诊断']
                         ErrorFlg=1
                 else:
-                    if 56 in df_Diag_Ram['code'].values.tolist():
+                    if 'C156' in df_Diag_Ram['code'].values.tolist():
                             QuitErrCount[56]=QuitErrCount[56]+1
                             if QuitErrCount[56]>3:
                                 QuitErrCount[56]=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']==56].index,['end_time']]=end_time
+                                df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C156'].index,['end_time']]=end_time
                                 
                 if (maxCellTemp-maxOtherTemp)>param.AvgOtherTempGap and  maxOtherTemp<param.OtherOTlmt and maxCellTemp<param.PackOTlmt and not 8 in df_Diag_Ram['code']:
                     QuitErrCount[8]=0
-                    if not 8 in df_Diag_Ram['code'].values.tolist():
-                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,8,2,str(OutlierTempNo.values)+'号电芯温度异常离群','技术立即介入诊断']
+                    if not 'C108' in df_Diag_Ram['code'].values.tolist():
+                        df_Diag_Ram.loc[len(df_Diag_Ram)]=[bms_infoN['时间戳'],'0000-00-00 00:00:00',sn,'C108',1,str(OutlierTempNo.values)+'号电芯温度异常离群','技术立即介入诊断']
                         
                         ErrorFlg=1
                 else:
-                    if 8 in df_Diag_Ram['code'].values.tolist():
+                    if 'C108' in df_Diag_Ram['code'].values.tolist():
                             QuitErrCount[8]=QuitErrCount[8]+1
                             if QuitErrCount[8]>3:
                                 QuitErrCount[8]=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']==8].index,['end_time']]=end_time              
+                                df_Diag_Ram.loc[df_Diag_Ram[df_Diag_Ram['code']=='C108'].index,['end_time']]=end_time              
 
         return df_Diag_Ram

+ 5 - 4
LIB/MIDDLE/SaftyCenter/DataDiag_Static/main.py

@@ -121,14 +121,15 @@ def diag_cal():
         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)
+            #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=BMSReportError.main(sn,df_bms,df_Diag_Batdiag_update_xq2,FactoryType,errorcode_map)
             # 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_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)
     task_on=0