Commit 1065f08c authored by duanruiming's avatar duanruiming

[update] 济南测试平台-态势检测-重点路口检测

parent 76baa26e
......@@ -13,10 +13,7 @@ import net.wanji.opt.dto.trend.EventAlarmDTO;
import net.wanji.opt.dto.trend.GreenwaveListDTO;
import net.wanji.opt.service.impl.TrendServiceImpl;
import net.wanji.opt.vo.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
import java.text.ParseException;
......@@ -173,7 +170,7 @@ public class TrendController {
return jsonViewObject.success(eventAlarmVOList);
}
@ApiOperation(value = "数量实时推送", notes = "数量实时推送",response = JsonViewObject.class,
@ApiOperation(value = "数量实时推送", notes = "数量实时推送", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/countRealTime",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -186,7 +183,7 @@ public class TrendController {
return JsonViewObject.newInstance().success(countRealTimeVO);
}
@ApiOperation(value = "表格分时段查询", notes = "表格分时段查询",response = JsonViewObject.class,
@ApiOperation(value = "表格分时段查询", notes = "表格分时段查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/tableQuery",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -198,7 +195,7 @@ public class TrendController {
return JsonViewObject.newInstance().success(tableQueryVO);
}
@ApiOperation(value = "表格实时推送", notes = "表格实时推送",response = JsonViewObject.class,
@ApiOperation(value = "表格实时推送", notes = "表格实时推送", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/tableRealTime",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -210,7 +207,7 @@ public class TrendController {
return JsonViewObject.newInstance().success(tableRealTimeVO);
}
@ApiOperation(value = "优化类型", notes = "优化类型",response = JsonViewObject.class,
@ApiOperation(value = "优化类型", notes = "优化类型", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/optType",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -221,4 +218,11 @@ public class TrendController {
OptTypeVO optTypeVO = trendService.optType(crossIdBO);
return JsonViewObject.newInstance().success(optTypeVO);
}
@ApiOperation(value = "重点路口监测", notes = "重点路口监测", response = JsonViewObject.class)
@GetMapping(value = "/hotspotCross")
public JsonViewObject hotspotCross() throws Exception {
List<HotspotCrossVO> hotspotCrossVOS = trendService.hotspotCross();
return JsonViewObject.newInstance().success(hotspotCrossVOS);
}
}
\ No newline at end of file
......@@ -46,4 +46,6 @@ public interface TrendService {
TableQueryVO tableRealTime(CrossIdAndIsFirstBO crossIdAndIsFirstBO) throws Exception;
OptTypeVO optType(CrossIdBO crossIdBO);
List<HotspotCrossVO> hotspotCross() throws Exception;
}
......@@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -238,7 +239,7 @@ public class TrendServiceImpl implements TrendService {
spilloverDirList.add(Integer.parseInt(s));
}
buildRidData(abnormalCrossListVO, endCrossId, spilloverDirList);
} else if (Objects.equals(realtimeStatus, CrossStatusEnum.CONGESTION.getCode())){
} else if (Objects.equals(realtimeStatus, CrossStatusEnum.CONGESTION.getCode())) {
// 拥堵返回所有方向关联路口
List<Integer> inDirs = baseCrossDirInfoMapper.selectInDirsByCrossId(endCrossId);
buildRidData(abnormalCrossListVO, endCrossId, inDirs);
......@@ -268,7 +269,6 @@ public class TrendServiceImpl implements TrendService {
}
abnormalCrossVO.setAbnormalCrossList(abnormalCrossListVOList);
// 构造统计信息
List<AbnormalCrossListVO> listForStats =
......@@ -281,7 +281,7 @@ public class TrendServiceImpl implements TrendService {
private int getFrequent(String crossId, Integer batchTime) {
LambdaQueryWrapper<CrossDataHistPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CrossDataHistPO::getCrossId, crossId);
queryWrapper.between(CrossDataHistPO::getBatchTime, batchTime - 30 * 86400 , batchTime);
queryWrapper.between(CrossDataHistPO::getBatchTime, batchTime - 30 * 86400, batchTime);
queryWrapper.eq(CrossDataHistPO::getIsCongestion, 1);
List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectList(queryWrapper);
List<CrossDataHistPO> result = new ArrayList<>();
......@@ -310,7 +310,7 @@ public class TrendServiceImpl implements TrendService {
return 0.0;
}
Double lastCongestionIndex = lastHistPO.getCongestionIndex();
return (congestionIndex - lastCongestionIndex)/ lastCongestionIndex * 100;
return (congestionIndex - lastCongestionIndex) / lastCongestionIndex * 100;
}
private static class CrossComparator implements Comparator<AbnormalCrossListVO> {
......@@ -367,7 +367,7 @@ public class TrendServiceImpl implements TrendService {
CrossDataRealtimePO crossDataRealtimePO = crossDataRealtimeMapper.selectByCrossId(crossId);
abnormalCrossDetailVO.setCrossStatus(crossDataRealtimePO.getStatus());
abnormalCrossDetailVO.setCrossQueueLength(crossDataRealtimePO.getQueueLength());
abnormalCrossDetailVO.setCrossFlowRate((double)crossDataRealtimePO.getFlow());
abnormalCrossDetailVO.setCrossFlowRate((double) crossDataRealtimePO.getFlow());
abnormalCrossDetailVO.setCrossStopTimes(crossDataRealtimePO.getStopTimes());
BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getCongestionIndex()).setScale(2, RoundingMode.HALF_UP);
abnormalCrossDetailVO.setCongestionIndex(bigDecimal);
......@@ -491,7 +491,7 @@ public class TrendServiceImpl implements TrendService {
double width = foundItem.getWidth();
double designSpeed = foundItem.getDesignSpeed() / 3.6; // 换算成米/秒
int widthSeconds = (int)(width / designSpeed);
int widthSeconds = (int) (width / designSpeed);
Integer dir = greenwaveInfoPO.getDir();
if (dir == 0) { // 正向
res.setForwardWidth(widthSeconds);
......@@ -503,7 +503,7 @@ public class TrendServiceImpl implements TrendService {
}
double uncoordinatePhaseQueue = greenwaveRealtimePO.getUncoordinatePhaseQueue();
res.setUncoordinatePhaseQueue((int)uncoordinatePhaseQueue);
res.setUncoordinatePhaseQueue((int) uncoordinatePhaseQueue);
double noparkPassRate = greenwaveRealtimePO.getNoparkPassRate();
res.setNoparkPassRate((int) (noparkPassRate * 100));
res.setTrvalTime(greenwaveRealtimePO.getTrvalTime());
......@@ -603,7 +603,7 @@ public class TrendServiceImpl implements TrendService {
LocalTime startTimeObj = LocalTime.parse(startTime);
Duration duration = Duration.between(startTimeObj, now);
long seconds = duration.getSeconds();
return (int)seconds;
return (int) seconds;
}
private List<GreenwaveDetailVO.GreenwavePoint> buildReverseGreenwaveList(
......@@ -632,7 +632,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int distanceToNextCross = greenwaveCross.getDistanceToNextCross();
double designSpeed = greenwaveInfoPO.getDesignSpeed() / 3.6; // 换算成米/秒
int travalTime = (int)(distanceToNextCross / designSpeed);
int travalTime = (int) (distanceToNextCross / designSpeed);
// 计算协调相位绿灯开始的绝对时间
int absoluteSecondsBegin = calcCoordBeginSeconds(greenwaveCross);
// 计算绿波点位的绝对时间
......@@ -651,7 +651,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int distanceToNextCross = greenwaveCrossAbove.getDistanceToNextCross();
double designSpeed = greenwaveInfoPO.getDesignSpeed() / 3.6; // 换算成米/秒
int travalTime = (int)(distanceToNextCross / designSpeed);
int travalTime = (int) (distanceToNextCross / designSpeed);
// 计算协调相位绿灯开始的绝对时间
int absoluteSecondsBegin = calcCoordBeginSeconds(greenwaveCross);
// 计算绿波点位的绝对时间
......@@ -692,7 +692,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int distanceToNextCross = greenwaveCross.getDistanceToNextCross();
double designSpeed = greenwaveInfoPO.getDesignSpeed() / 3.6; // 换算成米/秒
int travalTime = (int)(distanceToNextCross / designSpeed);
int travalTime = (int) (distanceToNextCross / designSpeed);
// 计算协调相位绿灯开始的绝对时间
int absoluteSecondsBegin = calcCoordBeginSeconds(greenwaveCross);
// 计算绿波点位的绝对时间
......@@ -711,7 +711,7 @@ public class TrendServiceImpl implements TrendService {
// 计算行程时间
int distanceToNextCross = greenwaveCrossAbove.getDistanceToNextCross();
double designSpeed = greenwaveInfoPO.getDesignSpeed() / 3.6; // 换算成米/秒
int travalTime = (int)(distanceToNextCross / designSpeed);
int travalTime = (int) (distanceToNextCross / designSpeed);
// 计算协调相位绿灯开始的绝对时间
int absoluteSecondsBegin = calcCoordBeginSeconds(greenwaveCross);
// 计算绿波点位的绝对时间
......@@ -816,7 +816,7 @@ public class TrendServiceImpl implements TrendService {
Double speed = null;
if (i < size - 1) { // 不是最后一个路口
double nextCrossLen = greenwaveCrossPO.getNextCrossLen();
distanceToNextCross = (int)nextCrossLen;
distanceToNextCross = (int) nextCrossLen;
GreenwaveCrossPO nextCrossPO = filteredList.get(i + 1);
String nextCrossId = nextCrossPO.getCrossId();
......@@ -904,7 +904,7 @@ public class TrendServiceImpl implements TrendService {
greenwavePhase.setSort(i + 2);
greenwavePhase.setPhaseNo(crossPhasePO.getPhaseNo());
if (i == size - 1){
if (i == size - 1) {
greenwavePhase.setSeconds(crossPhasePO.getPhaseTime() - absoluteOffset);
} else {
greenwavePhase.setSeconds(crossPhasePO.getPhaseTime());
......@@ -1411,7 +1411,7 @@ public class TrendServiceImpl implements TrendService {
Double length = greenwaveCrossPO.getNextCrossLen();
Double speed = getSpeed(listForNoPark);
double travelTime = length / speed;
greenwaveCrossMetricsVO.setTrvalTime((int)travelTime);
greenwaveCrossMetricsVO.setTrvalTime((int) travelTime);
}
}
......@@ -1433,7 +1433,7 @@ public class TrendServiceImpl implements TrendService {
maxQueue = queueLength;
}
}
return (int)maxQueue;
return (int) maxQueue;
}
private Integer getAveRate(List<CrossTurnDataHistPO> crossDirDataHistPOList) {
......@@ -1444,7 +1444,7 @@ public class TrendServiceImpl implements TrendService {
}
int size = crossDirDataHistPOList.size();
double avg = total / size;
return (int)(avg * 100);
return (int) (avg * 100);
}
private List<GreenWaveCrossMonitorVO> buildRes(List<GreenwaveCrossPO> greenwaveCrossPOList) {
......@@ -1538,7 +1538,7 @@ public class TrendServiceImpl implements TrendService {
long batchTime = crossDirDataHistPO.getBatchTime();
long preSecond = preMinute.getTime() / 1000;
long currentSecond = currentMinute.getTime() / 1000;
if ( dirType == dir && batchTime <= currentSecond && batchTime >= preSecond) {
if (dirType == dir && batchTime <= currentSecond && batchTime >= preSecond) {
Integer status = crossDirDataHistPO.getStatus();
// 转换状态,3、4都算拥堵
if (status == 4) {
......@@ -1661,4 +1661,48 @@ public class TrendServiceImpl implements TrendService {
}
greenwaveListVO.setDuration(duration);
}
@Override
public List<HotspotCrossVO> hotspotCross() throws Exception {
List<HotspotCrossVO> hotspotCrossVOS = new ArrayList<>();
LambdaQueryWrapper<CrossDataRealtimePO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(CrossDataRealtimePO::getCrossId, CrossDataRealtimePO::getStartTime, CrossDataRealtimePO::getBatchTime)
.orderByDesc(CrossDataRealtimePO::getCongestionIndex)
.last("limit 1");
List<CrossDataRealtimePO> crossRealtimePOS = crossDataRealtimeMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(crossRealtimePOS) && crossRealtimePOS.size() == 1) {
CrossDataRealtimePO crossDataRealtimePO = crossRealtimePOS.get(0);
// 查询当前拥堵指数最大,历史表中一个小时以内数据
LambdaQueryWrapper<CrossDirDataHistPO> histQuery = new LambdaQueryWrapper<>();
histQuery.eq(CrossDirDataHistPO::getCrossId, crossDataRealtimePO.getCrossId())
.between(CrossDirDataHistPO::getBatchTime, crossDataRealtimePO.getBatchTime() - 3600, crossDataRealtimePO.getBatchTime());
List<CrossDirDataHistPO> histPOS = crossDirDataHistMapper.selectList(histQuery);
if (!CollectionUtils.isEmpty(histPOS)) {
Map<Date, List<CrossDirDataHistPO>> map = histPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getStartTime));
if (!map.isEmpty()) {
for (Map.Entry<Date, List<CrossDirDataHistPO>> entry : map.entrySet()) {
HotspotCrossVO hotspotCrossVO = new HotspotCrossVO();
List<CrossDirDataHistPO> value = entry.getValue();
if (!CollectionUtils.isEmpty(value)) {
List<HotspotCrossVO.DetailVO> detailVOS = new ArrayList<>(value.size());
for (CrossDirDataHistPO crossDirDataHistPO : value) {
HotspotCrossVO.DetailVO detailVO = new HotspotCrossVO.DetailVO();
detailVO.setDir(crossDirDataHistPO.getDirType());
detailVO.setQueueLength(crossDirDataHistPO.getQueueLength());
detailVOS.add(detailVO);
}
hotspotCrossVO.setDetailList(detailVOS);
hotspotCrossVO.setTimeStamp(entry.getKey());
hotspotCrossVOS.add(hotspotCrossVO);
}
}
}
}
}
return hotspotCrossVOS;
}
}
package net.wanji.opt.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
* @date 2024/05/06 10:58
*/
@NoArgsConstructor
@Data
@ApiModel(value = "重点路口监测实体", description = "重点路口监测实体")
public class HotspotCrossVO {
private Date timeStamp;
private List<DetailVO> detailList;
@Data
public static class DetailVO {
private Integer dir;
private Double queueLength;
}
}
......@@ -88,7 +88,7 @@
and t1.type = #{type}
</if>
<if test="status == null">
and t1.status in (0, 1, 2, 3)
and t1.status in (0, 1, 2, 3, 5)
</if>
and t2.is_signal = 1
</where>
......
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