Commit 7bf33daf authored by duanruiming's avatar duanruiming

[update] 优化海信平峰无左转灯态

parent a2a46f5f
...@@ -71,7 +71,7 @@ public class HisensePhaseCountDownTask { ...@@ -71,7 +71,7 @@ public class HisensePhaseCountDownTask {
Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap(); Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap();
for (String dir : dirList) { for (String dir : dirList) {
if (!dirLampGroupMap.containsKey(dir)) { if (!dirLampGroupMap.containsKey(dir)) {
Map<String, String> value = new HashMap<>(); Map<Integer, String> value = new HashMap<>();
setAllTurnColorRed(value, null, null); setAllTurnColorRed(value, null, null);
dirLampGroupMap.put(dir, value); dirLampGroupMap.put(dir, value);
} }
...@@ -194,6 +194,7 @@ public class HisensePhaseCountDownTask { ...@@ -194,6 +194,7 @@ public class HisensePhaseCountDownTask {
/** /**
* 统一方向转向倒计时 * 统一方向转向倒计时
*
* @param phaseMap * @param phaseMap
* @param dir * @param dir
* @param turnCountDown * @param turnCountDown
...@@ -280,56 +281,69 @@ public class HisensePhaseCountDownTask { ...@@ -280,56 +281,69 @@ public class HisensePhaseCountDownTask {
List<CrossPhaseDirTurnPojo> crossPhaseDirTurnCache = CrossPhaseDirTurnCache.getCrossPhaseDirTurnCache(crossId); List<CrossPhaseDirTurnPojo> crossPhaseDirTurnCache = CrossPhaseDirTurnCache.getCrossPhaseDirTurnCache(crossId);
if (!CollectionUtils.isEmpty(crossPhaseDirTurnCache)) { if (!CollectionUtils.isEmpty(crossPhaseDirTurnCache)) {
Map<String, Object> dirLampGroupMap = new HashMap<>(); Map<String, Object> dirLampGroupMap = new HashMap<>();
for (CrossPhaseDirTurnPojo phaseDirTurnPojo : crossPhaseDirTurnCache) { setPhaseLampColor(crossId, currentSchemeNo, currentPhaseNo, cyclePhaseCountDown, crossPhaseDirTurnCache, dirLampGroupMap);
String schemeNo = String.valueOf(phaseDirTurnPojo.getSchemeNo()); // 海信,箭头灯变圆饼灯
String phaseNo = String.valueOf(phaseDirTurnPojo.getPhaseNo()); for (Map.Entry<String, Object> arrowEntry : dirLampGroupMap.entrySet()) {
if (StringUtils.equalsIgnoreCase(schemeNo, currentSchemeNo)) { String dir = arrowEntry.getKey();
if (!StringUtils.equalsIgnoreCase(currentPhaseNo, String.valueOf(phaseNo))) { Map<Integer, String> turnColor = (Map<Integer, String>) arrowEntry.getValue();
// 相位红灯 if (!turnColor.isEmpty() && !turnColor.containsKey(1)) {
Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap(); // 如果不包含左转, 左转灯色为直行
if (!dirTurnMap.isEmpty()) { String straightColor = turnColor.get(2);
for (Map.Entry<Integer, List<CrossLightsPO>> entry : dirTurnMap.entrySet()) { turnColor.put(1, straightColor);
String dir = String.valueOf(entry.getKey()); dirLampGroupMap.put(dir, turnColor);
Map<Integer, String> turnColor = null; }
if (!dirLampGroupMap.containsKey(dir)) { }
turnColor = new HashMap<>(); lightsStatusVO.setDirLampGroupMap(dirLampGroupMap);
} else { }
turnColor = (Map<Integer, String>) dirLampGroupMap.get(dir); }
}
List<CrossLightsPO> value = entry.getValue(); private void setPhaseLampColor(String crossId, String currentSchemeNo, String currentPhaseNo, Integer cyclePhaseCountDown, List<CrossPhaseDirTurnPojo> crossPhaseDirTurnCache, Map<String, Object> dirLampGroupMap) throws Exception {
int type = 1; for (CrossPhaseDirTurnPojo phaseDirTurnPojo : crossPhaseDirTurnCache) {
for (CrossLightsPO crossLightsPO : value) { String schemeNo = String.valueOf(phaseDirTurnPojo.getSchemeNo());
Integer turn = crossLightsPO.getTurn(); String phaseNo = String.valueOf(phaseDirTurnPojo.getPhaseNo());
type = crossLightsPO.getType(); if (StringUtils.equalsIgnoreCase(schemeNo, currentSchemeNo)) {
// 搭接相位跳过绿灯变红灯 if (!StringUtils.equalsIgnoreCase(currentPhaseNo, String.valueOf(phaseNo))) {
if (turnColor.containsKey(turn) && turnColor.get(turn).equals("green")) { // 相位红灯
continue; Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap();
} if (!dirTurnMap.isEmpty()) {
turnColor.put(turn, "red"); for (Map.Entry<Integer, List<CrossLightsPO>> entry : dirTurnMap.entrySet()) {
} String dir = String.valueOf(entry.getKey());
if (type == 2) { Map<Integer, String> turnColor = null;
setAllTurnColor(turnColor, "red"); //红灯时,圆饼灯操作 if (!dirLampGroupMap.containsKey(dir)) {
turnColor = new HashMap<>();
} else {
turnColor = (Map<Integer, String>) dirLampGroupMap.get(dir);
}
List<CrossLightsPO> value = entry.getValue();
int type = 1;
for (CrossLightsPO crossLightsPO : value) {
Integer turn = crossLightsPO.getTurn();
type = crossLightsPO.getType();
// 搭接相位跳过绿灯变红灯
if (turnColor.containsKey(turn) && turnColor.get(turn).equals("green")) {
continue;
} }
turnColor.put(3, "green"); turnColor.put(turn, "red");
dirLampGroupMap.put(dir, turnColor);
} }
if (type == 2) {
setAllTurnColor(turnColor, "red"); //红灯时,圆饼灯操作
}
turnColor.put(3, "green");
dirLampGroupMap.put(dir, turnColor);
} }
} else {
// 相位绿灯
PhaseCountDownDTO phaseCountDownDTO = getPhaseCountDownDTO(crossId, schemeNo, phaseNo);
if (Objects.isNull(phaseCountDownDTO)) {
continue;
}
Integer yellowTime = phaseCountDownDTO.getYellowTime();
Integer redTime = phaseCountDownDTO.getRedTime();
Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap();
if (!dirTurnMap.isEmpty()) {
setDirTurnColor(cyclePhaseCountDown, dirLampGroupMap, yellowTime, redTime, dirTurnMap);
}
lightsStatusVO.setDirLampGroupMap(dirLampGroupMap);
} }
lightsStatusVO.setDirLampGroupMap(dirLampGroupMap); } else {
// 相位绿灯
PhaseCountDownDTO phaseCountDownDTO = getPhaseCountDownDTO(crossId, schemeNo, phaseNo);
if (Objects.isNull(phaseCountDownDTO)) {
continue;
}
Integer yellowTime = phaseCountDownDTO.getYellowTime();
Integer redTime = phaseCountDownDTO.getRedTime();
Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap();
if (!dirTurnMap.isEmpty()) {
setDirTurnColor(cyclePhaseCountDown, dirLampGroupMap, yellowTime, redTime, dirTurnMap);
}
} }
} }
} }
...@@ -394,14 +408,14 @@ public class HisensePhaseCountDownTask { ...@@ -394,14 +408,14 @@ public class HisensePhaseCountDownTask {
* @param type * @param type
* @param color * @param color
*/ */
private static void setAllTurnColorRed(Map<String, String> turnColor, Integer type, String color) throws Exception { private static void setAllTurnColorRed(Map<Integer, String> turnColor, Integer type, String color) throws Exception {
List<String> allTurn = Arrays.asList("1", "2", "3"); List<Integer> allTurn = Arrays.asList(1, 2, 3);
for (String turnStr : allTurn) { for (Integer turnStr : allTurn) {
if (!turnColor.containsKey(turnStr)) { if (!turnColor.containsKey(turnStr)) {
turnColor.put(turnStr, "red"); turnColor.put(turnStr, "red");
} }
} }
for (Map.Entry<String, String> entry : turnColor.entrySet()) { for (Map.Entry<Integer, String> entry : turnColor.entrySet()) {
entry.setValue("red"); entry.setValue("red");
} }
} }
......
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