Commit 8bf5ad86 authored by zhouleilei's avatar zhouleilei

Merge remote-tracking branch 'origin/master'

parents f0c4b077 2ca7a1cc
......@@ -130,8 +130,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
vo.setStartTime(controlTime);
String crossGreenDetail = entity.getCrossGreenDetail();
Integer cycle = entity.getCycle();
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = mapper.readValue(crossGreenDetail, new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {
});
List<GreenBeltInfoVO.CrossGreenDetail> crossGreenDetails = mapper.readValue(crossGreenDetail, new TypeReference<List<GreenBeltInfoVO.CrossGreenDetail>>() {});
if (!CollectionUtils.isEmpty(crossGreenDetails)) {
List<GreenBeltInfoVO.CrossGreenDetail> keyCrossDetail = crossGreenDetails.stream().filter(details -> StringUtils.equalsIgnoreCase(keyCross, details.getCrossId())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(keyCrossDetail)) {
......@@ -159,7 +158,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
Integer flow = crossDataHistPO.getFlow();
GreenBeltKeyCrossFlowTimeVO resultVO = new GreenBeltKeyCrossFlowTimeVO();
resultVO.setStartTime(minuteDate);
resultVO.setFlow(0);
resultVO.setFlow(flow);
resultVO.setGreenTimeRatio(0.0);
resultVO.setCrossId(tempCrossId);
resultVO.setDirName("未执行");
......@@ -290,6 +289,7 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
detail.setCrossId(crossDirDataHistPO.getCrossId());
detail.setFlow(crossDirDataHistPO.getFlow());
detail.setStopTimes(crossDirDataHistPO.getStopTimes());
detail.setSpeed(crossDirDataHistPO.getSpeed());
detailList.add(detail);
}
}
......
......@@ -14,9 +14,10 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.opt.cache.BaseCrossInfoCache;
import net.wanji.opt.cache.GreenWaveInfoCache;
import net.wanji.opt.common.enums.StrategyControlEnum;
......@@ -73,6 +74,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
private StrategyCrossResultMapper strategyCrossResultMapper;
@Resource
private BaseCrossInfoCache baseCrossInfoCache;
@Resource
private CrossDataRealtimeMapper crossDataRealtimeMapper;
@Override
......@@ -255,25 +258,21 @@ public class StrategyControlServiceImpl implements StrategyControlService {
Map<String, StrategyControlDataEntity> map = runList.stream().collect(Collectors.toMap(StrategyControlDataEntity::getBizId, entity -> entity));
// 路口
if (Objects.equals(0, type)) {
LambdaQueryWrapper<TBaseCrossInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TBaseCrossInfo::getIsSignal, 1);
List<TBaseCrossInfo> baseCrossInfoPOS = baseCrossInfoMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(baseCrossInfoPOS)) {
for (TBaseCrossInfo baseCrossInfoPO : baseCrossInfoPOS) {
List<AbnormalCrossListVO> abnormalCrossListVOS = crossDataRealtimeMapper.selectAbnormalCross(null, null, null);
if (!CollectionUtils.isEmpty(abnormalCrossListVOS)) {
for (AbnormalCrossListVO baseCrossInfoPO : abnormalCrossListVOS) {
StrategyControlDataEntity strategyControlDataEntity = new StrategyControlDataEntity();
String crossId = baseCrossInfoPO.getId();
strategyControlDataEntity.setBizType(0);
strategyControlDataEntity.setBizId(baseCrossInfoPO.getId());
strategyControlDataEntity.setBizId(crossId);
// 转化成 0 畅通 1失衡 2拥堵 3溢出 4死锁 5空放 6干线拥堵 7干线缓行 8干线畅通
strategyControlDataEntity.setStrategy(0);
strategyControlDataEntity.setOptMethod("均衡调控");
Integer status = baseCrossInfoPO.getRealtimeStatus();
strategyControlDataEntity.setStrategy(status);
strategyControlDataEntity.setOptMethod(Objects.equals(1, status) ? "均衡调控" : "效率提升");
strategyControlDataEntity.setTime(null);
strategyControlDataEntity.setStatus(0);
if (map.containsKey(crossId)) {
strategyControlDataEntity = map.get(crossId);
}
strategyControlDataEntity.setStatus(status);
strategyControlDataEntity.setCrossName(baseCrossInfoPO.getName());
String location = baseCrossInfoPO.getLocation();
String location = baseCrossInfoPO.getLocationStr();
location = location.replace("POINT(", "").replace(" ", ",").replace(")", "");
strategyControlDataEntity.setWkt(location);
results.add(strategyControlDataEntity);
......
......@@ -103,12 +103,12 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
@Override
public List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId) {
long currentTimeMillis = System.currentTimeMillis();
LambdaQueryWrapper<GreenwaveHistPO> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(GreenwaveHistPO::getGreenId, greenId);
// 查询两个小时之前的
Integer startTime = (int) (currentTimeMillis / 1000) - 3600 * 2;
queryWrapper.ge(GreenwaveHistPO::getStartTime, new Date(startTime * 1000L));
LocalDate currentDate = LocalDate.now();
LocalTime startTime = LocalTime.MIDNIGHT;
LocalDateTime startOfDay = LocalDateTime.of(currentDate, startTime);
queryWrapper.ge(GreenwaveHistPO::getStartTime, startOfDay);
List<GreenwaveHistPO> greenwaveHistPOS = greenwaveHistMapper.selectList(queryWrapper);
List<GreenBeltStopTimesQueueLengthVO> results = new ArrayList<>();
if (!CollectionUtils.isEmpty(greenwaveHistPOS)) {
......@@ -120,6 +120,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
vo.setStopTimes(greenwaveHistPO.getStopTimes());
vo.setCordQueueRatio(Objects.isNull(greenwaveHistPO.getCordQueueRatio()) ? 0.0 : greenwaveHistPO.getCordQueueRatio() * 100);
vo.setTravelTime(greenwaveHistPO.getTrvalTime());
vo.setSpeed(greenwaveHistPO.getSpeed());
vo.setRoadDirection(GreenBeltDirEnum.getDesc(greenwaveHistPO.getRoadDirection()));
results.add(vo);
}
}
......@@ -214,6 +216,7 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
LinkedList<Double> backCrossGreenStartList = new LinkedList<>();
Map<String, Double> distanceMap = new LinkedHashMap<>();
Map<String, Double> backDistanceMap = new TreeMap<>();
String decideSpeed = "";
String backDecideSpeed = "";
String crossSpeed = "";
......@@ -221,6 +224,9 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
String travelTime = "";
String backtravelTime = "";
String offset = "";
String distanceStr = "";
String backDistanceStr = "";
// 处理绿波时序图数据
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = greenBeltInfoVO.getDirGreenDetails();
Double greenWidthTime = 0.0;
......@@ -246,6 +252,9 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
crossSpeed = mapper.writeValueAsString(integerList);
List<Double> offsetList = list.stream().map(GreenBeltInfoVO.CrossGreenDetail::getOffset).collect(Collectors.toList());
offset = mapper.writeValueAsString(offsetList);
List<Double> distance = list.stream().filter(vo -> vo.getDistance() > 0).map(GreenBeltInfoVO.CrossGreenDetail::getDistance).collect(Collectors.toList());
distanceStr = mapper.writeValueAsString(distance);
}
if (dirType == 0) {
backDecideSpeed = String.join("~", String.valueOf(dirGreenDetail.getMinSpeed()), String.valueOf(dirGreenDetail.getMaxSpeed()));
......@@ -263,6 +272,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
}
}
backCrossSpeed = mapper.writeValueAsString(integerList);
List<Double> distance = list.stream().filter(vo -> vo.getDistance() > 0).map(GreenBeltInfoVO.CrossGreenDetail::getDistance).collect(Collectors.toList());
backDistanceStr = mapper.writeValueAsString(distance);
}
}
}
......@@ -285,6 +296,8 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
greenBeltChartVO.setCrossGreenStartList(strArray(crossGreenStartList));
Collections.reverse(backCrossGreenStartList);
greenBeltChartVO.setBackCrossGreenStartList(strArray(backCrossGreenStartList));
greenBeltChartVO.setDistance(distanceStr);
greenBeltChartVO.setBackDistance(backDistanceStr);
return greenBeltChartVO;
}
......
......@@ -37,28 +37,28 @@ public class CrossMonitorTask {
* 路口实时监测
*
*/
@Scheduled(fixedRate = 1 * 60 * 1000)
public void realtimeMonitor() {
log.info("路口实时监测任务...");
//@Scheduled(fixedRate = 1 * 60 * 1000)
//public void realtimeMonitor() {
// log.info("路口实时监测任务...");
// 获取路口实时监测数据
List<CrossDataRealtimePO> crossDataRealtimePOList = listCrossDataRealtime();
log.info("路口实时数据:{}条", crossDataRealtimePOList.size());
//List<CrossDataRealtimePO> crossDataRealtimePOList = listCrossDataRealtime();
//log.info("路口实时数据:{}条", crossDataRealtimePOList.size());
// 测试时无数据暂时注释
// if(crossDataRealtimePOList.isEmpty()) {
// return ;
// }
// 获取所有信控路口异常数据(失衡/拥堵/溢出/死锁)
List<CrossDataRealtimePO> abnormalCrossList = listAbnormalCross(crossDataRealtimePOList);
log.info("加载异常路口:{}条", abnormalCrossList.size());
//List<CrossDataRealtimePO> abnormalCrossList = listAbnormalCross(crossDataRealtimePOList);
//log.info("加载异常路口:{}条", abnormalCrossList.size());
// if(abnormalCrossList.isEmpty()) {
// return ;
// }
// 调用路口实时优化
crossOptimizeService.realtimeOptimize(abnormalCrossList, crossDataRealtimePOList);
//crossOptimizeService.realtimeOptimize(abnormalCrossList, crossDataRealtimePOList);
}
//}
/**
* 获取异常路口数据
......
......@@ -43,6 +43,8 @@ public class GreenBeltChartVO {
private String offset;
private String crossGreenStartList;
private String backCrossGreenStartList;
private String distance;
private String backDistance;
@JsonCreator
public GreenBeltChartVO(){
......
......@@ -37,5 +37,8 @@ public class GreenBeltFlowStopTimeVO {
@ApiModelProperty("行程时间")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double travelTime;
@ApiModelProperty("速度")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double speed;
}
}
......@@ -33,4 +33,7 @@ public class GreenBeltStopTimesQueueLengthVO {
private Double cordQueueRatio;
@ApiModelProperty("行程时间")
private Integer travelTime;
@ApiModelProperty("速度")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double speed;
}
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