Commit 17f0378c authored by duanruiming's avatar duanruiming

[update] 控制正计时

parent 67165d17
......@@ -16,10 +16,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
......@@ -41,6 +38,7 @@ public class SignalStatusTask {
private HkLightsStatusService hkLightsStatusService;
private static Map<String, List<LightsStatusVO>> lightStatusCache = new HashMap<>();
private static Map<String, Integer> runModeTimeMap = new HashMap();
// 运行状态、告警,5分钟一次
@Scheduled(fixedRate = 1 * 60 * 1000)
......@@ -73,6 +71,18 @@ public class SignalStatusTask {
if (!CollectionUtils.isEmpty(lightsStatusVOS)) {
for (LightsStatusVO lightsStatusVO : lightsStatusVOS) {
if (Objects.equals(lightsStatusVO.getCrossId(), crossId)) {
Integer coutTime = 0;
if (Arrays.asList(2, 3, 4, 9).contains(Integer.valueOf(lightsStatusVO.getRunMode()))) {
if (runModeTimeMap.isEmpty() || Objects.isNull(runModeTimeMap.get(crossId))) {
runModeTimeMap.put(crossId, coutTime);
} else {
Integer countTimeCahce = runModeTimeMap.get(crossId);
runModeTimeMap.put(crossId, ++countTimeCahce);
}
lightsStatusVO.setCycleCountDown(runModeTimeMap.get(crossId));
} else if (StringUtils.equals(lightsStatusVO.getRunMode(), "11")){
runModeTimeMap.remove(crossId);
}
try {
webSocket.sendInfo(JSONObject.toJSONString(lightsStatusVOS, SerializerFeature.WriteMapNullValue), crossIdStr);
} catch (Exception e) {
......
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