Commit 8338777b authored by duanruiming's avatar duanruiming

[add] 代码优化

parent 2930a9cf
......@@ -14,8 +14,4 @@ public class StrategyControlDataExt extends StrategyControlDataEntity{
private String optStatus;
@ApiModelProperty(value = "策略类型")
private String optMethod;
@ApiModelProperty(value = "交通指数")
private Double trafficIndex;
@ApiModelProperty(value = "排队长度")
private int queueLength;
}
......@@ -30,6 +30,7 @@ import net.wanji.opt.synthesis.service.PushStrategyControlService;
import net.wanji.opt.synthesis.service.StrategyControlService;
import net.wanji.opt.vo.StrategyLockSendVO;
import net.wanji.opt.vo.StrategyNameCrossVO;
import net.wanji.opt.vo2.OptMonitoringVO;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
......@@ -581,7 +582,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
Date date = Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
List<StrategyControlDataExt> results = new ArrayList<>();
if (Objects.equals(0, type)) {
results = getCrossList(date);
results = getCrossList();
}
if (Objects.equals(1, type)) {
results = getGreenList(date);
......@@ -661,12 +662,27 @@ public class StrategyControlServiceImpl implements StrategyControlService {
}
}
// 添加逻辑,事件类型
List<OptMonitoringVO> optMonitoringVOS = holoEventMapper.selectGreenOptMonitoringList();
if (!CollectionUtils.isEmpty(optMonitoringVOS)) {
for (OptMonitoringVO optMonitoringVO : optMonitoringVOS) {
String id = optMonitoringVO.getId();
String type = optMonitoringVO.getType();
for (StrategyControlDataExt result : results) {
String bizId = result.getBizId();
if (StringUtils.equals(id, bizId)) {
result.setBizType(Integer.valueOf(type));
}
}
}
}
Collections.sort(results, Comparator.comparingInt(StrategyControlDataExt::getStatus).reversed());
results.stream().distinct().collect(Collectors.toList());
return results;
}
private List<StrategyControlDataExt> getCrossList(Date date) {
private List<StrategyControlDataExt> getCrossList() {
List<StrategyControlDataExt> results = new ArrayList<>();
List<StrategyCrossResultEntity> resultList = strategyCrossResultMapper.selectAICrossList(null);
if (!CollectionUtils.isEmpty(resultList)) {
......@@ -695,12 +711,20 @@ public class StrategyControlServiceImpl implements StrategyControlService {
if (Objects.isNull(currentAlgo) || Objects.equals(0, currentAlgo)) {
ext.setOptStatus("正常");
ext.setOptMethod("畅通");
ext.setBizType(700);
} else if (Objects.equals(2, currentAlgo)) {
ext.setOptStatus("优化中");
ext.setOptMethod("均衡调控");
ext.setBizType(702);
} else {
ext.setOptStatus("优化中");
ext.setOptMethod("效率提升");
if (Objects.equals(1, currentAlgo)) {
ext.setBizType(701);
}
if (Objects.equals(3, currentAlgo)) {
ext.setBizType(703);
}
}
results.add(ext);
}
......
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