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_TIMESTEMP(#{startTime},'%Y-%m-%d %H:%i:%s') as congest_start_time,TO_TIMESTAMP(DATE_ADD(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s') 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_TIMESTEMP(#{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},'%Y-%m-%d') as week_start_time,TO_TIMESTAMP(#{weekEndTime},'%Y-%m-%d') 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},'%Y-%m-%d %H:%i:%s') and TO_TIMESTAMP(#{endTime},'%Y-%m-%d %H:%i:%s')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
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>
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
select t.green_id,t1.key_cross_id as cross_id, t1.road_direction,t1.dir,t1.turn,t.start_time,t.traffic_index
select t.green_id,t1.key_cross_id as cross_id, t1.road_direction,t1.dir,t1.turn,t.start_time,t.traffic_index
from t_greenwave_hist t
from t_greenwave_hist t
left join t_greenwave_key_cross_lane t1 on t.green_id = t1.green_id and t.road_direction = t1.road_direction
left join t_greenwave_key_cross_lane t1 on t.green_id = t1.green_id and t.road_direction = t1.road_direction
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'%Y-%m-%d 00:00:00') and TO_TIMESTAMP(#{date},'%Y-%m-%d 23:59:59')
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59')
and t1.dir is not null
and t1.dir is not null
order by t.green_id,t1.road_direction,t1.dir,t1.turn,t.start_time
order by t.green_id,t1.road_direction,t1.dir,t1.turn,t.start_time
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'%Y-%m-%d 09:00:00') and TO_TIMESTAMP(#{date},'%Y-%m-%d 16:30:10')
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 09:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 16:30:10')
and CAST(t.green_id AS VARCHAR) = #{greenId}
and CAST(t.green_id AS VARCHAR) = #{greenId}
and t.road_direction = #{roadDirection}
and t.road_direction = #{roadDirection}
order by t.traffic_index desc
order by t.traffic_index desc
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,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),'%Y-%m-%d %H:%i:00') and TO_TIMESTAMP(#{endTime},'%Y-%m-%d %H:%i:%s')
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')
group by t4.cross_id,t4.start_time
group by t4.cross_id,t4.start_time
</select>
</select>
...
@@ -79,12 +79,12 @@
...
@@ -79,12 +79,12 @@
insert into t_analysis_green_wave_peak_detail (green_id,road_direction,week_day,peak_start_time,peak_end_time,
insert into t_analysis_green_wave_peak_detail (green_id,road_direction,week_day,peak_start_time,peak_end_time,
select a.green_id,a.road_direction,#{weekDay} as week_day,TO_TIMESTAMP(#{startTime},'%Y-%m-%d %H:%i:%s') as peak_start_time,
select a.green_id,a.road_direction,#{weekDay} as week_day,TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') as peak_start_time,
TO_TIMESTAMP(#{endTime},'%Y-%m-%d %H:%i:%s') as peak_end_time, AVG(traffic_index),CEIL(AVG(trval_time)),AVG(speed),
TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS') as peak_end_time, AVG(traffic_index),CEIL(AVG(trval_time)),AVG(speed),
#{avgFlow} as flow,#{maxFlow} as max_flow,#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'%Y-%m-%d') 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},'%Y-%m-%d') 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,'%Y-%m-%d %H:%i:00') between TO_TIMESTAMP(#{startTime},'%Y-%m-%d %H:%i:%s') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s')
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')
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 +93,7 @@
...
@@ -93,7 +93,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},'%Y-%m-%d 00:00:00') and TO_TIMESTAMP(#{date},'%Y-%m-%d 23:59:59')
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')
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