Selaa lähdekoodia

更新低电量和离线

lmstack 3 vuotta sitten
vanhempi
commit
1c5c487cdf

+ 3 - 2
LIB/MIDDLE/SaftyCenter/Low_Soc_Alarm/low_soc_alarm_sta.py

@@ -6,7 +6,7 @@ from sqlalchemy.orm import sessionmaker
 from urllib import parse
 import pymysql
 
-def low_soc_alarm_sta(db_qxcas_engine, conn, db_sp_engine):
+def low_soc_alarm_sta(df_sns, db_qxcas_engine, conn, db_sp_engine):
     
     cursor = conn.cursor()
 
@@ -35,7 +35,8 @@ def low_soc_alarm_sta(db_qxcas_engine, conn, db_sp_engine):
     now = datetime.datetime.now()
     for sn in sn_new:
         df = df_lowsocalarm_lastday[df_lowsocalarm_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':58, 'level':1}, ignore_index=True)
+        factory = df_sns[df_sns['sn']==sn]['factory'].values[0]
+        df_new = df_new.append({'add_time':now, 'product_id':sn, 'factory':factory, 'start_time':df['time'].values[0], 'end_time':'0000-00-00 00:00:00', 'info':"低电量报警", 'code':58, '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)
 

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

@@ -7,7 +7,7 @@ from urllib import parse
 import pymysql
 
 
-def offline_alarm_sta(db_iotp_engine, db_qxcas_engine, conn, db_sp_engine):
+def offline_alarm_sta(df_sns, db_iotp_engine, db_qxcas_engine, conn, db_sp_engine):
 
     cursor = conn.cursor()
     sql = "select sn, DATE_FORMAT(add_time, '%Y-%m-%d %H:%i:%s') as time, level, last_time from offline_info where add_time >= DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 0 DAY), '%Y-%m-%d 00:00:00')"+ \
@@ -33,7 +33,8 @@ def offline_alarm_sta(db_iotp_engine, db_qxcas_engine, conn, db_sp_engine):
         df = df_offlinealarm_lastday[df_offlinealarm_lastday['sn']==sn]
         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)
+        factory = df_sns[df_sns['sn']==sn]['factory'].values[0]
+        df_new = df_new.append({'add_time':now, 'product_id':sn, 'factory':factory, '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)