Commit c5aa8951 authored by duwei's avatar duwei

交通指标接口mock数据

parent 8d4624d6
package net.wanji.opt.controller; package net.wanji.opt.controller;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
...@@ -16,6 +17,7 @@ import net.wanji.opt.po.trend.AnalysisRidTurnIndicators; ...@@ -16,6 +17,7 @@ import net.wanji.opt.po.trend.AnalysisRidTurnIndicators;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
import net.wanji.opt.service.impl.TrendServiceImpl; import net.wanji.opt.service.impl.TrendServiceImpl;
import net.wanji.opt.vo.*; import net.wanji.opt.vo.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -34,6 +36,8 @@ import java.util.List; ...@@ -34,6 +36,8 @@ import java.util.List;
@RequestMapping("/trend") @RequestMapping("/trend")
@RestController @RestController
public class TrendController { public class TrendController {
@Value("${mock.flag:false}")
private boolean isMock = false;
private final TrendServiceImpl trendService; private final TrendServiceImpl trendService;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
...@@ -292,6 +296,10 @@ public class TrendController { ...@@ -292,6 +296,10 @@ public class TrendController {
@ApiResponse(code = 200, message = "OK", response = TableQueryVO.CycleDataElement.class), @ApiResponse(code = 200, message = "OK", response = TableQueryVO.CycleDataElement.class),
}) })
public JsonViewObject laneTrafficIndex(@RequestBody LanePeriodVO crossIdDateTimeVO) throws Exception { public JsonViewObject laneTrafficIndex(@RequestBody LanePeriodVO crossIdDateTimeVO) throws Exception {
if(isMock == true){
crossIdDateTimeVO.setStart(DateUtil.parse("2025-04-09 00:00:00", "yyyy-MM-dd HH:mm:ss"));
crossIdDateTimeVO.setEnd(DateUtil.parse("2025-04-12 00:00:00", "yyyy-MM-dd HH:mm:ss"));
}
List<TableQueryVO.CycleDataElement> result = trendService.laneTrafficIndex(crossIdDateTimeVO); List<TableQueryVO.CycleDataElement> result = trendService.laneTrafficIndex(crossIdDateTimeVO);
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
...@@ -310,6 +318,10 @@ public class TrendController { ...@@ -310,6 +318,10 @@ public class TrendController {
@ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class), @ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class),
}) })
public JsonViewObject lanePeriodTurnData(@RequestBody LanePeriodTurnVO lanePeriodTurnVO) throws Exception { public JsonViewObject lanePeriodTurnData(@RequestBody LanePeriodTurnVO lanePeriodTurnVO) throws Exception {
if(isMock == true){
lanePeriodTurnVO.setStart(DateUtil.parse("2025-04-09 00:00:00", "yyyy-MM-dd HH:mm:ss"));
lanePeriodTurnVO.setEnd(DateUtil.parse("2025-04-12 00:00:00", "yyyy-MM-dd HH:mm:ss"));
}
String turns = lanePeriodTurnVO.getTurns(); String turns = lanePeriodTurnVO.getTurns();
if (turns != null){ if (turns != null){
StringBuilder inDir = new StringBuilder(); StringBuilder inDir = new StringBuilder();
...@@ -358,6 +370,10 @@ public class TrendController { ...@@ -358,6 +370,10 @@ public class TrendController {
@ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class), @ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class),
}) })
public JsonViewObject periodDirectionData(@RequestBody PeriodDirectionVO periodDirectionVO) throws Exception { public JsonViewObject periodDirectionData(@RequestBody PeriodDirectionVO periodDirectionVO) throws Exception {
if(isMock == true){
periodDirectionVO.setStart(DateUtil.parse("2025-04-10 00:00:00", "yyyy-MM-dd HH:mm:ss"));
periodDirectionVO.setEnd(DateUtil.parse("2025-04-13 00:00:00", "yyyy-MM-dd HH:mm:ss"));
}
List<CrossingDirectionQueryVO.CycleDataElement> result = trendService.periodDirectionData(periodDirectionVO); List<CrossingDirectionQueryVO.CycleDataElement> result = trendService.periodDirectionData(periodDirectionVO);
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
...@@ -383,6 +399,10 @@ public class TrendController { ...@@ -383,6 +399,10 @@ public class TrendController {
@ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class), @ApiResponse(code = 200, message = "OK", response = AnalysisRidTurnIndicators.class),
}) })
public JsonViewObject periodDirectionData(@RequestBody PeriodCrossingVO periodCrossingVO) throws Exception { public JsonViewObject periodDirectionData(@RequestBody PeriodCrossingVO periodCrossingVO) throws Exception {
if(isMock == true){
periodCrossingVO.setStart(DateUtil.parse("2025-04-09 00:00:00", "yyyy-MM-dd HH:mm:ss"));
periodCrossingVO.setEnd(DateUtil.parse("2025-04-12 00:00:00", "yyyy-MM-dd HH:mm:ss"));
}
List<CrossingQueryVO.CycleDataElement> result = trendService.periodCrossingData(periodCrossingVO); List<CrossingQueryVO.CycleDataElement> result = trendService.periodCrossingData(periodCrossingVO);
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
......
...@@ -161,34 +161,34 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService { ...@@ -161,34 +161,34 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
List<CrossDataHistPO> congestionEventList = buildCongestionEvents(crossDataHistPOList); // 获取拥堵事件集合 List<CrossDataHistPO> congestionEventList = buildCongestionEvents(crossDataHistPOList); // 获取拥堵事件集合
vo.setCongestionTimes(congestionEventList.size()); vo.setCongestionTimes(congestionEventList.size());//拥堵次数
int congestionSum = congestionEventList.stream() int congestionSum = congestionEventList.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(CrossDataHistPO::getDuration) .map(CrossDataHistPO::getDuration)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.mapToInt(Integer::intValue) .mapToInt(Integer::intValue)
.sum(); .sum();
vo.setCongestionSum(congestionSum); vo.setCongestionSum(congestionSum);//拥堵时长
List<CrossDataHistPO> unbalanceEventList = buildUnbalanceEvents(crossDataHistPOList); // 获取失衡事件集合 List<CrossDataHistPO> unbalanceEventList = buildUnbalanceEvents(crossDataHistPOList); // 获取失衡事件集合
vo.setUnbalanceTimes(unbalanceEventList.size()); vo.setUnbalanceTimes(unbalanceEventList.size());//失衡次数
int unbalanceSum = unbalanceEventList.stream() int unbalanceSum = unbalanceEventList.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(CrossDataHistPO::getDuration) .map(CrossDataHistPO::getDuration)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.mapToInt(Integer::intValue) .mapToInt(Integer::intValue)
.sum(); .sum();
vo.setUnbalanceSum(unbalanceSum); vo.setUnbalanceSum(unbalanceSum);//失衡时长
List<CrossDataHistPO> spilloverEventList = buildSpilloverEvents(crossDataHistPOList); // 获取溢出事件集合 List<CrossDataHistPO> spilloverEventList = buildSpilloverEvents(crossDataHistPOList); // 获取溢出事件集合
vo.setSpilloverTimes(spilloverEventList.size()); vo.setSpilloverTimes(spilloverEventList.size());//溢出次数
int spilloverSum = spilloverEventList.stream() int spilloverSum = spilloverEventList.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(CrossDataHistPO::getDuration) .map(CrossDataHistPO::getDuration)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.mapToInt(Integer::intValue) .mapToInt(Integer::intValue)
.sum(); .sum();
vo.setSpilloverSum(spilloverSum); vo.setSpilloverSum(spilloverSum);//溢出时长
// 相位空放指标 // 相位空放指标
Date startDate = bo.getStartDate(); Date startDate = bo.getStartDate();
......
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