Commit 33295e5d authored by zhouleilei's avatar zhouleilei

灯态优化

parent 4989b034
...@@ -295,16 +295,6 @@ public class ControlCommandServiceImpl implements ControlCommandService { ...@@ -295,16 +295,6 @@ public class ControlCommandServiceImpl implements ControlCommandService {
messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode()); messageContent.addElement(HttpConstants.SPOT).setText(crossInfoPOExt.getCode());
messageContent.addElement(HttpConstants.PATTERN).setText(tempSchemeSendVO.getPattern()); messageContent.addElement(HttpConstants.PATTERN).setText(tempSchemeSendVO.getPattern());
messageContent.addElement(HttpConstants.CYCLE).setText(tempSchemeSendVO.getCycle()); messageContent.addElement(HttpConstants.CYCLE).setText(tempSchemeSendVO.getCycle());
//如果为空赋值神思的默认值
if (ObjectUtils.isEmpty(tempSchemeSendVO.getOffset())) {
tempSchemeSendVO.setOffset("0");
}
if (ObjectUtils.isEmpty(tempSchemeSendVO.getType())) {
tempSchemeSendVO.setType("1");
}
if (ObjectUtils.isEmpty(tempSchemeSendVO.getSplit())) {
tempSchemeSendVO.setSplit("40,0,0,40,50,50,0,0,0,0,0,0,0,0,0,0");
}
messageContent.addElement(HttpConstants.OFFSET).setText(tempSchemeSendVO.getOffset()); messageContent.addElement(HttpConstants.OFFSET).setText(tempSchemeSendVO.getOffset());
messageContent.addElement(HttpConstants.TYPE).setText(tempSchemeSendVO.getType()); messageContent.addElement(HttpConstants.TYPE).setText(tempSchemeSendVO.getType());
messageContent.addElement(HttpConstants.SPLIT).setText(tempSchemeSendVO.getSplit()); messageContent.addElement(HttpConstants.SPLIT).setText(tempSchemeSendVO.getSplit());
......
package net.wanji.utc.hisense.task; package net.wanji.utc.hisense.task;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.StringUtils; import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.dao.entity.CrossLightsPO; import net.wanji.databus.dao.entity.CrossLightsPO;
...@@ -113,79 +114,85 @@ public class HisensePhaseCountDownTask { ...@@ -113,79 +114,85 @@ public class HisensePhaseCountDownTask {
if (StringUtils.equalsIgnoreCase(schemeId, String.valueOf(dirTurnPojo.getSchemeNo()))) { if (StringUtils.equalsIgnoreCase(schemeId, String.valueOf(dirTurnPojo.getSchemeNo()))) {
if (!StringUtils.equalsIgnoreCase(currenPhaseId, String.valueOf(dirTurnPojo.getPhaseNo()))) { if (!StringUtils.equalsIgnoreCase(currenPhaseId, String.valueOf(dirTurnPojo.getPhaseNo()))) {
Map<Integer, List<CrossLightsPO>> dirTurnMap = dirTurnPojo.getDirTurnMap(); Map<Integer, List<CrossLightsPO>> dirTurnMap = dirTurnPojo.getDirTurnMap();
for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) { if (ObjectUtil.isNotEmpty(dirTurnMap)) {
Integer dir = dirEntry.getKey(); for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) {
Map<Integer, Integer> turnCountDown = new HashMap<>(); Integer dir = dirEntry.getKey();
List<CrossLightsPO> lightsPOS = dirEntry.getValue(); Map<Integer, Integer> turnCountDown = new HashMap<>();
if (!CollectionUtils.isEmpty(lightsPOS)) { List<CrossLightsPO> lightsPOS = dirEntry.getValue();
// 忽略行人 if (!CollectionUtils.isEmpty(lightsPOS)) {
List<CrossLightsPO> person = lightsPOS.stream().filter(po -> po.getTurn() == 20).collect(Collectors.toList()); // 忽略行人
if (person.size() == lightsPOS.size()) { List<CrossLightsPO> person = lightsPOS.stream().filter(po -> po.getTurn() == 20).collect(Collectors.toList());
continue; if (person.size() == lightsPOS.size()) {
} continue;
Integer type = lightsPOS.get(0).getType(); }
redCountDown = changePhaseTime - runtime - phaseTime; Integer type = lightsPOS.get(0).getType();
if (redCountDown <= 0) { redCountDown = changePhaseTime - runtime - phaseTime;
redCountDown = cycleLen - runtime; if (redCountDown <= 0) {
} redCountDown = cycleLen - runtime;
//if (redCountDown <= 0) {
// redCountDown = 1;
//}
if (type == 2) { // 圆饼灯
List<Integer> dirList = Arrays.asList(1, 2, 3);
for (Integer commonTurn : dirList) {
turnCountDown.put(commonTurn, redCountDown);
} }
} else { //if (redCountDown <= 0) {
Map<Integer, List<CrossLightsPO>> turnMap = lightsPOS.stream().collect(Collectors.groupingBy(CrossLightsPO::getTurn)); // redCountDown = 1;
for (Map.Entry<Integer, List<CrossLightsPO>> turnEntry : turnMap.entrySet()) { //}
Integer turn = turnEntry.getKey(); if (type == 2) { // 圆饼灯
List<CrossLightsPO> value = turnEntry.getValue(); List<Integer> dirList = Arrays.asList(1, 2, 3);
for (CrossLightsPO lightsPO : value) { for (Integer commonTurn : dirList) {
if (lightsPO.getTurn() != 20) { turnCountDown.put(commonTurn, redCountDown);
turnCountDown.put(turn, redCountDown); }
} else {
Map<Integer, List<CrossLightsPO>> turnMap = lightsPOS.stream().collect(Collectors.groupingBy(CrossLightsPO::getTurn));
for (Map.Entry<Integer, List<CrossLightsPO>> turnEntry : turnMap.entrySet()) {
Integer turn = turnEntry.getKey();
List<CrossLightsPO> value = turnEntry.getValue();
for (CrossLightsPO lightsPO : value) {
if (lightsPO.getTurn() != 20) {
turnCountDown.put(turn, redCountDown);
}
} }
} }
} }
} }
setPhaseMap(phaseMap, dir, turnCountDown);
} }
setPhaseMap(phaseMap, dir, turnCountDown);
} }
} else { } else {
Integer cyclePhaseCountDown = lightsStatusVO.getCyclePhaseCountDown(); Integer cyclePhaseCountDown = lightsStatusVO.getCyclePhaseCountDown();
Map<Integer, List<CrossLightsPO>> dirTurnMap = dirTurnPojo.getDirTurnMap(); Map<Integer, List<CrossLightsPO>> dirTurnMap = dirTurnPojo.getDirTurnMap();
for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) { if (ObjectUtil.isNotEmpty(dirTurnMap)) {
Integer dir = dirEntry.getKey(); for (Map.Entry<Integer, List<CrossLightsPO>> dirEntry : dirTurnMap.entrySet()) {
Map<Integer, Integer> turnCountDown = new HashMap<>(); Integer dir = dirEntry.getKey();
List<CrossLightsPO> lightsPOS = dirEntry.getValue(); Map<Integer, Integer> turnCountDown = new HashMap<>();
if (!CollectionUtils.isEmpty(lightsPOS)) { List<CrossLightsPO> lightsPOS = dirEntry.getValue();
// 忽略行人 if (!CollectionUtils.isEmpty(lightsPOS)) {
List<CrossLightsPO> person = lightsPOS.stream().filter(po -> po.getTurn() == 20).collect(Collectors.toList()); // 忽略行人
if (person.size() == lightsPOS.size()) { List<CrossLightsPO> person = lightsPOS.stream().filter(po -> po.getTurn() == 20).collect(Collectors.toList());
continue; if (person.size() == lightsPOS.size()) {
} continue;
Integer type = lightsPOS.get(0).getType();
redCountDown = cyclePhaseCountDown;
if (type == 2) { // 圆饼灯
List<Integer> dirList = Arrays.asList(1, 2, 3);
for (Integer commonTurn : dirList) {
turnCountDown.put(commonTurn, redCountDown);
} }
} else { Integer type = lightsPOS.get(0).getType();
Map<Integer, List<CrossLightsPO>> turnMap = lightsPOS.stream().collect(Collectors.groupingBy(CrossLightsPO::getTurn)); redCountDown = cyclePhaseCountDown;
for (Map.Entry<Integer, List<CrossLightsPO>> turnEntry : turnMap.entrySet()) { if (type == 2) { // 圆饼灯
Integer turn = turnEntry.getKey(); List<Integer> dirList = Arrays.asList(1, 2, 3);
List<CrossLightsPO> value = turnEntry.getValue(); for (Integer commonTurn : dirList) {
for (CrossLightsPO lightsPO : value) { turnCountDown.put(commonTurn, redCountDown);
if (lightsPO.getTurn() != 20) { }
turnCountDown.put(turn, redCountDown); } else {
Map<Integer, List<CrossLightsPO>> turnMap = lightsPOS.stream().collect(Collectors.groupingBy(CrossLightsPO::getTurn));
for (Map.Entry<Integer, List<CrossLightsPO>> turnEntry : turnMap.entrySet()) {
Integer turn = turnEntry.getKey();
List<CrossLightsPO> value = turnEntry.getValue();
for (CrossLightsPO lightsPO : value) {
if (lightsPO.getTurn() != 20) {
turnCountDown.put(turn, redCountDown);
}
} }
} }
} }
} }
setPhaseMap(phaseMap, dir, turnCountDown);
} }
setPhaseMap(phaseMap, dir, turnCountDown);
} }
} }
} }
} }
...@@ -299,7 +306,7 @@ public class HisensePhaseCountDownTask { ...@@ -299,7 +306,7 @@ public class HisensePhaseCountDownTask {
if (!StringUtils.equalsIgnoreCase(currentPhaseNo, String.valueOf(phaseNo))) { if (!StringUtils.equalsIgnoreCase(currentPhaseNo, String.valueOf(phaseNo))) {
// 相位红灯 // 相位红灯
Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap(); Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap();
if (!dirTurnMap.isEmpty()) { if (ObjectUtil.isNotEmpty(dirTurnMap)) {
for (Map.Entry<Integer, List<CrossLightsPO>> entry : dirTurnMap.entrySet()) { for (Map.Entry<Integer, List<CrossLightsPO>> entry : dirTurnMap.entrySet()) {
String dir = String.valueOf(entry.getKey()); String dir = String.valueOf(entry.getKey());
Map<Integer, String> turnColor = null; Map<Integer, String> turnColor = null;
...@@ -344,8 +351,10 @@ public class HisensePhaseCountDownTask { ...@@ -344,8 +351,10 @@ public class HisensePhaseCountDownTask {
Integer yellowTime = phaseCountDownDTO.getYellowTime(); Integer yellowTime = phaseCountDownDTO.getYellowTime();
Integer redTime = phaseCountDownDTO.getRedTime(); Integer redTime = phaseCountDownDTO.getRedTime();
Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap(); Map<Integer, List<CrossLightsPO>> dirTurnMap = phaseDirTurnPojo.getDirTurnMap();
if (!dirTurnMap.isEmpty()) { if (ObjectUtil.isNotEmpty(dirTurnMap)) {
setDirTurnColor(cyclePhaseCountDown, dirLampGroupMap, yellowTime, redTime, dirTurnMap, crossLightsPOS); setDirTurnColor(cyclePhaseCountDown, dirLampGroupMap, yellowTime, redTime, dirTurnMap, crossLightsPOS);
} else {
log.error("路口:{},dirTurnMap为空,{}", crossId, dirTurnMap);
} }
} }
} }
......
...@@ -175,6 +175,7 @@ public class LocalDateTimeUtil { ...@@ -175,6 +175,7 @@ public class LocalDateTimeUtil {
LocalDateTime localDateTime = parseStringToDateTimeTwo(nowStageStartTime, LocalDateTimeUtil.TIMEFORMATTERTILT); LocalDateTime localDateTime = parseStringToDateTimeTwo(nowStageStartTime, LocalDateTimeUtil.TIMEFORMATTERTILT);
String time = nowStageStartTime.isEmpty() ? "0" : Long.toString(LocalDateTimeUtil.betweenTwoTime(localDateTime, LocalDateTime.now(), ChronoUnit.SECONDS)); String time = nowStageStartTime.isEmpty() ? "0" : Long.toString(LocalDateTimeUtil.betweenTwoTime(localDateTime, LocalDateTime.now(), ChronoUnit.SECONDS));
System.out.println(time); System.out.println(time);
System.out.println(new Date().getTime());
} }
/** /**
......
...@@ -32,8 +32,7 @@ public class TempSchemeSendVO { ...@@ -32,8 +32,7 @@ public class TempSchemeSendVO {
@NotBlank(message = "offset不能为空") @NotBlank(message = "offset不能为空")
private String offset; private String offset;
@ApiModelProperty(value = "优化模式", notes = "目前支持 Type=1(预案模式,按时间调整),Type=15(瓶颈模式,\n" + @ApiModelProperty(value = "优化模式", notes = "目前支持 Type=1(预案模式,按时间调整),Type=1 时为协调模式,Type=15(瓶颈模式,按比例调整)")
"按比例调整)")
@NotBlank(message = "type不能为空") @NotBlank(message = "type不能为空")
private String type; private String type;
......
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