Commit ea29bad8 authored by duwei's avatar duwei

优化交通指标查询

parent b9b4bb6d
......@@ -1415,7 +1415,8 @@ public class TrendServiceImpl implements TrendService {
vo.setSpeed((double) Math.round(speed *100)/100.0 );//Math.round(0.01d * 100) / 100.0
Double queueLength = po.getQueueLength();
if(queueLength != null){
vo.setQueueLength(Integer.parseInt(String.valueOf(queueLength)));
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Integer delayTime = po.getDelayTime();
......@@ -1558,7 +1559,8 @@ public class TrendServiceImpl implements TrendService {
Double queueLength = po.getQueueLength();
if (queueLength != null) {
vo.setQueueLength(Integer.parseInt(String.valueOf(queueLength)));
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Integer delayTime = po.getDelayTime();
......@@ -1637,7 +1639,9 @@ public class TrendServiceImpl implements TrendService {
// vo.setCrossNoClearRate(0);
//平均排队长度
if (po.getQueueLength() != null) {
vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
// vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
int queueLengthInt = (int) Math.round(queueLength);
vo.setAvgQueueLength(queueLengthInt);
}else{
// vo.setAvgQueueLength(0.0);
}
......@@ -1699,7 +1703,8 @@ public class TrendServiceImpl implements TrendService {
// vo.setVehheadDist(0d);//车头间距
Double queueLength = po.getQueueLength();
if (queueLength != null) {
vo.setQueueLength(Integer.parseInt(String.valueOf(queueLength)));
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();
if (stopTimes != null) {
......@@ -1858,7 +1863,8 @@ public class TrendServiceImpl implements TrendService {
// vo.setVehheadTime(Math.round(vehheadTime *100)/100.0);//车头时距
Double queueLength = po.getQueueLength();
if (queueLength != null) {
vo.setQueueLength(Integer.parseInt(queueLength.toString()));
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();//停车次数
if (stopTimes != null) {
......@@ -1957,7 +1963,9 @@ public class TrendServiceImpl implements TrendService {
// vo.setCrossNoClearRate(0);
//平均排队长度
if (po.getQueueLength() != null) {
vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
// vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
int queueLengthInt = (int) Math.round(queueLength);
vo.setAvgQueueLength(queueLengthInt);
}else {
// vo.setAvgQueueLength(0.0);
}
......@@ -2013,7 +2021,9 @@ public class TrendServiceImpl implements TrendService {
vo.setVehheadTime(Math.round(vehheadTime*100)/100.0);//车头时距
Double queueLength = po.getQueueLength();
if (queueLength != null) {
vo.setQueueLength(Integer.parseInt(String.valueOf(queueLength)));
//queueLength的值是105.0,需要转换为105
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();
if (stopTimes != null) {
......
......@@ -148,7 +148,7 @@
AND t2.cross_id = #{crossId}
</if>
and t2.start_time <![CDATA[ >= ]]> #{startStamp}
and t2.start_time <![CDATA[ <= ]]> #{endStamp}
and t2.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t2.cross_id,
startTime
......
<?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 </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}) </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> <!-- 方向级查询,条件:路口id、时间、方向 --> <select id="selectByCrossIdAndStartEndDir" resultType="net.wanji.databus.vo.CrossDirDataHistVO"> SELECT t1.cross_id AS crossId, t1.dir_type as dirType, <choose> <!-- 小时 --> <when test="granularity==1"> DATE_FORMAT(t2.start_time, '%Y-%m-%d %H:00:00') AS startTime, </when> <!-- 分钟 --> <otherwise> DATE_FORMAT( CONCAT( DATE ( t2.start_time ), ' ', HOUR ( t2.start_time ), ':', FLOOR( MINUTE ( t2.start_time ) / #{granularity} ) * #{granularity} ), '%Y-%m-%d %H:%i:00' ) AS startTime, </otherwise> </choose> SUM( t2.flow ) AS flow, COALESCE ( sum( t2.traffic_flow_C ), 0 ) AS trafficFlowC, COALESCE ( sum( t2.traffic_flow_B ), 0 ) AS trafficFlowB, COALESCE ( sum( t2.traffic_flow_A ), 0 ) AS trafficFlowA, avg( t2.speed ) AS speed, MAX( t2.queue_length ) AS queueLength, AVG( t2.stop_times ) AS stopTimes, AVG( t2.time_occupancy) as timeOccupancy, AVG( t2.sturation) as sturation, AVG( t2.no_stop_rate) as noStopRate, AVG( t2.one_stop_rate) as oneStopRate, AVG( t2.two_stop_rate) as twoStopRate, AVG( t2.three_stop_rate) as threeStopRate, AVG( t2.non_motor_flow) as nonMotorFlow FROM t_base_cross_dir_info t1 LEFT JOIN t_cross_dir_data_hist t2 ON t1.cross_id = t2.cross_id and t1.dir_type = t2.dir_type WHERE 1=1 <if test="crossId != null"> AND t1.cross_id = #{crossId} </if> <if test="dirTypeList != null"> AND t1.dir_type IN <foreach item="dirType" index="index" collection="dirTypeList" open="(" separator="," close=")"> #{dirType} </foreach> </if> and t2.start_time <![CDATA[ >= ]]> #{startStamp} and t2.start_time <![CDATA[ <= ]]> #{endStamp} GROUP BY t1.cross_id, t1.dir_type, startTime ORDER BY t2.start_time asc, t1.dir_type </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> <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> </mapper>
\ No newline at end of file
<?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 </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}) </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> <!-- 方向级查询,条件:路口id、时间、方向 --> <select id="selectByCrossIdAndStartEndDir" resultType="net.wanji.databus.vo.CrossDirDataHistVO"> SELECT t1.cross_id AS crossId, t1.dir_type as dirType, <choose> <!-- 小时 --> <when test="granularity==1"> DATE_FORMAT(t2.start_time, '%Y-%m-%d %H:00:00') AS startTime, </when> <!-- 分钟 --> <otherwise> DATE_FORMAT( CONCAT( DATE ( t2.start_time ), ' ', HOUR ( t2.start_time ), ':', FLOOR( MINUTE ( t2.start_time ) / #{granularity} ) * #{granularity} ), '%Y-%m-%d %H:%i:00' ) AS startTime, </otherwise> </choose> SUM( t2.flow ) AS flow, COALESCE ( sum( t2.traffic_flow_C ), 0 ) AS trafficFlowC, COALESCE ( sum( t2.traffic_flow_B ), 0 ) AS trafficFlowB, COALESCE ( sum( t2.traffic_flow_A ), 0 ) AS trafficFlowA, avg( t2.speed ) AS speed, MAX( t2.queue_length ) AS queueLength, AVG( t2.stop_times ) AS stopTimes, AVG( t2.time_occupancy) as timeOccupancy, AVG( t2.sturation) as sturation, AVG( t2.no_stop_rate) as noStopRate, AVG( t2.one_stop_rate) as oneStopRate, AVG( t2.two_stop_rate) as twoStopRate, AVG( t2.three_stop_rate) as threeStopRate, AVG( t2.non_motor_flow) as nonMotorFlow FROM t_base_cross_dir_info t1 LEFT JOIN t_cross_dir_data_hist t2 ON t1.cross_id = t2.cross_id and t1.dir_type = t2.dir_type WHERE 1=1 <if test="crossId != null"> AND t1.cross_id = #{crossId} </if> <if test="dirTypeList != null"> AND t1.dir_type IN <foreach item="dirType" index="index" collection="dirTypeList" open="(" separator="," close=")"> #{dirType} </foreach> </if> and t2.start_time <![CDATA[ >= ]]> #{startStamp} and t2.start_time <![CDATA[ < ]]> #{endStamp} GROUP BY t1.cross_id, t1.dir_type, startTime ORDER BY t2.start_time asc, t1.dir_type </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> <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> </mapper>
\ No newline at end of file
......
......@@ -178,7 +178,7 @@
</foreach>
</if>
and t1.start_time <![CDATA[ >= ]]> #{startStamp}
and t1.start_time <![CDATA[ <= ]]> #{endStamp}
and t1.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t2.id,
t2.dir,
......
......@@ -133,7 +133,7 @@
)
</if>
and t2.start_time <![CDATA[ >= ]]> #{startStamp}
and t2.start_time <![CDATA[ <= ]]> #{endStamp}
and t2.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t1.cross_id,
t2.in_dir,
......
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