Ver Fonte

更新热失控报警main,解决结束时间未写入的问题

qingfeng há 3 anos atrás
pai
commit
13a095008a
1 ficheiros alterados com 6 adições e 7 exclusões
  1. 6 7
      LIB/MIDDLE/CellStateEstimation/BatSafetyAlarm/main.py

+ 6 - 7
LIB/MIDDLE/CellStateEstimation/BatSafetyAlarm/main.py

@@ -1,6 +1,5 @@
 import CBMSSafetyAlarm
 import pymysql
-from urllib import parse
 import datetime
 import pandas as pd
 import multiprocessing
@@ -23,11 +22,11 @@ def diag_cal(sn_list, df_bms_ram):
     host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
     port=3306
     user='qx_algo_readonly'
-    password = parse.quote_plus('qx@123456')
+    password = 'qx@123456'
 
     #读取故障结果库中code==119且end_time='0000-00-00 00:00:00'...............................
     db='safety_platform'
-    mysql = pymysql.connect (host=host, user=user, password=password, port=port, database=db)
+    mysql = pymysql.connect (host=host, port=port, user=user, password=password, database=db)
     cursor = mysql.cursor()
     param='start_time, end_time, product_id, code, level, info,advice'
     tablename='all_fault_info'
@@ -79,11 +78,11 @@ def diag_cal(sn_list, df_bms_ram):
                         file.write(str(tuple(df_diag_res.iloc[-1]))+'\n')
                 
             #当前热失控已超过一天变为历史故障并更改数据库
-            elif (now_time-df_diag_ram_sn.iloc[-1]['start_time']).total_seconds()>24*3600:
+            elif (now_time-datetime.strptime(df_diag_ram_sn.iloc[-1]['start_time'], '%Y-%m-%d %H:%M:%S')).total_seconds()>24*3600:
                 df_diag_ram_sn.iloc[-1]['end_time']=now_time
                 df_diag_ram_sn['Batpos']=1
                 with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控.txt','a') as file:
-                        file.write(str(tuple(df_diag_res.iloc[-1]))+'\n')
+                    file.write(str(tuple(df_diag_res.iloc[-1]))+'\n')
 
         #故障处理........................................................................................................................................................
         end=time.time()
@@ -120,7 +119,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=[[],['PK504B00100004161']]
+    SNnums=[[], ['MGMCLN750N215N205']]
     
     mylog=log.Mylog('log_diag.txt','error')
     mylog.logcfg()
@@ -130,7 +129,7 @@ if __name__ == "__main__":
 
     #定时任务.......................................................................................................................................................................
     scheduler = BlockingScheduler()
-    scheduler.add_job(mainprocess, 'interval', seconds=60, id='diag_job')
+    scheduler.add_job(mainprocess, 'interval', seconds=10, id='diag_job')
 
     try:  
         scheduler.start()