From e8bf742cda3f9c85e1efe7bd729da71b3573ee35 Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Sun, 16 Feb 2025 18:18:30 +0700 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/schedulers/tasks.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/apps/schedulers/tasks.py b/apps/schedulers/tasks.py index 4fd28f7..dca384c 100644 --- a/apps/schedulers/tasks.py +++ b/apps/schedulers/tasks.py @@ -559,11 +559,31 @@ def load_asd(): element.speed = speed element.save() - sql_query = """SELECT * FROM v$version;""" cursor = connection.cursor() cursor.execute(sql_query) - logging.message(cursor) - sql_query = """SELECT * FROM MFSB.TRUCKALARMS""" + + sql_query = """ + SELECT + ta1.ALARMID, + ta1.OBJID, + ta1.LAT, + ta1.LON, + ta1.ALARMTIME, + ta1.ALARMTYPE + FROM + MFSB.TRUCKALARMS ta1 + WHERE + ta1.ALARMTYPE = 'Усталость водителя' + AND EXISTS ( + SELECT 1 + FROM MFSB.TRUCKALARMS ta2 + WHERE + ta2.OBJID = ta1.OBJID + AND ta2.ALARMTIME BETWEEN ta1.ALARMTIME - (1 / 1440) AND ta1.ALARMTIME + AND ta2.ALARMTYPE = 'Усталость водителя' + HAVING COUNT(*) > 3 + ) + """ cursor = connection.cursor() cursor.execute(sql_query)