Commit 38369168 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/traffic-signal-platform-国产化' into traffic-signal-platform-国产化

parents 2c97986a cbcd31bb
......@@ -7,8 +7,8 @@
FROM t_event_optimize_info
WHERE 1=1
<if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime}
AND happen_start_time &lt;= #{endTime}
AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="crossId != null">
AND cross_id = #{crossId}
......@@ -39,8 +39,8 @@
<select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT *
FROM t_event_optimize_info
WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime})
AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime})
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;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{crossId} IS NULL OR cross_id = #{crossId})
AND (#{greenId} IS NULL OR green_id = #{greenId})
AND opt_status != 0
......@@ -49,7 +49,7 @@
<select id="getCrossOptimizeDistribute" parameterType="map" resultType="java.util.Map">
SELECT
(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
END) AS time_label,
event_type,
......@@ -58,11 +58,11 @@
FROM (
SELECT
(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} = 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} = 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} = 3 THEN DATE_FORMAT(happen_start_time, '%Y-%m-%d %H:00:00')
WHEN #{groupType} = 4 THEN DATE_FORMAT(happen_start_time, '%Y-%m-%d 00:00: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 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 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 TO_CHAR(happen_start_time, 'YYYY-MM-DD HH24:00:00')
WHEN #{groupType} = 4 THEN TO_CHAR(happen_start_time, 'YYYY-MM-DD 00:00:00')
END) AS unit_time,
event_type,
COUNT(*) AS total_count,
......@@ -76,8 +76,8 @@
AND green_id = #{greenId}
</if>
<if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime}
AND happen_start_time &lt; #{endTime}
AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS'))
AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS'))
</if>
GROUP BY unit_time, event_type
) t
......@@ -94,8 +94,8 @@
JOIN t_config_event_category t2 ON t1.event_type=t2.event_type
WHERE 1=1
<if test="startTime != null and endTime != null">
AND happen_start_time >= #{startTime}
AND happen_start_time &lt;= #{endTime}
AND happen_start_time >= TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS'))
AND happen_start_time &lt;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS'))
</if>
<if test="greenId != null and greenId != ''">
AND green_id = #{greenId}
......
......@@ -131,8 +131,8 @@
,#{optimizeCount}
,#{optimizeDuration}
,#{statisticTime}
,#{gmtCreate}
,#{gmtModified}
,TO_TIMESTAMP(#{gmtCreate},'YYYY-MM-DD HH24:MI:SS')
,TO_TIMESTAMP(#{gmtModified},'YYYY-MM-DD HH24:MI:SS')
,#{type}
)
</insert>
......
......@@ -30,61 +30,61 @@
a.type as eventType,
a.start_time as happenStartTime,
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,
dt
from t_event_info a
where 1=1
<choose>
<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>
<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>
</choose>
and a.type in (701, 702, 703, 707)
and a.type in ('701', '702', '703', '707')
</select>
<select id="selectGreenEvent" resultMap="AnalysisProblemAndStrategyDayMap">
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,
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
where 1=1
<choose>
<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>
<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>
</choose>
and a.type in (705,706)
and a.type in ('705','706')
</select>
<select id="getGreenStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
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
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[ >= ]]> DATE_FORMAT(DATE_sub(#{time}, INTERVAL control_duration SECOND), 'YYYY-MM-DD HH24:MI:SS')
and control_time <![CDATA[ <= ]]> TO_TIMESTAMP(#{time}, 'YYYY-MM-DD HH24:MI:SS')
and response_code = 200)
and a.green_id = #{greenID}
</select>
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
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
from t_strategy_cross_result a
where a.event_id = #{eventSerialNumber}
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}
</select>
......@@ -100,35 +100,33 @@
#{entity.eventSerialNumber},
#{entity.eventCategory},
#{entity.eventType},
DATE_FORMAT(#{entity.happenStartTime},'%Y-%m-%d %H:%i:%s'),
DATE_FORMAT(#{entity.happenEndTime},'%Y-%m-%d %H:%i:%s'),
TO_TIMESTAMP(#{entity.happenStartTime},'YYYY-MM-DD HH24:MI:SS'),
TO_TIMESTAMP(#{entity.happenEndTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.duration},
#{entity.optStatus},
#{entity.dir},
DATE_FORMAT(#{entity.optStartTime},'%Y-%m-%d %H:%i:%s'),
DATE_FORMAT(#{entity.optEndTime},'%Y-%m-%d %H:%i:%s'),
TO_TIMESTAMP(#{entity.optStartTime},'YYYY-MM-DD HH24:MI:SS'),
TO_TIMESTAMP(#{entity.optEndTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.optDuration},
#{entity.dt},
DATE_FORMAT(#{entity.insertTime},'%Y-%m-%d %H:%i:%s'),
TO_TIMESTAMP(#{entity.insertTime},'YYYY-MM-DD HH24:MI:SS'),
#{entity.greenId}
)
</foreach>
ON DUPLICATE KEY UPDATE
event_serial_number=VALUES(event_serial_number),
cross_id=VALUES(cross_id),
event_category=VALUES(event_category),
event_type=VALUES(event_type),
happen_start_time=VALUES(happen_start_time),
happen_end_time=VALUES(happen_end_time),
duration=VALUES(duration),
opt_status=VALUES(opt_status),
dir=VALUES(dir),
opt_start_time=VALUES(opt_start_time),
opt_end_time=VALUES(opt_end_time),
opt_duration=VALUES(opt_duration),
insert_time=VALUES(insert_time),
green_id=VALUES(green_id),
dt=VALUES(dt)
ON CONFLICT (event_type,event_serial_number,dt)
DO UPDATE SET
cross_id=excluded.cross_id,
event_category=excluded.event_category,
happen_start_time=excluded.happen_start_time,
happen_end_time=excluded.happen_end_time,
duration=excluded.duration,
opt_status=excluded.opt_status,
opt_start_time=excluded.opt_start_time,
opt_end_time=excluded.opt_end_time,
opt_duration=excluded.opt_duration,
insert_time=excluded.insert_time,
green_id=excluded.green_id,
dir=excluded.dir
</insert>
</mapper>
\ No newline at end of file
......@@ -12,7 +12,7 @@
WHERE
1 = 1
<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 test="areaId != null and areaId != ''">
and tapcd.area_id = #{areaId}
......@@ -27,7 +27,7 @@
WHERE
1 = 1
<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 test="areaId != null and areaId != ''">
and tapcd.area_id = #{areaId}
......@@ -48,7 +48,7 @@
WHERE
1 = 1
<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 test="areaId != null and areaId != ''">
and t1.area_id = #{areaId}
......@@ -66,7 +66,7 @@
WHERE
1 = 1
<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 test="areaId != null and areaId != ''">
and t1.area_id = #{areaId}
......@@ -88,7 +88,7 @@
WHERE
1 = 1
<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 test="eventType != null and eventType != ''">
and t1.event_type = #{eventType}
......@@ -113,7 +113,7 @@
WHERE
1 = 1
<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 test="eventType != null and eventType != ''">
and t1.event_type = #{eventType}
......
......@@ -185,7 +185,7 @@
WHERE
1=1
<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 test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
......@@ -202,8 +202,8 @@
dir,
t1.cross_id,
sum(event_number)AS 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
......@@ -220,7 +220,7 @@
and t1.event_type = #{eventType}
</if>
GROUP BY
DATE_FORMAT(t1.window_start_time,'%H:%i')
TO_CHAR(t1.window_start_time,'HH24:MI')
ORDER BY event_number desc
limit 1
</select>
......@@ -231,7 +231,7 @@
dir,
t1.cross_id,
sum(event_number)AS event_number ,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time,
TO_CHAR(t1.window_start_time,'HH24:MI') AS hours_window_start_time,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1
......@@ -239,7 +239,7 @@
WHERE
1=1
<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 test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
......@@ -301,7 +301,7 @@
and t1.cross_id = #{nextCrossid}
</if>
<if test="startTimeAll != null and endTimeALL !=null ">
and start_time >= #{startTimeAll} AND start_time &lt;= #{endTimeALL}
and start_time >= TO_TIMESTAMP(#{startTimeAll},'YYYY-MM-DD HH24:MI:SS') AND start_time &lt;= TO_TIMESTAMP(#{endTimeALL},'YYYY-MM-DD HH24:MI:SS')
</if>
</select>
<select id="getCrossTurnInfo" parameterType="map" resultType="CrossTurnInfo">
......@@ -326,7 +326,7 @@
and b.cross_id = #{crossId}
</if>
<if test="startTimeAll!=null and endTimeALL!=null ">
AND b.start_time >= #{startTimeAll} and b.start_time &lt;= #{endTimeALL}
AND b.start_time >= TO_TIMESTAMP(#{startTimeAll},'YYYY-MM-DD HH24:MI:SS') AND b.start_time &lt;= TO_TIMESTAMP(#{endTimeALL},'YYYY-MM-DD HH24:MI:SS')
</if>
AND (in_dir,turn_type) in (
<foreach collection="crossTurnInfo" item="pair" open="(" separator="),(" close=")">
......@@ -341,7 +341,7 @@
VALUES
<foreach collection="crossHourOverFlowList" item="item" separator=",">
(#{item.crossId},#{item.overflowDir},#{item.outFlowSum},#{item.outFlowAvg},#{item.nextCrossLaneNum},#{item.nextCrossCapacity},
#{item.lengthToNextCross}, #{item.overflowStartTime}, #{item.overflowEndTime}, #{item.overflowNum}, #{item.dt})
#{item.lengthToNextCross}, TO_TIMESTAMP(#{item.overflowStartTime},'YYYY-MM-DD HH24:MI:SS'), TO_TIMESTAMP(#{item.overflowEndTime},'YYYY-MM-DD HH24:MI:SS'), #{item.overflowNum}, #{item.dt})
</foreach>
</select>
......
......@@ -167,61 +167,55 @@
<!-- 新增表t_analysis_problem_green_day信息 -->
<insert id="insertAnalysisProblemGreenDay">
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(), a.green_id, b.area_id,a.category,a.type,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) ) as duration ,
select uuid_generate_v4(), a.green_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 ,
dt , now()
from t_event_info a
left join t_greenwave_info b on a.green_id = b.id
where dt = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d') 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
ON DUPLICATE KEY UPDATE
id=VALUES(id),
green_id=VALUES(green_id),
area_id=VALUES(area_id),
event_category=VALUES(event_category),
event_type=VALUES(event_type),
event_number=VALUES(event_number),
event_total_time=VALUES(event_total_time),
window_start_time=VALUES(window_start_time),
window_end_time=VALUES(window_end_time),
dt=VALUES(dt),
insert_time=VALUES(insert_time)
ON CONFLICT (green_id,event_type,dt)
DO UPDATE SET
id=excluded.id,
area_id=excluded.area_id,
event_category=excluded.event_category,
event_number=excluded.event_number,
event_total_time=excluded.event_total_time,
window_start_time=excluded.window_start_time,
window_end_time=excluded.window_end_time,
insert_time=excluded.insert_time
</insert>
<!-- 新增表t_analysis_problem_green_hour信息 -->
<insert id="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)
select uuid(), d.green_id, e.area_id,d.category,d.type,d.dir,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, d.start_time , d.end_time) ) as duration ,
DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 HOUR),'%Y-%m-%d %H:00:00') as dh1, DATE_FORMAT(now(),'%Y-%m-%d %H:00:00') as dh2,
DATE_FORMAT(now(),'%Y%m%d') as dt , now()
select uuid_generate_v4(), d.green_id, e.area_id,d.category,d.type,d.dir,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, d.start_time , d.end_time) ) as duration ,
DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 HOUR),'YYYY-MM-DD HH24:00:00') as dh1, DATE_FORMAT(now(),'YYYY-MM-DD HH24:00:00') as dh2,
DATE_FORMAT(now(),'YYYYMMDD') as dt , now()
from
(select DISTINCT b.green_id,b.category,b.type,b.start_time,b.end_time, SUBSTRING_INDEX( SUBSTRING_INDEX( b.dir, ',', c.help_topic_id + 1 ), ',', -1 ) AS dir
(select DISTINCT b.green_id,b.category,b.type,b.start_time,b.end_time, unnest(string_to_array(dir, ',')) AS dir
from
(select a.green_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir
from t_event_info a
where DATE_FORMAT(a.start_time,'%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 HOUR),'%Y-%m-%d %H:00:00')
and DATE_FORMAT(a.start_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ < ]]> DATE_FORMAT(now(),'%Y-%m-%d %H:00:00')
and a.type in (705,706) and a.green_id != ''
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')
and a.type in ('705','706') and a.green_id != ''
and a.dir is not null
and length(a.dir)>2
) b
INNER JOIN mysql.help_topic c ON c.help_topic_id <![CDATA[ < ]]> (
LENGTH( b.dir ) - LENGTH( REPLACE(b.dir,',','') ) + 1
)) d
) d
left join t_greenwave_info e on d.green_id = e.id
group by d.green_id, e.area_id,d.category,d.type,d.dir
ON DUPLICATE KEY UPDATE
id=VALUES(id),
green_id=VALUES(green_id),
area_id=VALUES(area_id),
event_category=VALUES(event_category),
event_type=VALUES(event_type),
dir=VALUES(dir),
event_number=VALUES(event_number),
event_total_time=VALUES(event_total_time),
window_start_time=VALUES(window_start_time),
window_end_time=VALUES(window_end_time),
dt=VALUES(dt),
insert_time=VALUES(insert_time)
ON CONFLICT (dir,green_id,dt,event_type,window_start_time)
DO UPDATE SET
id=excluded.id,
area_id=excluded.area_id,
event_category=excluded.event_category,
dir=excluded.dir,
event_number=excluded.event_number,
event_total_time=excluded.event_total_time,
window_end_time=excluded.window_end_time,
insert_time=excluded.insert_time
;
</insert>
......@@ -229,7 +223,7 @@
<select id="checkData" resultMap="AnalysisProblemGreenDayMap">
SELECT dt
FROM t_analysis_problem_green_day
WHERE dt = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 DAY),'%Y%m%d')
WHERE dt = cast(to_char(DATE_SUB(now(),INTERVAL 1 DAY),'YYYYMMDD') as int4)
</select>
<select id="getListGreenByProblemSum" parameterType="map" resultMap="AnalysisProblemGreenDayMap">
......@@ -244,7 +238,7 @@
1=1
<if test="startTime!=null and endTime!=''">
<![CDATA[
AND dt>=#{startTime} AND dt<=#{endTime}
AND dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
]]>
</if>
<if test="greenId!=null and greenId!=''">
......@@ -266,7 +260,7 @@
WHERE
1 = 1
<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 test="greenId != null and greenId != ''">
and t1.green_id = #{greenId}
......
......@@ -165,12 +165,12 @@
,#{eventType}
,#{eventNumber}
,#{eventTotalTime}
,#{windowStartTime}
,#{windowEndTime}
,to_timestamp(#{windowStartTime},'YYYY-MM-DD HH24:MI:SS')
,to_timestamp(#{windowEndTime},'YYYY-MM-DD HH24:MI:SS')
,#{greenId}
,#{dir}
,#{dt}
,#{insertTime}
,o_timestamp(#{insertTime},'YYYY-MM-DD HH24:MI:SS')
)
</insert>
......@@ -178,7 +178,7 @@
SELECT
t1.green_id,
t2.cross_id,
t3.`name` as crossname,
t3.name as crossname,
t2.event_type,
t4.label typeName,
dt,
......@@ -191,7 +191,7 @@
WHERE
1=1
<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 test="greenId!=null and greenId!=''">
AND t1.green_id= #{greenId}
......@@ -207,7 +207,7 @@
dt,
dir,
sum(event_number)AS event_number ,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
to_char(t1.window_start_time,'HH24:MI') AS hours_window_start_time ,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_green_hour t1
......@@ -245,7 +245,7 @@
WHERE
1=1
<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 test="greenId!=null and greenId!=''">
AND t1.green_id= #{greenId}
......@@ -275,7 +275,7 @@
WHERE
1=1
<if test="startTime!=null and endTime!=null">
AND dt>= #{startTime} and dt &lt;= #{endTime}
AND dt >= CAST(#{startTime} AS INT4) and dt &lt;= CAST(#{endTime} AS INT4)
</if>
GROUP BY
cross_id,
......
......@@ -6,11 +6,11 @@
</select>
<select id="getSpecialDate" resultType="java.util.Map">
SELECT DATE_FORMAT(special_date, '%Y-%m-%d %H:%i:%s') AS special_date, plan_id
SELECT to_char(special_date, 'YYYY-MM-DD HH24:MI:SS') AS special_date, plan_id
FROM t_base_cross_schedules_plan
WHERE cross_id = #{crossId}
<if test="endTime != null and endTime != '' and startTime != null and startTime !='' ">
and special_date between #{startTime} and #{endTime}
and special_date between to_timestamp(#{startTime}, 'YYYY-MM-DD HH24:MI:SS') and to_timestamp(#{endTime}, 'YYYY-MM-DD HH24:MI:SS')
</if>
AND week = 0
</select>
......
......@@ -256,9 +256,9 @@
,#{travelTime}
,#{speed}
,#{yearWeek}
,#{weekStartTime}
,#{weekEndTime}
,#{insertTime}
,to_timestamp(#{weekStartTime}, 'YYYY-MM-DD HH24:MI:SS')
,to_timestamp(#{weekEndTime}, 'YYYY-MM-DD HH24:MI:SS')
,to_timestamp(#{insertTime}, 'YYYY-MM-DD HH24:MI:SS')
,#{congestIndex}
,#{lastWeekCongestIndex},#{lastWeekCapacity},#{lastWeekStopTimes},#{lastWeekDelayTime},#{lastWeekTravelTime},#{lastWeekSpeed}
)
......@@ -297,8 +297,8 @@
#{entity.greenId}
,#{entity.roadDirection}
,#{entity.weekDay}
,#{entity.optimizeStartTime}
,#{entity.optimizeEndTime}
,to_timestamp(#{entity.optimizeStartTime}, 'YYYY-MM-DD HH24:MI:SS')
,to_timestamp(#{entity.optimizeEndTime}, 'YYYY-MM-DD HH24:MI:SS')
,#{entity.stragetyId}
,#{entity.optimizeCount}
,#{entity.optimizeDuration}
......@@ -308,9 +308,9 @@
,#{entity.travelTime}
,#{entity.speed}
,#{entity.yearWeek}
,#{entity.weekStartTime}
,to_timestamp(#{entity.weekStartTime}, 'YYYY-MM-DD HH24:MI:SS')
,#{entity.weekEndTime}
,#{entity.insertTime}
,to_timestamp(#{entity.insertTime}, 'YYYY-MM-DD HH24:MI:SS')
,#{entity.congestIndex}
,#{entity.lastWeekCongestIndex}
,#{entity.lastWeekCapacity}
......@@ -320,32 +320,29 @@
,#{entity.lastWeekSpeed}
)
</foreach>
ON DUPLICATE KEY UPDATE
green_id = VALUES(green_id),
road_direction = VALUES(road_direction),
week_day = VALUES(week_day),
optimize_start_time = VALUES(optimize_start_time),
optimize_end_time = VALUES(optimize_end_time),
stragety_id = VALUES(stragety_id),
optimize_count = VALUES(optimize_count),
optimize_duration = VALUES(optimize_duration),
capacity = VALUES(capacity),
stop_times = VALUES(stop_times),
delay_time = VALUES(delay_time),
delay_time = VALUES(delay_time),
travel_time = VALUES(travel_time),
speed = VALUES(speed),
year_week = VALUES(year_week),
week_start_time = VALUES(week_start_time),
week_end_time = VALUES(week_end_time),
insert_time = VALUES(insert_time),
congest_index = VALUES(congest_index),
last_week_congest_index = VALUES(last_week_congest_index),
last_week_capacity = VALUES(last_week_capacity),
last_week_stop_times = VALUES(last_week_stop_times),
last_week_delay_time = VALUES(last_week_delay_time),
last_week_travel_time = VALUES(last_week_travel_time),
last_week_speed = VALUES(last_week_speed)
ON CONFLICT (year_week,green_id,road_direction,week_day,optimize_start_time)
DO UPDATE SET
optimize_end_time = excluded.optimize_end_time,
stragety_id = excluded.stragety_id,
optimize_count = excluded.optimize_count,
optimize_duration = excluded.optimize_duration,
capacity = excluded.capacity,
stop_times = excluded.stop_times,
delay_time = excluded.delay_time,
delay_time = excluded.delay_time,
travel_time = excluded.travel_time,
speed = excluded.speed,
year_week = excluded.year_week,
week_start_time = excluded.week_start_time,
week_end_time = excluded.week_end_time,
insert_time = excluded.insert_time,
congest_index = excluded.congest_index,
last_week_congest_index = excluded.last_week_congest_index,
last_week_capacity = excluded.last_week_capacity,
last_week_stop_times = excluded.last_week_stop_times,
last_week_delay_time = excluded.last_week_delay_time,
last_week_travel_time = excluded.last_week_travel_time,
last_week_speed = excluded.last_week_speed
</insert>
......
......@@ -37,7 +37,7 @@
from t_analysis_green_wave_congest_time_span
where
year_week=#{yearWeek} and green_id=#{greenId}
and congest_start_time > #{peakStartTime} and congest_end_time &lt; #{peakEndTime}
and congest_start_time > to_timestamp(#{peakStartTime},'YYYY-MM-DD HH24:00:00') and congest_end_time &lt; to_timestamp(#{peakEndTime},'YYYY-MM-DD HH24:00:00')
<!-- and status=3 -->
</select>
......@@ -51,8 +51,8 @@
#{greenId}
,#{roadDirection}
,#{weekDay}
,#{peakStartTime}
,#{peakEndTime}
,to_timestamp(#{peakStartTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{peakEndTime},'YYYY-MM-DD HH24:00:00')
,#{trafficIndex}
,#{status}
,#{travelTime}
......@@ -60,9 +60,9 @@
,#{flow}
,#{peakType}
,#{yearWeek}
,#{weekStartTime}
,#{weekEndTime}
,#{insertTime}
,to_timestamp(#{weekStartTime} ,'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{weekEndTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{insertTime},'YYYY-MM-DD HH24:00:00')
)
</insert>
......
......@@ -240,8 +240,8 @@
) VALUES (
#{crossId}
,#{weekDay}
,#{optimizeStartTime}
,#{optimizeEndTime}
,to_timestamp(#{optimizeStartTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{optimizeEndTime},'YYYY-MM-DD HH24:00:00')
,#{stragetyId}
,#{optimizeCount}
,#{optimizeDuration}
......@@ -250,9 +250,9 @@
,#{delayTime}
,#{maxQueueLength}
,#{yearWeek}
,#{weekStartTime}
,#{weekEndTime}
,#{insertTime}
,to_timestamp(#{weekStartTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{weekEndTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{insertTime},'YYYY-MM-DD HH24:00:00')
,#{lastWeekCapacity}
,#{lastWeekStopTimes}
,#{lastWeekDelayTime}
......@@ -296,8 +296,8 @@
(
#{entity.crossId}
,#{entity.weekDay}
,#{entity.optimizeStartTime}
,#{entity.optimizeEndTime}
,to_timestamp(#{entity.optimizeStartTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{entity.optimizeEndTime},'YYYY-MM-DD HH24:00:00')
,#{entity.stragetyId}
,#{entity.optimizeCount}
,#{entity.optimizeDuration}
......@@ -306,9 +306,9 @@
,#{entity.delayTime}
,#{entity.maxQueueLength}
,#{entity.yearWeek}
,#{entity.weekStartTime}
,#{entity.weekEndTime}
,#{entity.insertTime}
,to_timestamp(#{entity.weekStartTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{entity.weekEndTime},'YYYY-MM-DD HH24:00:00')
,to_timestamp(#{entity.insertTime},'YYYY-MM-DD HH24:00:00')
,#{entity.lastWeekCapacity}
,#{entity.lastWeekStopTimes}
,#{entity.lastWeekDelayTime}
......@@ -322,32 +322,28 @@
,#{entity.lastWeekProblemCount}
)
</foreach>
ON DUPLICATE KEY UPDATE
cross_id = VALUES(cross_id),
week_day = VALUES(week_day),
optimize_start_time = VALUES(optimize_start_time),
optimize_end_time = VALUES(optimize_end_time),
stragety_id = VALUES(stragety_id),
optimize_count = VALUES(optimize_count),
optimize_duration = VALUES(optimize_duration),
capacity = VALUES(capacity),
stop_times = VALUES(stop_times),
delay_time = VALUES(delay_time),
max_queue_length = VALUES(max_queue_length),
year_week = VALUES(year_week),
week_start_time = VALUES(week_start_time),
week_end_time = VALUES(week_end_time),
insert_time = VALUES(insert_time),
last_week_capacity = VALUES(last_week_capacity),
last_week_stop_times = VALUES(last_week_stop_times),
last_week_delay_time = VALUES(last_week_delay_time),
last_week_max_queue_length = VALUES(last_week_max_queue_length),
last_week_speed = VALUES(last_week_speed),
last_week_congest_index = VALUES(last_week_congest_index),
dirs = VALUES(dirs),
problem_count = VALUES(problem_count),
last_week_optimize_count = VALUES(last_week_optimize_count),
last_week_optimize_duration = VALUES(last_week_optimize_duration),
last_week_problem_count = VALUES(last_week_problem_count)
ON CONFLICT (cross_id,year_week,week_day,optimize_start_time,stragety_id)
DO UPDATE SET
optimize_end_time = excluded.optimize_end_time,
optimize_count = excluded.optimize_count,
optimize_duration = excluded.optimize_duration,
capacity = excluded.capacity,
stop_times = excluded.stop_times,
delay_time = excluded.delay_time,
max_queue_length = excluded.max_queue_length,
week_start_time = excluded.week_start_time,
week_end_time = excluded.week_end_time,
insert_time = excluded.insert_time,
last_week_capacity = excluded.last_week_capacity,
last_week_stop_times = excluded.last_week_stop_times,
last_week_delay_time = excluded.last_week_delay_time,
last_week_max_queue_length = excluded.last_week_max_queue_length,
last_week_speed = excluded.last_week_speed,
last_week_congest_index = excluded.last_week_congest_index,
dirs = excluded.dirs,
problem_count = excluded.problem_count,
last_week_optimize_count = excluded.last_week_optimize_count,
last_week_optimize_duration = excluded.last_week_optimize_duration,
last_week_problem_count = excluded.last_week_problem_count
</insert>
</mapper>
......@@ -26,26 +26,27 @@
#{item.maxCongestionPeriod},
#{item.secondCongestionPeriod},
#{item.dayType},
#{item.startTime},
#{item.endTime},
to_timestamp(#{item.startTime},'YYYY-MM-DD HH24:00:00'),
to_timestamp(#{item.endTime},'YYYY-MM-DD HH24:00:00'),
#{item.yearWeek},
#{item.insertTime}
to_timestamp(#{item.insertTime},'YYYY-MM-DD HH24:00:00')
)
</foreach>
ON DUPLICATE KEY UPDATE
congest_index = VALUES(congest_index),
max_congest_index = VALUES(max_congest_index),
congest_count = VALUES(congest_count),
congest_duration = VALUES(congest_duration),
max_congest_duration = VALUES(max_congest_duration),
flow = VALUES(flow),
travel_time = VALUES(travel_time),
speed = VALUES(speed),
max_congestion_period = VALUES(max_congestion_period),
second_congestion_period = VALUES(second_congestion_period),
start_time = VALUES(start_time),
end_time = VALUES(end_time),
insert_time = VALUES(insert_time);
ON CONFLICT (green_id,peak_type,day_type,year_week,road_direction)
DO UPDATE SET
congest_index = excluded.congest_index,
max_congest_index = excluded.max_congest_index,
congest_count = excluded.congest_count,
congest_duration = excluded.congest_duration,
max_congest_duration = excluded.max_congest_duration,
flow = excluded.flow,
travel_time = excluded.travel_time,
speed = excluded.speed,
max_congestion_period = excluded.max_congestion_period,
second_congestion_period = excluded.second_congestion_period,
start_time = excluded.start_time,
end_time = excluded.end_time,
insert_time = excluded.insert_time;
</insert>
<!-- 基本的 CRUD 方法由 MyBatis-Plus 自动生成,无需手动编写 -->
......@@ -54,19 +55,27 @@
select * from t_config_peak_hours;
</select>
<select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3 and status &lt;=4)*60*5 congest_duration,avg(speed) speed,avg(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,
sum(status>=3 and status &lt;=4)*60*5 congest_duration,avg(speed) speed,avg(trval_time) travel_time
from t_greenwave_hist
where to_timestamp(start_time,'YYYY-MM-DD') BETWEEN to_timestamp(#{startDate},'YYYY-MM-DD') AND to_timestamp(#{endDate},'YYYY-MM-DD')
AND to_timestamp( start_time,'HH24:MI:SS' ) BETWEEN to_timestamp(#{startTime},'HH24:MI:SS' ) AND to_timestamp(#{endTime} ,'HH24:MI:SS' )
GROUP BY green_id,road_direction
</select>
<select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3 and status&lt;=4)*60*5 congest_duration,avg(speed) speed,avg(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} GROUP BY green_id,road_direction
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,
sum(status>=3 and status&lt;=4)*60*5 congest_duration,avg(speed) speed,avg(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN to_timestamp(#{startDate},'YYYY-MM-DD HH24:MI:SS') AND to_timestamp(#{endDate} ,'YYYY-MM-DD HH24:MI:SS')
GROUP BY green_id,road_direction
</select>
<select id="getFlow" resultType="java.lang.Integer">
SELECT COALESCE(flow, 0) from
(select cross_id from t_greenwave_cross where green_id = #{greenId} and is_key_route = 1 limit 1) cross_data
left join
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} AND #{endDate} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist
where start_time BETWEEN to_timestamp(#{startDate},'YYYY-MM-DD HH24:MI:SS') AND to_timestamp(#{endDate} ,'YYYY-MM-DD HH24:MI:SS')
and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
</select>
<select id="getFlowByTime" resultType="java.lang.Integer">
......@@ -78,7 +87,7 @@
<select id="selectAllByTime" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select * from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate}
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and TIME( start_time ) BETWEEN #{startTime} AND #{endTime}
and to_timestamp( start_time,'HH24:MI:SS' ) BETWEEN to_timestamp(#{startTime},'HH24:MI:SS' ) AND to_timestamp(#{endTime} ,'HH24:MI:SS' )
</if>
and green_id = #{greenId}
and status >= 3 and status &lt;= 4 and road_direction = #{roadDirection} order by start_time
......
......@@ -115,7 +115,7 @@
DISTINCT
t4.`name` as waveName, t3.`name` as crossName,
t3.id as crossId,
GROUP_CONCAT(t2.daily_plan_details SEPARATOR ', ') AS dailyPlanDetails
STRING_AGG(t2.daily_plan_details , ', ') AS dailyPlanDetails
FROM
t_base_cross_info t3
LEFT JOIN t_strategy_priority_daily_info t2 on t3.id = t2.cross_id
......
......@@ -21,7 +21,7 @@
select
id,event_id,event_desc,type,start_time,end_time,source,wkt,image_url,gmt_create,gmt_modified
from t_event_data
where to_days(#{todayTime}) = to_days(start_time)
where TO_CHAR(#{todayTime},'YYYY-MM-DD') = TO_CHAR(start_time,'YYYY-MM-DD')
order by start_time desc;
</select>
......
......@@ -51,8 +51,8 @@
WHERE
1=1
<if test="startTime != null and endTime != null">
AND issue_time >= #{startTime}
AND issue_time &lt; #{endTime}
AND issue_time >=TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS')
AND issue_time &lt; TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="crossId != null" >
AND a.cross_id = #{crossId}
......@@ -63,8 +63,8 @@
<select id="selectPageWithCrossIdAndGreenId" parameterType="map" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT *
FROM t_event_optimize_info
WHERE (#{startTime} IS NULL OR happen_start_time >= #{startTime})
AND (#{endTime} IS NULL OR happen_end_time &lt;= #{endTime})
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;= TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
AND (#{crossId} IS NULL OR cross_id = #{crossId})
AND (#{greenId} IS NULL OR green_id = #{greenId})
AND opt_status != 0
......
......@@ -24,7 +24,7 @@
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
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
order by a.green_id,a.road_direction,a.start_time
</select>
......@@ -36,10 +36,10 @@
<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)
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()
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},'YYYY-MM-DD') as week_start_time,TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
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 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 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
order by t.green_id,t1.road_direction,t1.dir,t1.turn,t.start_time
</select>
......@@ -56,7 +56,7 @@
<select id="selectGreenTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.green_id,t.traffic_index
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 t.road_direction = #{roadDirection}
order by t.traffic_index desc
......@@ -71,7 +71,7 @@
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 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
</select>
......@@ -79,12 +79,12 @@
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 )
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
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},'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},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
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 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 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
</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