Parcourir la source

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

zhuxi il y a 2 ans
Parent
commit
f512609536
1 fichiers modifiés avec 8 ajouts et 13 suppressions
  1. 8 13
      LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/main.py

+ 8 - 13
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/main.py

@@ -1,6 +1,6 @@
 import pandas as pd
 import pymysql
-from LIB.BACKEND import DBManager
+from LIB.BACKEND import DBManager, Log
 from apscheduler.schedulers.blocking import BlockingScheduler
 import datetime
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload
@@ -20,15 +20,14 @@ def saftywarning_cal():
     global df_lfp_ram
     global df_lfp_ram1
     global df_chrgvolt_ram
-    global now_time
 
     pd.set_option('display.width', 300) # 设置字符显示宽度
     pd.set_option('display.max_rows', None) # 设置显示最大行
     pd.set_option('display.max_columns', None) # 设置显示最大列,None为显示所有列
     
     # start=time.time()
-    # now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=24)
+    now_time=datetime.datetime.now()
+    start_time=now_time-datetime.timedelta(hours=6)
     start_time1=now_time-datetime.timedelta(days=7)
     start_time2=now_time-datetime.timedelta(days=3)
     start_time3=now_time-datetime.timedelta(days=1)
@@ -180,17 +179,16 @@ def saftywarning_cal():
             df_warning_res=BatWarning.diag()
             #当前热失控故障写入数据库
             if not df_warning_res.empty:
-                pass
-                # with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
-                #     file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
+                with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
+                    file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
         
         else:
             fault_time=datetime.datetime.strptime(df_fault_ram_sn.iloc[-1]['start_time'], '%Y-%m-%d %H:%M:%S')
             if (now_time-fault_time).total_seconds()>3*24*3600:   #df_warning_end历史故障筛选并更改数据库故障结束时间
                 df_fault_ram_sn['end_time']=end_time
                 df_fault_ram_sn['Batpos']=1
-                # with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
-                #     file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
+                with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\热失控预警.txt','a',encoding="utf-8") as file:
+                    file.write(str(tuple(df_warning_res.iloc[-1]))+'\n')
 
 
 #...............................................主函数起定时作用.......................................................................................................................
@@ -210,9 +208,7 @@ if __name__ == "__main__":
     # SNnums_C7255=SNdata_C7255['SN号'].tolist()
     # SNnums_U7255=SNdata_U7255['SN号'].tolist()
     # SNnums=SNnums_L7255 + SNnums_C7255 + SNnums_U7255 + SNnums_6040 + SNnums_4840 + SNnums_6060
-    SNnums = ['PK500A20100000811']
-    now_time = '2022-9-18 2:00:56'
-    now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
+    SNnums=['PK50001A100000577']
     
     # mylog=log.Mylog('log_warning.txt','error')
     # mylog.logcfg()
@@ -228,7 +224,6 @@ if __name__ == "__main__":
 
 
     #定时任务.......................................................................................................................................................................
-    saftywarning_cal()
     scheduler = BlockingScheduler()
     scheduler.add_job(saftywarning_cal, 'interval', seconds=6)