Commit 32a958d0 authored by 杜伟's avatar 杜伟

方向级查询

parent f44ff826
...@@ -316,6 +316,14 @@ public class TrendController { ...@@ -316,6 +316,14 @@ public class TrendController {
/** /**
* 交通指标 - 路口方向级 * 交通指标 - 路口方向级
* *
* 条件:
* {
* "granularity": "5m",
* "direction": "1,3,5",
* "crossId": "12345",
* "start": "2024-05-15 10:00:00",
* "end": "2025-05-15 11:00:00"
* }
* 表:t_cross_dir_data_hist * 表:t_cross_dir_data_hist
* @param periodDirectionVO * @param periodDirectionVO
* @return * @return
......
...@@ -19,6 +19,7 @@ import net.wanji.databus.dao.mapper.*; ...@@ -19,6 +19,7 @@ import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.MetricHistDTO; import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.*; import net.wanji.databus.po.*;
import net.wanji.databus.vo.AbnormalCrossListVO; import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.CrossDirDataHistVO;
import net.wanji.databus.vo.GreenwaveListVO; import net.wanji.databus.vo.GreenwaveListVO;
import net.wanji.opt.bo.*; import net.wanji.opt.bo.*;
import net.wanji.opt.cache.BaseCrossInfoCache; import net.wanji.opt.cache.BaseCrossInfoCache;
...@@ -1511,46 +1512,51 @@ public class TrendServiceImpl implements TrendService { ...@@ -1511,46 +1512,51 @@ public class TrendServiceImpl implements TrendService {
/** /**
* 构建路口方向的周期数据 * 构建路口方向的周期数据
* @param crossId * @param crossId
* @param poExtList * @param vos
* @return * @return
*/ */
private List<CrossingDirectionQueryVO.CycleDataElement> buildCrossingDirectionCycleData(String crossId, List<CrossLaneDataHistPOExt> poExtList) { private List<CrossingDirectionQueryVO.CycleDataElement> buildCrossingDirectionCycleData(String crossId, List<CrossDirDataHistVO> vos) {
List<CrossingDirectionQueryVO.CycleDataElement> res = new ArrayList<>(); List<CrossingDirectionQueryVO.CycleDataElement> res = new ArrayList<>();
int pedFlow = 0; int pedFlow = 0;
for (CrossLaneDataHistPOExt po : poExtList) { for (CrossDirDataHistVO po : vos) {
CrossingDirectionQueryVO.CycleDataElement vo = new CrossingDirectionQueryVO.CycleDataElement(); CrossingDirectionQueryVO.CycleDataElement vo = new CrossingDirectionQueryVO.CycleDataElement();
if (po.getId().contains(crossId.concat(Constants.SystemParam.SEPARATOR_MINUS))) { vo.setTime(po.getStartTime());
pedFlow += po.getFlow(); vo.setDir(po.getDirType());
} vo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getDirType()));
Integer batchTime = po.getBatchTime();
// 将10位时间戳转换为毫秒
long millis = batchTime * 1000L;
// 使用毫秒值创建Date对象
Date dateFromTimestamp = new Date(millis);
vo.setTime(dateFromTimestamp);
vo.setDir(po.getDir());
vo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getDir()));
vo.setFlow(po.getFlow()); vo.setFlow(po.getFlow());
vo.setPedFlow(pedFlow);
vo.setNonMotorFlow(0);//非机动车流量
vo.setTrafficFlowA((int) po.getTrafficFlowA());
vo.setTrafficFlowB((int) po.getTrafficFlowB());
vo.setTrafficFlowC((int) po.getTrafficFlowC());
Double speed = po.getSpeed(); Double speed = po.getSpeed();
vo.setSpeed((int) Math.round(speed)); vo.setSpeed((int) Math.round(speed));
vo.setVehheadDist(0d);//车头间距
Double vehheadTime = 0d;
vo.setVehheadTime((int) Math.round(vehheadTime));//车头时距
Double queueLength = po.getQueueLength(); Double queueLength = po.getQueueLength();
vo.setQueueLength((int) Math.round(queueLength)); vo.setQueueLength((int) Math.round(queueLength));
Double stopTimes = po.getStopTimes();
vo.setStopTimes((int) Math.round(stopTimes));
//----------------------------------------------------------------------------------------------
// if (po.getId().contains(crossId.concat(Constants.SystemParam.SEPARATOR_MINUS))) {
// pedFlow += po.getFlow();
// }
// Integer batchTime = po.getBatchTime();
// // 将10位时间戳转换为毫秒
// long millis = batchTime * 1000L;
// // 使用毫秒值创建Date对象
// Date dateFromTimestamp = new Date(millis);
// vo.setTime(dateFromTimestamp);
Integer delayTime = po.getDelayTime(); Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime); vo.setDelayTime(delayTime);
//路口效率指数 //路口效率指数
vo.setEfficiencyIndex(0.0); vo.setEfficiencyIndex(0.0);
//效率评价等级 //效率评价等级
vo.setEfficiencyEvaluateLevel(0.0); vo.setEfficiencyEvaluateLevel(0.0);
Double stopTimes = po.getStopTimes();
vo.setStopTimes((int) Math.round(stopTimes));
Double vehheadTime = po.getVehheadTime();
vo.setVehheadTime((int) Math.round(vehheadTime));
//饱和度 //饱和度
vo.setSaturation(0.0);//po.getSaturation() vo.setSaturation(0.0);//po.getSaturation()
//拥堵指数 //拥堵指数
...@@ -1572,15 +1578,15 @@ public class TrendServiceImpl implements TrendService { ...@@ -1572,15 +1578,15 @@ public class TrendServiceImpl implements TrendService {
//冲突点 //冲突点
vo.setConflictPoint(0); vo.setConflictPoint(0);
Double timeOccupancyDouble = po.getTimeOccupancy(); // Double timeOccupancyDouble = po.getTimeOccupancy();
if (timeOccupancyDouble != null) { // if (timeOccupancyDouble != null) {
vo.setTimeOccupancy((int) Math.round(timeOccupancyDouble * 100)); vo.setTimeOccupancy((int) Math.round(0 * 100));
} // }
Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean(); // Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean();
if (vehicleLengthRatioMean != null) { // if (vehicleLengthRatioMean != null) {
vo.setVehicleNumsRatioMean((int) Math.round(vehicleLengthRatioMean * 100)); vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
} // }
//路口服务水平 //路口服务水平
vo.setServiceLevel(0); vo.setServiceLevel(0);
//路口安全系数 //路口安全系数
...@@ -1608,20 +1614,17 @@ public class TrendServiceImpl implements TrendService { ...@@ -1608,20 +1614,17 @@ public class TrendServiceImpl implements TrendService {
//行人闯红灯率 //行人闯红灯率
vo.setPedCrossRedLightRate(0.0); vo.setPedCrossRedLightRate(0.0);
vo.setVehheadDist(po.getVehheadDist());
vo.setTrafficFlowA(po.getTrafficFlowA());
vo.setTrafficFlowB(po.getTrafficFlowB());
vo.setTrafficFlowC(po.getTrafficFlowC());
vo.setNonMotorFlow(po.getNonMotorFlow());
vo.setV85(Math.round(po.getV85() * 100) / 100);
vo.setPedFlow(pedFlow);
vo.setAllFlow(pedFlow + po.getNonMotorFlow() + po.getFlow());
vo.setAllVehiceleFlow(po.getFlow() + po.getNonMotorFlow());
vo.setTurn(po.getTurn());
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(po.getDir());
String turnName = TurnConvertEnum.getDescByKey(po.getTurn());
vo.setLaneSort(String.join("-", dirName, turnName, String.valueOf(po.getSort()))); // vo.setV85(Math.round(po.getV85() * 100) / 100);
// vo.setAllFlow(pedFlow + po.getNonMotorFlow() + po.getFlow());
// vo.setAllVehiceleFlow(po.getFlow() + po.getNonMotorFlow());
// vo.setTurn(po.getTurn());
// String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(po.getDir());
// String turnName = TurnConvertEnum.getDescByKey(po.getTurn());
// vo.setLaneSort(String.join("-", dirName, turnName, String.valueOf(po.getSort())));
res.add(vo); res.add(vo);
} }
...@@ -2289,6 +2292,14 @@ public class TrendServiceImpl implements TrendService { ...@@ -2289,6 +2292,14 @@ public class TrendServiceImpl implements TrendService {
/** /**
* 获取方向级数据 * 获取方向级数据
* 参考一下查询条件:路口、方向、专向、车道 【看看到底用哪个】 * 参考一下查询条件:路口、方向、专向、车道 【看看到底用哪个】
* {
* "granularity": "5m",
* "direction": "1,3,5",
* "crossId": "12345",
* "start": "2024-05-15 10:00:00",
* "end": "2025-05-15 11:00:00"
* }
* 表:t_cross_dir_data_hist
* @param lanePeriodTurnVO * @param lanePeriodTurnVO
* @return * @return
* @throws Exception * @throws Exception
...@@ -2298,25 +2309,20 @@ public class TrendServiceImpl implements TrendService { ...@@ -2298,25 +2309,20 @@ public class TrendServiceImpl implements TrendService {
try { try {
//路口 //路口
String crossId = lanePeriodTurnVO.getCrossId(); String crossId = lanePeriodTurnVO.getCrossId();
// Date start = lanePeriodTurnVO.getStart();
// Date end = lanePeriodTurnVO.getEnd();
int start = (int) (lanePeriodTurnVO.getStart().getTime() / 1000); int start = (int) (lanePeriodTurnVO.getStart().getTime() / 1000);
int end = (int) (lanePeriodTurnVO.getEnd().getTime() / 1000); int end = (int) (lanePeriodTurnVO.getEnd().getTime() / 1000);
//方向 //方向
String direction = lanePeriodTurnVO.getDirection(); String dirType = lanePeriodTurnVO.getDirection();
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = lanePeriodTurnVO.getGranularity(); String granularity = lanePeriodTurnVO.getGranularity();
if (StringUtils.isBlank(granularity)) { if (StringUtils.isBlank(granularity)) {
granularity = "5m"; granularity = "5";
} }
// LambdaQueryWrapper<AnalysisRidTurnIndicators> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(AnalysisRidTurnIndicators::getCrossId, crossId);
// queryWrapper.eq(AnalysisRidTurnIndicators::getGranularity, granularity);
// queryWrapper.between(AnalysisRidTurnIndicators::getWindowStartTime, start, end);
// queryWrapper.orderByDesc(AnalysisRidTurnIndicators::getWindowStartTime);
// return ridTurnIndicatorsMapper.selectList(queryWrapper);
// 查询周期数据 // 查询周期数据
List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end); // List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end);
return buildCrossingDirectionCycleData(crossId, poExtList); List<CrossDirDataHistVO> vo = crossDirDataHistMapper.selectByCrossIdAndStartEndDir(crossId, start, end, dirType, granularity);
return buildCrossingDirectionCycleData(crossId, vo);
} catch (Exception e) { } catch (Exception e) {
log.error("全是周期数据方向级查询异常:", e); log.error("全是周期数据方向级查询异常:", e);
throw new OptServiceException(e); throw new OptServiceException(e);
......
...@@ -37,9 +37,9 @@ public class CrossingDirectionQueryVO { ...@@ -37,9 +37,9 @@ public class CrossingDirectionQueryVO {
@ExcelProperty("方向") @ExcelProperty("方向")
private String dirName; private String dirName;
@ApiModelProperty(value = "总流量") // @ApiModelProperty(value = "总流量")
@ExcelProperty("总流量") // @ExcelProperty("总流量")
private int allFlow; // private int allFlow;
@ApiModelProperty(value = "行人流量") @ApiModelProperty(value = "行人流量")
@ExcelProperty("行人流量") @ExcelProperty("行人流量")
...@@ -207,8 +207,8 @@ public class CrossingDirectionQueryVO { ...@@ -207,8 +207,8 @@ public class CrossingDirectionQueryVO {
@ExcelProperty("行人闯红灯率") @ExcelProperty("行人闯红灯率")
private double pedCrossRedLightRate; private double pedCrossRedLightRate;
@ApiModelProperty(value = "车辆总和") // @ApiModelProperty(value = "车辆总和")
@ExcelProperty("车辆总和") // @ExcelProperty("车辆总和")
private int allVehiceleFlow; // private int allVehiceleFlow;
} }
} }
...@@ -5,6 +5,7 @@ import net.wanji.databus.bo.CrossDirDataHistAvgBO; ...@@ -5,6 +5,7 @@ import net.wanji.databus.bo.CrossDirDataHistAvgBO;
import net.wanji.databus.dto.MetricHistDTO; import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.CrossDirDataHistPO; import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossDirDataHistPOExt; import net.wanji.databus.po.CrossDirDataHistPOExt;
import net.wanji.databus.vo.CrossDirDataHistVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -38,6 +39,18 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> { ...@@ -38,6 +39,18 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
List<CrossDirDataHistPO> selectByCrossIdAndStartEnd(String crossId, int startStamp, int endStamp); List<CrossDirDataHistPO> selectByCrossIdAndStartEnd(String crossId, int startStamp, int endStamp);
/**
* 方向级查询
*
* @param crossId 路口ID
* @param startStamp 开始时间
* @param endStamp 截止时间
* @param dirType 方向
* @param granularity 时段
* @return
*/
List<CrossDirDataHistVO> selectByCrossIdAndStartEndDir(String crossId, int startStamp, int endStamp, String dirType, String granularity);
Integer selectMaxDelayTime(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp); Integer selectMaxDelayTime(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp);
Double selectMaxQueueLength(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp); Double selectMaxQueueLength(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp);
......
package net.wanji.databus.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import net.wanji.databus.po.CrossDirDataRealtimePO;
/**
* 交通指标 - 方向级vo
*
*/
@Data
@ApiModel(value = "CrossDirDataHistVO", description = "路口转向实时数据历史")
public class CrossDirDataHistVO extends CrossDirDataRealtimePO {
public double trafficFlowC;
public double trafficFlowB;
public double trafficFlowA;
}
<?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> <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> <?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 cross_id AS crossId, dir_type as dirType, <choose> <!-- 方向级 --> <when test="granularity==1"> DATE_FORMAT(start_time, '%Y-%m-%d %H:00:00') AS startTime, </when> <!-- 转向级 --> <otherwise> DATE_FORMAT( CONCAT( DATE ( start_time ), ' ', HOUR ( start_time ), ':', FLOOR( MINUTE ( start_time ) / #{granularity} ) * #{granularity} ), '%Y-%m-%d %H:%i:00' ) AS startTime, </otherwise> </choose> SUM( flow ) AS flow, avg( traffic_flow_C ) AS trafficFlowC, avg( traffic_flow_B ) AS trafficFlowB, avg( traffic_flow_A ) AS trafficFlowA, avg( speed ) AS speed, MAX( queue_length ) AS queueLength, AVG( stop_times ) AS stopTimes FROM t_cross_dir_data_hist WHERE 1=1 <if test="crossId != null"> AND cross_id = #{crossId} </if> <if test="dirType != null"> AND dir_type IN ( #{dirType} ) </if> and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} GROUP BY cross_id, dir_type, startTime ORDER BY startTime DESC, 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 \ No newline at end of file
......
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