From 63845ac273ba24c5c52af36564ddd36c2e85c931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D1=86=D0=BA=D0=B8=D0=B9?= Date: Tue, 30 Jun 2026 22:30:27 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20hardwareAvailabilityReport.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardwareAvailabilityReport.sql | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/hardwareAvailabilityReport.sql b/hardwareAvailabilityReport.sql index 3ccc4e9..631a798 100644 --- a/hardwareAvailabilityReport.sql +++ b/hardwareAvailabilityReport.sql @@ -36,6 +36,7 @@ checks AS ( WHERE -- Только мониторимые хосты h.status = 0 + and h.host not like '%WiMAX' -- Исключаем оборудование, начинающееся на IRZ (любой регистр) --AND UPPER(h.host) NOT LIKE 'IRZ%' -- Период: май 2026 года (измените под свои даты) @@ -122,6 +123,30 @@ grouped_intervals AS ( object_number, coordinates, interval_id +), + +-- Определение маршрутизатора (заглушка) +router as +( + select + m.host_name, + m.visible_name, + m.equipment_type, + v.object_number, + v.coordinates, + v.check_time, + v.next_check_time, + v.status + from grouped_intervals v + join + ( + select host_name, visible_name, object_number, equipment_type, date_trunc('day', check_time) as time_start_dt + from grouped_intervals + where equipment_type like 'Маршрутизатор%' + group by 1,2,3,4,5 + ) m on m.object_number = v.object_number + where v.equipment_type like 'Видеокамера%' + and m.time_start_dt = date_trunc('day', v.check_time) ), daily_stats AS ( @@ -144,7 +169,12 @@ daily_stats AS ( sum(case when status = 1 then next_check_time - check_time else null end) AS available_hours, sum(case when status = 0 then next_check_time - check_time else null end) AS unavailable_hours --sum(next_check_time - check_time) AS all_hours - FROM grouped_intervals + FROM + ( + select * from grouped_intervals where equipment_type not like 'Маршрутизатор%' + union all + select * from router + ) g GROUP BY host_name, visible_name,