Commit 68c1f78a authored by duanruiming's avatar duanruiming

[update] 添加开始时间

parent 0af226e5
package net.wanji.databus.dao.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -8,8 +9,11 @@ import java.util.Date;
@Data
public class GreenwaveRealtimePO {
/** 绿波ID */
@ApiModelProperty(name = "绿波ID",notes = "")
@ApiModelProperty(name = "id",notes = "")
@TableId
private Integer id ;
@ApiModelProperty(name = "绿波ID",notes = "")
private Integer greenId;
/** 交通状态:1畅通;2缓行;3拥堵;4严重拥堵;5未知 */
@ApiModelProperty(name = "交通状态:1畅通;2缓行;3拥堵;4严重拥堵;5未知",notes = "")
private Integer status ;
......@@ -51,6 +55,9 @@ public class GreenwaveRealtimePO {
@ApiModelProperty(name = "非协调相位二次排队",notes = "")
private Double uncoordinatePhaseQueue ;
/** 创建时间 */
@ApiModelProperty(name = "数据时间",notes = "")
private Date startTime ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
......
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="net.wanji.databus.dao.entity.GreenwaveHistPO">
<result property="id" column="id"/>
<result property="greenId" column="green_id"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
<result property="trafficIndex" column="traffic_index"/>
......@@ -17,58 +18,71 @@
<result property="cordReliability" column="cord_reliability"/>
<result property="cordQueueRatio" column="cord_queue_ratio"/>
<result property="uncoordinatePhaseQueue" column="uncoordinate_phase_queue"/>
<result property="startTime" column="start_time"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="Base_Column_List">
id,status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability,cord_queue_ratio,uncoordinate_phase_queue,gmt_create,gmt_modified
id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability,cord_queue_ratio,uncoordinate_phase_queue, start_time, gmt_create,gmt_modified
</sql>
<select id="selectRunMonitor" resultType="net.wanji.databus.dao.entity.GreenwaveHistPOExt">
SELECT
DATE_FORMAT(gmt_modified, '%Y-%m-%d %H:00:00') AS hour,
ROUND(AVG(speed)) AS avg_speed,
ROUND(AVG(traffic_index),2) AS congestion_index
FROM
t_greenwave_hist
WHERE
gmt_modified &gt;= DATE_SUB(DATE_FORMAT(#{nowTime}, '%Y-%m-%d %H:00:00'), INTERVAL 10 HOUR)
AND
gmt_modified &lt; DATE_FORMAT(DATE_ADD(#{nowTime}, INTERVAL 1 HOUR), '%Y-%m-%d %H:00:00')
GROUP BY
hour
ORDER BY
hour
SELECT DATE_FORMAT(gmt_modified, '%Y-%m-%d %H:00:00') AS hour,
ROUND(AVG(speed)) AS avg_speed,
ROUND(AVG(traffic_index), 2) AS congestion_index
FROM t_greenwave_hist
WHERE gmt_modified &gt;= DATE_SUB(DATE_FORMAT(#{nowTime}, '%Y-%m-%d %H:00:00'), INTERVAL 10 HOUR)
AND gmt_modified &lt; DATE_FORMAT(DATE_ADD(#{nowTime}, INTERVAL 1 HOUR), '%Y-%m-%d %H:00:00')
GROUP BY hour
ORDER BY hour
</select>
<select id="selectByTimeSection" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select t1.id,t1.status,t1.type,t1.traffic_index,t1.speed,t1.trval_time,t1.stop_times,t1.queue_length,
t1.cong_rate,t1.delay_time,t1.nopark_pass_rate,t1.cord_reliability,t1.cord_queue_ratio,
t1.uncoordinate_phase_queue,t1.gmt_create,t1.gmt_modified, t2.name as greenwaveName, t2.dir, t2.section_id
from t_greenwave_hist t1 join t_greenwave_info t2 on t1.id = t2.id
select t1.id,
t1.status,
t1.type,
t1.traffic_index,
t1.speed,
t1.trval_time,
t1.stop_times,
t1.queue_length,
t1.cong_rate,
t1.delay_time,
t1.nopark_pass_rate,
t1.cord_reliability,
t1.cord_queue_ratio,
t1.uncoordinate_phase_queue,
t1.gmt_create,
t1.gmt_modified,
t2.name as greenwaveName,
t2.dir,
t2.section_id
from t_greenwave_hist t1
join t_greenwave_info t2 on t1.id = t2.id
where t1.gmt_modified <![CDATA[ <= ]]> #{endTimeStr}
and t1.gmt_modified <![CDATA[ >= ]]> #{startTimeStr}
</select>
<select id="selectByIdAndTimeSection" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select <include refid="Base_Column_List"/>
select
<include refid="Base_Column_List"/>
from t_greenwave_hist
where id = #{greenwaveId}
and gmt_modified <![CDATA[ <= ]]> #{endTimeStr}
and gmt_modified <![CDATA[ >= ]]> #{startTimeStr}
and gmt_modified <![CDATA[ <= ]]> #{endTimeStr}
and gmt_modified <![CDATA[ >= ]]> #{startTimeStr}
</select>
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveHistPO">
insert into t_greenwave_realtime (status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability,cord_queue_ratio,uncoordinate_phase_queue)
insert into t_greenwave_hist
(<include refid="Base_Column_List"/>)
values
<foreach collection="list" item="entity" separator="," open="(" close=")">
#{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
<foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified})
</foreach>
</insert>
......
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
<result property="id" column="id"/>
<result property="greenId" column="green_id"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
<result property="trafficIndex" column="traffic_index"/>
......@@ -17,32 +18,32 @@
<result property="cordReliability" column="cord_reliability"/>
<result property="cordQueueRatio" column="cord_queue_ratio"/>
<result property="uncoordinatePhaseQueue" column="uncoordinate_phase_queue"/>
<result property="startTime" column="start_time"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="baseColumnList">
id,status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability, cord_queue_ratio, uncoordinate_phase_queue,gmt_create,gmt_modified
<sql id="Base_Column_List">
id, green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability, cord_queue_ratio, uncoordinate_phase_queue, start_time, gmt_create,gmt_modified
</sql>
<select id="selectById" resultType="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
select
<include refid="baseColumnList"/>
<include refid="Base_Column_List"/>
from t_greenwave_realtime
where id = #{id}
</select>
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
insert into t_greenwave_realtime
(status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability, cord_queue_ratio, uncoordinate_phase_queue)
(<include refid="Base_Column_List"></include>)
values
<foreach collection="list" item="entity" separator="," open="(" close=")">
#{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
<foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified})
</foreach>
</insert>
......
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