|
@@ -7,7 +7,7 @@ from urllib import parse
|
|
import pymysql
|
|
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()
|
|
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')"+ \
|
|
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]
|
|
df = df_offlinealarm_lastday[df_offlinealarm_lastday['sn']==sn]
|
|
sql = "select * from ff_battery_status where devcode = '{}'".format(sn)
|
|
sql = "select * from ff_battery_status where devcode = '{}'".format(sn)
|
|
df_on = pd.read_sql(sql, db_iotp_engine)
|
|
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:
|
|
if not df_new.empty:
|
|
df_new.to_sql('all_fault_info', db_sp_engine, if_exists='append', index=False)
|
|
df_new.to_sql('all_fault_info', db_sp_engine, if_exists='append', index=False)
|
|
|
|
|