insert into t_analysis_green_wave_congest_time_span (green_id,road_direction,week_day,congest_start_time,congest_end_time,congest_index,status,travel_time,speed,peak_type,year_week,week_start_time,week_end_time,insert_time)
insert into t_analysis_green_wave_congest_time_span (green_id,road_direction,week_day,congest_start_time,congest_end_time,congest_index,status,travel_time,speed,peak_type,year_week,week_start_time,week_end_time,insert_time)
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') as congest_start_time,TO_TIMESTAMP(DATE_ADD(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') as congest_start_time,TO_TIMESTAMP(DATE_ADD(#{endTime},INTERVAL '5 MINUTE'),'YYYY-MM-DD HH24:MI:SS') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
FROM t_greenwave_hist a
FROM t_greenwave_hist a
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
...
@@ -71,7 +72,7 @@
...
@@ -71,7 +72,7 @@
where t1.key_cross_id is not null and t.type = 2) t3 on t2.id = t3.id
where t1.key_cross_id is not null and t.type = 2) t3 on t2.id = t3.id
where t3.key_cross_id is not null and dt = CAST(#{date} AS INT4) ) t4
where t3.key_cross_id is not null and dt = CAST(#{date} AS INT4) ) t4
where t4.cross_id = #{crossId}
where t4.cross_id = #{crossId}
and t4.start_time between TO_TIMESTAMP(DATE_SUB(#{startTime},INTERVAL '10 MINUTE'),'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
and t4.start_time between DATE_SUB(#{startTime},INTERVAL '10 MINUTE') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
group by t4.cross_id,t4.start_time
group by t4.cross_id,t4.start_time
</select>
</select>
...
@@ -84,7 +85,7 @@
...
@@ -84,7 +85,7 @@
#{avgFlow} as flow,#{maxFlow} as max_flow,#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
#{avgFlow} as flow,#{maxFlow} as max_flow,#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
from t_greenwave_hist a
from t_greenwave_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL '5 MINUTE'),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and CAST(a.green_id AS VARCHAR) = #{greenId}
and CAST(a.green_id AS VARCHAR) = #{greenId}
and a.road_direction = #{roadDirection}
and a.road_direction = #{roadDirection}
</insert>
</insert>
...
@@ -93,7 +94,7 @@
...
@@ -93,7 +94,7 @@
select t.green_id,t1.key_cross_id as cross_id, t.road_direction,t.peak_start_time as start_time,t.peak_end_time as endTime ,t.traffic_index,t.peak_type
select t.green_id,t1.key_cross_id as cross_id, t.road_direction,t.peak_start_time as start_time,t.peak_end_time as endTime ,t.traffic_index,t.peak_type
from t_analysis_green_wave_peak_detail t
from t_analysis_green_wave_peak_detail t
left join t_greenwave_key_cross_lane t1 on t1.green_id = t.green_id
left join t_greenwave_key_cross_lane t1 on t1.green_id = t.green_id
where t.peak_start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59')
where t.peak_start_time BETWEEN TO_TIMESTAMP(#{date}||' 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{date}||' 23:59:59','YYYY-MM-DD HH24:MI:SS')
order by t.green_id,t1.key_cross_id ,t.road_direction,t.peak_type,t.traffic_index desc
order by t.green_id,t1.key_cross_id ,t.road_direction,t.peak_type,t.traffic_index desc
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 09:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 16:30:10')
where t.start_time BETWEEN TO_TIMESTAMP(#{date}||'090000','YYYYMMDDHH24MISS') and TO_TIMESTAMP(#{date}||'163010','YYYYMMDDHH24MISS')
and t.cross_id = #{crossId}
and t.cross_id = #{crossId}
order by t.traffic_index desc
order by t.traffic_index desc
</select>
</select>
...
@@ -131,8 +132,22 @@
...
@@ -131,8 +132,22 @@
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
from t_cross_data_hist a
from t_cross_data_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and a.cross_id = #{crossId}
and a.cross_id = #{crossId}
ON CONFLICT ("year_week", "cross_id", "peak_start_time", "week_day", "day_type", "peak_type")
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{maxFlow},sum(flow),AVG(speed)
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{maxFlow},sum(flow),AVG(speed)
from t_cross_data_hist a
from t_cross_data_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and a.cross_id = #{crossId}
and a.cross_id = #{crossId}
ON CONFLICT ("year_week", "cross_id", "peak_start_time", "week_day", "day_type", "peak_type")
insert into t_analysis_problem_green_day (id,green_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
insert into t_analysis_problem_green_day (id,green_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
select uuid_generate_v4(), a.green_id, b.area_id,a.category,a.type,count(1) as event_number ,
select uuid_generate_v4(), cast(a.green_id as int), b.area_id,a.category,a.type,count(1) as event_number ,
sum( extract(epoch from (a.end_time - a.start_time)) ) as duration ,
sum( extract(epoch from (a.end_time - a.start_time)) ) as duration ,
dt , now()
dt , now()
from t_event_info a
from t_event_info a
left join t_greenwave_info b on a.green_id = b.id
left join t_greenwave_info b on cast(a.green_id as int) = b.id
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL 1 DAY),'YYYYMMDD') AS INT4) and a.type in ('705','706') and a.green_id != ''
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL '1 DAY'),'YYYYMMDD') AS INT4) and a.type in ('705','706') and a.green_id != ''
group by a.green_id, b.area_id,a.category,a.type
group by a.green_id, b.area_id,a.category,a.type
ON CONFLICT (green_id,event_type,dt)
ON CONFLICT (green_id,event_type,dt)
DO UPDATE SET
DO UPDATE SET
...
@@ -188,35 +188,66 @@
...
@@ -188,35 +188,66 @@
<!-- 新增表t_analysis_problem_green_hour信息 -->
<!-- 新增表t_analysis_problem_green_hour信息 -->
<insertid="insertAnalysisProblemGreenHour">
<insertid="insertAnalysisProblemGreenHour">
insert into t_analysis_problem_green_hour (id,green_id,area_id,event_category,event_type,dir,event_number,event_total_time,window_start_time,window_end_time,dt,insert_time)