From 665ed50bf94f57d8f19fe778ad427229be3db7f0 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, 4 Aug 2026 23:38:26 +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 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/hardwareAvailabilityReport.sql b/hardwareAvailabilityReport.sql index 4f9ebc7..3deca04 100644 --- a/hardwareAvailabilityReport.sql +++ b/hardwareAvailabilityReport.sql @@ -37,15 +37,16 @@ checks AS ( -- Только мониторимые хосты h.status = 0 and h.host not like '%WiMAX' - -- Исключаем оборудование, начинающееся на IRZ (любой регистр) - --AND UPPER(h.host) NOT LIKE 'IRZ%' - -- Период: май 2026 года (измените под свои даты) - --and hinv.notes = 'ОБЪЕКТ № 8' - --and hinv."name" = 'Видеокамера Trassir TR-D6254IR15' - and CAST(nullif(regexp_replace(hinv.notes, 'ОБЪЕКТ №\s*', '', 'g'),'') as INTEGER) - between 1 and 85 --in (44,77,43,54,27,48,12,49,65,9,60,35,38,1,51,41,53,84,8) + and h.host not like '%DP%' + and h.host not like '%CO%' + and ((CAST(nullif(regexp_replace(hinv.notes, 'ОБЪЕКТ №\s*', '', 'g'),'') as INTEGER) + in (1,2,4,5,8,9,11,12,14,23,24,25,27,28,29,30,31,32,34,35,36,38,39,40,41,42,43,44,45,46,48,49,50,51,53,54,55,57,58,60,62,63,64,65,66,67,68,69,70,75,76,77,81,82,84,85) AND TO_TIMESTAMP(hx.clock) >= to_date(${start_dt}, 'yyyymmdd') - interval '1 day' - AND TO_TIMESTAMP(hx.clock) <= to_date(${end_dt}, 'yyyymmdd') + interval '1 day' + AND TO_TIMESTAMP(hx.clock) <= to_date(${end_dt}, 'yyyymmdd') + interval '1 day' ) + or (CAST(nullif(regexp_replace(hinv.notes, 'ОБЪЕКТ №\s*', '', 'g'),'') as INTEGER) + in (6,10,16,74,78) + AND TO_TIMESTAMP(hx.clock) >= to_date('20260709', 'yyyymmdd') - interval '1 day' + AND TO_TIMESTAMP(hx.clock) <= to_date(${end_dt}, 'yyyymmdd') + interval '1 day' )) --and hinv.notes is null ), @@ -55,7 +56,7 @@ checks_with_prev AS ( SELECT *, LAG(status) OVER (PARTITION BY host_name ORDER BY check_time) AS prev_status, - coalesce(lead(check_time) OVER (PARTITION BY host_name ORDER BY check_time), now()) AS next_check_time + coalesce(lead(check_time) OVER (PARTITION BY host_name ORDER BY check_time), date_trunc('day', check_time) + interval '1 day') AS next_check_time FROM checks ), @@ -101,7 +102,11 @@ intervals AS ( SUM(is_start) OVER (PARTITION BY host_name ORDER BY check_time) AS interval_id FROM status_changes WHERE status IS NOT null - and date_trunc('day', check_time) >= to_date(${start_dt}, 'yyyymmdd') and date_trunc('day', check_time) <= to_date(${end_dt}, 'yyyymmdd') + and ((regexp_replace(object_number, 'ОБЪЕКТ №\s*', '', 'g')::INT in (6,10,16,74,78) + AND date_trunc('day', check_time) >= to_date('20260709', 'yyyymmdd') + AND date_trunc('day', check_time) <= to_date(${end_dt}, 'yyyymmdd')) + or (regexp_replace(object_number, 'ОБЪЕКТ №\s*', '', 'g')::INT not in (6,10,16,74,78) and date_trunc('day', check_time) >= to_date(${start_dt}, 'yyyymmdd') and date_trunc('day', check_time) <= to_date(${end_dt}, 'yyyymmdd'))) + and check_time <= now() ), -- 5. Агрегируем каждый непрерывный интервал