Commit c5b78da3 authored by duanruiming's avatar duanruiming

[add] 绿波绿信比流量优化

parent 9ebadf1a
...@@ -336,12 +336,12 @@ public class TrendServiceImpl implements TrendService { ...@@ -336,12 +336,12 @@ public class TrendServiceImpl implements TrendService {
double roundedTrafficIndex = Math.round(abnormalCrossListVO.getCongestionIndex() * 100.0) / 100.0; double roundedTrafficIndex = Math.round(abnormalCrossListVO.getCongestionIndex() * 100.0) / 100.0;
abnormalCrossListVO.setCongestionIndex(roundedTrafficIndex); abnormalCrossListVO.setCongestionIndex(roundedTrafficIndex);
// todo
Double congestionIndex = abnormalCrossListVO.getCongestionIndex(); //Double congestionIndex = abnormalCrossListVO.getCongestionIndex();
double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800); //double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800);
double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300); //double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300);
abnormalCrossListVO.setLastWeekIndex(Math.floor(lastWeekIndex)); //abnormalCrossListVO.setLastWeekIndex(Math.floor(lastWeekIndex));
abnormalCrossListVO.setLastPeriodIndex(Math.floor(lastPeriodIndex)); //abnormalCrossListVO.setLastPeriodIndex(Math.floor(lastPeriodIndex));
// 常发性偶发性 一个月内超过三次 // 常发性偶发性 一个月内超过三次
int frequent = getFrequent(crossId, batchTime); int frequent = getFrequent(crossId, batchTime);
......
package net.wanji.opt.service.signalopt.impl; package net.wanji.opt.service.signalopt.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -91,6 +92,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -91,6 +92,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
Map<Integer, GreenwaveInfoPO> greenWaveMap = GreenWaveInfoCache.greenWaveMap; Map<Integer, GreenwaveInfoPO> greenWaveMap = GreenWaveInfoCache.greenWaveMap;
GreenwaveInfoPO greenwaveInfoPO = greenWaveMap.get(greenId); GreenwaveInfoPO greenwaveInfoPO = greenWaveMap.get(greenId);
greenBeltCrossDetailVO.setGreenName(greenwaveInfoPO.getName()); greenBeltCrossDetailVO.setGreenName(greenwaveInfoPO.getName());
greenBeltCrossDetailVO.setCrossNum(detailList.size());
} }
return greenBeltCrossDetailVO; return greenBeltCrossDetailVO;
...@@ -98,13 +100,15 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -98,13 +100,15 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
@Override @Override
public Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception { public Map<String, List<GreenBeltKeyCrossFlowTimeVO>> greenBeltKeyCrossFlowTime(Integer greenId) throws Exception {
try {
ObjectMapper mapper = JacksonUtils.getInstance(); ObjectMapper mapper = JacksonUtils.getInstance();
DecimalFormat df = new DecimalFormat("#.00"); DecimalFormat df = new DecimalFormat("#0.00");
List<GreenBeltKeyCrossFlowTimeVO> tempResult = new ArrayList<>(); List<GreenBeltKeyCrossFlowTimeVO> tempResult = new ArrayList<>();
List<GreenBeltKeyCrossFlowTimeVO> results = new ArrayList<>(); List<GreenBeltKeyCrossFlowTimeVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
LocalDate localDate = currentDate.minusDays(1);
LocalTime startTime = LocalTime.MIDNIGHT; LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime); LocalDateTime startOfDay = LocalDateTime.of(localDate, startTime);
// 绿波优化数据 // 绿波优化数据
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
...@@ -118,7 +122,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -118,7 +122,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
GreenBeltKeyCrossFlowTimeVO vo = new GreenBeltKeyCrossFlowTimeVO(); GreenBeltKeyCrossFlowTimeVO vo = new GreenBeltKeyCrossFlowTimeVO();
String keyCross = entity.getKeyCross(); String keyCross = entity.getKeyCross();
vo.setCrossId(keyCross); vo.setCrossId(keyCross);
vo.setDirName(entity.getDir()); vo.setDirName(GreenBeltDirEnum.getDesc(entity.getDir()));
Date controlTime = get5MinuteDate(entity.getControlTime()); Date controlTime = get5MinuteDate(entity.getControlTime());
vo.setStartTime(controlTime); vo.setStartTime(controlTime);
String crossGreenDetail = entity.getCrossGreenDetail(); String crossGreenDetail = entity.getCrossGreenDetail();
...@@ -155,6 +159,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -155,6 +159,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
resultVO.setFlow(0); resultVO.setFlow(0);
resultVO.setGreenTimeRatio(0.0); resultVO.setGreenTimeRatio(0.0);
resultVO.setCrossId(tempCrossId); resultVO.setCrossId(tempCrossId);
resultVO.setDirName("未执行");
for (GreenBeltKeyCrossFlowTimeVO result : tempResult) { for (GreenBeltKeyCrossFlowTimeVO result : tempResult) {
if (StringUtils.equalsIgnoreCase(tempCrossId, result.getCrossId()) if (StringUtils.equalsIgnoreCase(tempCrossId, result.getCrossId())
&& minuteDate.getTime() == result.getStartTime().getTime()) { && minuteDate.getTime() == result.getStartTime().getTime()) {
...@@ -168,6 +173,10 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -168,6 +173,10 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
} }
Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO::getDirName)); Map<String, List<GreenBeltKeyCrossFlowTimeVO>> map = results.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO::getDirName));
return map; return map;
} catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e);
throw new RuntimeException(e);
}
} }
......
...@@ -17,6 +17,8 @@ import java.util.List; ...@@ -17,6 +17,8 @@ import java.util.List;
public class GreenBeltCrossDetailVO { public class GreenBeltCrossDetailVO {
@ApiModelProperty("干线名称") @ApiModelProperty("干线名称")
private String greenName; private String greenName;
@ApiModelProperty("路口数量")
private Integer crossNum;
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class) @JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
@ApiModelProperty("干线指数") @ApiModelProperty("干线指数")
private Double greenIndex; private Double greenIndex;
......
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