From 4a15ef08b700b505499eacd535487b92daafb3c3 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:39:13 +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=20gantReport.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gantReport.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gantReport.sql b/gantReport.sql index 43cb509..de446db 100644 --- a/gantReport.sql +++ b/gantReport.sql @@ -50,7 +50,7 @@ checks AS ( -- AND UPPER(h.host) NOT LIKE 'IRZ%' -- Период: май 2026 года (измените под свои даты) and hinv.notes is not null and hinv.notes <> '' - --and hinv.notes = 'ОБЪЕКТ № 67' --and hinv.name like '%Маршрутизатор%' + --and hinv.notes = 'ОБЪЕКТ № 14' --and hinv.name like '%Маршрутизатор%' and CAST(nullif(regexp_replace(hinv.notes, 'ОБЪЕКТ №\s*', '', 'g'),'') as INTEGER) --between 1 and 85 in (1,2,4,5,8,9,11,12,14,24,25,27,28,29,30,31,32,34,35,36,38,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,76,77,81,82,84,85) @@ -63,7 +63,7 @@ checks_with_prev AS ( SELECT *, LAG(status) OVER (PARTITION BY host_name ORDER BY ts) AS prev_status, - coalesce(lead(ts) OVER (PARTITION BY host_name ORDER BY ts), date_trunc('month', to_date(${start_dt}, 'yyyymmdd')) + interval '1 month') AS next_ts + coalesce(lead(ts) OVER (PARTITION BY host_name ORDER BY ts), date_trunc('day', ts) + interval '1 day') AS next_ts FROM checks ), --3. Определяем моменты смены статуса (начало нового интервала) status_changes AS ( @@ -110,7 +110,7 @@ intervals AS ( SUM(is_start) OVER (PARTITION BY host_name ORDER BY ts) AS interval_id FROM status_changes WHERE status IS NOT null - and date_trunc('day', ts) >= to_date(${start_dt}, 'yyyymmdd') and date_trunc('day', ts) <= to_date(${end_dt}, 'yyyymmdd') + and date_trunc('day', ts) >= to_date(${start_dt}, 'yyyymmdd') and date_trunc('day', ts) <= to_date(${end_dt}, 'yyyymmdd') and ts <= now() ), -- 5. Агрегируем каждый непрерывный интервал grouped_intervals AS ( SELECT @@ -307,7 +307,7 @@ router as left join sum_interval i on g.object_num = i.object_num and g.equipment_id = i.equipment_id and g.date_check = i.date_check - where abs(extract('minute' from g.time_end_tm - i.available_hours)::int) > 5 + where (abs(extract('minute' from g.time_end_tm - i.available_hours)::int) > 5 or abs(extract('hours' from g.time_end_tm - i.available_hours)::int) > 0) and g.status = 1 union all select g.*, i.available_hours, INTERVAL '00:00:00' as diff_tm, null as diff_fl @@ -377,8 +377,8 @@ SELECT m.equipment_type as "Тип оборудования", m.object_name as "Номер_объекта_ИТС_РО", m.coordinates as "Координаты_расположения", - TO_CHAR(u.time_start, 'HH24:MI:SS') AS "Время начала статуса", - TO_CHAR(u.time_end, 'HH24:MI:SS') as "Время окончания статуса", + case when TO_CHAR(u.time_start, 'HH24:MI:SS') = '24:00:00' then '00:00:00' else TO_CHAR(u.time_start, 'HH24:MI:SS') end AS "Время начала статуса", + case when TO_CHAR(u.time_end, 'HH24:MI:SS') = '24:00:00' then '00:00:00' else TO_CHAR(u.time_end, 'HH24:MI:SS') end as "Время окончания статуса", CASE WHEN u.status = 1 THEN 'доступно' ELSE 'недоступно'