extract(epoch from (t1.end_time - t1.start_time)) duration,
t2.event_id
from t_event_info t1
left JOIN
...
...
@@ -61,18 +62,18 @@
AND t2.cross_id=#{crossId}
</if>
<iftest="contrastStartTime!=null and constrastEndTime!=null">
AND t2.issue_time>=#{contrastStartTime} and t2.issue_time <=#{constrastEndTime}
AND t2.issue_time>= TO_TIMESTAMP(#{contrastStartTime},'YYYY-MM-DD HH24:MI:SS') and t2.issue_time <=TO_TIMESTAMP(#{constrastEndTime},'YYYY-MM-DD HH24:MI:SS')
</if>
<iftest="currentAlgo!=null">
AND t2.current_algo=#{currentAlgo}
<iftest="currentAlgo!=null">
AND t2.current_algo=#{currentAlgo}
</if>
WHERE
1=1
1=1
<iftest="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
</if>
</if>
<iftest="contrastStartTime!=null and constrastEndTime!=null">
AND t1.start_time>=#{contrastStartTime} and t1.start_time <=#{constrastEndTime}
AND t1.start_time>=TO_TIMESTAMP(#{contrastStartTime},'YYYY-MM-DD HH24:MI:SS') and t1.start_time <=TO_TIMESTAMP(#{constrastEndTime},'YYYY-MM-DD HH24:MI:SS')
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, DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') as congest_start_time,DATE_FORMAT(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),
#{peakType} as peak_type,#{weekNumber} as year_week,DATE_FORMAT(#{weekStartTime},'%Y-%m-%d') as week_start_time,DATE_FORMAT(#{weekEndTime},'%Y-%m-%d') as week_end_time,now()
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),
#{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()
FROM t_greenwave_hist a
where a.start_time between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
and a.green_id = #{greenId}
where a.start_time between TO_TIMESTAMP(#{startTime},'%Y-%m-%d %H:%i:%s') and TO_TIMESTAMP(#{endTime},'%Y-%m-%d %H:%i:%s')
and CAST(a.green_id AS VARCHAR) = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
...
...
@@ -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
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
where t.start_time BETWEEN DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59')
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'%Y-%m-%d 00:00:00') and TO_TIMESTAMP(#{date},'%Y-%m-%d 23:59:59')
and t1.dir is not null
order by t.green_id,t1.road_direction,t1.dir,t1.turn,t.start_time
select a.green_id,a.road_direction,#{weekDay} as week_day,DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') as peak_start_time,
DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s') 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,DATE_FORMAT(#{weekStartTime},'%Y-%m-%d') as week_start_time,
DATE_FORMAT(#{weekEndTime},'%Y-%m-%d') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
select a.green_id,a.road_direction,#{weekDay} as week_day,TO_TIMESTAMP(#{startTime},'%Y-%m-%d %H:%i:%s') 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),
#{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,
TO_TIMESTAMP(#{weekEndTime},'%Y-%m-%d') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
from t_greenwave_hist a
where DATE_FORMAT(a.start_time,'%Y-%m-%d %H:%i:00') between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s')
and a.green_id = #{greenId}
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')
and CAST(a.green_id AS VARCHAR) = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
...
...
@@ -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
from t_analysis_green_wave_peak_detail t
left join t_greenwave_key_cross_lane t1 on t1.green_id = t.green_id
where t.peak_start_time BETWEEN DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59')
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')
order by t.green_id,t1.key_cross_id ,t.road_direction,t.peak_type,t.traffic_index desc
select DISTINCT a.control_time as optStartTime,DATE_ADD(a.control_time,INTERVAL a.control_duration SECOND ) as optEndTime ,a.control_duration as optDuration from t_strategy_green_opt_hist a
select DISTINCT a.control_time as optStartTime,a.control_time + a.control_duration* interval '1 second' as optEndTime ,a.control_duration as optDuration from t_strategy_green_opt_hist a
where a.control_time = (select MAX(control_time) from t_strategy_green_opt_hist where green_id = #{greenID}
and control_time <![CDATA[ >= ]]>DATE_FORMAT(DATE_sub(#{time},INTERVAL control_duration SECOND),'%Y-%m-%d %H:%i:%s') and control_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
and control_time <![CDATA[ >= ]]>TO_TIMESTAMP( #{time} - control_duration* interval '1 second','%Y-%m-%d %H:%i:%s') and control_time <![CDATA[ <= ]]> TO_TIMESTAMP(#{time}, '%Y-%m-%d %H:%i:%s')
select a.issue_time as optStartTime,DATE_ADD(a.issue_time,INTERVAL a.duration SECOND ) as optEndTime,a.duration as optDuration from t_strategy_cross_result a
select a.issue_time as optStartTime,a.issue_time + a.control_duration* interval '1 second' as optEndTime,a.duration as optDuration from t_strategy_cross_result a
insert into t_analysis_problem_cross_day (id,cross_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
select UUID(), a.cross_id, b.area_id,a.category,a.type,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) ) as duration ,
DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d') as dt , now()
select uuid_generate_v4() as id, a.cross_id, b.area_id,a.category,a.type,count(1) as event_number , sum( extract(epoch from (a.end_time - a.start_time)) ) as duration ,
TO_TIMESTAMP(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d') as dt , now()
from t_event_info a
left join t_base_cross_info b on a.cross_id = b.id
where DATE_FORMAT(a.start_time,'%Y-%m-%d') = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y-%m-%d') and a.type in (701,702,703,707)
where TO_TIMESTAMP(a.start_time,'%Y-%m-%d') = TO_TIMESTAMP(DATE_SUB(now(),INTERVAL 1 DAY),'%Y-%m-%d') and a.type in ('701','702','703','707')
and start_time BETWEEN #{startTime} AND #{endTime}
and start_time BETWEEN TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
<iftest="greenId != null">
and green_id = #{greenId}
and green_id = CAST(#{greenId} AS INT4)
</if>
GROUP BY cross_id, dir_type, status
</select>
...
...
@@ -395,10 +395,10 @@
select COALESCE(AVG(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<iftest="greenId != null">
green_id = #{greenId}
green_id = CAST(#{greenId} AS INT4)
</if>
<iftest="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
and start_time BETWEEN TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
and status in (3,4)
</select>
...
...
@@ -406,10 +406,10 @@
select COALESCE(sum(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<iftest="greenId != null">
green_id = #{greenId}
green_id = CAST(#{greenId} AS INT4)
</if>
<iftest="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
and start_time BETWEEN TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
and status in (3,4)
</select>
...
...
@@ -417,10 +417,10 @@
select COALESCE(sum(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<iftest="greenId != null">
green_id = #{greenId}
green_id = CAST(#{greenId} AS INT4)
</if>
<iftest="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
and start_time BETWEEN TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
and status = 2
</select>
...
...
@@ -431,7 +431,7 @@
LEFT JOIN
(
SELECT id,sturation from t_lane_data_hist
where cross_id = #{crossId} and start_time BETWEEN #{startTime} AND #{endTime}
where cross_id = #{crossId} and start_time BETWEEN TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
DATE_FORMAT(t1.overflow_start_time,'%H:%i') as overflowStartTimeHours,
DATE_FORMAT(t1.overflow_end_time,'%H:%i') as overflowEndTimeHours
TO_CHAR(t1.overflow_start_time,'HH24:MI') as overflowStartTimeHours,
TO_CHAR(t1.overflow_end_time,'HH24:MI') as overflowEndTimeHours
FROM t_analysis_cross_overflow_reason t1
WHERE
1=1
<iftest="startTime != null and endTime != ''">
and t1.dt >= #{startTime} AND t1.dt <= #{endTime}
and t1.dt >= CAST(TO_CHAR(#{startTime},'YYYYMMDD') AS INT4) AND t1.dt <= CAST(TO_CHAR(#{endTime},'YYYYMMDD') AS INT4)
</if>
<iftest="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
...
...
@@ -289,7 +289,7 @@
and t1.turn_type = #{turn}
</if>
<iftest="startTimeAll != null and endTimeALL != ''">
and t1.start_time >= #{startTimeAll} AND t1.start_time <= #{endTimeALL}
and t1.start_time >= TO_TIMESTAMP(#{startTimeAll},'YYYY-MM-DD HH24:MI:SS') AND t1.start_time <= TO_TIMESTAMP(#{endTimeALL},'YYYY-MM-DD HH24:MI:SS')
</if>
</select>
...
...
@@ -305,8 +305,8 @@
turn,
t1.cross_id,
event_number,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
DATE_FORMAT(t1.window_start_time, '%Y-%m-%d %H:%i:%s') AS winStartTime,
TO_CHAR(t1.window_start_time,'HH24:MI') AS hours_window_start_time ,
TO_CHAR(t1.window_start_time, 'YYYY-MM-DD HH24:MI:SS') AS winStartTime,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1
...
...
@@ -314,7 +314,7 @@
WHERE
1=1
<iftest="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt <= #{endTime}
and dt >= CAST(TO_CHAR(#{startTime},'YYYYMMDD') AS INT4) AND dt <= CAST(TO_CHAR(#{endTime},'YYYYMMDD') AS INT4)
</if>
<iftest="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
...
...
@@ -341,7 +341,7 @@
and t1.cross_id = #{crossId}
</if>
<iftest="moningPeakStartAll != null and moningPeakEndAll != null ">
and t1.start_time >= #{moningPeakStartAll} AND t1.start_time <= #{moningPeakEndAll}
and t1.start_time >= TO_TIMESTAMP(#{moningPeakStartAll},'YYYY-MM-DD HH24:MI:SS') AND t1.start_time <= TO_TIMESTAMP(#{moningPeakEndAll},'YYYY-MM-DD HH24:MI:SS')
</if>
</select>
...
...
@@ -352,8 +352,8 @@
turn,
t1.cross_id,
event_number,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
DATE_FORMAT(t1.window_start_time, '%Y-%m-%d %H:%i:%s') AS winStartTime,
TO_CHAR(t1.window_start_time,'HH24:MI') AS hours_window_start_time ,
TO_CHAR(t1.window_start_time, 'YYYY-MM-DD HH24:MI:SS') AS winStartTime,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1
...
...
@@ -361,7 +361,7 @@
WHERE
1=1
<iftest="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt <= #{endTime}
and dt >= CAST(TO_CHAR(#{startTime},'YYYYMMDD') AS INT4) AND dt <= CAST(TO_CHAR(#{endTime},'YYYYMMDD') AS INT4)
</if>
<iftest="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
...
...
@@ -386,7 +386,7 @@
</if>
<iftest="startTimeAll != null and endTimeALL != ''">
and start_time BETWEEN #{startTimeAll} AND #{endTimeALL}
and start_time BETWEEN TO_TIMESTAMP(#{startTimeAll},'YYYY-MM-DD HH24:MI:SS') AND TO_TIMESTAMP(#{endTimeALL},'YYYY-MM-DD HH24:MI:SS')