lmstack 3 years ago
parent
commit
852a65abc8
1 changed files with 3 additions and 1 deletions
  1. 3 1
      LIB/MIDDLE/SaftyCenter/Offline/offline_alarm_sta.py

+ 3 - 1
LIB/MIDDLE/SaftyCenter/Offline/offline_alarm_sta.py

@@ -31,7 +31,9 @@ def offline_alarm_sta(db_iotp_engine, db_qxcas_engine, conn, db_sp_engine):
     now = datetime.datetime.now()
     for sn in sn_new:
         df = df_offlinealarm_lastday[df_offlinealarm_lastday['sn']==sn]
-        df_new = df_new.append({'add_time':now, 'product_id':sn, 'start_time':df['time'].values[0], 'end_time':'0000-00-00 00:00:00', 'info':'离线报警','code':59, 'level':1}, ignore_index=True)
+        sql = "select * from ff_battery_status where devcode = '{}'".format(sn)
+        df_on = pd.read_sql(sql, db_iotp_engine)
+        df_new = df_new.append({'add_time':now, 'product_id':sn, 'start_time':pd.to_datetime(df_on['status_time'].values[0]), 'end_time':'0000-00-00 00:00:00', 'info':'离线报警','code':59, 'level':1}, ignore_index=True)
     if not df_new.empty:
         df_new.to_sql('all_fault_info', db_sp_engine, if_exists='append', index=False)