Commit 7afbcd94 authored by 杜伟's avatar 杜伟

转向级统计查询

parent f74c43eb
...@@ -296,7 +296,7 @@ public class TrendController { ...@@ -296,7 +296,7 @@ public class TrendController {
} }
/** /**
* 车道交通指标 - 车道周期转向数据 * 车道交通指标 - 转向级数据
* @param lanePeriodTurnVO * @param lanePeriodTurnVO
* @return * @return
* @throws Exception * @throws Exception
...@@ -309,7 +309,7 @@ public class TrendController { ...@@ -309,7 +309,7 @@ public class TrendController {
@ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class), @ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class),
}) })
public JsonViewObject lanePeriodTurnData(@RequestBody LanePeriodTurnVO lanePeriodTurnVO) throws Exception { public JsonViewObject lanePeriodTurnData(@RequestBody LanePeriodTurnVO lanePeriodTurnVO) throws Exception {
List<AnalysisRidTurnIndicators> result = trendService.lanePeriodTurnData(lanePeriodTurnVO); List<CrossingTurnQueryVO.CycleDataElement> result = trendService.lanePeriodTurnData(lanePeriodTurnVO);
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
......
...@@ -65,7 +65,7 @@ public interface TrendService { ...@@ -65,7 +65,7 @@ public interface TrendService {
List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception; List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception;
List<OverflowEvent> overFlowEvent(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception; List<OverflowEvent> overFlowEvent(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception;
List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception; List<CrossingTurnQueryVO.CycleDataElement> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception;
/** /**
* 获取时段方向级数据 * 获取时段方向级数据
......
...@@ -21,6 +21,7 @@ import net.wanji.databus.po.*; ...@@ -21,6 +21,7 @@ import net.wanji.databus.po.*;
import net.wanji.databus.vo.AbnormalCrossListVO; import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.CrossDataHistVO; import net.wanji.databus.vo.CrossDataHistVO;
import net.wanji.databus.vo.CrossDirDataHistVO; import net.wanji.databus.vo.CrossDirDataHistVO;
import net.wanji.databus.vo.CrossTurnDataHistVO;
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;
...@@ -1510,6 +1511,132 @@ public class TrendServiceImpl implements TrendService { ...@@ -1510,6 +1511,132 @@ public class TrendServiceImpl implements TrendService {
return sortedRes; return sortedRes;
} }
/**
* 构建转向级
* @param crossId
* @param vos
* @return
*/
private List<CrossingTurnQueryVO.CycleDataElement> buildCrossingTurnCycleData(String crossId, List<CrossTurnDataHistVO> vos) {
List<CrossingTurnQueryVO.CycleDataElement> res = new ArrayList<>();
int pedFlow = 0;
for (CrossTurnDataHistVO po : vos) {
CrossingTurnQueryVO.CycleDataElement vo = new CrossingTurnQueryVO.CycleDataElement();
if (po.getStartTime() == null || po.getStartTime().equals("0000")){
continue;
}
vo.setTime(po.getStartTime());
vo.setInDir(po.getInDir());
vo.setInDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getInDir()));
vo.setTurnType(po.getTurnType());
vo.setTurnTypeName(TurnConvertEnum.getDescByCode(po.getTurnType()));
vo.setFlow(po.getFlow());
vo.setPedFlow(pedFlow);
vo.setNonMotorFlow(0);//非机动车流量
vo.setTrafficFlowA( po.getTrafficFlowA());
vo.setTrafficFlowB( po.getTrafficFlowB());
vo.setTrafficFlowC( po.getTrafficFlowC());
Double speed = po.getSpeed();
vo.setSpeed((int) Math.round(speed));
vo.setVehheadDist(0d);//车头间距
Double vehheadTime = 0d;
vo.setVehheadTime((int) Math.round(vehheadTime));//车头时距
Double queueLength = po.getQueueLength();
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();
vo.setDelayTime(delayTime);
//路口效率指数
vo.setEfficiencyIndex(0.0);
//效率评价等级
vo.setEfficiencyEvaluateLevel(0.0);
//饱和度
vo.setSaturation(0.0);//po.getSaturation()
//拥堵指数
vo.setCongestionIndex(0.0);
//溢出指数
vo.setOverflowIndex(0.0);
//失衡指数
vo.setImbalanceIndex(0.0);
//拥堵次数
vo.setCongestionTimes(0);
//溢出次数
vo.setOverflowTimes(0);
//失衡次数
vo.setImbalanceTimes(0);
//空放次数
vo.setFreeFlowTimes(0);
//溢流率
vo.setOverflowRate(0.0);
//冲突点
vo.setConflictPoint(0);
// Double timeOccupancyDouble = po.getTimeOccupancy();
// if (timeOccupancyDouble != null) {
vo.setTimeOccupancy((int) Math.round(0 * 100));
// }
// Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean();
// if (vehicleLengthRatioMean != null) {
vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
// }
//路口服务水平
vo.setServiceLevel(0);
//路口安全系数
vo.setSafetyCoefficient(0.0);
//安全评价等级
vo.setSafetyEvaluateLevel(0);
//交通事件数
vo.setTrafficEventNum(0);
//交通事故数
vo.setTrafficAccidentNum(0);
//不停车通过率
vo.setNoStopPassRate(0);
//一次停车通过率
vo.setOneStopPassRate(0);
//二次停车通过率
vo.setTwoStopPassRate(0);
//路口未清空率
vo.setCrossNoClearRate(0);
//平均排队长度
vo.setAvgQueueLength(0.0);
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
vo.setPedAvgPassTime(0.0);
//行人闯红灯率
vo.setPedCrossRedLightRate(0.0);
// 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);
}
List<CrossingTurnQueryVO.CycleDataElement> sortedRes = res.stream()
.sorted(Comparator.comparing(CrossingTurnQueryVO.CycleDataElement::getTime).reversed())
.collect(Collectors.toList());
return sortedRes;
}
/** /**
* 构建路口方向的周期数据 * 构建路口方向的周期数据
* @param crossId * @param crossId
...@@ -2291,6 +2418,49 @@ public class TrendServiceImpl implements TrendService { ...@@ -2291,6 +2418,49 @@ public class TrendServiceImpl implements TrendService {
} }
} }
/**
* 交通指标转向级查询
*
* @param turnVO
* @return
* @throws Exception
*/
@Override
public List<CrossingTurnQueryVO.CycleDataElement> lanePeriodTurnData(LanePeriodTurnVO turnVO) throws Exception {
try {
//路口
String crossId = turnVO.getCrossId();
int start = (int) (turnVO.getStart().getTime() / 1000);
int end = (int) (turnVO.getEnd().getTime() / 1000);
//转向 用逗号分隔
String turnType = turnVO.getTurnType();
List<String> turnTypeList = null;
if (!StringUtils.isBlank(turnType)) {
turnTypeList = Arrays.asList(turnType.split(","));
}
//驶入方向 用逗号分隔
String inDir = turnVO.getInDir();
List<Integer> inDirList = null;
if (!StringUtils.isBlank(inDir)) {
inDirList = Arrays.stream(inDir.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = turnVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5";
}else {
granularity = granularity.replace("m", "").replace("h", "");;
}
// 查询周期数据
List<CrossTurnDataHistVO> vo = crossTurnDataHistMapper.selectByCrossIdTurn(crossId, start, end, granularity, turnTypeList, inDirList);
return buildCrossingTurnCycleData(crossId, vo);
} catch (Exception e) {
log.error("全是周期车道数据方向转向查询异常:", e);
throw new OptServiceException(e);
}
}
/** /**
* 获取方向级数据 * 获取方向级数据
* 参考一下查询条件:路口、方向、专向、车道 【看看到底用哪个】 * 参考一下查询条件:路口、方向、专向、车道 【看看到底用哪个】
...@@ -2302,29 +2472,33 @@ public class TrendServiceImpl implements TrendService { ...@@ -2302,29 +2472,33 @@ public class TrendServiceImpl implements TrendService {
* "end": "2025-05-15 11:00:00" * "end": "2025-05-15 11:00:00"
* } * }
* 表:t_cross_dir_data_hist * 表:t_cross_dir_data_hist
* @param lanePeriodTurnVO * @param directionVO
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Override @Override
public List<CrossingDirectionQueryVO.CycleDataElement> periodDirectionData(PeriodDirectionVO lanePeriodTurnVO) throws Exception { public List<CrossingDirectionQueryVO.CycleDataElement> periodDirectionData(PeriodDirectionVO directionVO) throws Exception {
try { try {
//路口 //路口
String crossId = lanePeriodTurnVO.getCrossId(); String crossId = directionVO.getCrossId();
int start = (int) (lanePeriodTurnVO.getStart().getTime() / 1000); int start = (int) (directionVO.getStart().getTime() / 1000);
int end = (int) (lanePeriodTurnVO.getEnd().getTime() / 1000); int end = (int) (directionVO.getEnd().getTime() / 1000);
//方向 //方向
String dirType = lanePeriodTurnVO.getDirection(); String dirType = directionVO.getDirection();
List<Integer> dirTypeList = null;
if (!StringUtils.isBlank(dirType)) {
dirTypeList = Arrays.stream(dirType.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】 //分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = lanePeriodTurnVO.getGranularity(); String granularity = directionVO.getGranularity();
if (StringUtils.isBlank(granularity)) { if (StringUtils.isBlank(granularity)) {
granularity = "5"; granularity = "5";
}else { }else {
granularity = granularity.replace("m", ""); granularity = granularity.replace("m", "").replace("h", "");;
} }
// 查询周期数据 // 查询周期数据
List<CrossDirDataHistVO> vo = crossDirDataHistMapper.selectByCrossIdAndStartEndDir(crossId, start, end, dirType, granularity); List<CrossDirDataHistVO> vo = crossDirDataHistMapper.selectByCrossIdAndStartEndDir(crossId, start, end, dirTypeList, granularity);
return buildCrossingDirectionCycleData(crossId, vo); return buildCrossingDirectionCycleData(crossId, vo);
} catch (Exception e) { } catch (Exception e) {
log.error("全是周期数据方向级查询异常:", e); log.error("全是周期数据方向级查询异常:", e);
...@@ -2334,23 +2508,23 @@ public class TrendServiceImpl implements TrendService { ...@@ -2334,23 +2508,23 @@ public class TrendServiceImpl implements TrendService {
/** /**
* 获取路口级数据 * 获取路口级数据
* @param lanePeriodTurnVO * @param crossingVO
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Override @Override
public List<CrossingQueryVO.CycleDataElement> periodCrossingData(PeriodCrossingVO lanePeriodTurnVO) throws Exception { public List<CrossingQueryVO.CycleDataElement> periodCrossingData(PeriodCrossingVO crossingVO) throws Exception {
try { try {
//路口 //路口
String crossId = lanePeriodTurnVO.getCrossId(); String crossId = crossingVO.getCrossId();
int start = (int) (lanePeriodTurnVO.getStart().getTime() / 1000); int start = (int) (crossingVO.getStart().getTime() / 1000);
int end = (int) (lanePeriodTurnVO.getEnd().getTime() / 1000); int end = (int) (crossingVO.getEnd().getTime() / 1000);
//分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】 //分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】
String granularity = lanePeriodTurnVO.getGranularity(); String granularity = crossingVO.getGranularity();
if (StringUtils.isBlank(granularity)) { if (StringUtils.isBlank(granularity)) {
granularity = "5"; granularity = "5";
}else { }else {
granularity = granularity.replace("m", ""); granularity = granularity.replace("m", "").replace("h", "");
} }
// 查询周期数据 // 查询周期数据
...@@ -2445,27 +2619,6 @@ public class TrendServiceImpl implements TrendService { ...@@ -2445,27 +2619,6 @@ public class TrendServiceImpl implements TrendService {
return laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, start, end, pageNum, null, overFlow); return laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, start, end, pageNum, null, overFlow);
} }
@Override
public List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception {
try {
String crossId = lanePeriodTurnVO.getCrossId();
Date start = lanePeriodTurnVO.getStart();
Date end = lanePeriodTurnVO.getEnd();
String granularity = lanePeriodTurnVO.getGranularity();
if (StringUtils.isBlank(granularity)) {
granularity = "5m";
}
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);
} catch (Exception e) {
log.error("全是周期车道数据方向转向查询异常:", e);
throw new OptServiceException(e);
}
}
......
package net.wanji.opt.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* 路口转向级VO
*/
@Data
@NoArgsConstructor
@ApiModel(value = "CrossingTurnQueryVO", description = "表格分时段查询")
public class CrossingTurnQueryVO {
@ApiModelProperty(value = "周期数据")
private List<CycleDataElement> cycleData;
@NoArgsConstructor
@Data
public static class CycleDataElement {
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("时间")
private Date time;
/** 驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北 */
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
@ExcelProperty("驶入方向")
public Integer inDir ;
@ExcelProperty("驶入方向名称")
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private String inDirName;
/** 转向类型:u掉头;l左转;s直行;r右转; */
@ApiModelProperty(name = "转向类型:u掉头;l左转;s直行;r右转;",notes = "")
@ExcelProperty("转向类型")
public String turnType ;
@ApiModelProperty(name = "转向类型名称:u掉头;l左转;s直行;r右转;",notes = "")
@ExcelProperty("转向类型名称")
private String turnTypeName;
// @ApiModelProperty(value = "总流量")
// @ExcelProperty("总流量")
// private int allFlow;
@ApiModelProperty(value = "行人流量")
@ExcelProperty("行人流量")
private int pedFlow;
@ApiModelProperty(value = "非机动车流量")
@ExcelProperty("非机动车流量")
private int nonMotorFlow;
@ExcelProperty("小车流量")
private Integer trafficFlowC;
@ExcelProperty("中车流量")
private Integer trafficFlowB;
@ExcelProperty("大车流量")
private Integer trafficFlowA;
@ApiModelProperty(value = "平均速度")
@ExcelProperty("平均速度")
private Integer speed;
@ApiModelProperty(value = "平均车头间距")
@ExcelProperty("平均车头间距")
private Double vehheadDist;
@ApiModelProperty(value = "平均车头时距")
@ExcelProperty("平均车头时距")
private Integer vehheadTime;
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private Integer queueLength;
@ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
private Integer stopTimes;
//-----------------------------
@ApiModelProperty(value = "车道转向:1左转;2直行;3右转;4掉头;5直左;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头',\n")
@ExcelIgnore
private Integer turn;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
@ExcelProperty("车道号")
private String laneSort;
@ApiModelProperty(value = "流量")
@ExcelIgnore
private Integer flow;
@ApiModelProperty(value = "平均延误")
@ExcelProperty("平均延误")
private Integer delayTime ;
@ApiModelProperty(value = "路口效率指数")
@ExcelProperty("路口效率指数")
private Double efficiencyIndex ;
@ApiModelProperty(value = "效率评价等级")
@ExcelProperty("效率评价等级")
private Double efficiencyEvaluateLevel ;
@ApiModelProperty(value = "饱和度")
@ExcelProperty("饱和度")
private Double saturation;
@ApiModelProperty(value = "拥堵指数")
@ExcelProperty("拥堵指数")
private Double congestionIndex;
@ApiModelProperty(value = "溢出指数")
@ExcelProperty("溢出指数")
private Double overflowIndex;
@ApiModelProperty(value = "失衡指数")
@ExcelProperty("失衡指数")
private Double imbalanceIndex;
@ApiModelProperty(value = "时间占有率")
@ExcelProperty("平均时间占有率%")
private Integer timeOccupancy;
@ApiModelProperty(value = "空间占有率")
// 空间长度占比 todo字段名称展示先不改了
@ExcelProperty("平均空间占有率%")
private Integer vehicleNumsRatioMean;
@ExcelProperty("85位速度")
private double v85;
@ApiModelProperty(value = "路口服务水平")
@ExcelProperty("路口服务水平")
private int serviceLevel;
@ApiModelProperty(value = "拥堵次数")
@ExcelProperty("拥堵次数")
private int congestionTimes;
@ApiModelProperty(value = "溢出次数")
@ExcelProperty("溢出次数")
private int overflowTimes;
@ApiModelProperty(value = "失衡次数")
@ExcelProperty("失衡次数")
private int imbalanceTimes;
@ApiModelProperty(value = "空放次数")
@ExcelProperty("空放次数")
private int freeFlowTimes;
@ApiModelProperty(value = "溢流率")
@ExcelProperty("溢流率")
private double overflowRate;
@ApiModelProperty(value = "冲突点")
@ExcelProperty("冲突点")
private int conflictPoint;
@ApiModelProperty(value = "路口安全系数")
@ExcelProperty("路口安全系数")
private double safetyCoefficient;
@ApiModelProperty(value = "安全评价等级")
@ExcelProperty("安全评价等级")
private double safetyEvaluateLevel;
@ApiModelProperty(value = "交通事件数")
@ExcelProperty("交通事件数")
private int trafficEventNum;
@ApiModelProperty(value = "交通事故数")
@ExcelProperty("交通事故数")
private int trafficAccidentNum;
@ApiModelProperty(value = "不停车通过率")
@ExcelProperty("不停车通过率")
private double noStopPassRate;
@ApiModelProperty(value = "一次停车通过率")
@ExcelProperty("一次停车通过率")
private double oneStopPassRate;
@ApiModelProperty(value = "二次停车通过率")
@ExcelProperty("二次停车通过率")
private double twoStopPassRate;
@ApiModelProperty(value = "路口未清空率")
@ExcelProperty("路口未清空率")
private double crossNoClearRate;
@ApiModelProperty(value = "平均排队长度")
@ExcelProperty("平均排队长度")
private double avgQueueLength;
@ApiModelProperty(value = "绿灯有效利用率")
@ExcelProperty("绿灯有效利用率")
private double greenLightEfficiency ;
@ApiModelProperty(value = "行人平均通过时间")
@ExcelProperty("行人平均通过时间")
private double pedAvgPassTime;
@ApiModelProperty(value = "行人闯红灯率")
@ExcelProperty("行人闯红灯率")
private double pedCrossRedLightRate;
// @ApiModelProperty(value = "车辆总和")
// @ExcelProperty("车辆总和")
// private int allVehiceleFlow;
}
}
...@@ -15,4 +15,14 @@ import lombok.NoArgsConstructor; ...@@ -15,4 +15,14 @@ import lombok.NoArgsConstructor;
public class LanePeriodTurnVO extends CommonCrossIdDateTimeVO { public class LanePeriodTurnVO extends CommonCrossIdDateTimeVO {
@ApiModelProperty(value = "分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】") @ApiModelProperty(value = "分析粒度【5m:五分钟 10m:10分钟 30m:30分钟 1h:一小时】")
private String granularity; private String granularity;
/**
* 用逗号分隔
*/
@ApiModelProperty(value = "转向")
private String turnType;
/**
* 用逗号分隔
*/
@ApiModelProperty(value = "驶入方向")
private String inDir;
} }
...@@ -49,7 +49,7 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> { ...@@ -49,7 +49,7 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
* @param granularity 时段 * @param granularity 时段
* @return * @return
*/ */
List<CrossDirDataHistVO> selectByCrossIdAndStartEndDir(String crossId, int startStamp, int endStamp, String dirType, String granularity); List<CrossDirDataHistVO> selectByCrossIdAndStartEndDir(String crossId, int startStamp, int endStamp, List<Integer> dirTypeList, 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);
......
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dto.MetricHistDTO; import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.CrossTurnDataHistPO; import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPOExt; import net.wanji.databus.po.CrossTurnDataHistPOExt;
import net.wanji.databus.vo.CrossTurnDataHistVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -23,6 +24,18 @@ public interface CrossTurnDataHistMapper extends BaseMapper<CrossTurnDataHistPO> ...@@ -23,6 +24,18 @@ public interface CrossTurnDataHistMapper extends BaseMapper<CrossTurnDataHistPO>
List<CrossTurnDataHistPO> selectByCrossId(String crossId, long endTimeStamp, long startTimeStamp); List<CrossTurnDataHistPO> selectByCrossId(String crossId, long endTimeStamp, long startTimeStamp);
/**
* 转向级查询
* @param crossId
* @param startStamp
* @param endStamp
* @param granularity
* @param turnType
* @param inDir
* @return
*/
List<CrossTurnDataHistVO> selectByCrossIdTurn(String crossId, long startStamp, long endStamp, String granularity, List<String> turnTypeList , List<Integer> inDirList);
List<MetricHistDTO> selectMetricHistDTO(String crossId, int startStamp, int endStamp, int dir, String turn); List<MetricHistDTO> selectMetricHistDTO(String crossId, int startStamp, int endStamp, int dir, String turn);
List<CrossTurnDataHistPOExt> selectByMetrics(String crossId, int dirInt, String turnType, int startTimeStamp, int endTimeStamp); List<CrossTurnDataHistPOExt> selectByMetrics(String crossId, int dirInt, String turnType, int startTimeStamp, int endTimeStamp);
......
...@@ -93,4 +93,11 @@ public class CrossTurnDataRealtimePO { ...@@ -93,4 +93,11 @@ public class CrossTurnDataRealtimePO {
public Double greenLightEfficiency; public Double greenLightEfficiency;
@ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "") @ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "")
public Double effusionRate; public Double effusionRate;
@ApiModelProperty(value = "大车流量", notes = "")
private int trafficFlowA;
@ApiModelProperty(value = "中车流量", notes = "")
private int trafficFlowB;
@ApiModelProperty(value = "小车流量", notes = "")
private int trafficFlowC;
} }
package net.wanji.databus.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import net.wanji.databus.po.CrossTurnDataRealtimePO;
/**
* @author duanruiming
* @date 2023/03/12 20:54
*/
@Data
@ApiModel(value = "CrossTurnDataHistVO", description = "路口转向实时数据历史")
public class CrossTurnDataHistVO extends CrossTurnDataRealtimePO {
}
<?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> <?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 <foreach item="turnType" index="index" collection="turnTypeList" open="(" separator="," close=")"> #{turnType} </foreach> </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
......
...@@ -77,6 +77,67 @@ ...@@ -77,6 +77,67 @@
and batch_time <![CDATA[ <= ]]> #{endTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp}
and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ >= ]]> #{startTimeStamp}
</select> </select>
<!-- 交通指标转向级统计查询:条件:路口id、时间、驶入方向、转向 -->
<select id="selectByCrossIdTurn" resultType="net.wanji.databus.vo.CrossTurnDataHistVO">
SELECT
cross_id AS crossId,
in_dir AS inDir,
turn_type AS turnType,
<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_turn_data_hist
WHERE
1 = 1
<if test="crossId != null">
AND cross_id = #{crossId}
</if>
<if test="inDirList != null">
AND in_dir IN
<foreach item="inDir" index="index" collection="inDirList"
open="(" separator="," close=")">
#{inDir}
</foreach>
</if>
<if test="turnTypeList != null">
AND turn_type IN
<foreach item="turnType" index="index" collection="turnTypeList"
open="(" separator="," close=")">
#{turnType}
</foreach>
</if>
and batch_time <![CDATA[ >= ]]> #{startStamp}
and batch_time <![CDATA[ <= ]]> #{endStamp}
GROUP BY
cross_id,
in_dir,
turn_type,
startTime
ORDER BY
startTime DESC,
in_dir,
turn_type
</select>
<select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO">
select status, flow, speed, sturation, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency select status, flow, speed, sturation, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency
......
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