Commit 7bf33daf authored by duanruiming's avatar duanruiming

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

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