Обновить hardwareAvailabilityReport.sql
This commit is contained in:
@@ -39,8 +39,8 @@ checks AS (
|
||||
-- Исключаем оборудование, начинающееся на IRZ (любой регистр)
|
||||
--AND UPPER(h.host) NOT LIKE 'IRZ%'
|
||||
-- Период: май 2026 года (измените под свои даты)
|
||||
--and hinv.notes = 'ОБЪЕКТ № 12'
|
||||
--and hinv."name" = 'Видеокамера Trassir TR-D6254IR15'
|
||||
--and hinv.notes = 'ОБЪЕКТ № 5'
|
||||
--and hinv."name" = 'Метеостанция Кондор'
|
||||
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 TO_TIMESTAMP(hx.clock) >= to_date(${start_dt}, 'yyyymmdd') - interval '1 day'
|
||||
@@ -111,8 +111,8 @@ grouped_intervals AS (
|
||||
equipment_type,
|
||||
object_number,
|
||||
coordinates,
|
||||
MIN(date_trunc('second', check_time)) AS check_time,
|
||||
MAX(date_trunc('second', next_check_time)) AS next_check_time,
|
||||
MIN(check_time) AS check_time,
|
||||
MAX(next_check_time) AS next_check_time,
|
||||
MAX(status) AS status
|
||||
FROM intervals
|
||||
GROUP BY
|
||||
@@ -126,12 +126,12 @@ grouped_intervals AS (
|
||||
|
||||
daily_stats AS (
|
||||
select *,
|
||||
extract('hour' from available_hours)::int AS a_h,
|
||||
extract('minute' from available_hours)::int AS a_m,
|
||||
extract('second' from available_hours)::int AS a_s,
|
||||
extract('hour' from unavailable_hours)::int AS u_h,
|
||||
extract('minute' from unavailable_hours)::int AS u_m,
|
||||
extract('second' from unavailable_hours)::int AS u_s
|
||||
case when unavailable_hours is not null then coalesce(extract('hour' from available_hours)::int,0) else 24 end AS a_h,
|
||||
coalesce(extract('minute' from available_hours)::int,0) AS a_m,
|
||||
coalesce(extract('second' from available_hours)::int,0) AS a_s,
|
||||
case when available_hours is not null then coalesce(extract('hour' from unavailable_hours)::int,0) else 24 end AS u_h,
|
||||
coalesce(extract('minute' from unavailable_hours)::int,0) AS u_m,
|
||||
coalesce(extract('second' from unavailable_hours)::int,0) AS u_s
|
||||
from
|
||||
(
|
||||
SELECT
|
||||
@@ -140,10 +140,10 @@ daily_stats AS (
|
||||
equipment_type,
|
||||
object_number,
|
||||
coordinates,
|
||||
DATE(check_time) AS check_date,
|
||||
DATE(check_time) AS check_date,
|
||||
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
|
||||
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
|
||||
GROUP BY
|
||||
host_name,
|
||||
|
||||
Reference in New Issue
Block a user