Commit 06c99fb0 authored by hanbing's avatar hanbing

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

parent d1214f75
......@@ -361,11 +361,12 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
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);
List<CrossTurnDataHistPO> dirTurnPOList = crossTurnDataHistPOList.stream()
.filter(item -> Objects.equals(item.getInDir(), dirCode))
.collect(Collectors.toList());
tableContent.setSubList(buildSecuritySublist(problemList, dirTurnPOList, dirCode, crossId,
startTimeStamp, endTimeStamp));
tableContent.setMetricsMap(metricsMap);
for (SchemeEvaluateSchemeDetailedProblemVO.TableContent content : tableContent.getSubList()) {
if (content.getHasProblem() == 1) {
......@@ -378,12 +379,85 @@ public class SchemeEvaluateServiceImpl implements SchemeEvaluateService {
vo.setTableContentList(tableContentList);
if (CollectionUtil.isNotEmpty(problemList)) {
problemList.add("其他方向均衡状况良好");
problemList.add("其他方向满足安全保障需求");
}
vo.setProblems(problemList);
}
private List<SchemeEvaluateSchemeDetailedProblemVO.TableContent> buildSecuritySublist(
List<String> problemList, List<CrossTurnDataHistPO> currentDirTurnPOList,
Integer dirCode, String crossId, int startTimeStamp, int endTimeStamp) {
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 effusionRateMax = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToDouble(CrossTurnDataHistPO::getEffusionRate)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getCode(),
effusionRateMax * 100 + StrategyAndMetricsEnum.Metrics.EFFUSION_RATE.getUnit());
// 绿灯间隔清空率取最大
double clearRateMax = currentDirTurnPOList.stream()
.filter(item -> Objects.equals(item.getTurnType(), turnType))
.mapToDouble(CrossTurnDataHistPO::getClearRate)
.max()
.orElse(0.0);
metricsMap.put(StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getCode(),
clearRateMax + StrategyAndMetricsEnum.Metrics.CLEAR_RATE.getUnit());
// 转向级别三急一速数量
// 查询该转向所有的车道ID
Integer intTurnCode = BaseEnum.TurnTypeEnum.getIntCodeByStrCode(turnType);
List<String> laneIds = baseCrossTurnInfoMapper.selectLaneIds(crossId, dirCode, intTurnCode);
// 加总该转向的三急一速
Integer emergencyCount = baseCrossTurnInfoMapper.selectTurnEmergencyCount(
crossId, laneIds, startTimeStamp, endTimeStamp);
metricsMap.put(StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.getCode(),
emergencyCount + StrategyAndMetricsEnum.Metrics.EMERGENCY_COUNT.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());
// 计算指标是否合格
boolean isQualified = calcSecurity(maxSaturation, OptionalDouble.of(clearRateMax));
if (!isQualified) {
tableContent.setHasProblem(1);
problemList.add(BaseEnum.SignalDirectionEnum.getNameByCode(dirCode) + "进口"
+ TurnConvertEnum.getDescByCode(turnType) + "存在安全隐患");
}
tableContent.setMetricsMap(metricsMap);
tableContentList.add(tableContent);
}
return tableContentList;
}
private void buildBalanceDetailVO(List<CrossDirDataHistPO> crossDirDataHistPOList,
List<CrossTurnDataHistPO> crossTurnDataHistPOList,
SchemeEvaluateSchemeDetailedProblemVO vo, String crossId) {
......
......@@ -3,6 +3,8 @@ package net.wanji.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Objects;
/**
* @author wanji
* @version 1.0
......@@ -200,25 +202,25 @@ public class BaseEnum {
public enum TurnTypeEnum {
//步类型:1-左转 2-直行 3-右转 4-调头
LEFT(1, "左转"),
STRAIGHT(2, "直行"),
LEFT(1, "l", "左转"),
RIGHT(3, "右转"),
STRAIGHT(2, "s", "直行"),
TURN(4, "调头"),
RIGHT(3, "r", "右转"),
ALL(5, "圆饼灯"),
TURN(4, "u", "调头"),
PEDESTRIAN(6, "行人"),
ALL(5, "all", "圆饼灯"),
ONCE_PEDESTRIAN(7, "一次行人"),
PEDESTRIAN(6, "pedestrian", "行人"),
TWO_PEDESTRIAN(8, "二次行人");
ONCE_PEDESTRIAN(7, "once_pedestrian", "一次行人"),
TWO_PEDESTRIAN(8, "two_pedestrian", "二次行人");
private Integer type;
private Integer intCode;
private String strCode;
private String name;
/**
......@@ -229,12 +231,22 @@ public class BaseEnum {
*/
public static TurnTypeEnum getEnumByType(int type) {
for (TurnTypeEnum testEnums : TurnTypeEnum.values()) {
if (testEnums.getType() == type) {
if (testEnums.getIntCode() == type) {
return testEnums;
}
}
return null;
}
public static Integer getIntCodeByStrCode(String strCode) {
for (TurnTypeEnum testEnums : TurnTypeEnum.values()) {
if (Objects.equals(testEnums.getStrCode(), strCode)) {
return testEnums.getIntCode();
}
}
return null;
}
}
/**
......
......@@ -9,4 +9,8 @@ import java.util.List;
public interface BaseCrossTurnInfoMapper {
List<CrossTurnInfoPO> selectByCrossIdAndDir(String crossId, Integer dir);
List<String> selectLaneIds(String crossId, Integer dirCode, Integer intTurnCode);
Integer selectTurnEmergencyCount(String crossId, List<String> laneIds, int startTimeStamp, int endTimeStamp);
}
......@@ -12,5 +12,24 @@
where cross_id = #{crossId} and in_dir = #{dir}
</select>
<select id="selectLaneIds" resultType="java.lang.String">
select id
from t_base_lane_info
where cross_id = #{crossId} and dir = #{dirCode} and turn = #{intTurnCode}
</select>
<select id="selectTurnEmergencyCount" 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>
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