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,