Commit d1214f75 authored by hanbing's avatar hanbing

[update] 新信号评价-方案评价-均衡调控和安全保障策略详细问题

parent 8cc1f43e
......@@ -96,7 +96,7 @@ public class LanePeriodicDataEventListConvert {
crossDirDataRealTimePO.setBatchTime(batchTime);
crossDirDataRealTimePO.setGmtCreate(now);
crossDirDataRealTimePO.setGmtModified(now);//
crossDirDataRealTimePO.setEffusionTime(0000.0);//
crossDirDataRealTimePO.seteffusionRate(0000.0);//
return crossDirDataRealTimePO;
}
......
......@@ -127,15 +127,13 @@ public class EvaluateServiceImpl implements EvaluateService {
List<CrossDirDataRealtimePO> realtimeObj = dirObjMapRealtime.get(dir);
if (CollectionUtil.isNotEmpty(realtimeObj)) {
CrossDirDataRealtimePO crossDirDataRealtimePO = realtimeObj.get(0);
Double effusionTime = crossDirDataRealtimePO.getEffusionTime();
Double effusionRate = effusionTime / minutes;
Double effusionRate = crossDirDataRealtimePO.getEffusionRate();
effusionRateElement.setCurrentRate(effusionRate);
}
List<CrossDirDataHistAvgBO> histObj = dirObjMapHist.get(dir);
if (CollectionUtil.isNotEmpty(histObj)) {
CrossDirDataHistAvgBO crossDirDataHistAvgBO = histObj.get(0);
Double avgEffusionTime = crossDirDataHistAvgBO.getAvgEffusionTime();
Double avgEffusionRate = avgEffusionTime / minutes;
Double avgEffusionRate = crossDirDataHistAvgBO.getAvgEffusionRate();
effusionRateElement.setCompareRate(avgEffusionRate);
}
res.add(effusionRateElement);
......
......@@ -15,10 +15,7 @@ import net.wanji.databus.dao.entity.BaseCrossSchedulesPlanPO;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.dao.entity.CrossSectionPO;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.databus.po.*;
import net.wanji.opt.bo.CrossSchemeListBO;
import net.wanji.opt.bo.ProblemSchemeBO;
import net.wanji.opt.bo.SchemeDetailOverallBO;
......@@ -60,6 +57,7 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
private final CrossDirDataHistMapper crossDirDataHistMapper;
private final BaseCrossDirInfoMapper baseCrossDirInfoMapper;
private final CrossTurnDataHistMapper crossTurnDataHistMapper;
private final BaseCrossTurnInfoMapper baseCrossTurnInfoMapper;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
......@@ -75,7 +73,8 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
@Qualifier("baseCrossSchedulesPlanMapper") BaseCrossSchedulesPlanMapper baseCrossSchedulesPlanMapper,
CrossDataRealtimeMapper crossDataRealtimeMapper, CrossDirDataHistMapper crossDirDataHistMapper,
@Qualifier("baseCrossDirInfoMapper") BaseCrossDirInfoMapper baseCrossDirInfoMapper,
CrossTurnDataHistMapper crossTurnDataHistMapper) {
CrossTurnDataHistMapper crossTurnDataHistMapper,
@Qualifier("baseCrossTurnInfoMapper") BaseCrossTurnInfoMapper baseCrossTurnInfoMapper) {
this.crossDataHistMapper = crossDataHistMapper;
this.runningEvaluateService = runningEvaluateService;
this.baseCrossSectionMapper = baseCrossSectionMapper;
......@@ -89,6 +88,7 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
this.crossDirDataHistMapper = crossDirDataHistMapper;
this.baseCrossDirInfoMapper = baseCrossDirInfoMapper;
this.crossTurnDataHistMapper = crossTurnDataHistMapper;
this.baseCrossTurnInfoMapper = baseCrossTurnInfoMapper;
}
@Override
......@@ -299,24 +299,232 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
if (Objects.equals(strategyCode, StrategyAndMetricsEnum.Strategy.EFFICIENCY.getCode())) {
buildEfficiencyDetailVO(
crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId, startTimeStamp, endTimeStamp);
crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId);
} else if (Objects.equals(strategyCode, StrategyAndMetricsEnum.Strategy.BALANCE.getCode())) {
// buildBalanceDetailVO(
// crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId, startTimeStamp, endTimeStamp);
buildBalanceDetailVO(
crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId);
} else if (Objects.equals(strategyCode, StrategyAndMetricsEnum.Strategy.SECURITY.getCode())) {
// buildSecurityDetailVO(
// crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId, startTimeStamp, endTimeStamp);
buildSecurityDetailVO(
crossDirDataHistPOList, crossTurnDataHistPOList, vo, crossId, startTimeStamp, endTimeStamp);
}
return vo;
}
private void buildEfficiencyDetailVO(List<CrossDirDataHistPO> crossDirDataHistPOList,
private void buildSecurityDetailVO(List<CrossDirDataHistPO> crossDirDataHistPOList,
List<CrossTurnDataHistPO> crossTurnDataHistPOList,
SchemeEvaluateSchemeDetailedProblemVO vo, String crossId,
int startTimeStamp, int endTimeStamp) {
List<String> problemList = new ArrayList<>();
List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> tableContentList = new ArrayList<>();
// 获取路口方向
List<Integer> dirCodes = baseCrossDirInfoMapper.selectInDirsByCrossId(crossId);
for (Integer dirCode : dirCodes) {
Map<String, String> metricsMap = new HashMap<>();
SchemeEvaluateSchemeDetailedProblemVO.TableContent tableContent =
new SchemeEvaluateSchemeDetailedProblemVO.TableContent();
tableContent.setPosition(BaseEnum.SignalDirectionEnum.getNameByCode(dirCode) + "进口");
// 流量加总
int flow = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToInt(CrossDirDataHistPO::getFlow)
.sum();
tableContent.setFlow(flow);
// 溢流率取最大
double effusionRateMax = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToDouble(CrossDirDataHistPO::getEffusionRate)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getCode(),
effusionRateMax * 100 + StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getUnit());
// 绿灯间隔清空率取最大
double clearRateMax = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToDouble(CrossDirDataHistPO::getClearRate)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getCode(),
clearRateMax + StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getUnit());
// 方向级别三急一速数量
// 查询该方向所有的车道ID
List<String> laneIds = baseCrossDirInfoMapper.selectLaneIds(crossId, dirCode);
// 加总该方向的三急一速
Integer emergencyCount = baseCrossDirInfoMapper.selectDirEmergencyCount(
crossId, laneIds, startTimeStamp, endTimeStamp);
metricsMap.put(StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getCode(),
emergencyCount + StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getUnit());
// 筛选当前方向的转向数据
// List<CrossTurnDataHistPO> dirTurnPOList = crossTurnDataHistPOList.stream()
// .filter(item -> Objects.equals(item.getInDir(), dirCode))
// .collect(Collectors.toList());
// tableContent.setSubList(buildBalanceSublist(problemList, dirTurnPOList, dirCode));
// tableContent.setMetricsMap(metricsMap);
for (SchemeEvaluateSchemeDetailedProblemVO.TableContent content : tableContent.getSubList()) {
if (content.getHasProblem() == 1) {
tableContent.setHasProblem(1);
}
}
tableContentList.add(tableContent);
}
vo.setTableContentList(tableContentList);
if (CollectionUtil.isNotEmpty(problemList)) {
problemList.add("其他方向均衡状况良好");
}
vo.setProblems(problemList);
}
private void buildBalanceDetailVO(List<CrossDirDataHistPO> crossDirDataHistPOList,
List<CrossTurnDataHistPO> crossTurnDataHistPOList,
SchemeEvaluateSchemeDetailedProblemVO vo, String crossId) {
List<String> problemList = new ArrayList<>();
List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> tableContentList = new ArrayList<>();
// 获取路口方向
List<Integer> dirCodes = baseCrossDirInfoMapper.selectInDirsByCrossId(crossId);
for (Integer dirCode : dirCodes) {
Map<String, String> metricsMap = new HashMap<>();
SchemeEvaluateSchemeDetailedProblemVO.TableContent tableContent =
new SchemeEvaluateSchemeDetailedProblemVO.TableContent();
tableContent.setPosition(BaseEnum.SignalDirectionEnum.getNameByCode(dirCode) + "进口");
// 流量加总
int flow = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToInt(CrossDirDataHistPO::getFlow)
.sum();
tableContent.setFlow(flow);
// 绿灯有效利用率取最大
double greenLightEfficiencyMax = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToDouble(CrossDirDataHistPO::getGreenLightEfficiency)
.max()
.orElse(0.0);
long greenLightEfficiencyMaxLong = Math.round(greenLightEfficiencyMax * 100);
metricsMap.put(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode(),
greenLightEfficiencyMaxLong + StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getUnit());
// 饱和度取最大
double maxSaturation = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToDouble(CrossDirDataHistPO::getSturation)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.SATURATION.getCode(),
maxSaturation + StrategyAndMetricsEnum.Metrics.SATURATION.getUnit());
// 负载均衡度取最大
double maxLoadBalance = crossDirDataHistPOList.stream()
.filter(item -> Objects.equals(item.getDirType(), dirCode)
&& Objects.equals(item.getInOutType(), CrossInOutEnum.IN.getCode()))
.mapToDouble(CrossDirDataHistPO::getLoadBalance)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode(),
maxLoadBalance + StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getUnit());
// 筛选当前方向的转向数据
List<CrossTurnDataHistPO> dirTurnPOList = crossTurnDataHistPOList.stream()
.filter(item -> Objects.equals(item.getInDir(), dirCode))
.collect(Collectors.toList());
tableContent.setSubList(buildBalanceSublist(problemList, dirTurnPOList, dirCode));
tableContent.setMetricsMap(metricsMap);
for (SchemeEvaluateSchemeDetailedProblemVO.TableContent content : tableContent.getSubList()) {
if (content.getHasProblem() == 1) {
tableContent.setHasProblem(1);
}
}
tableContentList.add(tableContent);
}
vo.setTableContentList(tableContentList);
if (CollectionUtil.isNotEmpty(problemList)) {
problemList.add("其他方向均衡状况良好");
}
vo.setProblems(problemList);
}
private List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> buildBalanceSublist(
List<String> problemList, List<CrossTurnDataHistPO> currentDirTurnPOList, Integer dirCode) {
List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> tableContentList = new ArrayList<>();
// 获取该方向的每个转向
List<String> turnTypes = currentDirTurnPOList.stream()
.map(CrossTurnDataHistPO::getTurnType)
.distinct()
.collect(Collectors.toList());
for (String turnType : turnTypes) {
SchemeEvaluateSchemeDetailedProblemVO.TableContent tableContent =
new SchemeEvaluateSchemeDetailedProblemVO.TableContent();
tableContent.setPosition(TurnConvertEnum.getDescByCode(turnType));
Map<String, String> metricsMap = new HashMap<>();
// 流量加总
int flow = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToInt(CrossTurnDataHistPO::getFlow)
.sum();
tableContent.setFlow(flow);
// 绿灯有效利用率取最大
double greenLightEfficiencyMax = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToDouble(CrossTurnDataHistPO::getGreenLightEfficiency)
.max()
.orElse(0.0);
long greenLightEfficiencyMaxLong = Math.round(greenLightEfficiencyMax * 100);
metricsMap.put(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode(),
greenLightEfficiencyMaxLong + StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getUnit());
// 饱和度取最大
double maxSaturation = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToDouble(CrossTurnDataHistPO::getSturation)
.max()
.orElse(0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.SATURATION.getCode(),
maxSaturation + StrategyAndMetricsEnum.Metrics.SATURATION.getUnit());
// 负载均衡度取最大
double maxLoadBalance = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToDouble(CrossTurnDataHistPO::getLoadBalance)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getCode(),
maxLoadBalance + StrategyAndMetricsEnum.Metrics.LOAD_BALANCE.getUnit());
// 计算指标是否合格
boolean isQualified = calcBalance(maxSaturation, greenLightEfficiencyMax);
if (!isQualified) {
tableContent.setHasProblem(1);
problemList.add(BaseEnum.SignalDirectionEnum.getNameByCode(dirCode) + "进口"
+ TurnConvertEnum.getDescByCode(turnType) + "失衡");
}
tableContent.setMetricsMap(metricsMap);
tableContentList.add(tableContent);
}
return tableContentList;
}
private void buildEfficiencyDetailVO(List<CrossDirDataHistPO> crossDirDataHistPOList,
List<CrossTurnDataHistPO> crossTurnDataHistPOList,
SchemeEvaluateSchemeDetailedProblemVO vo, String crossId) {
List<String> problemList = new ArrayList<>();
List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> tableContentList = new ArrayList<>();
// 获取路口方向
List<Integer> dirCodes = baseCrossDirInfoMapper.selectInDirsByCrossId(crossId);
......@@ -517,17 +725,16 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
SchemeEvaluateSchemeDetailOverallVO vo, String crossId,
int startTimeStamp, int endTimeStamp) {
List<SchemeEvaluateSchemeDetailOverallVO.OverallMetrics> overallMetricsList = new ArrayList<>();
// 溢流率时长取最大
// 溢流率取最大
OptionalDouble effusionMax = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getEffusionTime)
.mapToDouble(CrossDirDataHistPO::getEffusionRate)
.max();
if (effusionMax.isPresent()) {
int minutes = (endTimeStamp - startTimeStamp) / 60; // 观测时长
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
buildEffusionOverallMetrics(effusionMax, minutes);
buildEffusionOverallMetrics(effusionMax);
overallMetricsList.add(overallMetrics);
} else {
throw new RuntimeException("该时段无溢流时长数据");
throw new RuntimeException("该时段无溢流数据");
}
// 绿灯间隔清空率取最大
OptionalDouble clearRateMax = crossDataHistPOList.stream()
......@@ -540,21 +747,11 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
} else {
throw new RuntimeException("该时段无绿灯间隔清空率数据");
}
// 三急一速数量取最大
// todo 数据库中待添加字段
OptionalDouble emergencyCountMax = OptionalDouble.of(12.56);
// OptionalDouble emergencyCountMax = crossDataHistPOList.stream()
// .map(CrossDataHistPO::getEmergencyCount)
// .filter(Objects::nonNull)
// .mapToDouble(Double::doubleValue) // 将Double转换为double
// .max();
if (emergencyCountMax.isPresent()) {
// 路口级别三急一速数量
Integer emergencyCount = crossDataHistMapper.selectCrossEmergencyCount(crossId, startTimeStamp, endTimeStamp);
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
buildEmergencyCountOverallMetrics(emergencyCountMax);
buildEmergencyCountOverallMetrics(emergencyCount);
overallMetricsList.add(overallMetrics);
} else {
throw new RuntimeException("该时段无三急一速数量数据");
}
vo.setOverallMetricsList(overallMetricsList);
// 查询路口指标数值(都取最大),并与评价标准比较:如果饱和度<0.8,则需绿灯间隔清空率大于70%;如果饱和度>0.8,则需绿灯间隔清空率大于60%
// 达到指标要求,显示路口满足安全保障策略需求;未达到指标,显示路口存在安全隐患
......@@ -585,13 +782,12 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
}
private SchemeEvaluateSchemeDetailOverallVO.OverallMetrics buildEmergencyCountOverallMetrics(
OptionalDouble emergencyCountMax) {
int intMax = (int) Math.round(emergencyCountMax.getAsDouble());
Integer emergencyCount) {
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
new SchemeEvaluateSchemeDetailOverallVO.OverallMetrics();
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getDescription());
overallMetrics.setMetricValue(intMax);
overallMetrics.setMetricValue(emergencyCount);
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getUnit());
return overallMetrics;
}
......@@ -602,11 +798,13 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
int startTimeStamp, int endTimeStamp) {
List<SchemeEvaluateSchemeDetailOverallVO.OverallMetrics> overallMetricsList = new ArrayList<>();
// 绿灯有效利用率取最大
// todo 数据库中待添加字段
OptionalDouble greenLightUse = OptionalDouble.of(0.9);
if (greenLightUse.isPresent()) {
OptionalDouble greenLightEfficiencyMax = crossDataHistPOList.stream()
.mapToDouble(CrossDataHistPO::getGreenLightEfficiency)
.filter(Objects::nonNull)
.max();
if (greenLightEfficiencyMax.isPresent()) {
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
buildGreenLightUseOverallMetrics(greenLightUse);
buildGreenLightUseOverallMetrics(greenLightEfficiencyMax);
overallMetricsList.add(overallMetrics);
} else {
throw new RuntimeException("该时段无绿灯有效利用率数据");
......@@ -645,10 +843,8 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
for (Integer dirCode : dirCodes) {
Double maxSaturation = crossDirDataHistMapper.selectMaxSaturation(
crossId, dirCode, CrossInOutEnum.IN.getCode(), startTimeStamp, endTimeStamp);
// todo 待添加绿灯有效利用率字段
Double maxGreenLightUse = 0.9;
// Double maxGreenLightUse = crossDirDataHistMapper.selectMaxGreenLightUse(
// crossId, dirCode, CrossInOutEnum.IN.getCode(), startTimeStamp, endTimeStamp);
Double maxGreenLightUse = crossDirDataHistMapper.selectMaxGreenLightEfficiency(
crossId, dirCode, CrossInOutEnum.IN.getCode(), startTimeStamp, endTimeStamp);
boolean isQualified = calcBalance(maxSaturation, maxGreenLightUse);
if (!isQualified) {
strategyEvaluateList.add(BaseEnum.SignalDirectionEnum.getNameByCode(dirCode) + "进口方向失衡");
......@@ -664,31 +860,29 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
int intMax = (int) Math.round(clearRateMax.getAsDouble());
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
new SchemeEvaluateSchemeDetailOverallVO.OverallMetrics();
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.GREEN_INTERVAL_CLEAR.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.GREEN_INTERVAL_CLEAR.getDescription());
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getDescription());
overallMetrics.setMetricValue(intMax);
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.GREEN_INTERVAL_CLEAR.getUnit());
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getUnit());
return overallMetrics;
}
private SchemeEvaluateSchemeDetailOverallVO.OverallMetrics buildEffusionOverallMetrics(
OptionalDouble effusionMax, int minutes) {
int intMax = (int) Math.round(effusionMax.getAsDouble());
int effusionRateMax = intMax / minutes;
private SchemeEvaluateSchemeDetailOverallVO.OverallMetrics buildEffusionOverallMetrics(OptionalDouble effusionMax) {
int intMax = (int) Math.round(effusionMax.getAsDouble() * 100);
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
new SchemeEvaluateSchemeDetailOverallVO.OverallMetrics();
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getDescription());
overallMetrics.setMetricValue(effusionRateMax);
overallMetrics.setMetricValue(intMax);
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getUnit());
return overallMetrics;
}
private boolean calcBalance(Double maxSaturation, Double maxGreenLightUse) {
private boolean calcBalance(Double maxSaturation, Double greenLightEfficiencyMax) {
// 如果饱和度<0.8,则需绿灯利用率大于50%;如果饱和度>0.8,则需绿灯利用率大于80%
if (maxSaturation < 0.8 && maxGreenLightUse > 0.5) {
if (maxSaturation < 0.8 && greenLightEfficiencyMax > 0.5) {
return true;
} else if (maxSaturation >= 0.8 && maxGreenLightUse > 0.8) {
} else if (maxSaturation >= 0.8 && greenLightEfficiencyMax > 0.8) {
return true;
}
return false;
......@@ -719,14 +913,14 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
}
private SchemeEvaluateSchemeDetailOverallVO.OverallMetrics buildGreenLightUseOverallMetrics(
OptionalDouble greenLightUse) {
int intGreenLightUseAverage = (int) Math.round(greenLightUse.getAsDouble() * 100);
OptionalDouble greenLightEfficiencyMax) {
int intGreenLightEfficiencyMax = (int) Math.round(greenLightEfficiencyMax.getAsDouble() * 100);
SchemeEvaluateSchemeDetailOverallVO.OverallMetrics overallMetrics =
new SchemeEvaluateSchemeDetailOverallVO.OverallMetrics();
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_UTILIZATION.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_UTILIZATION.getDescription());
overallMetrics.setMetricValue(intGreenLightUseAverage);
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_UTILIZATION.getUnit());
overallMetrics.setMetricCode(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode());
overallMetrics.setMetricName(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getDescription());
overallMetrics.setMetricValue(intGreenLightEfficiencyMax);
overallMetrics.setMetricUnit(StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getUnit());
return overallMetrics;
}
......
......@@ -38,11 +38,11 @@ public class StrategyAndMetricsEnum {
MAX_QUEUE_LENGTH("4", "最大排队长度", "m"),
STOP_TIMES("5", "停车次数", "次"),
AVERAGE_SPEED("6", "平均速度", "km/h"),
GREEN_LIGHT_UTILIZATION("7", "绿灯有效利用率", "%"),
GREEN_LIGHT_EFFICIENCY("7", "绿灯有效利用率", "%"),
SATURATION("8", "饱和度", ""),
LOAD_BALANCE("9", "负载均衡度", ""),
EFFUSION_RATE("10", "溢流率", "%"),
GREEN_INTERVAL_CLEAR("11", "绿灯间隔清空率", "%"),
CLEAR_RATE("11", "绿灯间隔清空率", "%"),
EMERGENCY_COUNT("12", "三急一速数量", "");
private final String code;
......@@ -71,13 +71,13 @@ public class StrategyAndMetricsEnum {
Metrics.AVERAGE_SPEED
));
map.put(Strategy.BALANCE, Arrays.asList(
Metrics.GREEN_LIGHT_UTILIZATION,
Metrics.GREEN_LIGHT_EFFICIENCY,
Metrics.SATURATION,
Metrics.LOAD_BALANCE
));
map.put(Strategy.SECURITY, Arrays.asList(
Metrics.EFFUSION_RATE,
Metrics.GREEN_INTERVAL_CLEAR,
Metrics.CLEAR_RATE,
Metrics.EMERGENCY_COUNT
));
STRATEGY_METRICS_MAP = Collections.unmodifiableMap(map);
......
......@@ -14,6 +14,6 @@ public class CrossDirDataHistAvgBO {
private Double avgQueueLength;
// 平均拥堵指数
private Double avgIndex;
// 平均溢流时长
private Double avgEffusionTime;
// 平均溢流
private Double avgEffusionRate;
}
......@@ -20,4 +20,8 @@ public interface BaseCrossDirInfoMapper {
List<BaseCrossDirInfoPO> selectByCrossId(String crossId);
List<BaseCrossDirInfoPO> selectByCrossIdAndInOutType(String crossId, Integer type);
List<String> selectLaneIds(String crossId, Integer dirCode);
Integer selectDirEmergencyCount(String crossId, List<String> laneIds, int startTimeStamp, int endTimeStamp);
}
......@@ -26,4 +26,6 @@ public interface CrossDataHistMapper extends BaseMapper<CrossDataHistPO> {
List<MetricHistDTO> selectMetricHistDTO(String crossId, int startStamp, int endStamp);
Double selectMaxSaturation(String crossId, int startStamp, int endStamp);
Integer selectCrossEmergencyCount(String crossId, int startTimeStamp, int endTimeStamp);
}
......@@ -42,4 +42,6 @@ public interface CrossDirDataHistMapper extends BaseMapper<CrossDirDataHistPO> {
Double selectMaxQueueLength(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp);
Double selectMaxSaturation(String crossId, Integer dirType, Integer inOutType, int startStamp, int endStamp);
Double selectMaxGreenLightEfficiency(String crossId, Integer dirCode, Integer code, int startTimeStamp, int endTimeStamp);
}
......@@ -63,6 +63,13 @@ public class CrossDirDataRealtimePO {
private Date gmtCreate ;
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
@ApiModelProperty(name = "溢流时长,计算溢流率提供;溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "")
private Double effusionTime;
@ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "")
private Double effusionRate;
@ApiModelProperty(value = "绿灯间隔清空率", notes = "")
private Double clearRate;
@ApiModelProperty(value = "负载均衡度", notes = "")
private Double loadBalance;
@ApiModelProperty(value = "绿灯有效利用率", notes = "")
private Double greenLightEfficiency;
}
......@@ -88,4 +88,13 @@ public class CrossTurnDataRealtimePO {
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
@ApiModelProperty(value = "绿灯间隔清空率", notes = "")
private Double clearRate;
@ApiModelProperty(value = "负载均衡度", notes = "")
private Double loadBalance;
@ApiModelProperty(value = "绿灯有效利用率", notes = "")
private Double greenLightEfficiency;
@ApiModelProperty(name = "溢流率:交叉口间路段车辆排队长度超出可容纳空间的时长与观测总时长的百分比",notes = "")
private Double effusionRate;
}
......@@ -32,4 +32,23 @@
where cross_id = #{crossId} and in_out_type = #{type}
</select>
<select id="selectLaneIds" resultType="java.lang.String">
select id
from t_base_lane_info
where cross_id = #{crossId} and dir = #{dirCode}
</select>
<select id="selectDirEmergencyCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM holo_roadnet_jinan.t_event_info
WHERE type IN ('33', '34', '35', '6')
AND UNIX_TIMESTAMP(start_time) <![CDATA[ >= ]]> #{startStamp}
AND UNIX_TIMESTAMP(start_time) <![CDATA[ <= ]]> #{endStamp}
AND cross_id = #{crossId}
AND lane_id in
<foreach collection="laneIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
</mapper>
......@@ -95,4 +95,13 @@
and batch_time <![CDATA[ <= ]]> #{endStamp}
</select>
<select id="selectCrossEmergencyCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM holo_roadnet_jinan.t_event_info
WHERE type IN ('33', '34', '35', '6')
AND UNIX_TIMESTAMP(start_time) <![CDATA[ >= ]]> #{startStamp}
AND UNIX_TIMESTAMP(start_time) <![CDATA[ <= ]]> #{endStamp}
AND cross_id = #{crossId}
</select>
</mapper>
\ No newline at end of file
......@@ -22,12 +22,17 @@
<result column="batch_time" property="batchTime"></result>
<result column="gmt_create" property="gmtCreate"></result>
<result column="gmt_modified" property="gmtModified"></result>
<result column="effusion_time" property="effusionTime"></result>
<result column="effusion_rate" property="effusionRate"></result>
<result column="clear_rate" property="clearRate"></result>
<result column="load_balance" property="loadBalance"></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_time
delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate,
load_balance,clear_rate,green_light_efficiency
</sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataHistPO">
......@@ -39,7 +44,7 @@
#{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.effusionTime} )
#{entity.gmtCreate}, #{entity.gmtModified}, #{entity.effusionRate} )
</foreach>
</insert>
......@@ -70,7 +75,7 @@
<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_time) as avgEffusionTime
avg(effusion_rate) as avgeffusionRate
FROM t_cross_dir_data_hist
WHERE cross_id = #{crossId}
AND in_out_type = #{inOutType}
......@@ -127,7 +132,7 @@
and batch_time <![CDATA[ <= ]]> #{endStamp}
</select>
<select id="selectMaxDelayTime" resultType="java.lang.Double">
<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}
......@@ -151,4 +156,12 @@
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 = #{dirType} and in_out_type = #{inOutType}
and batch_time <![CDATA[ >= ]]> #{startStamp}
and batch_time <![CDATA[ <= ]]> #{endStamp}
</select>
</mapper>
\ No newline at end of file
......@@ -26,12 +26,17 @@
<result column="batch_time" property="batchTime"></result>
<result column="gmt_create" property="gmtCreate"></result>
<result column="gmt_modified" property="gmtModified"></result>
<result column="effusion_time" property="effusionTime"></result>
<result column="effusion_rate" property="effusionRate"></result>
<result column="clear_rate" property="clearRate"></result>
<result column="load_balance" property="loadBalance"></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_time
delay_time,sturation,no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,batch_time,gmt_create,gmt_modified,effusion_rate,
load_balance,clear_rate,green_light_efficiency
</sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossDirDataRealtimePO">
......@@ -42,7 +47,7 @@
( #{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.effusionTime} )
#{entity.gmtCreate}, #{entity.gmtModified}, #{entity.effusionRate} )
</foreach>
</insert>
......
......@@ -29,12 +29,18 @@
<result column="gmt_create" property="gmtCreate"></result>
<result column="gmt_modified" property="gmtModified"></result>
<result column="start_time" property="startTime"></result>
<result column="clear_rate" property="clearRate"></result>
<result column="load_balance" property="loadBalance"></result>
<result column="green_light_efficiency" property="greenLightEfficiency"></result>
<result column="effusion_rate" property="effusionRate"></result>
</resultMap>
<sql id="Base_Column_List">
id, turn_type, in_dir, out_dir, cross_id, flow, status, traffic_index, speed, in_speed, out_speed, queue_length,
stop_times, delay_time, sturation, vehhead_dist, vehhead_time, quality, batch_time, gmt_create, gmt_modified,
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,start_time
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,start_time,
load_balance,clear_rate,green_light_efficiency,effusion_rate
</sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossTurnDataRealtimePO">
......
......@@ -29,12 +29,19 @@
<result column="gmt_create" property="gmtCreate"></result>
<result column="gmt_modified" property="gmtModified"></result>
<result column="start_time" property="startTime"></result>
<result column="clear_rate" property="clearRate"></result>
<result column="load_balance" property="loadBalance"></result>
<result column="green_light_efficiency" property="greenLightEfficiency"></result>
<result column="effusion_rate" property="effusionRate"></result>
</resultMap>
<sql id="Base_Column_List">
id, turn_type, in_dir, out_dir, cross_id, flow, status, traffic_index, speed, in_speed, out_speed, queue_length,
stop_times, delay_time, sturation, vehhead_dist, vehhead_time, quality, batch_time, gmt_create, gmt_modified,
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,start_time
no_stop_rate,one_stop_rate,two_stop_rate,three_stop_rate,start_time,
load_balance,clear_rate,green_light_efficiency,effusion_rate
</sql>
<insert id="insertBatch" parameterType="net.wanji.databus.po.CrossTurnDataRealtimePO">
......
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