diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 944eb5a0..7d2d76bd 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -1130,7 +1130,7 @@ class Sf_Dashboard_Connect(http.Controller): SELECT * FROM device_data WHERE device_name = %s AND time::date = CURRENT_DATE - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1143,7 +1143,7 @@ class Sf_Dashboard_Connect(http.Controller): SELECT * FROM device_data WHERE device_name = %s AND time::date = CURRENT_DATE - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1161,11 +1161,11 @@ class Sf_Dashboard_Connect(http.Controller): # 获取当月第一条记录(排除device_state等于‘离线’的记录) with conn.cursor() as cur: cur.execute(""" - SELECT * FROM device_datas + SELECT * FROM device_data WHERE device_name = %s AND time >= DATE_TRUNC('MONTH', CURRENT_DATE) AND time < DATE_TRUNC('MONTH', CURRENT_DATE) + INTERVAL '1 MONTH' - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1179,7 +1179,7 @@ class Sf_Dashboard_Connect(http.Controller): WHERE device_name = %s AND time >= DATE_TRUNC('MONTH', CURRENT_DATE) AND time < DATE_TRUNC('MONTH', CURRENT_DATE) + INTERVAL '1 MONTH' - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1200,7 +1200,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1212,7 +1212,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1290,7 +1290,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') AND process_time IS NOT NULL + AND device_state in ('待机', '警告', '运行中') AND process_time IS NOT NULL ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1299,7 +1299,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') AND time >= %s AND process_time IS NOT NULL + AND device_state in ('待机', '警告', '运行中') AND time >= %s AND process_time IS NOT NULL ORDER BY time ASC LIMIT 1; """, (item, time_threshold))