Commit 73675fa9 authored by 黄伟铭's avatar 黄伟铭

国产化修改

parent 42929683
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
FROM t_event_optimize_info FROM t_event_optimize_info
WHERE 1=1 WHERE 1=1
<if test="startTime != null and endTime != null"> <if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime} AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND happen_start_time &lt;= #{endTime} AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if> </if>
<if test="crossId != null"> <if test="crossId != null">
AND cross_id = #{crossId} AND cross_id = #{crossId}
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
<select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo"> <select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT * SELECT *
FROM t_event_optimize_info FROM t_event_optimize_info
WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime}) WHERE (#{startTime} IS NULL OR happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime}) AND (#{endTime} IS NULL OR happen_end_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{crossId} IS NULL OR cross_id = #{crossId}) AND (#{crossId} IS NULL OR cross_id = #{crossId})
AND (#{greenId} IS NULL OR green_id = #{greenId}) AND (#{greenId} IS NULL OR green_id = #{greenId})
AND opt_status != 0 AND opt_status != 0
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<select id="getCrossOptimizeDistribute" parameterType="map" resultType="java.util.Map"> <select id="getCrossOptimizeDistribute" parameterType="map" resultType="java.util.Map">
SELECT SELECT
(CASE (CASE
WHEN #{groupType} = 4 THEN DATE_FORMAT(unit_time, '%Y-%m-%d') -- 按天粒度格式化为 yyyy-MM-dd WHEN #{groupType} = 4 THEN TO_CHAR(unit_time, 'YYYY-MM-DD') -- 按天粒度格式化为 yyyy-MM-dd
ELSE unit_time -- 其他粒度格式化为 HH:mm ELSE unit_time -- 其他粒度格式化为 HH:mm
END) AS time_label, END) AS time_label,
event_type, event_type,
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
FROM ( FROM (
SELECT SELECT
(CASE (CASE
WHEN #{groupType} = 0 THEN DATE_FORMAT(CONCAT(DATE(happen_start_time), ' ', HOUR(happen_start_time), ':', FLOOR(MINUTE(happen_start_time) / 5) * 5), '%Y-%m-%d %H:%i:00') WHEN #{groupType} = 0 THEN TO_CHAR(CONCAT(TO_CHAR(happen_start_time,'YYYY-MM-DD'), ' ', TO_CHAR(happen_start_time,'HH24'), ':', FLOOR(EXTRACT(MINUTE FROM happen_start_time) / 5) * 5), 'YYYY-MM-DD HH24:MI:00')
WHEN #{groupType} = 1 THEN DATE_FORMAT(CONCAT(DATE(happen_start_time), ' ', HOUR(happen_start_time), ':', FLOOR(MINUTE(happen_start_time) / 15) * 15), '%Y-%m-%d %H:%i:00') WHEN #{groupType} = 1 THEN TO_CHAR(CONCAT(TO_CHAR(happen_start_time,'YYYY-MM-DD'), ' ', TO_CHAR(happen_start_time,'HH24'), ':', FLOOR(EXTRACT(MINUTE FROM happen_start_time) / 15) * 15), 'YYYY-MM-DD HH24:MI:00')
WHEN #{groupType} = 2 THEN DATE_FORMAT(CONCAT(DATE(happen_start_time), ' ', HOUR(happen_start_time), ':', FLOOR(MINUTE(happen_start_time) / 30) * 30), '%Y-%m-%d %H:%i:00') WHEN #{groupType} = 2 THEN TO_CHAR(CONCAT(TO_CHAR(happen_start_time,'YYYY-MM-DD'), ' ', TO_CHAR(happen_start_time,'HH24'), ':', FLOOR(EXTRACT(MINUTE FROM happen_start_time) / 30) * 30), 'YYYY-MM-DD HH24:MI:00')
WHEN #{groupType} = 3 THEN DATE_FORMAT(happen_start_time, '%Y-%m-%d %H:00:00') WHEN #{groupType} = 3 THEN TO_CHAR(happen_start_time, 'YYYY-MM-DD HH24:00:00')
WHEN #{groupType} = 4 THEN DATE_FORMAT(happen_start_time, '%Y-%m-%d 00:00:00') WHEN #{groupType} = 4 THEN TO_CHAR(happen_start_time, 'YYYY-MM-DD 00:00:00')
END) AS unit_time, END) AS unit_time,
event_type, event_type,
COUNT(*) AS total_count, COUNT(*) AS total_count,
...@@ -76,8 +76,8 @@ ...@@ -76,8 +76,8 @@
AND green_id = #{greenId} AND green_id = #{greenId}
</if> </if>
<if test="startTime != null and endTime != null"> <if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime} AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS'))
AND happen_start_time &lt; #{endTime} AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS'))
</if> </if>
GROUP BY unit_time, event_type GROUP BY unit_time, event_type
) t ) t
...@@ -94,8 +94,8 @@ ...@@ -94,8 +94,8 @@
JOIN t_config_event_category t2 ON t1.event_type=t2.event_type JOIN t_config_event_category t2 ON t1.event_type=t2.event_type
WHERE 1=1 WHERE 1=1
<if test="startTime != null and endTime != null"> <if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime} AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS'))
AND happen_start_time &lt;= #{endTime} AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS'))
</if> </if>
<if test="greenId != null and greenId != ''"> <if test="greenId != null and greenId != ''">
AND green_id = #{greenId} AND green_id = #{greenId}
......
...@@ -131,8 +131,8 @@ ...@@ -131,8 +131,8 @@
,#{optimizeCount} ,#{optimizeCount}
,#{optimizeDuration} ,#{optimizeDuration}
,#{statisticTime} ,#{statisticTime}
,#{gmtCreate} ,TO_TIMESTAMP(#{gmtCreate},'YYYY-MM-DD HH24:MI:SS')
,#{gmtModified} ,TO_TIMESTAMP(#{gmtModified},'YYYY-MM-DD HH24:MI:SS')
,#{type} ,#{type}
) )
</insert> </insert>
......
...@@ -30,61 +30,61 @@ ...@@ -30,61 +30,61 @@
a.type as eventType, a.type as eventType,
a.start_time as happenStartTime, a.start_time as happenStartTime,
a.end_time as happenEndTime, a.end_time as happenEndTime,
TIMESTAMPDIFF(SECOND, a.start_time, a.end_time) as duration, extract(epoch from (a.end_time - a.start_time)) as duration,
a.dir, a.dir,
dt dt
from t_event_info a from t_event_info a
where 1=1 where 1=1
<choose> <choose>
<when test="dtStart !=null and dtEnd!=null"> <when test="dtStart !=null and dtEnd!=null">
and a.dt >= #{dtStart} and a.dt &lt;= #{dtEnd} and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when> </when>
<otherwise> <otherwise>
and a.dt = DATE_FORMAT(DATE_sub(now(), INTERVAL 24 HOUR ), '%Y%m%d') and a.dt = CAST(TO_CHAR(DATE_sub(now(), INTERVAL 24 HOUR ), 'YYYYMMDD') AS INT4)
</otherwise> </otherwise>
</choose> </choose>
and a.type in (701, 702, 703, 707) and a.type in ('701', '702', '703', '707')
</select> </select>
<select id="selectGreenEvent" resultMap="AnalysisProblemAndStrategyDayMap"> <select id="selectGreenEvent" resultMap="AnalysisProblemAndStrategyDayMap">
select a.event_serial_number as eventSerialNumber , a.cross_id as crossId ,a.green_id as greenId, select a.event_serial_number as eventSerialNumber , a.cross_id as crossId ,a.green_id as greenId,
a.category as eventCategory,a.type as eventType ,a.start_time as happenStartTime ,a.end_time as happenEndTime, a.category as eventCategory,a.type as eventType ,a.start_time as happenStartTime ,a.end_time as happenEndTime,
TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) as duration , a.dir,dt extract(epoch from (a.end_time - a.start_time)) as duration , a.dir,dt
from t_event_info a from t_event_info a
where 1=1 where 1=1
<choose> <choose>
<when test="dtStart !=null and dtEnd!=null"> <when test="dtStart !=null and dtEnd!=null">
and a.dt >= #{dtStart} and a.dt &lt;= #{dtEnd} and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when> </when>
<otherwise> <otherwise>
and a.dt = DATE_FORMAT(DATE_sub(now(), INTERVAL 24 HOUR ), '%Y%m%d') and a.dt = CASE(TO_CHAR((DATE_sub(now(), INTERVAL 24 HOUR ), 'YYYYMMDD') AS INT4)
</otherwise> </otherwise>
</choose> </choose>
and a.type in (705,706) and a.type in ('705','706')
</select> </select>
<select id="getGreenStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap"> <select id="getGreenStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
select DISTINCT a.control_time as optStartTime, select DISTINCT a.control_time as optStartTime,
DATE_ADD(a.control_time, INTERVAL a.control_duration SECOND ) as optEndTime, a.control_time + a.control_duration * interval '1 second' as optEndTime,
a.control_duration as optDuration a.control_duration as optDuration
from t_strategy_green_opt_hist a from t_strategy_green_opt_hist a
where a.control_time = (select MAX(control_time) where a.control_time = (select MAX(control_time)
from t_strategy_green_opt_hist from t_strategy_green_opt_hist
where green_id = #{greenID} 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(DATE_sub(#{time}, INTERVAL control_duration SECOND), 'YYYY-MM-DD HH24:MI:SS')
and control_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s') and control_time <![CDATA[ <= ]]> TO_TIMESTAMP(#{time}, 'YYYY-MM-DD HH24:MI:SS')
and response_code = 200) and response_code = 200)
and a.green_id = #{greenID} and a.green_id = #{greenID}
</select> </select>
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap"> <select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
select a.issue_time as optStartTime, select a.issue_time as optStartTime,
DATE_ADD(a.issue_time, INTERVAL a.duration SECOND ) as optEndTime, a.issue_time + a.duration * interval '1 second' as optEndTime,
a.duration as optDuration a.duration as optDuration
from t_strategy_cross_result a from t_strategy_cross_result a
where a.event_id = #{eventSerialNumber} where a.event_id = #{eventSerialNumber}
and response_code = 200 and response_code = 200
and dt = DATE_FORMAT(#{time}, '%Y%m%d') and dt = CAST(TO_CHAR(#{time}, 'YYYYMMDD') AS INT4)
and a.cross_id = #{crossID} and a.cross_id = #{crossID}
</select> </select>
...@@ -100,35 +100,33 @@ ...@@ -100,35 +100,33 @@
#{entity.eventSerialNumber}, #{entity.eventSerialNumber},
#{entity.eventCategory}, #{entity.eventCategory},
#{entity.eventType}, #{entity.eventType},
DATE_FORMAT(#{entity.happenStartTime},'%Y-%m-%d %H:%i:%s'), TO_TIMESTAMP(#{entity.happenStartTime},'YYYY-MM-DD HH24:MI:SS'),
DATE_FORMAT(#{entity.happenEndTime},'%Y-%m-%d %H:%i:%s'), TO_TIMESTAMP(#{entity.happenEndTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.duration}, #{entity.duration},
#{entity.optStatus}, #{entity.optStatus},
#{entity.dir}, #{entity.dir},
DATE_FORMAT(#{entity.optStartTime},'%Y-%m-%d %H:%i:%s'), TO_TIMESTAMP(#{entity.optStartTime},'YYYY-MM-DD HH24:MI:SS'),
DATE_FORMAT(#{entity.optEndTime},'%Y-%m-%d %H:%i:%s'), TO_TIMESTAMP(#{entity.optEndTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.optDuration}, #{entity.optDuration},
#{entity.dt}, #{entity.dt},
DATE_FORMAT(#{entity.insertTime},'%Y-%m-%d %H:%i:%s'), TO_TIMESTAMP(#{entity.insertTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.greenId} #{entity.greenId}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE ON CONFLICT (event_type,event_serial_number,dt)
event_serial_number=VALUES(event_serial_number), DO UPDATE SET
cross_id=VALUES(cross_id), cross_id=excluded.cross_id,
event_category=VALUES(event_category), event_category=excluded.event_category,
event_type=VALUES(event_type), happen_start_time=excluded.happen_start_time,
happen_start_time=VALUES(happen_start_time), happen_end_time=excluded.happen_end_time,
happen_end_time=VALUES(happen_end_time), duration=excluded.duration,
duration=VALUES(duration), opt_status=excluded.opt_status,
opt_status=VALUES(opt_status), opt_start_time=excluded.opt_start_time,
dir=VALUES(dir), opt_end_time=excluded.opt_end_time,
opt_start_time=VALUES(opt_start_time), opt_duration=excluded.opt_duration,
opt_end_time=VALUES(opt_end_time), insert_time=excluded.insert_time,
opt_duration=VALUES(opt_duration), green_id=excluded.green_id,
insert_time=VALUES(insert_time), dir=excluded.dir
green_id=VALUES(green_id),
dt=VALUES(dt)
</insert> </insert>
</mapper> </mapper>
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
and tapcd.area_id = #{areaId} and tapcd.area_id = #{areaId}
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
and tapcd.area_id = #{areaId} and tapcd.area_id = #{areaId}
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
and t1.area_id = #{areaId} and t1.area_id = #{areaId}
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="areaId != null and areaId != ''"> <if test="areaId != null and areaId != ''">
and t1.area_id = #{areaId} and t1.area_id = #{areaId}
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="eventType != null and eventType != ''"> <if test="eventType != null and eventType != ''">
and t1.event_type = #{eventType} and t1.event_type = #{eventType}
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
WHERE WHERE
1 = 1 1 = 1
<if test="startTime != null and endTime != ''"> <if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime} and dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if> </if>
<if test="eventType != null and eventType != ''"> <if test="eventType != null and eventType != ''">
and t1.event_type = #{eventType} and t1.event_type = #{eventType}
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
WHERE WHERE
1=1 1=1
<if test="startTime != null and endTime != null"> <if test="startTime != null and endTime != null">
AND issue_time >= #{startTime} AND issue_time >=TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND issue_time &lt; #{endTime} AND issue_time &lt; TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if> </if>
<if test="crossId != null" > <if test="crossId != null" >
AND a.cross_id = #{crossId} AND a.cross_id = #{crossId}
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
<select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo"> <select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT * SELECT *
FROM t_event_optimize_info FROM t_event_optimize_info
WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime}) WHERE (#{startTime} IS NULL OR happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime}) AND (#{endTime} IS NULL OR happen_end_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{crossId} IS NULL OR cross_id = #{crossId}) AND (#{crossId} IS NULL OR cross_id = #{crossId})
AND (#{greenId} IS NULL OR green_id = #{greenId}) AND (#{greenId} IS NULL OR green_id = #{greenId})
AND opt_status != 0 AND opt_status != 0
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap"> <select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a
where a.start_time between TO_TIMESTAMP(#{date},'%Y-%m-%d 00:00:00') and TO_TIMESTAMP(#{date},'%Y-%m-%d 23:59:59') where a.start_time between TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59')
and a.green_id is not null and a.green_id is not null
order by a.green_id,a.road_direction,a.start_time order by a.green_id,a.road_direction,a.start_time
</select> </select>
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
<insert id="insertGreenCongestionPeriodData" parameterType="map"> <insert id="insertGreenCongestionPeriodData" parameterType="map">
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
</select> </select>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<select id="selectGreenTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap"> <select id="selectGreenTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.green_id,t.traffic_index select t.green_id,t.traffic_index
from t_greenwave_hist t from t_greenwave_hist t
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,
traffic_index,travel_time,speed,flow,max_flow,peak_type,year_week,week_start_time,week_end_time,insert_time,traffic_threshold ) traffic_index,travel_time,speed,flow,max_flow,peak_type,year_week,week_start_time,week_end_time,insert_time,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, 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
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment