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

方向级查询

parent f44ff826
......@@ -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
* @param periodDirectionVO
* @return
......
......@@ -19,6 +19,7 @@ import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.*;
import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.CrossDirDataHistVO;
import net.wanji.databus.vo.GreenwaveListVO;
import net.wanji.opt.bo.*;
import net.wanji.opt.cache.BaseCrossInfoCache;
......@@ -1511,46 +1512,51 @@ public class TrendServiceImpl implements TrendService {
/**
* 构建路口方向的周期数据
* @param crossId
* @param poExtList
* @param vos
* @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<>();
int pedFlow = 0;
for (CrossLaneDataHistPOExt po : poExtList) {
for (CrossDirDataHistVO po : vos) {
CrossingDirectionQueryVO.CycleDataElement vo = new CrossingDirectionQueryVO.CycleDataElement();
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);
vo.setDir(po.getDir());
vo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getDir()));
vo.setTime(po.getStartTime());
vo.setDir(po.getDirType());
vo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(po.getDirType()));
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();
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);
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()
//拥堵指数
......@@ -1572,15 +1578,15 @@ public class TrendServiceImpl implements TrendService {
//冲突点
vo.setConflictPoint(0);
Double timeOccupancyDouble = po.getTimeOccupancy();
if (timeOccupancyDouble != null) {
vo.setTimeOccupancy((int) Math.round(timeOccupancyDouble * 100));
}
// 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(vehicleLengthRatioMean * 100));
}
// Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean();
// if (vehicleLengthRatioMean != null) {
vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
// }
//路口服务水平
vo.setServiceLevel(0);
//路口安全系数
......@@ -1608,20 +1614,17 @@ public class TrendServiceImpl implements TrendService {
//行人闯红灯率
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);
}
......@@ -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
* @return
* @throws Exception
......@@ -2298,25 +2309,20 @@ public class TrendServiceImpl implements TrendService {
try {
//路口
String crossId = lanePeriodTurnVO.getCrossId();
// Date start = lanePeriodTurnVO.getStart();
// Date end = lanePeriodTurnVO.getEnd();
int start = (int) (lanePeriodTurnVO.getStart().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();
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);
return buildCrossingDirectionCycleData(crossId, poExtList);
// List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, start, end);
List<CrossDirDataHistVO> vo = crossDirDataHistMapper.selectByCrossIdAndStartEndDir(crossId, start, end, dirType, granularity);
return buildCrossingDirectionCycleData(crossId, vo);
} catch (Exception e) {
log.error("全是周期数据方向级查询异常:", e);
throw new OptServiceException(e);
......
......@@ -37,9 +37,9 @@ public class CrossingDirectionQueryVO {
@ExcelProperty("方向")
private String dirName;
@ApiModelProperty(value = "总流量")
@ExcelProperty("总流量")
private int allFlow;
// @ApiModelProperty(value = "总流量")
// @ExcelProperty("总流量")
// private int allFlow;
@ApiModelProperty(value = "行人流量")
@ExcelProperty("行人流量")
......@@ -207,8 +207,8 @@ public class CrossingDirectionQueryVO {
@ExcelProperty("行人闯红灯率")
private double pedCrossRedLightRate;
@ApiModelProperty(value = "车辆总和")
@ExcelProperty("车辆总和")
private int allVehiceleFlow;
// @ApiModelProperty(value = "车辆总和")
// @ExcelProperty("车辆总和")
// private int allVehiceleFlow;
}
}
......@@ -5,6 +5,7 @@ import net.wanji.databus.bo.CrossDirDataHistAvgBO;
import net.wanji.databus.dto.MetricHistDTO;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossDirDataHistPOExt;
import net.wanji.databus.vo.CrossDirDataHistVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -38,6 +39,18 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
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);
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;
}
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