Commit dd2a909a authored by zhaowenhao's avatar zhaowenhao

Merge remote-tracking branch 'origin/dev-wuhan' into dev-wuhan

# Conflicts:
#	signal-feign-service/src/main/resources/application-demo.properties
#	signal-utc-service/src/main/java/net/wanji/utc/config/RedisConfig.java
parents 71aa5287 eb220b3d
utc.service.url=http://fuzhujuece-signal-utc-service:32000/utc
utc.dt.service.url=http://10.102.1.182:39002/utc-dt
utc.hisense.service.url=http://10.102.1.182:39003/utc-hisense
control.url=http://10.102.1.182:32001/web
utc.service.url=http://192.168.208.43:32000/utc
utc.dt.service.url=http://192.168.208.43:39002/utc-dt
utc.hisense.service.url=http://192.168.208.43:39003/utc-hisense
control.url=http://192.168.208.43:32001/web
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.CrossStatusEnum;
import net.wanji.common.enums.TurnConvertEnum;
......@@ -157,6 +158,9 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
.sum();
double saturation = sumA / sumB;
if (Double.isNaN(saturation)){
saturation = 0.0;
}
String serviceLevel = CrossUtil.getServiceLevel(saturation);
vo.setServiceLevel(serviceLevel);
......@@ -307,7 +311,9 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
//2. 查询路口统计表 t_cross_data_hist
List<RunningEvaluateIndexStatusVO> runningEvaluateIndexStatusVOS = buildRes(bo, crossId, status);
runningEvaluateStatusVO.setRunningEvaluateIndexStatusVOList(runningEvaluateIndexStatusVOS);
if (runningEvaluateIndexStatusVOS.isEmpty()){
runningEvaluateStatusVO.setContent("没有查询到相关数据");
}
//3. 获取问题列表
// 路口级别全量数据
List<MetricHistDTO> crossDTOList = crossDataHistMapper.selectMetricHistDTO2(
......@@ -831,9 +837,14 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
List<RunningEvaluateScopeTreeVO.TurnVO> res = new ArrayList<>();
List<CrossTurnInfoPO> crossTurnInfoPOList = baseCrossTurnInfoMapper.selectByCrossIdAndDir(crossId, dir);
Map<String, Boolean> m = Maps.newHashMap();
for (CrossTurnInfoPO crossTurnInfoPO : crossTurnInfoPOList) {
RunningEvaluateScopeTreeVO.TurnVO turnVO = new RunningEvaluateScopeTreeVO.TurnVO();
String turnType = crossTurnInfoPO.getTurnType();
if (m.get(turnType) != null){
continue;
}
m.put(turnType, true);
turnVO.setTurn(turnType);
List<RunningEvaluateScopeTreeVO.LaneVO> laneVOList = buildLaneVOList(crossId, dir, turnType);
turnVO.setChild(laneVOList);
......@@ -960,6 +971,12 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
res.add(vo);
}
if (res != null && res.size() ==1){
Double index = res.get(0).getIndex();
if (index == 0.0){
res.clear();
}
}
return res;
}
......
......@@ -1414,7 +1414,10 @@ public class TrendServiceImpl implements TrendService {
Double speed = po.getSpeed();
vo.setSpeed((double) Math.round(speed *100)/100.0 );//Math.round(0.01d * 100) / 100.0
Double queueLength = po.getQueueLength();
vo.setQueueLength((int) Math.round(queueLength));
if(queueLength != null){
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime);
......@@ -1481,7 +1484,9 @@ public class TrendServiceImpl implements TrendService {
//路口未清空率
vo.setCrossNoClearRate(0);
//平均排队长度
vo.setAvgQueueLength(0.0);
if(queueLength != null){
vo.setAvgQueueLength(Integer.parseInt(String.valueOf(queueLength)));
}
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
......@@ -1553,51 +1558,56 @@ public class TrendServiceImpl implements TrendService {
// Date dateFromTimestamp = new Date(millis);
Double queueLength = po.getQueueLength();
vo.setQueueLength(Math.round(queueLength *100)/100.0);
if (queueLength != null) {
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Integer delayTime = po.getDelayTime();
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(Math.round(stopTimes *100)/100.0);
if (stopTimes != null) {
vo.setStopTimes(Math.round(stopTimes * 100) / 100.0);
}
Double vehheadTime = po.getVehheadTime();
vo.setVehheadTime(Math.round(vehheadTime*100)/100.0);
//饱和度 sturation
if (po.getSturation() != null) {
vo.setSaturation((double) Math.round(po.getSturation()*100)/100.0);
}else {
vo.setSaturation(0.0);
// vo.setSaturation(0.0);
}
//拥堵指数
vo.setCongestionIndex(0.0);
// vo.setCongestionIndex(0.0);
//溢出指数
vo.setOverflowIndex(po.getEffusionRate());
//失衡指数
vo.setImbalanceIndex(0.0);
//拥堵次数
vo.setCongestionTimes(0);
// vo.setImbalanceIndex(0.0);
// //拥堵次数
// vo.setCongestionTimes(0);
//溢出次数
if (po.getEffusionRate() != null) {
vo.setOverflowTimes(Math.round(po.getEffusionRate() *100)/100.0);
}else {
vo.setOverflowTimes(0);
// vo.setOverflowTimes(0);
}
//失衡次数
vo.setImbalanceTimes(0);
//空放次数
vo.setFreeFlowTimes(0);
// vo.setImbalanceTimes(0);
// //空放次数
// vo.setFreeFlowTimes(0);
//溢流率
if (po.getEffusionRate() != null) {
vo.setOverflowRate(Math.round(po.getEffusionRate()*100)/100.0);
}else {
vo.setOverflowRate(0.0);
// vo.setOverflowRate(0.0);
}
//冲突点
vo.setConflictPoint(0);
// vo.setConflictPoint(0);
Double timeOccupancyDouble = po.getTimeOccupancy();
if (timeOccupancyDouble != null) {
......@@ -1609,15 +1619,15 @@ public class TrendServiceImpl implements TrendService {
vo.setVehicleNumsRatioMean(Math.round(vehicleLengthRatioMean * 100)/100.0);
}
//路口服务水平
vo.setServiceLevel(0);
//路口安全系数
vo.setSafetyCoefficient(0.0);
//安全评价等级
vo.setSafetyEvaluateLevel(0);
//交通事件数
vo.setTrafficEventNum(0);
//交通事故数
vo.setTrafficAccidentNum(0);
// vo.setServiceLevel(0);
// //路口安全系数
// vo.setSafetyCoefficient(0.0);
// //安全评价等级
// vo.setSafetyEvaluateLevel(0);
// //交通事件数
// vo.setTrafficEventNum(0);
// //交通事故数
// vo.setTrafficAccidentNum(0);
//不停车通过率
vo.setNoStopPassRate((double) Math.round(po.getNoStopRate()*100)/100.0);
......@@ -1626,19 +1636,21 @@ public class TrendServiceImpl implements TrendService {
//二次停车通过率
vo.setTwoStopPassRate((double) Math.round(po.getTwoStopRate()*100)/100.0);
//路口未清空率
vo.setCrossNoClearRate(0);
// vo.setCrossNoClearRate(0);
//平均排队长度
if (po.getQueueLength() != null) {
vo.setAvgQueueLength(po.getQueueLength());
// vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
int queueLengthInt = (int) Math.round(queueLength);
vo.setAvgQueueLength(queueLengthInt);
}else{
vo.setAvgQueueLength(0.0);
// vo.setAvgQueueLength(0.0);
}
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
vo.setPedAvgPassTime(0.0);
//行人闯红灯率
vo.setPedCrossRedLightRate(0.0);
// vo.setGreenLightEfficiency(0.0);
// //行人平均通过时间
// vo.setPedAvgPassTime(0.0);
// //行人闯红灯率
// vo.setPedCrossRedLightRate(0.0);
vo.setVehheadDist((double) Math.round(po.getVehheadDist()*100)/100.0);
......@@ -1681,22 +1693,27 @@ public class TrendServiceImpl implements TrendService {
//vo.setAllVehiceleFlow(po.getFlow() + po.getNonMotorFlow());
vo.setAllVehiceleFlow(po.getFlow() + 0);//车辆总和
vo.setAllFlow(0 + 0 + po.getFlow());
vo.setPedFlow(0);
vo.setNonMotorFlow(0);//非机动车流量
// vo.setPedFlow(0);
// vo.setNonMotorFlow(0);//非机动车流量
vo.setTrafficFlowA( po.getTrafficFlowA());
vo.setTrafficFlowB( po.getTrafficFlowB());
vo.setTrafficFlowC( po.getTrafficFlowC());
Double speed = po.getSpeed();
vo.setSpeed( Math.round(speed*100)/100.0);
vo.setVehheadDist(0d);//车头间距
// vo.setVehheadDist(0d);//车头间距
Double queueLength = po.getQueueLength();
vo.setQueueLength(Math.round(queueLength *100)/100.0);
if (queueLength != null) {
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();
vo.setStopTimes(Math.round(stopTimes*100)/100.0);
if (stopTimes != null) {
vo.setStopTimes(Math.round(stopTimes * 100) / 100.0);
}
if (po.getVehheadTime() != null) {
vo.setVehheadTime(Math.round(po.getVehheadTime()*100)/100.0);
}else {
vo.setVehheadTime(0);
// vo.setVehheadTime(0);
}
//----------------------------------------------------------------------------------------------
......@@ -1712,36 +1729,36 @@ public class TrendServiceImpl implements TrendService {
Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime);
//路口效率指数
vo.setEfficiencyIndex(0.0);
// vo.setEfficiencyIndex(0.0);
//效率评价等级
vo.setEfficiencyEvaluateLevel(0.0);
// vo.setEfficiencyEvaluateLevel(0.0);
//饱和度
if(po.getSturation() != null) {
//保留小数点后两位
vo.setSaturation(Math.round(po.getSturation() * 100) / 100.0);
}
//拥堵指数
vo.setCongestionIndex(0.0);
// vo.setCongestionIndex(0.0);
//溢出指数
if (po.getEffusionRate() != null) {
vo.setOverflowIndex(po.getEffusionRate());
}else {
vo.setOverflowIndex(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);
// 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) {
......@@ -1753,43 +1770,43 @@ public class TrendServiceImpl implements TrendService {
vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
// }
//路口服务水平
vo.setServiceLevel(0);
//路口安全系数
vo.setSafetyCoefficient(0.0);
//安全评价等级
vo.setSafetyEvaluateLevel(0);
//交通事件数
vo.setTrafficEventNum(0);
//交通事故数
vo.setTrafficAccidentNum(0);
// vo.setServiceLevel(0);
// //路口安全系数
// vo.setSafetyCoefficient(0.0);
// //安全评价等级
// vo.setSafetyEvaluateLevel(0);
// //交通事件数
// vo.setTrafficEventNum(0);
// //交通事故数
// vo.setTrafficAccidentNum(0);
//不停车通过率
if (po.getNoStopRate() != null) {
vo.setNoStopPassRate(Math.round(po.getNoStopRate() * 100) / 100.0);
}else {
vo.setNoStopPassRate(0);
// vo.setNoStopPassRate(0);
}
//一次停车通过率
if (po.getOneStopRate() != null) {
vo.setOneStopPassRate(Math.round(po.getOneStopRate() * 100) / 100.0);
}else {
vo.setOneStopPassRate(0);
// vo.setOneStopPassRate(0);
}
//二次停车通过率
if (po.getTwoStopRate() != null) {
vo.setTwoStopPassRate(Math.round(po.getTwoStopRate() * 100) / 100.0);
}else {
vo.setTwoStopPassRate(0);
// vo.setTwoStopPassRate(0);
}
//路口未清空率
vo.setCrossNoClearRate(0);
//平均排队长度
vo.setAvgQueueLength(0.0);
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
vo.setPedAvgPassTime(0.0);
//行人闯红灯率
vo.setPedCrossRedLightRate(0.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);
//
......@@ -1830,24 +1847,29 @@ public class TrendServiceImpl implements TrendService {
vo.setAllFlow(0 + 0 + po.getFlow());//总流量
//vo.setAllVehiceleFlow(po.getFlow() + po.getNonMotorFlow());
vo.setAllVehiceleFlow(po.getFlow() + 0);//车辆总和
vo.setPedFlow(0);
// vo.setPedFlow(0);
if (po.getNonMotorFlow() != null) {
vo.setNonMotorFlow(Math.round(po.getNonMotorFlow() *100)/100.0);//非机动车流量
}else {
vo.setNonMotorFlow(0);
// vo.setNonMotorFlow(0);
}
vo.setTrafficFlowA((int) po.getTrafficFlowA());
vo.setTrafficFlowB((int) po.getTrafficFlowB());
vo.setTrafficFlowC((int) po.getTrafficFlowC());
Double speed = po.getSpeed();
vo.setSpeed(Math.round(speed *100)/100.0);
vo.setVehheadDist(0d);//车头间距
Double vehheadTime = 0d;
vo.setVehheadTime(Math.round(vehheadTime *100)/100.0);//车头时距
// vo.setVehheadDist(0d);//车头间距
// Double vehheadTime = 0d;
// vo.setVehheadTime(Math.round(vehheadTime *100)/100.0);//车头时距
Double queueLength = po.getQueueLength();
vo.setQueueLength(Math.round(queueLength*100)/100.0);
if (queueLength != null) {
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();//停车次数
vo.setStopTimes( Math.round(stopTimes *100)/100.0);
if (stopTimes != null) {
vo.setStopTimes(Math.round(stopTimes * 100) / 100.0);
}
//----------------------------------------------------------------------------------------------
// if (po.getId().contains(crossId.concat(Constants.SystemParam.SEPARATOR_MINUS))) {
......@@ -1862,95 +1884,97 @@ public class TrendServiceImpl implements TrendService {
Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime);
//路口效率指数
vo.setEfficiencyIndex(0.0);
// vo.setEfficiencyIndex(0.0);
//效率评价等级
vo.setEfficiencyEvaluateLevel(0.0);
// vo.setEfficiencyEvaluateLevel(0.0);
//饱和度
if(po.getSturation() != null) {
vo.setSaturation(Math.round(po.getSturation()*100)/100.0);
}else {
vo.setSaturation(0.0);
// vo.setSaturation(0.0);
}
//拥堵指数
if(po.getEffusionRate() != null) {
vo.setCongestionIndex(Math.round(po.getEffusionRate()*100)/100.0);
}else {
vo.setCongestionIndex(0.0);
// vo.setCongestionIndex(0.0);
}
//溢出指数
if (po.getEffusionRate() != null) {
vo.setOverflowIndex(po.getEffusionRate());
}
//失衡指数
vo.setImbalanceIndex(0.0);
//拥堵次数
vo.setCongestionTimes(0);
//溢出次数
vo.setOverflowTimes(0);
//失衡次数
vo.setImbalanceTimes(0);
//空放次数
vo.setFreeFlowTimes(0);
// vo.setImbalanceIndex(0.0);
// //拥堵次数
// vo.setCongestionTimes(0);
// //溢出次数
// vo.setOverflowTimes(0);
// //失衡次数
// vo.setImbalanceTimes(0);
// //空放次数
// vo.setFreeFlowTimes(0);
//溢流率
if (po.getEffusionRate() != null) {
vo.setOverflowRate(po.getEffusionRate());
}
//冲突点
vo.setConflictPoint(0);
// vo.setConflictPoint(0);
Double timeOccupancyDouble = po.getTimeOccupancy();
if (timeOccupancyDouble != null) {
vo.setTimeOccupancy(Math.round(timeOccupancyDouble * 100)/100.0);
}else {
vo.setTimeOccupancy(0);
// vo.setTimeOccupancy(0);
}
// Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean();
// if (vehicleLengthRatioMean != null) {
vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
// vo.setVehicleNumsRatioMean((int) Math.round(0 * 100));
// }
//路口服务水平
vo.setServiceLevel(0);
//路口安全系数
vo.setSafetyCoefficient(0.0);
//安全评价等级
vo.setSafetyEvaluateLevel(0);
//交通事件数
vo.setTrafficEventNum(0);
//交通事故数
vo.setTrafficAccidentNum(0);
// vo.setServiceLevel(0);
// //路口安全系数
// vo.setSafetyCoefficient(0.0);
// //安全评价等级
// vo.setSafetyEvaluateLevel(0);
// //交通事件数
// vo.setTrafficEventNum(0);
// //交通事故数
// vo.setTrafficAccidentNum(0);
//不停车通过率
if (po.getNoStopRate() != null) {
vo.setNoStopPassRate(Math.round(po.getNoStopRate()*100)/100.0);
}else {
vo.setNoStopPassRate(0);
// vo.setNoStopPassRate(0);
}
//一次停车通过率
if (po.getOneStopRate() != null) {
vo.setOneStopPassRate(Math.round(po.getOneStopRate()*100)/100.0);
}else {
vo.setOneStopPassRate(0);
// vo.setOneStopPassRate(0);
}
//二次停车通过率
if (po.getTwoStopRate() != null) {
vo.setTwoStopPassRate(Math.round(po.getTwoStopRate()*100)/100.0);
}else {
vo.setTwoStopPassRate(0);
// vo.setTwoStopPassRate(0);
}
//路口未清空率
vo.setCrossNoClearRate(0);
// vo.setCrossNoClearRate(0);
//平均排队长度
if (po.getQueueLength() != null) {
vo.setAvgQueueLength(Math.round(po.getQueueLength()*100)/100.0);
// vo.setAvgQueueLength(Integer.parseInt(String.valueOf(po.getQueueLength())));
int queueLengthInt = (int) Math.round(queueLength);
vo.setAvgQueueLength(queueLengthInt);
}else {
vo.setAvgQueueLength(0.0);
// vo.setAvgQueueLength(0.0);
}
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
vo.setPedAvgPassTime(0.0);
//行人闯红灯率
vo.setPedCrossRedLightRate(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());
//
......@@ -1985,23 +2009,27 @@ public class TrendServiceImpl implements TrendService {
//行人流量 + 非机动车流量 + 流量
vo.setAllFlow(0 + po.getNonMotorFlow() + po.getFlow());
vo.setAllVehiceleFlow(po.getFlow() + po.getNonMotorFlow());
vo.setPedFlow(0);
// vo.setPedFlow(0);
vo.setNonMotorFlow(po.getNonMotorFlow());
vo.setTrafficFlowA( po.getTrafficFlowA());
vo.setTrafficFlowB( po.getTrafficFlowB());
vo.setTrafficFlowC( po.getTrafficFlowC());
Double speed = po.getSpeed();
vo.setSpeed(Math.round(speed * 100)/ 100.0);
vo.setVehheadDist(0d);//车头间距
// vo.setVehheadDist(0d);//车头间距
Double vehheadTime = 0d;
vo.setVehheadTime(Math.round(vehheadTime*100)/100.0);//车头时距
Double queueLength = po.getQueueLength();
vo.setQueueLength(Math.round(queueLength*100)/100.0);
if (queueLength != null) {
//queueLength的值是105.0,需要转换为105
int queueLengthInt = (int) Math.round(queueLength);
vo.setQueueLength(queueLengthInt);
}
Double stopTimes = po.getStopTimes();
if (stopTimes != null) {
vo.setStopTimes(Math.round(stopTimes *100)/100.0);//Math.round(0.01d * 100) / 100.0
}else {
vo.setStopTimes(0);
// vo.setStopTimes(0);
}
//----------------------------------------------------------------------------------------------
......@@ -2019,105 +2047,105 @@ public class TrendServiceImpl implements TrendService {
Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime);
//路口效率指数
vo.setEfficiencyIndex(0.0);
// vo.setEfficiencyIndex(0.0);
//效率评价等级
vo.setEfficiencyEvaluateLevel(0.0);
// vo.setEfficiencyEvaluateLevel(0.0);
//饱和度
if (po.getSturation() != null) {
vo.setSaturation(Math.round(po.getSturation() *100)/100.0);//Math.round(0.01d * 100) / 100.0
}else {
vo.setSaturation(0.0);
// vo.setSaturation(0.0);
}
//拥堵指数
if (po.getCongestionIndex() != null) {
vo.setCongestionIndex(Math.round(po.getCongestionIndex()*100)/100.0);
}else {
vo.setCongestionIndex(0.0);
// vo.setCongestionIndex(0.0);
}
//溢出指数
if (po.getSpilloverIndex() != null) {
vo.setOverflowIndex(Math.round(po.getSpilloverIndex()*100)/100.0);
}else {
vo.setOverflowIndex(0.0);
// vo.setOverflowIndex(0.0);
}
//失衡指数
if (po.getUnbalanceIndex() != null) {
vo.setImbalanceIndex(Math.round(po.getUnbalanceIndex()*100)/100.0);
}else {
vo.setImbalanceIndex(0.0);
// vo.setImbalanceIndex(0.0);
}
//拥堵次数
vo.setCongestionTimes(0);
// vo.setCongestionTimes(0);
//溢出次数
vo.setOverflowTimes(0);
// vo.setOverflowTimes(0);
//失衡次数
vo.setImbalanceTimes(0);
// vo.setImbalanceTimes(0);
//空放次数
vo.setFreeFlowTimes(0);
// vo.setFreeFlowTimes(0);
//溢流率
vo.setOverflowRate(0.0);
// vo.setOverflowRate(0.0);
//冲突点
vo.setConflictPoint(0);
// vo.setConflictPoint(0);
Double timeOccupancyDouble = po.getTimeOccupancy();
if (timeOccupancyDouble != null) {
vo.setTimeOccupancy(Math.round(timeOccupancyDouble * 100) /100.0);//Math.round(0.01d * 100) / 100.0
}else {
vo.setTimeOccupancy(0);
// vo.setTimeOccupancy(0);
}
Double vehicleLengthRatioMean = po.getVehicleLengthRatioMean();
if (vehicleLengthRatioMean != null) {
vo.setVehicleNumsRatioMean(Math.round(vehicleLengthRatioMean * 100) /100.0);
}else {
vo.setVehicleNumsRatioMean(0);
// vo.setVehicleNumsRatioMean(0);
}
//路口服务水平
vo.setServiceLevel(0);
// vo.setServiceLevel(0);
//路口安全系数
vo.setSafetyCoefficient(0.0);
// vo.setSafetyCoefficient(0.0);
//安全评价等级
vo.setSafetyEvaluateLevel(0);
// vo.setSafetyEvaluateLevel(0);
//交通事件数
vo.setTrafficEventNum(0);
// vo.setTrafficEventNum(0);
//交通事故数
vo.setTrafficAccidentNum(0);
// vo.setTrafficAccidentNum(0);
//不停车通过率
if (po.getNoStopRate() != null) {
vo.setNoStopPassRate(Math.round(po.getNoStopRate() *100) / 100.0d);//Math.round(0.01d * 100) / 100.0
}else {
vo.setNoStopPassRate(0);
// vo.setNoStopPassRate(0);
}
//一次停车通过率
if (po.getOneStopRate() != null) {
vo.setOneStopPassRate( Math.round(po.getOneStopRate() *100)/ 100.0);//Math.round(0.01d * 100) / 100.0
}else {
vo.setOneStopPassRate(0);
// vo.setOneStopPassRate(0);
}
//二次停车通过率
if (po.getTwoStopRate() != null) {
vo.setTwoStopPassRate(Math.round(po.getTwoStopRate() *100)/100.0);//Math.round(0.01d * 100) / 100.0
}else {
vo.setTwoStopPassRate(0);
// vo.setTwoStopPassRate(0);
}
//三次停车通过率
if (po.getThreeStopRate() != null) {
vo.setThreeStopRate(Math.round(po.getThreeStopRate()*100)/100.0);
}else {
vo.setThreeStopRate(0.0);
// vo.setThreeStopRate(0.0);
}
//路口未清空率
vo.setCrossNoClearRate(0);
// vo.setCrossNoClearRate(0);
//平均排队长度
vo.setAvgQueueLength(0.0);
// vo.setAvgQueueLength(0.0);
//绿灯有效利用率
vo.setGreenLightEfficiency(0.0);
// vo.setGreenLightEfficiency(0.0);
//行人平均通过时间
vo.setPedAvgPassTime(0.0);
// vo.setPedAvgPassTime(0.0);
//行人闯红灯率
vo.setPedCrossRedLightRate(0.0);
// vo.setPedCrossRedLightRate(0.0);
// vo.setVehheadDist(po.getVehheadDist());
......@@ -3326,4 +3354,9 @@ public class TrendServiceImpl implements TrendService {
}
}
public static void main(String[] args) {
double v = Math.round(1 * 100) / 100.0;
System.out.println(v);
}
}
......@@ -72,7 +72,7 @@ public class CrossingDirectionQueryVO {
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private double queueLength;
private int queueLength;
@ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
......@@ -194,7 +194,7 @@ public class CrossingDirectionQueryVO {
@ApiModelProperty(value = "平均排队长度")
@ExcelProperty("平均排队长度")
private double avgQueueLength;
private int avgQueueLength;
@ApiModelProperty(value = "绿灯有效利用率")
@ExcelProperty("绿灯有效利用率")
......
......@@ -72,7 +72,7 @@ public class CrossingQueryVO {
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private double queueLength;
private int queueLength;
@ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
......@@ -198,7 +198,7 @@ public class CrossingQueryVO {
@ApiModelProperty(value = "平均排队长度")
@ExcelProperty("平均排队长度")
private double avgQueueLength;
private int avgQueueLength;
@ApiModelProperty(value = "绿灯有效利用率")
@ExcelProperty("绿灯有效利用率")
......
......@@ -84,7 +84,7 @@ public class CrossingTurnQueryVO {
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private double queueLength;
private int queueLength;
@ApiModelProperty(value = "平均停车次数")
@ExcelProperty("平均停车次数")
......@@ -206,7 +206,7 @@ public class CrossingTurnQueryVO {
@ApiModelProperty(value = "平均排队长度")
@ExcelProperty("平均排队长度")
private double avgQueueLength;
private int avgQueueLength;
@ApiModelProperty(value = "绿灯有效利用率")
@ExcelProperty("绿灯有效利用率")
......
......@@ -20,4 +20,6 @@ public class RunningEvaluateStatusVO {
@ApiModelProperty(value = "时间列表")
private List<String> timeList;
//提示无数据
private String content;
}
......@@ -136,7 +136,7 @@ public class TableQueryVO {
@ApiModelProperty(value = "最大排队")
@ExcelProperty("最大排队")
private double queueLength;
private int queueLength;
@ApiModelProperty(value = "平均延误")
@ExcelProperty("平均延误")
......@@ -266,7 +266,7 @@ public class TableQueryVO {
@ApiModelProperty(value = "平均排队长度")
@ExcelProperty("平均排队长度")
private double avgQueueLength;
private int avgQueueLength;
@ApiModelProperty(value = "绿灯有效利用率")
@ExcelProperty("绿灯有效利用率")
......
spring:
profiles:
active: docker
\ No newline at end of file
#docker是武汉环境,demo是北京环境
active: demo
\ No newline at end of file
......@@ -167,6 +167,11 @@
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</dependency>
<dependency>
<groupId>net.jodah</groupId>
<artifactId>expiringmap</artifactId>
<version>0.5.10</version>
</dependency>
</dependencies>
<build>
......
......@@ -119,7 +119,11 @@ public class RedisConfig extends CachingConfigurerSupport {
@Bean
public Jedis jedis() {
Jedis jedis = new Jedis(redisHost, redisPort);
jedis.auth(password);
if (password != null && !"".equals(password)) {
jedis.auth(password);
}else {
jedis.auth("Wanji300552");
}
return jedis;
}
......
package net.wanji.utc.dto.twinspat;
import lombok.Data;
import java.util.List;
/**
* 路口信息
*/
@Data
public class Intersection {
// 路口id (这个id需要与库表中路口id要映射)
private int nodeId;
private List<Phase> phases;
}
\ No newline at end of file
package net.wanji.utc.dto.twinspat;
import lombok.Data;
/**
* 相位信息
* 解释名词:
* 相位是指在一个信号灯周期中,某一组特定方向的交通流获得通行权(如绿灯)的状态。
* “相位”就是信号灯在某个时间段内允许某些方向车辆通行的一种状态。
* “当前相位”是指当前正在运行的信号灯状态,决定了哪些方向可以通行、哪些需要等待。
*
*/
@Data
public class Phase {
private String id; // 唯一值 phaseId + "_" + laneId
private int phaseId; // 相位ID [1-16], 控制一个灯组
private int laneId; // 车道编号
private int state; // 转向(灯组状态 [参考表E.3])
private int importDirect; // 进口方向 [参考表E.2]
private int turn; // 车道转向
private int light; // 信号灯颜色 [0..8]
private int limitEndTime; // 信号灯倒计时, 单位:秒
private String log; // 经度
private String lat; // 纬度
private float angle; // 信号灯角度
}
\ No newline at end of file
package net.wanji.utc.dto.twinspat;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.util.List;
/**
* 孪生专用信号灯数据
*/
@Data
public class WHSpatData {
private String rsuId;//要配映射路口id
private int msgCnt;
private long timestamp;
private String uuid;
private String msgType;
/**
* 路口列表
*/
private List<Intersection> intersections;
public static void main(String[] args) {
String json = "{\"intersections\":[{\"nodeId\":15,\"phases\":[{\"angle\":261.0,\"id\":\"4_1\",\"importDirect\":0,\"laneId\":1,\"lat\":\"30.4518233\",\"light\":3,\"limitEndTime\":28,\"log\":\"114.0926314\",\"phaseId\":4,\"state\":4},{\"angle\":261.0,\"id\":\"4_2\",\"importDirect\":0,\"laneId\":2,\"lat\":\"30.4518180\",\"light\":3,\"limitEndTime\":28,\"log\":\"114.0925986\",\"phaseId\":4,\"state\":4},{\"angle\":348.0,\"id\":\"66_1\",\"importDirect\":4,\"laneId\":1,\"lat\":\"30.4516888\",\"light\":3,\"limitEndTime\":5,\"log\":\"114.0930230\",\"phaseId\":66,\"state\":2},{\"angle\":348.0,\"id\":\"65_3\",\"importDirect\":4,\"laneId\":3,\"lat\":\"30.4517495\",\"light\":4,\"limitEndTime\":2,\"log\":\"114.0930097\",\"phaseId\":65,\"state\":1},{\"angle\":348.0,\"id\":\"65_2\",\"importDirect\":4,\"laneId\":2,\"lat\":\"30.4517189\",\"light\":4,\"limitEndTime\":2,\"log\":\"114.0930162\",\"phaseId\":65,\"state\":1},{\"angle\":91.0,\"id\":\"132_1\",\"importDirect\":8,\"laneId\":1,\"lat\":\"30.4511704\",\"light\":3,\"limitEndTime\":28,\"log\":\"114.0927570\",\"phaseId\":132,\"state\":4},{\"angle\":91.0,\"id\":\"132_2\",\"importDirect\":8,\"laneId\":2,\"lat\":\"30.4511697\",\"light\":3,\"limitEndTime\":28,\"log\":\"114.0927937\",\"phaseId\":132,\"state\":4},{\"angle\":169.0,\"id\":\"194_1\",\"importDirect\":12,\"laneId\":1,\"lat\":\"30.4515106\",\"light\":3,\"limitEndTime\":5,\"log\":\"114.0924748\",\"phaseId\":194,\"state\":2},{\"angle\":169.0,\"id\":\"193_2\",\"importDirect\":12,\"laneId\":2,\"lat\":\"30.4514799\",\"light\":4,\"limitEndTime\":2,\"log\":\"114.0924808\",\"phaseId\":193,\"state\":1},{\"angle\":170.0,\"id\":\"193_3\",\"importDirect\":12,\"laneId\":3,\"lat\":\"30.4514491\",\"light\":4,\"limitEndTime\":2,\"log\":\"114.0924865\",\"phaseId\":193,\"state\":1}]}],\"msgCnt\":92,\"msgType\":\"spat\",\"rsuId\":\"R-081507\",\"timestamp\":1746685493855,\"uuid\":\"R-081507_1746685493855\"}";
WHSpatData whSpatData = JSONObject.parseObject(json, WHSpatData.class);
System.out.println(whSpatData);
}
}
package net.wanji.utc.task;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.dao.entity.CrossLightsStatusHistPO;
......@@ -17,11 +21,17 @@ import net.wanji.feign.service.UtcDTFeignClients;
import net.wanji.feign.service.UtcHisenseFeignClients;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.common.typeenum.BasicEnum;
import net.wanji.utc.dto.twinspat.Intersection;
import net.wanji.utc.dto.twinspat.Phase;
import net.wanji.utc.dto.twinspat.WHSpatData;
import net.wanji.utc.kafka.ProducerHandler;
import net.wanji.utc.service.runninginfo.HkLightsStatusService;
import net.wanji.utc.service.runninginfo.SignalStatusService;
import net.wanji.utc.util.DirectionConverter;
import net.wanji.utc.util.TurnDirectionMapper;
import net.wanji.utc.websocket.RealTimeDataWebSocket;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
......@@ -33,6 +43,8 @@ import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
......@@ -43,6 +55,8 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 订阅信号运行状态、告警、灯态
......@@ -65,7 +79,7 @@ public class SignalStatusTask {
private ManufacturerInfoMapper manufacturerInfoMapper;
@Resource
private CrossInfoMapper crossInfoMapper;
@Resource
// @Resource
private UtcDTFeignClients utcDTFeignClients;
@Resource
private CrossLightsStatusHistMapper crossLightsStatusHistMapper;
......@@ -81,30 +95,99 @@ public class SignalStatusTask {
private static final ConcurrentHashMap<String, List<LightsStatusVO2>> produceListMap = new ConcurrentHashMap<>();
//路口信息过期map<路口id,路口信息>
public static final ExpiringMap<String, CrossInfoPO> crossCacheMap = ExpiringMap.builder()
.expiration(1, TimeUnit.MINUTES)
.maxSize(100)
.variableExpiration()
.expirationPolicy(ExpirationPolicy.CREATED)
//过期监听
.asyncExpirationListener((rcuIdStr, value) -> {
}).build();
//信号灯倒计时缓存map<crossid_相位id, 倒计时>
public static final ExpiringMap<String, Integer> phaseCountdownCacheMap = ExpiringMap.builder()
.expiration(60 * 24, TimeUnit.MINUTES)
.maxSize(100)
.variableExpiration()
.expirationPolicy(ExpirationPolicy.CREATED)
//过期监听
.asyncExpirationListener((rcuIdStr, value) -> {
}).build();
// 运行状态、告警,1分钟一次
@Scheduled(fixedRate = 60 * 1000)
public void runningStatusAlarm() throws Exception {
signalStatusService.runningStatusAlarm();
}
/**
* 消费孪生灯态kafka数据
*/
@KafkaListener(topics = {"WHSpatData"}, groupId = "utc-whspat-consumer-01")
public void consumeTwinSpat(ConsumerRecord<Object, Object> record, Acknowledgment acknowledgment) {
try {
String lightStatusJson = String.valueOf(record.value());
WHSpatData light = JSONObject.parseObject(lightStatusJson, WHSpatData.class);
if (Objects.nonNull(light)) {
//--------------------------------------------------------------------------
ConcurrentHashMap<String, RealTimeDataWebSocket> evenWarnWebSocketMap = RealTimeDataWebSocket.getEvenWarnWebSocketMap();
if (!evenWarnWebSocketMap.isEmpty()) {
//1. 按路口分组后的websocket连接列表:map<crossId, List<Map.Entry<String, RealTimeDataWebSocket>>>
Map<String, List<Map.Entry<String, RealTimeDataWebSocket>>> crossEntryMap = getCrossEntryMap(evenWarnWebSocketMap);
//2. 循环每一个路口,并且循环每一个websocket连接,发送灯态数据
for (Map.Entry<String, List<Map.Entry<String, RealTimeDataWebSocket>>> entry : crossEntryMap.entrySet()) {
ObjectMapper mapper = JacksonUtils.getInstance();
String crossId = entry.getKey();
//2.1 获取路口信息
CrossInfoPO crossInfoPO = crossCacheMap.get(crossId);
if (Objects.isNull(crossInfoPO)) {
crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.isNull(crossInfoPO)) {
continue;
}
crossCacheMap.put(crossId, crossInfoPO);
}
//2.2 获取灯态信息,传递参数:mapper,crossId,路口信息
List<LightsStatusVO> lightsStatusVOS = getLightsStatusVOS2(crossInfoPO, light);
//2.3 保存灯态数据并发送
saveAndSendLightsStatus(mapper, crossId, lightsStatusVOS, entry);
}
sendKafka();
}
//--------------------------------------------------------------------------
}
}catch (Exception e) {
log.error("解析灯态数据异常", e);
}
}
// 灯态,每秒一次
@Scheduled(fixedRate = 1000)
// @Scheduled(fixedRate = 1000)
public void lightStatus() {
ConcurrentHashMap<String, RealTimeDataWebSocket> evenWarnWebSocketMap = RealTimeDataWebSocket.getEvenWarnWebSocketMap();
try {
if (!evenWarnWebSocketMap.isEmpty()) {
//1. 按路口分组后的websocket连接列表:map<crossId, List<Map.Entry<String, RealTimeDataWebSocket>>>
Map<String, List<Map.Entry<String, RealTimeDataWebSocket>>> crossEntryMap = getCrossEntryMap(evenWarnWebSocketMap);
//2. 循环每一个路口,并且循环每一个websocket连接,发送灯态数据
for (Map.Entry<String, List<Map.Entry<String, RealTimeDataWebSocket>>> entry : crossEntryMap.entrySet()) {
//commonThreadPoolExecutor.execute(() -> {
ObjectMapper mapper = JacksonUtils.getInstance();
String crossId = entry.getKey();
//2.1 获取路口信息
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.isNull(crossInfoPO)) {
continue;
}
//2.2 获取灯态信息,传递参数:mapper,crossId,路口信息
List<LightsStatusVO> lightsStatusVOS = getLightsStatusVOS(mapper, crossId, crossInfoPO);
//2.3 保存灯态数据并发送
saveAndSendLightsStatus(mapper, crossId, lightsStatusVOS, entry);
//});
}
......@@ -125,23 +208,28 @@ public class SignalStatusTask {
*/
private void saveAndSendLightsStatus(ObjectMapper mapper, String crossId, List<LightsStatusVO> lightsStatusVOS,
Map.Entry<String, List<Map.Entry<String, RealTimeDataWebSocket>>> entry) {
//1. 获取路口websocket连接列表
List<Map.Entry<String, RealTimeDataWebSocket>> value = entry.getValue();
produceListMap.remove(crossId); // 清除上一秒缓存
if (!CollectionUtils.isEmpty(lightsStatusVOS)) {
//2. 循环遍历灯态数据,并保存灯态数据到数据库,并发送灯态数据到websocket
for (LightsStatusVO lightsStatusVO : lightsStatusVOS) {
if (Objects.nonNull(lightsStatusVO) && Objects.equals(lightsStatusVO.getCrossId(), crossId)) {
//
calculateControlCountDown(crossId, lightsStatusVO);
try {
// 相同路口不同websocket统一发送灯态
List<LightsStatusVO2> listResult = convertDirLampGroupMap2Entity(lightsStatusVOS);
String json = mapper.writeValueAsString(listResult);
List<LightsStatusVO2> listResult2 = convertDirLampGroupMap2Entity(lightsStatusVOS);
String json = mapper.writeValueAsString(listResult2);
for (Map.Entry<String, RealTimeDataWebSocket> socketEntry : value) {
String crossIdStr = socketEntry.getKey();
RealTimeDataWebSocket webSocket = socketEntry.getValue();
// 发送数据到websocket
webSocket.sendInfo(json, crossIdStr);
}
insertIntoHist(crossId, json);
produceListMap.put(crossId, listResult);
produceListMap.put(crossId, listResult2);
} catch (Exception e) {
log.error("RealTimeDataWebSocket发送异常,异常信息:", e);
}
......@@ -188,6 +276,139 @@ public class SignalStatusTask {
return Collections.emptyList();
}
public static Map<String, String> crossIdMap = new HashMap();
{
crossIdMap.put("R-081507", "12Q5V099C30");
}
/**
* 获取路口灯态列表
* @param crossInfoPO 路口信息
* @param light 孪生灯态数据
* @return
*/
private List<LightsStatusVO> getLightsStatusVOS2(CrossInfoPO crossInfoPO, WHSpatData light){
List<LightsStatusVO> result = new ArrayList<>();
//1. 获取路口列表
List<Intersection> intersections = light.getIntersections();
//2. 循环每一个路口(实际就一个路口,因为rsuId对应一个路口)
for (Intersection nodeCross : intersections) {
List<Phase> phases = nodeCross.getPhases();
String crossId = (String) crossIdMap.get(light.getRsuId());
//转向-方向-灯态
Map<String, Boolean> m = Maps.newHashMap();
//循环每一个相位,获取该相位相关字段:如周期时间、周期倒计时、相位灯态倒计时、方向、车道转向、灯态
for (Phase p : phases) {
LightsStatusVO infoVo = new LightsStatusVO();
infoVo.setRunMode("8");// 控制模式
infoVo.setPhasePlanId("1");// 相位方案号
infoVo.setSchemeId("1");
infoVo.setCode(light.getRsuId());
infoVo.setCrossId(crossId);
infoVo.setCycleCountDown(0);
String cycleLenKey = crossId + "_" + p.getPhaseId();
Integer len = phaseCountdownCacheMap.get(cycleLenKey);
if (len != null){
if (len < p.getLimitEndTime()){
phaseCountdownCacheMap.put(cycleLenKey, p.getLimitEndTime());
infoVo.setCycleLen(p.getLimitEndTime());
}else{
infoVo.setCycleLen(len);
}
}else{
phaseCountdownCacheMap.put(cycleLenKey, p.getLimitEndTime());
}
infoVo.setPhaseId(p.getPhaseId() + "");
infoVo.setCyclePhaseCountDown(p.getLimitEndTime());
//map<方向,倒计时>
Map<String, Object> phaseMap = new HashMap<>();
infoVo.setPhaseMap(phaseMap);
//后两个参数是map<方向,倒计时>, 倒计时
Map<String, Object> dirLampGroupMap = getDirLampGroupMap(p, m, phaseMap, p.getLimitEndTime());
infoVo.setDirLampGroupMap(dirLampGroupMap);
infoVo.setTimeStamp(light.getTimestamp() + "");
infoVo.setSchemeStartTime(light.getTimestamp() + "");
result.add(infoVo);
}
}
return result;
}
private Map<String, Object> getDirLampGroupMap(Phase phase, Map<String, Boolean> m, Map<String, Object> phaseMap, int limitEndTime) {
//Map<进口方向, Map<车道转向, 对应灯态>>
Map<String, Object> dirLampGroupMap = new HashMap<>();
//进口方向
int importDirect = phase.getImportDirect();
int dir = DirectionConverter.convertDirection(importDirect);//进口方向适配
phaseMap.put(dir + "", limitEndTime);//方向,倒计时
//Map<车道转向, 对应灯态>
Map<Integer, String> turnMap = new HashMap<>();
dirLampGroupMap.put(dir + "", turnMap);
//获取灯态
// 信号灯颜色 [0..8],0:未知状态,1:信号灯未工作,2:红闪,3:红灯状态,4:绿灯待行状态,
// 5:绿灯状态,6:受保护相位绿灯(箭头灯),7:黄灯状态,8:黄闪。
int light = phase.getLight();
String color = transferLampGroup(light);//车道灯态适配
int turn = phase.getTurn();
int turnDir = TurnDirectionMapper.mapToTargetValue(turn);//车道转向适配
if (m.containsKey(dir + "-" + turnDir + "-" + color)){
return null;
}else {
m.put(dir + "-" + turnDir + "-" + color, true);
}
turnMap.put(turnDir, color);
return dirLampGroupMap;
}
/**
* 信号灯状态转颜色
* 信号灯颜色 [0..8],
* 0:未知状态,1:信号灯未工作,2:红闪,3:红灯状态,
* 4:绿灯待行状态,5:绿灯状态,6:受保护相位绿灯(箭头灯),7:黄灯状态,8:黄闪。
* @param state
* @return
*/
private String transferLampGroup(int state) {
String color = "";
switch (state) {
case 1://信号灯未工作
color = "green";
break;
case 2:
color = "redFlash";
break;
case 3:
color = "red";
break;
case 4:
color = "greenFlash";
break;
case 5:
color = "green";
break;
case 6:
color = "green";
break;
case 7:
color = "yellow";
break;
case 8:
color = "yellowFlash";
break;
default:
color = "";
break;
}
return color;
}
private static List<LightsStatusVO2> convertDirLampGroupMap2Entity(List<LightsStatusVO> lightsStatusVOS) throws Exception {
List<LightsStatusVO2> listResult = null;
try {
......@@ -353,10 +574,13 @@ public class SignalStatusTask {
* 不同系统获取统一路口灯态,统一处理
*
* @param evenWarnWebSocketMap
* @return
* @return 返回类型是 Map<String, List<Map.Entry<String, RealTimeDataWebSocket>>>,表示按 crossId 分组后的连接条目。
*/
private static Map<String, List<Map.Entry<String, RealTimeDataWebSocket>>> getCrossEntryMap(ConcurrentHashMap<String, RealTimeDataWebSocket> evenWarnWebSocketMap) {
//map<crossId, List<Map.Entry<crossIdStr, RealTimeDataWebSocket>>>
Map<String, List<Map.Entry<String, RealTimeDataWebSocket>>> tempMap = new ConcurrentHashMap<>();
//遍历所有路口websocket
for (Map.Entry<String, RealTimeDataWebSocket> item : evenWarnWebSocketMap.entrySet()) {
String crossId = "";
String crossIdStr = item.getKey();
......
package net.wanji.utc.util;
/**
* 灯态的16个方向转换为8个方向类型
* 注:用于计算空放
*/
public class DirectionConverter {
/**
* 将0~15的进口方向编号转换为1~8的方向类型
* @param directionCode 0~15的输入方向编号
* @return 1~8的输出方向类型
*/
public static int convertDirection(int directionCode) {
if (directionCode < 0 || directionCode > 15) {
throw new IllegalArgumentException("directionCode must be between 0 and 15");
}
switch (directionCode) {
case 15:
case 0:
return 1; // 北
case 1:
case 2:
return 2; // 东北
case 3:
case 4:
return 3; // 东
case 5:
case 6:
return 4; // 东南
case 7:
case 8:
return 5; // 南
case 9:
case 10:
return 6; // 西南
case 11:
case 12:
return 7; // 西
case 13:
case 14:
return 8; // 西北
}
return 0; // 未知方向
}
public static void main(String[] args) {
for (int i = 0; i <= 15; i++) {
System.out.println("Input: " + i + " → Output: " + convertDirection(i));
}
}
}
package net.wanji.utc.util;
/**
* 灯态车道转向映射器
*/
public class TurnDirectionMapper {
// 定义映射关系,索引为源头转向值,值为目标转向值
private static final int[] DIRECTION_MAP = {
1, // 源头值 0 -> 目标值 1(左转)
2, // 源头值 1 -> 目标值 2(直行)
1, // 源头值 2 -> 目标值 1(左转)
5, // 源头值 3 -> 目标值 5(直左)
3, // 源头值 4 -> 目标值 3(右转)
6, // 源头值 5 -> 目标值 6(直右)
8, // 源头值 6 -> 目标值 8(左右)
7, // 源头值 7 -> 目标值 7(左直右)
4, // 源头值 8 -> 目标值 4(掉头)
10, // 源头值 9 -> 目标值 10(直行掉头)
9, // 源头值 10 -> 目标值 9(左转掉头)
12, // 源头值 11 -> 目标值 12(左直掉头)
11, // 源头值 12 -> 目标值 11(右转掉头)
13, // 源头值 13 -> 目标值 13(直右掉头)
15, // 源头值 14 -> 目标值 15(左右掉头)
14 // 源头值 15 -> 目标值 14(左直右掉头)
};
/**
* 转换源头转向值到目标转向值
*
* @param sourceValue 源头转向值 (0-15)
* @return 目标转向值 (1-15)
*/
public static int mapToTargetValue(int sourceValue) {
if (sourceValue < 0 || sourceValue >= DIRECTION_MAP.length) {
throw new IllegalArgumentException("非法源头转向值: " + sourceValue);
}
return DIRECTION_MAP[sourceValue];
}
public static void main(String[] args) {
for (int i = 0; i < 16; i++) {
System.out.println("源头值 " + i + " 映射的目标值为: " + mapToTargetValue(i));
}
}
}
spring:
profiles:
active: dev
\ No newline at end of file
#demo 北京环境
active: demo
\ No newline at end of file
......@@ -24,7 +24,7 @@ public class LightsStatusVO extends BaseCrossInfo {
private String phasePlanId;
@ApiModelProperty(value = "方案开始时间", notes = "目前没有用到")
private String schemeStartTime;
@ApiModelProperty(value = "相位周期剩余时长")
@ApiModelProperty(value = "周期剩余时长")
private Integer cycleCountDown;
@ApiModelProperty(value = "相位周期剩余时长")
private Integer cyclePhaseCountDown;
......
......@@ -148,7 +148,7 @@
AND t2.cross_id = #{crossId}
</if>
and t2.start_time <![CDATA[ >= ]]> #{startStamp}
and t2.start_time <![CDATA[ <= ]]> #{endStamp}
and t2.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t2.cross_id,
startTime
......
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="net.wanji.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate},#{entity.greenLightEfficiency}) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <!-- 方向级查询,条件:路口id、时间、方向 --> <select id="selectByCrossIdAndStartEndDir" resultType="net.wanji.databus.vo.CrossDirDataHistVO"> SELECT t1.cross_id AS crossId, t1.dir_type as dirType, <choose> <!-- 小时 --> <when test="granularity==1"> DATE_FORMAT(t2.start_time, '%Y-%m-%d %H:00:00') AS startTime, </when> <!-- 分钟 --> <otherwise> DATE_FORMAT( CONCAT( DATE ( t2.start_time ), ' ', HOUR ( t2.start_time ), ':', FLOOR( MINUTE ( t2.start_time ) / #{granularity} ) * #{granularity} ), '%Y-%m-%d %H:%i:00' ) AS startTime, </otherwise> </choose> SUM( t2.flow ) AS flow, COALESCE ( sum( t2.traffic_flow_C ), 0 ) AS trafficFlowC, COALESCE ( sum( t2.traffic_flow_B ), 0 ) AS trafficFlowB, COALESCE ( sum( t2.traffic_flow_A ), 0 ) AS trafficFlowA, avg( t2.speed ) AS speed, MAX( t2.queue_length ) AS queueLength, AVG( t2.stop_times ) AS stopTimes, AVG( t2.time_occupancy) as timeOccupancy, AVG( t2.sturation) as sturation, AVG( t2.no_stop_rate) as noStopRate, AVG( t2.one_stop_rate) as oneStopRate, AVG( t2.two_stop_rate) as twoStopRate, AVG( t2.three_stop_rate) as threeStopRate, AVG( t2.non_motor_flow) as nonMotorFlow FROM t_base_cross_dir_info t1 LEFT JOIN t_cross_dir_data_hist t2 ON t1.cross_id = t2.cross_id and t1.dir_type = t2.dir_type WHERE 1=1 <if test="crossId != null"> AND t1.cross_id = #{crossId} </if> <if test="dirTypeList != null"> AND t1.dir_type IN <foreach item="dirType" index="index" collection="dirTypeList" open="(" separator="," close=")"> #{dirType} </foreach> </if> and t2.start_time <![CDATA[ >= ]]> #{startStamp} and t2.start_time <![CDATA[ <= ]]> #{endStamp} GROUP BY t1.cross_id, t1.dir_type, startTime ORDER BY t2.start_time asc, t1.dir_type </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="net.wanji.databus.dao.mapper.CrossDirDataHistMapper"> <resultMap id="BaseResultMap" type="net.wanji.databus.po.CrossDirDataHistPO"> <result column="id" property="id"></result> <result column="dir_type" property="dirType"></result> <result column="in_out_type" property="inOutType"></result> <result column="cross_id" property="crossId"></result> <result column="length" property="length"></result> <result column="status" property="status"></result> <result column="traffic_index" property="trafficIndex"></result> <result column="start_time" property="startTime"></result> <result column="capacity" property="capacity"></result> <result column="duration" property="duration"></result> <result column="flow" property="flow"></result> <result column="speed" property="speed"></result> <result column="queue_length" property="queueLength"></result> <result column="stop_times" property="stopTimes"></result> <result column="delay_time" property="delayTime"></result> <result column="sturation" property="sturation"></result> <result column="batch_time" property="batchTime"></result> <result column="gmt_create" property="gmtCreate"></result> <result column="gmt_modified" property="gmtModified"></result> <result column="effusion_rate" property="effusionRate"></result> <result column="green_light_efficiency" property="greenLightEfficiency"></result> </resultMap> <sql id="Base_Column_List"> id,dir_type,in_out_type,cross_id,length,status,traffic_index,start_time,capacity,duration,flow,speed,queue_length,stop_times, delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate, green_light_efficiency </sql> <insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO"> insert ignore into t_cross_dir_data_hist (<include refid="Base_Column_List"></include>) values <foreach collection="list" item="entity" separator=","> ( #{entity.id}, #{entity.dirType}, #{entity.inOutType}, #{entity.crossId}, #{entity.length}, #{entity.status}, #{entity.trafficIndex}, #{entity.startTime}, #{entity.capacity}, #{entity.duration}, #{entity.flow}, #{entity.speed}, #{entity.queueLength}, #{entity.stopTimes}, #{entity.delayTime}, #{entity.sturation}, #{entity.noStopRate},#{entity.oneStopRate},#{entity.twoStopRate},#{entity.threeStopRate},#{entity.batchTime}, #{entity.gmtCreate}, #{entity.gmtModified},#{entity.effusionRate},#{entity.greenLightEfficiency}) </foreach> </insert> <delete id="deleteBatch" parameterType="String"> delete from t_cross_dir_data_hist where cross_id in <foreach collection="list" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> </delete> <select id="selectByCrossIdAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{preSeconds} order by batch_time </select> <select id="selectByCrossIdInOutTimestamp" resultType="net.wanji.databus.bo.CrossDirDataHistAvgBO"> SELECT dir_type as dirType, avg(capacity) as avgCapacity, avg(flow) as avgFlow, avg(queue_length) as avgQueueLength, avg(traffic_index) as avgIndex, avg(effusion_rate) as avgeffusionRate FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = #{inOutType} AND batch_time <![CDATA[ >= ]]> #{preSeconds} AND batch_time <![CDATA[ < ]]> #{endSeconds} GROUP BY dir_type </select> <select id="selectNoPark" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueue" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 2 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectNoParkEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectPhaseQueueEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type != #{dir} and batch_time <![CDATA[ <= ]]> #{currentSeconds} and batch_time <![CDATA[ >= ]]> #{preSeconds} </select> <select id="selectMetricHistDTO" resultType="net.wanji.databus.dto.MetricHistDTO"> select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time, one_stop_rate, queue_length, effusion_rate, no_stop_rate, green_light_efficiency from t_cross_dir_data_hist where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} order by batch_time </select> <select id="selectByCrossIdAndStartEnd" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"/> from t_cross_dir_data_hist where cross_id = #{crossId} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <!-- 方向级查询,条件:路口id、时间、方向 --> <select id="selectByCrossIdAndStartEndDir" resultType="net.wanji.databus.vo.CrossDirDataHistVO"> SELECT t1.cross_id AS crossId, t1.dir_type as dirType, <choose> <!-- 小时 --> <when test="granularity==1"> DATE_FORMAT(t2.start_time, '%Y-%m-%d %H:00:00') AS startTime, </when> <!-- 分钟 --> <otherwise> DATE_FORMAT( CONCAT( DATE ( t2.start_time ), ' ', HOUR ( t2.start_time ), ':', FLOOR( MINUTE ( t2.start_time ) / #{granularity} ) * #{granularity} ), '%Y-%m-%d %H:%i:00' ) AS startTime, </otherwise> </choose> SUM( t2.flow ) AS flow, COALESCE ( sum( t2.traffic_flow_C ), 0 ) AS trafficFlowC, COALESCE ( sum( t2.traffic_flow_B ), 0 ) AS trafficFlowB, COALESCE ( sum( t2.traffic_flow_A ), 0 ) AS trafficFlowA, avg( t2.speed ) AS speed, MAX( t2.queue_length ) AS queueLength, AVG( t2.stop_times ) AS stopTimes, AVG( t2.time_occupancy) as timeOccupancy, AVG( t2.sturation) as sturation, AVG( t2.no_stop_rate) as noStopRate, AVG( t2.one_stop_rate) as oneStopRate, AVG( t2.two_stop_rate) as twoStopRate, AVG( t2.three_stop_rate) as threeStopRate, AVG( t2.non_motor_flow) as nonMotorFlow FROM t_base_cross_dir_info t1 LEFT JOIN t_cross_dir_data_hist t2 ON t1.cross_id = t2.cross_id and t1.dir_type = t2.dir_type WHERE 1=1 <if test="crossId != null"> AND t1.cross_id = #{crossId} </if> <if test="dirTypeList != null"> AND t1.dir_type IN <foreach item="dirType" index="index" collection="dirTypeList" open="(" separator="," close=")"> #{dirType} </foreach> </if> and t2.start_time <![CDATA[ >= ]]> #{startStamp} and t2.start_time <![CDATA[ < ]]> #{endStamp} GROUP BY t1.cross_id, t1.dir_type, startTime ORDER BY t2.start_time asc, t1.dir_type </select> <select id="selectMaxDelayTime" resultType="java.lang.Integer"> select max(delay_time) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxQueueLength" resultType="java.lang.Double"> select max(queue_length) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxSaturation" resultType="java.lang.Double"> select max(sturation) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirType} and in_out_type = #{inOutType} and batch_time <![CDATA[ >= ]]> #{startStamp} and batch_time <![CDATA[ <= ]]> #{endStamp} </select> <select id="selectMaxGreenLightEfficiency" resultType="java.lang.Double"> select max(green_light_efficiency) from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type = #{dirCode} and in_out_type = #{code} and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} </select> <select id="selectByMetrics" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"/> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND in_out_type = 1 AND dir_type = #{dirInt} AND batch_time <![CDATA[ <= ]]> #{endTimeStamp} AND batch_time <![CDATA[ >= ]]> #{startTimeStamp} </select> <select id="selectByCrossIdsDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id in <foreach collection="crossIdList" item="crossId" separator="," open="(" close=")"> #{crossId} </foreach> and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type = #{dirCode} AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByCrossIdDirsAndTimestamp" resultType="net.wanji.databus.po.CrossDirDataHistPO"> select <include refid="Base_Column_List"></include> from t_cross_dir_data_hist where cross_id = #{crossId} and dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> and in_out_type = 1 and batch_time <![CDATA[ >= ]]> #{startTimeStamp} and batch_time <![CDATA[ <= ]]> #{endTimeStamp} order by batch_time </select> <select id="selectByCrossDirsAndTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE cross_id = #{crossId} AND dir_type in <foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")"> #{dirCode} </foreach> AND in_out_type = 1 AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr} AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr} </select> <select id="selectByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPO"><!-- SELECT <include refid="Base_Column_List"></include>--><!-- FROM t_cross_dir_data_hist--><!-- WHERE in_out_type = 1--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%Y-%m-%d') BETWEEN #{boStartDayStr} AND #{boEndDayStr}--><!-- AND DATE_FORMAT(FROM_UNIXTIME(batch_time), '%H:%i') BETWEEN #{startHourMinuteStr} AND #{endHourMinuteStr}--> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> <select id="selectExtByTimeSection" resultType="net.wanji.databus.po.CrossDirDataHistPOExt"> SELECT <include refid="Base_Column_List"></include> FROM t_cross_dir_data_hist WHERE batch_time BETWEEN UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boStartDayStr}, #{startHourMinuteStr}), '%Y-%m-%d%H:%i')) AND UNIX_TIMESTAMP(STR_TO_DATE(concat(#{boEndDayStr}, #{endHourMinuteStr}), '%Y-%m-%d%H:%i')) AND in_out_type = 1 </select> </mapper>
\ No newline at end of file
......
......@@ -178,7 +178,7 @@
</foreach>
</if>
and t1.start_time <![CDATA[ >= ]]> #{startStamp}
and t1.start_time <![CDATA[ <= ]]> #{endStamp}
and t1.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t2.id,
t2.dir,
......
......@@ -133,7 +133,7 @@
)
</if>
and t2.start_time <![CDATA[ >= ]]> #{startStamp}
and t2.start_time <![CDATA[ <= ]]> #{endStamp}
and t2.start_time <![CDATA[ < ]]> #{endStamp}
GROUP BY
t1.cross_id,
t2.in_dir,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment