Commit e5dc6b07 authored by duanruiming's avatar duanruiming

[add] 优化utc灯态圆饼灯

parent 9878ea6f
......@@ -16,6 +16,7 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO;
import net.wanji.databus.vo.LightsStatusVO2;
import net.wanji.utc.common.constant.Constants;
import net.wanji.utc.service.runninginfo.SignalStatusService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -26,6 +27,7 @@ import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 运行状态、告警、灯态信息接口
......@@ -74,10 +76,12 @@ public class SignalStatusController {
@ApiResponse(code = 200, message = "OK", response = LightsStatusVO.class)
})
public JsonViewObject lightStatusV2() throws Exception {
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus4StaticScheme();
//List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus4StaticScheme();
List<LightsStatusVO> lightsStatusVOList = signalStatusService.lightStatus();
List<LightsStatusVO2> listResult = new ArrayList<>(lightsStatusVOList.size());
for (LightsStatusVO lightsStatusVO : lightsStatusVOList) {
Integer cyclePhaseCountDown = lightsStatusVO.getCyclePhaseCountDown();
LightsStatusVO2 lightsStatusVO2 = new LightsStatusVO2();
BeanUtils.copyProperties(lightsStatusVO, lightsStatusVO2);
Map<String, Object> dirLampGroupMap = lightsStatusVO.getDirLampGroupMap();
......@@ -86,17 +90,23 @@ public class SignalStatusController {
for (Map.Entry<String, Object> groupEntry : dirLampGroupMap.entrySet()) {
LightsStatusVO2.DirInfo dirInfo = new LightsStatusVO2.DirInfo();
String dir = groupEntry.getKey();
Map<String, Integer> turnDountMap = (Map<String, Integer>) phaseMap.get(dir);
Map<Integer, String> turnColorMap = (Map<Integer, String>) groupEntry.getValue();
Map<String, String> turnColorMap = (Map<String, String>) groupEntry.getValue();
List<LightsStatusVO2.TurnInfo> turnList = new ArrayList<>();
for (Map.Entry<Integer, String> turnEntry : turnColorMap.entrySet()) {
Integer turn = turnEntry.getKey();
for (Map.Entry<String, String> turnEntry : turnColorMap.entrySet()) {
String turn = turnEntry.getKey();
String color = turnEntry.getValue();
LightsStatusVO2.TurnInfo turnInfo = new LightsStatusVO2.TurnInfo();
turnInfo.setTurn(String.valueOf(turn));
turnInfo.setColor(color);
Integer countDown = turnDountMap.get(turn);
turnInfo.setCountDown(countDown);
String key = dir.concat(Constants.SEPARATOR_UNDER_LINE).concat(turn);
Object countDown = phaseMap.get(key);
if (Objects.isNull(countDown)) {
countDown = cyclePhaseCountDown;
}
if (Objects.isNull(cyclePhaseCountDown)) {
countDown = lightsStatusVO.getCycleCountDown();
}
turnInfo.setCountDown((int) countDown);
turnList.add(turnInfo);
}
dirInfo.setDir(dir);
......
......@@ -165,11 +165,10 @@ public class HkLightsStatusServiceImpl implements HkLightsStatusService {
String turn = po.getTurn().toString();
if (dirLampGroupMap.get(direction) != null) {
Map<String, String> mstr = (Map<String, String>) dirLampGroupMap.get(direction);
mstr.put(turn, color);
mstr = setTurnColor(color, po, turn, mstr);
dirLampGroupMap.put(direction, mstr);
} else {
Map<String, String> lamp = new HashMap<>();
lamp.put(turn, color);
Map<String, String> lamp = setTurnColor(color, po, turn, new HashMap<>());
dirLampGroupMap.put(direction, lamp);
}
}
......@@ -341,11 +340,10 @@ public class HkLightsStatusServiceImpl implements HkLightsStatusService {
String turn = po.getTurn().toString();
if (dirLampGroupMap.get(direction) != null) {
Map<String, String> mstr = (Map<String, String>) dirLampGroupMap.get(direction);
mstr.put(turn, color);
mstr = setTurnColor(color, po, turn, mstr);
dirLampGroupMap.put(direction, mstr);
} else {
Map<String, String> lamp = new HashMap<>();
lamp.put(turn, color);
Map<String, String> lamp = setTurnColor(color, po, turn, new HashMap<>());
dirLampGroupMap.put(direction, lamp);
}
}
......@@ -362,6 +360,18 @@ public class HkLightsStatusServiceImpl implements HkLightsStatusService {
return result;
}
private static Map<String, String> setTurnColor(String color, CrossLightsPO po, String turn, Map<String, String> mstr) {
if (Objects.equals(2, po.getType())) {
List<String> dirList = Arrays.asList("1", "2", "3");
for (String commonTurn : dirList) {
mstr.put(commonTurn, color);
}
} else {
mstr.put(turn, color);
}
return mstr;
}
/**
* 灯组颜色转换
......
......@@ -168,7 +168,7 @@ public class SignalStatus4StaticSchemeTask {
}
Integer week4DB = schedulesPO.getWeek();
int weekCurrent = DateUtil.getWeek(currentDate);
if (week4DB == weekCurrent) {
if (week4DB == weekCurrent || weekCurrent == 0) {
return planId;
}
}
......
......@@ -90,6 +90,9 @@ public class SignalStatusTask {
String crossId = entry.getKey();
List<LightsStatusVO> lightsStatusVOS = null;
CrossInfoPO crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
if (Objects.isNull(crossInfoPO)) {
continue;
}
ManufacturerInfoPO manufacturerInfoPO = manufacturerInfoMapper.selectById(crossInfoPO.getManufacturerId());
try {
if (StringUtils.equals(BasicEnum.ManufacturerEnum.HK.getCode(), manufacturerInfoPO.getCode())) {
......@@ -102,9 +105,11 @@ public class SignalStatusTask {
lightsStatusVOS = mapper.convertValue(jsonViewObject.getContent(), new TypeReference<List<LightsStatusVO>>() {});
}
} catch (Exception e) {
lightsStatusVOS = new ArrayList<>();
LightsStatusVO lightsStatusVO = SignalStatus4StaticSchemeTask.currentCrossLightStatusCache.get(crossId);
lightsStatusVOS.add(lightsStatusVO);
log.error("灯态异常");
//throw new Exception(e);
//lightsStatusVOS = new ArrayList<>();
//LightsStatusVO lightsStatusVO = SignalStatus4StaticSchemeTask.currentCrossLightStatusCache.get(crossId);
//lightsStatusVOS.add(lightsStatusVO);
}
......
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