From 2b2da79e33e52bc8e09d44c42aaea08cf9c6b6b4 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 24 Mar 2025 17:18:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AD=9B=E9=80=89=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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))