Commit c5b78da3 authored by duanruiming's avatar duanruiming

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

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