insert into t_analysis_problem_cross_dir_hour (id,cross_id,area_id,event_category,event_type,dir,event_number,event_total_time,window_start_time,window_end_time,dt,insert_time)
insert into t_analysis_problem_cross_dir_hour (id,cross_id,area_id,event_category,event_type,dir,turn,event_number,event_total_time,window_start_time,window_end_time,dt,insert_time)
select uuid_generate_v4(),
d.cross_id,
e.area_id,
d.category,
d.type,
cast(d.dir as int),
cast((case when d.turn='ul' then '0' else d.turn end) as int),
count(1) as event_number ,
sum( extract(epoch from (d.end_time - d.start_time)) ) as duration ,
TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL '1 HOUR') AS VARCHAR),'YYYY-MM-DD HH24:00:00') as dh1,
...
...
@@ -365,9 +366,9 @@
now()
from
(
select DISTINCT b.cross_id,b.category,b.type,b.start_time,b.end_time, unnest(string_to_array(dir, ',')) AS dir
select DISTINCT b.cross_id,b.category,b.type,b.start_time,b.end_time, unnest(string_to_array(dir, ',')) AS dir,unnest(string_to_array(turn, ',')) AS turn
from
(select a.cross_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir
(select a.cross_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir,SUBSTR(a.turn,2,LENGTH(a.turn)-2) as turn
from t_event_info a
where a.start_time >= TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL '1 HOUR') AS VARCHAR),'YYYY-MM-DD HH24:00:00')
and a.start_time <![CDATA[ < ]]> TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00')
...
...
@@ -377,7 +378,7 @@
) b
) d
left join t_base_cross_info e on d.cross_id = e.id
group by d.cross_id, e.area_id,d.category,d.type,d.dir
group by d.cross_id, e.area_id,d.category,d.type,d.dir,d.turn
ON CONFLICT(dt,dir,cross_id,window_start_time,event_type)