Commit fe214c17 authored by duanruiming's avatar duanruiming

[update] 修改红灯倒计时

parent 5f9cc3a0
......@@ -15,8 +15,6 @@ import net.wanji.utc.hisense.cache.CrossSchemePhaseTimeCountCache;
import net.wanji.utc.hisense.cache.SignalDataCache;
import net.wanji.utc.hisense.common.enums.CrossLisghtsLaneDirEnum;
import net.wanji.utc.hisense.common.enums.DataBrainControlModeEnum;
import net.wanji.utc.hisense.common.enums.DataBrainDirEnum;
import net.wanji.utc.hisense.common.enums.DataBrainTurnEnum;
import net.wanji.utc.hisense.pojo.CrossPhaseDirTurnPojo;
import net.wanji.utc.hisense.pojo.convert.HisenseLightStatusPojo;
import net.wanji.utc.hisense.pojo.dto.CrossSchemePhaseCountDownDTO;
......@@ -174,23 +172,6 @@ public class SignalStatusServiceImpl implements SignalStatusService {
lightsStatusVO.setCode(hiCrossId);
lightsStatusVO.setManufacturerCode("Hisense");
lightsStatusVO.setPhasePlanId(String.valueOf(planId));
Map<String, Object> phaseMap = new HashMap<>();
// 红灯剩余时长
List<HisenseLightStatusPojo.ContentBody.LampRealInfos> lampRealInfos = content.getLampRealInfos();
if (!CollectionUtils.isEmpty(lampRealInfos)) {
for (HisenseLightStatusPojo.ContentBody.LampRealInfos lampRealInfo : lampRealInfos) {
Integer dir = lampRealInfo.getRoadDirection();
Integer wjLightsDir = DataBrainDirEnum.getWjLightsDir(dir);
Integer turn = lampRealInfo.getRoadFlowDirection();
Integer countDown = lampRealInfo.getCountDown();
if (turn == 98 || turn == 99 || countDown == 0) {
continue;
}
Integer wjTurn = DataBrainTurnEnum.getWjTurn(turn);
phaseMap.put(String.join("-", String.valueOf(wjLightsDir), String.valueOf(wjTurn)), countDown);
}
}
lightsStatusVO.setPhaseMap(phaseMap);
List<CrossSchemePhaseCountDownDTO> crossSchemePhaseCountDownList = CrossSchemePhaseTimeCountCache.crossSchemePhaseCountDownList;
setLightsStatusVOPhaseNoAndCountDown(lightsStatusVO, crossId, runTime, planId, crossSchemePhaseCountDownList);
SignalDataCache.runningStateInfoCacheNoLamp.put(crossId, lightsStatusVO);
......
......@@ -80,18 +80,7 @@ public class HisensePhaseCountDownTask {
// 当前时间戳自动加1s
lightsStatusVO.setTimeStamp(String.valueOf(timeStamp + 1000));
// 红灯倒计时
Map<String, Object> phaseMap = lightsStatusVO.getPhaseMap();
if (!phaseMap.isEmpty()) {
for (Map.Entry<String, Object> item : phaseMap.entrySet()) {
int value = (int) item.getValue();
if (value > 0) {
item.setValue(--value);
} else { //当前红灯倒计时为0,默认倒计时为周期
item.setValue(lightsStatusVO.getCycleLen());
}
}
}
lightsStatusVO.setPhaseMap(phaseMap);
getRedCountDown(crossId, lightsStatusVO, schemeId);
SignalDataCache.runningStateInfoCache.put(crossId, lightsStatusVO);
}
}
......@@ -102,6 +91,50 @@ public class HisensePhaseCountDownTask {
}
}
private void getRedCountDown(String crossId, LightsStatusVO lightsStatusVO, String schemeId) {
Map<String, Object> phaseMap = new HashMap<>();
List<CrossPhaseDirTurnPojo> crossPhaseDirTurnCache = CrossPhaseDirTurnCache.getCrossPhaseDirTurnCache(crossId);
List<PhaseCountDownDTO> phaseCountDownList = getPhaseCountDownList(crossId, schemeId);
if (!CollectionUtils.isEmpty(phaseCountDownList)) {
for (PhaseCountDownDTO phaseCountDownDTO : phaseCountDownList) {
String phaseNo = phaseCountDownDTO.getPhaseNo();
Integer changePhaseTime = phaseCountDownDTO.getChangePhaseTime();
Integer cycleLen = lightsStatusVO.getCycleLen();
Integer cycleCountDown = lightsStatusVO.getCycleCountDown();
int runtime = cycleLen - cycleCountDown;
int redCountDown = 0;
if (!CollectionUtils.isEmpty(crossPhaseDirTurnCache)) {
for (CrossPhaseDirTurnPojo dirTurnPojo : crossPhaseDirTurnCache) {
if (StringUtils.equalsIgnoreCase(schemeId, String.valueOf(dirTurnPojo.getSchemeNo()))
&& StringUtils.equalsIgnoreCase(phaseNo, String.valueOf(dirTurnPojo.getPhaseNo()))) {
Map<Integer, List<CrossLightsPO>> dirTurnMap = dirTurnPojo.getDirTurnMap();
for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) {
List<CrossLightsPO> lightsPOS = dirEntry.getValue();
if (!CollectionUtils.isEmpty(lightsPOS)) {
for (CrossLightsPO lightsPO : lightsPOS) {
Integer dir = lightsPO.getDir();
Integer turn = lightsPO.getTurn();
if (turn == 20) {
continue;
}
String key = String.valueOf(dir).concat("-").concat(String.valueOf(turn));
redCountDown = changePhaseTime - runtime;
if (redCountDown < 0) {
redCountDown = cycleLen + redCountDown;
}
phaseMap.put(key, redCountDown);
}
}
}
}
}
}
}
}
lightsStatusVO.setPhaseMap(phaseMap);
}
/**
* @param crossId
* @param lightsStatusVO
......@@ -310,4 +343,19 @@ public class HisensePhaseCountDownTask {
}
return null;
}
private List<PhaseCountDownDTO> getPhaseCountDownList(String crossId, String schemeNo) {
List<CrossSchemePhaseCountDownDTO> crossSchemePhaseCountDownList = CrossSchemePhaseTimeCountCache.crossSchemePhaseCountDownList;
if (!CollectionUtils.isEmpty(crossSchemePhaseCountDownList)) {
for (CrossSchemePhaseCountDownDTO dto : crossSchemePhaseCountDownList) {
if (Objects.equals(crossId, dto.getCrossId()) && Objects.equals(schemeNo, dto.getSchemeNo())) {
List<PhaseCountDownDTO> phaseCountDownDTOList = dto.getPhaseCountDownDTOList();
if (!CollectionUtils.isEmpty(phaseCountDownDTOList)) {
return phaseCountDownDTOList;
}
}
}
}
return Collections.emptyList();
}
}
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