Обновить hardwareAvailabilityReport.sql
This commit is contained in:
@@ -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. Агрегируем каждый непрерывный интервал
|
||||
|
||||
Reference in New Issue
Block a user