Commit bc941dc0 authored by duanruiming's avatar duanruiming

[add] 周期数据插入时间和修改时间优化

parent 9a62f7df
...@@ -50,6 +50,8 @@ public class CrossDataRealtimePO { ...@@ -50,6 +50,8 @@ public class CrossDataRealtimePO {
private Date startTime; private Date startTime;
@ApiModelProperty(value = "结束时间:yyyy-MM-dd HH:mm:ss", notes = "") @ApiModelProperty(value = "结束时间:yyyy-MM-dd HH:mm:ss", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime; private Date endTime;
@ApiModelProperty(value = "持续时间(单位:分钟)", notes = "") @ApiModelProperty(value = "持续时间(单位:分钟)", notes = "")
private Integer duration; private Integer duration;
...@@ -149,11 +151,15 @@ public class CrossDataRealtimePO { ...@@ -149,11 +151,15 @@ public class CrossDataRealtimePO {
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间", notes = "") @ApiModelProperty(value = "创建时间", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate; private Date gmtCreate;
/** /**
* 修改时间 * 修改时间
*/ */
@ApiModelProperty(value = "修改时间", notes = "") @ApiModelProperty(value = "修改时间", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified; private Date gmtModified;
/** /**
* 红灯清空率 * 红灯清空率
......
...@@ -65,8 +65,12 @@ public class CrossDirDataRealtimePO { ...@@ -65,8 +65,12 @@ public class CrossDirDataRealtimePO {
@ApiModelProperty(name = "采集时间(10位时间戳)",notes = "") @ApiModelProperty(name = "采集时间(10位时间戳)",notes = "")
public Integer batchTime; public Integer batchTime;
@ApiModelProperty(name = "创建时间",notes = "") @ApiModelProperty(name = "创建时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
public Date gmtCreate ; public Date gmtCreate ;
@ApiModelProperty(name = "修改时间",notes = "") @ApiModelProperty(name = "修改时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
public Date gmtModified ; public Date gmtModified ;
@ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "") @ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "")
public Double effusionRate; public Double effusionRate;
......
package net.wanji.databus.po; package net.wanji.databus.po;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -61,8 +63,12 @@ public class CrossLaneDataRealTimePO { ...@@ -61,8 +63,12 @@ public class CrossLaneDataRealTimePO {
@ApiModelProperty(name = "采集时间(10位时间戳)",notes = "") @ApiModelProperty(name = "采集时间(10位时间戳)",notes = "")
private Integer batchTime; private Integer batchTime;
@ApiModelProperty(name = "创建时间",notes = "") @ApiModelProperty(name = "创建时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate ; private Date gmtCreate ;
@ApiModelProperty(name = "修改时间",notes = "") @ApiModelProperty(name = "修改时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified ; private Date gmtModified ;
@ApiModelProperty(value = "溢流率", notes = "") @ApiModelProperty(value = "溢流率", notes = "")
private Double effusionRate; private Double effusionRate;
......
...@@ -92,9 +92,13 @@ public class CrossTurnDataRealtimePO { ...@@ -92,9 +92,13 @@ public class CrossTurnDataRealtimePO {
public Integer batchTime ; public Integer batchTime ;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "") @ApiModelProperty(name = "创建时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
public Date gmtCreate ; public Date gmtCreate ;
/** 修改时间 */ /** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "") @ApiModelProperty(name = "修改时间",notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
public Date gmtModified ; public Date gmtModified ;
@ApiModelProperty(value = "绿灯有效利用率", notes = "") @ApiModelProperty(value = "绿灯有效利用率", notes = "")
......
...@@ -75,7 +75,8 @@ ...@@ -75,7 +75,8 @@
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.crossId},#{entity.status},#{entity.type},#{entity.trafficIndex},#{entity.startTime},#{entity.endTime},#{entity.duration},#{entity.isUnbalance},#{entity.isSpillover},#{entity.isCongestion}, (#{entity.crossId},#{entity.status},#{entity.type},#{entity.trafficIndex},#{entity.startTime},#{entity.endTime},#{entity.duration},#{entity.isUnbalance},#{entity.isSpillover},#{entity.isCongestion},
#{entity.unbalanceIndex},#{entity.spilloverIndex},#{entity.congestionIndex},#{entity.unbalanceDirs},#{entity.spilloverDirs},#{entity.congestionDirs}, #{entity.unbalanceIndex},#{entity.spilloverIndex},#{entity.congestionIndex},#{entity.unbalanceDirs},#{entity.spilloverDirs},#{entity.congestionDirs},
#{entity.flow},#{entity.flowRate},#{entity.speed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.flow},#{entity.flowRate},#{entity.speed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.batchTime},
now(),now(),
#{entity.clearRate},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate}, #{entity.clearRate},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate},
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB}, #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},
......
...@@ -75,7 +75,8 @@ ...@@ -75,7 +75,8 @@
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.crossId},#{entity.status},#{entity.type},#{entity.trafficIndex},#{entity.startTime},#{entity.duration},#{entity.isSpillover},#{entity.isSpillover},#{entity.isCongestion}, (#{entity.crossId},#{entity.status},#{entity.type},#{entity.trafficIndex},#{entity.startTime},#{entity.duration},#{entity.isSpillover},#{entity.isSpillover},#{entity.isCongestion},
#{entity.unbalanceIndex},#{entity.spilloverIndex},#{entity.congestionIndex},#{entity.unbalanceDirs},#{entity.spilloverDirs},#{entity.congestionDirs}, #{entity.unbalanceIndex},#{entity.spilloverIndex},#{entity.congestionIndex},#{entity.unbalanceDirs},#{entity.spilloverDirs},#{entity.congestionDirs},
#{entity.flow},#{entity.flowRate},#{entity.speed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.flow},#{entity.flowRate},#{entity.speed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.batchTime},
now(), now(),
#{entity.clearRate},#{entity.endTime},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate}, #{entity.clearRate},#{entity.endTime},#{entity.loadBalance},#{entity.notClearCarNums},#{entity.greenLightEfficiency},#{entity.effusionRate},
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC}, #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC},
......
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="net.wanji.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency,dt </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate},#{entity.greenLightEfficiency}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d') ) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach><!-- and in_out_type = 1--> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <!-- 神思推送数据in_out_type=0 --> <select id="selectDirDataList" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectByCrossIdAndHour" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND start_time >= DATE_SUB( NOW(), INTERVAL #{hour} HOUR ) ORDER BY start_time DESC </select> </mapper> <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="net.wanji.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency,dt </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, now(), now(), #{entity.effusionRate},#{entity.greenLightEfficiency}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d') ) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach><!-- and in_out_type = 1--> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <!-- 神思推送数据in_out_type=0 --> <select id="selectDirDataList" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectByCrossIdAndHour" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND start_time >= DATE_SUB( NOW(), INTERVAL #{hour} HOUR ) ORDER BY start_time DESC </select> </mapper>
\ No newline at end of file \ No newline at end of file
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow},
#{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation},
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime},
#{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate}, #{entity.greenLightEfficiency} ) now(), now(),#{entity.effusionRate}, #{entity.greenLightEfficiency} )
</foreach> </foreach>
</insert> </insert>
......
...@@ -51,7 +51,8 @@ ...@@ -51,7 +51,8 @@
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.crossId},#{entity.flow},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.capacity},#{entity.sturation}, (#{entity.id},#{entity.crossId},#{entity.flow},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.capacity},#{entity.sturation},
#{entity.vehheadDist},#{entity.vehheadTime},#{entity.quality},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.vehheadDist},#{entity.vehheadTime},#{entity.quality},#{entity.batchTime},
now(),now(),
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime},
#{entity.effusionRate},#{entity.greenLightEfficiency},#{entity.vehicleNumsRatioMean},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy}, #{entity.effusionRate},#{entity.greenLightEfficiency},#{entity.vehicleNumsRatioMean},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d') #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d')
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.crossId},#{entity.flow},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.capacity},#{entity.sturation}, (#{entity.id},#{entity.crossId},#{entity.flow},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.capacity},#{entity.sturation},
#{entity.vehheadDist},#{entity.vehheadTime},#{entity.quality},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.vehheadDist},#{entity.vehheadTime},#{entity.quality},#{entity.batchTime},
now(), now(),
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime},
#{entity.effusionRate},#{entity.greenLightEfficiency},#{entity.vehicleNumsRatioMean},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy}, #{entity.effusionRate},#{entity.greenLightEfficiency},#{entity.vehicleNumsRatioMean},#{entity.vehicleLengthRatioMean},#{entity.timeOccupancy},
#{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC}) #{entity.nonMotorFlow},#{entity.v85},#{entity.trafficFlowA},#{entity.trafficFlowB},#{entity.trafficFlowC})
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
(#{entity.id},#{entity.turnType},#{entity.inDir},#{entity.outDir},#{entity.crossId},#{entity.flow}, (#{entity.id},#{entity.turnType},#{entity.inDir},#{entity.outDir},#{entity.crossId},#{entity.flow},
#{entity.status},#{entity.trafficIndex},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed}, #{entity.status},#{entity.trafficIndex},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},
#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.vehheadDist},#{entity.vehheadTime}, #{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.vehheadDist},#{entity.vehheadTime},
#{entity.quality},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.quality},#{entity.batchTime},now(),now(),
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime},
#{entity.greenLightEfficiency},#{entity.effusionRate}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d') #{entity.greenLightEfficiency},#{entity.effusionRate}, DATE_FORMAT(#{entity.startTime}, '%Y%m%d')
) )
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
(#{entity.id},#{entity.turnType},#{entity.inDir},#{entity.outDir},#{entity.crossId},#{entity.flow}, (#{entity.id},#{entity.turnType},#{entity.inDir},#{entity.outDir},#{entity.crossId},#{entity.flow},
#{entity.status},#{entity.trafficIndex},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed}, #{entity.status},#{entity.trafficIndex},#{entity.speed},#{entity.inSpeed},#{entity.outSpeed},
#{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.vehheadDist},#{entity.vehheadTime}, #{entity.queueLength},#{entity.stopTimes},#{entity.delayTime},#{entity.sturation},#{entity.vehheadDist},#{entity.vehheadTime},
#{entity.quality},#{entity.batchTime},#{entity.gmtCreate},#{entity.gmtModified}, #{entity.quality},#{entity.batchTime},now(),now(),
#{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.startTime},
#{entity.greenLightEfficiency},#{entity.effusionRate}) #{entity.greenLightEfficiency},#{entity.effusionRate})
</foreach> </foreach>
......
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