Commit 02844cc3 authored by duanruiming's avatar duanruiming

[add] 海信灯态优化

parent 8b03d0d2
......@@ -24,6 +24,7 @@ public class SignalDataCache {
// 海信推送灯态数据
public static final Map<String, RunningLightsStatusPojo> runningStateInfoCacheUdp = new HashMap<>();
public static final Map<String, LightsStatusVO> runningStateInfoCache = new ConcurrentHashMap<>();
// 海信推送方案相位信息,未计算灯态缓存
public static final Map<String, LightsStatusVO> runningStateInfoCacheNoLamp = new ConcurrentHashMap<>();
public static final Map<String, Long> runningStatusStampMap = new HashMap<>();
}
......@@ -15,6 +15,7 @@ import net.wanji.utc.hisense.cache.SignalDataCache;
import net.wanji.utc.hisense.pojo.CrossPhaseDirTurnPojo;
import net.wanji.utc.hisense.pojo.dto.CrossSchemePhaseCountDownDTO;
import net.wanji.utc.hisense.pojo.dto.PhaseCountDownDTO;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......@@ -36,7 +37,7 @@ public class HisensePhaseCountDownTask {
private CrossSchemeMapper crossSchemeMapper;
@Scheduled(fixedRate = 1000, initialDelay = 1000)
public void phaseTimeCountDown() throws Exception {
public void phaseTimeCountDown() throws Exception {
try {
Map<String, LightsStatusVO> runningStateInfoCacheNoLamp = SignalDataCache.runningStateInfoCacheNoLamp;
if (!runningStateInfoCacheNoLamp.isEmpty()) {
......@@ -50,8 +51,10 @@ public class HisensePhaseCountDownTask {
// 通过时段表,切换方案 凌晨00:00 如果切换下一个日期方案,可能RefreshCacheTask还没执行
String nextSectionSchemeNo = CrossRunSchemeCache.currentRunSchemeNoCache.get(crossId);
String currentTime = String.valueOf(new Date().getTime());
if (StringUtils.equalsIgnoreCase(schemeStartTime, currentTime)) {
Date currentDate = new Date();
String currentTime = String.valueOf(currentDate.getTime());
Date date2HoursAgo = DateUtils.addHours(currentDate, -1);
if (StringUtils.equalsIgnoreCase(schemeStartTime, currentTime) || Long.parseLong(schemeStartTime) < date2HoursAgo.getTime()) {
crossSchemePO = crossSchemeMapper.selectByCrossIdAndSchemeNo(crossId, Integer.valueOf(nextSectionSchemeNo));
executeNextSectionScheme(crossId, lightsStatusVO, crossSchemePO);
lightsStatusVO.setCycleLen(crossSchemePO.getCycle());
......@@ -61,6 +64,18 @@ public class HisensePhaseCountDownTask {
// 当前方案下一周期
setDirLampGroupMap(lightsStatusVO);
if (Objects.nonNull(lightsStatusVO.getDirLampGroupMap())) {
if (Objects.equals(crossId, "13NI00B5RM0")) {
List<String> dirList = Arrays.asList("1", "3", "7");
Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap();
for (String dir : dirList) {
if (!dirLampGroupMap.containsKey(dir)) {
Map<String, String> value = new HashMap<>();
setAllTurnColorRed(value, null, null);
dirLampGroupMap.put(dir, value);
}
}
lightsStatusVO.setDirLampGroupMap(dirLampGroupMap);
}
SignalDataCache.runningStateInfoCache.put(crossId, lightsStatusVO);
}
}
......@@ -161,7 +176,7 @@ public class HisensePhaseCountDownTask {
private static void setDirTurnColor(Integer cyclePhaseCountDown, Map<String, Object> dirLampGroupMap,
Integer yellowTime, Integer redTime, Map<Integer,
List<CrossLightsPO>> dirTurnMap) throws Exception {
List<CrossLightsPO>> dirTurnMap) throws Exception {
for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) {
Integer dir = dirEntry.getKey();
List<CrossLightsPO> lightsList = dirEntry.getValue();
......@@ -213,6 +228,7 @@ public class HisensePhaseCountDownTask {
/**
* 两秒倒计时,全场红
*
* @param turnColor
* @param type
* @param color
......@@ -225,12 +241,13 @@ public class HisensePhaseCountDownTask {
}
}
for (Map.Entry<String, String> entry : turnColor.entrySet()) {
entry.setValue("red");
entry.setValue("red");
}
}
/**
* 设置所有转向灯色
*
* @param turnColor
* @param type
* @param color
......
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