Commit f4376f1c authored by duanruiming's avatar duanruiming

[update] 微观大数据平台-溢出事件优化

parent 3284549b
...@@ -303,6 +303,18 @@ public class TrendController { ...@@ -303,6 +303,18 @@ public class TrendController {
return JsonViewObject.newInstance().success(result); return JsonViewObject.newInstance().success(result);
} }
@ApiOperation(value = "溢出事件", notes = "溢出事件", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/overFlowEvent",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = TableQueryVO.RealTimeDataElement.class),
})
public JsonViewObject overFlowEvent(@RequestBody LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception {
List<OverflowEvent> result = trendService.overFlowEvent(laneSnapshotIndexVO);
return JsonViewObject.newInstance().success(result);
}
@ApiOperation(value = "车道周期转向数据", notes = "车道周期转向数据", response = JsonViewObject.class, @ApiOperation(value = "车道周期转向数据", notes = "车道周期转向数据", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/lanePeriodTurnData", @PostMapping(value = "/lanePeriodTurnData",
......
...@@ -100,5 +100,5 @@ public class CrossLaneSnapshotDataDTO { ...@@ -100,5 +100,5 @@ public class CrossLaneSnapshotDataDTO {
/** /**
* 溢出区车辆数 * 溢出区车辆数
*/ */
private String overflowNums; private int overflowNums;
} }
...@@ -63,6 +63,7 @@ public interface TrendService { ...@@ -63,6 +63,7 @@ public interface TrendService {
List<TableQueryVO.CycleDataElement> laneTrafficIndex(CommonCrossIdDateTimeVO crossIdDateTimeVO) throws Exception; List<TableQueryVO.CycleDataElement> laneTrafficIndex(CommonCrossIdDateTimeVO crossIdDateTimeVO) throws Exception;
List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception; List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception;
List<OverflowEvent> overFlowEvent(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception;
List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception; List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception;
......
...@@ -38,7 +38,6 @@ import net.wanji.opt.dto.CrossEventDTO; ...@@ -38,7 +38,6 @@ import net.wanji.opt.dto.CrossEventDTO;
import net.wanji.opt.dto.CrossLaneSnapshotDataDTO; import net.wanji.opt.dto.CrossLaneSnapshotDataDTO;
import net.wanji.opt.dto.LineCongestion; import net.wanji.opt.dto.LineCongestion;
import net.wanji.opt.dto.LineSchemeDTO; import net.wanji.opt.dto.LineSchemeDTO;
import net.wanji.opt.dto.PhaseEmptyResult;
import net.wanji.opt.dto.trend.AbnormalCrossListDTO; import net.wanji.opt.dto.trend.AbnormalCrossListDTO;
import net.wanji.opt.dto.trend.GreenwaveListDTO; import net.wanji.opt.dto.trend.GreenwaveListDTO;
import net.wanji.opt.po.base.CrossSchemeOptLogPO; import net.wanji.opt.po.base.CrossSchemeOptLogPO;
...@@ -61,7 +60,6 @@ import org.springframework.util.CollectionUtils; ...@@ -61,7 +60,6 @@ import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*; import java.time.*;
...@@ -1973,6 +1971,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -1973,6 +1971,7 @@ public class TrendServiceImpl implements TrendService {
} }
} }
@Override @Override
public List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception { public List<TableQueryVO.RealTimeDataElement> laneSnapshotIndex(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception {
try { try {
...@@ -1998,6 +1997,56 @@ public class TrendServiceImpl implements TrendService { ...@@ -1998,6 +1997,56 @@ public class TrendServiceImpl implements TrendService {
} }
} }
@Override
public List<OverflowEvent> overFlowEvent(LaneSnapshotIndexVO laneSnapshotIndexVO) throws Exception {
try {
int start = (int) (laneSnapshotIndexVO.getStart().getTime() / 1000);
int end = (int) (laneSnapshotIndexVO.getEnd().getTime() / 1000);
int pageNum = laneSnapshotIndexVO.getPageNum();
boolean overFlow = laneSnapshotIndexVO.isOverFlow();
List<OverflowEvent> resultList = new ArrayList<>();
// 查询秒级数据
List<CrossLaneSnapshotDataDTO> dtoList =
laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(null, start, end, pageNum, null, overFlow);
if (!CollectionUtils.isEmpty(dtoList)) {
Map<String, List<CrossLaneSnapshotDataDTO>> timeMap = dtoList.stream().collect(Collectors.groupingBy(CrossLaneSnapshotDataDTO::getTimeStamp));
for (Map.Entry<String, List<CrossLaneSnapshotDataDTO>> timeEntry : timeMap.entrySet()) {
String time = timeEntry.getKey();
List<CrossLaneSnapshotDataDTO> timeList = timeEntry.getValue();
if (!CollectionUtil.isNotEmpty(timeList)) {
Map<Integer, List<CrossLaneSnapshotDataDTO>> dirMap = timeList.stream().collect(Collectors.groupingBy(CrossLaneSnapshotDataDTO::getDir));
for (Map.Entry<Integer, List<CrossLaneSnapshotDataDTO>> dirEntry : dirMap.entrySet()) {
Integer dir = dirEntry.getKey();
List<CrossLaneSnapshotDataDTO> dirList = dirEntry.getValue();
OverflowEvent resultPojo = new OverflowEvent();
int overflowNums = 0;
double vehicleLengthRatio = 0.0;
double meanV = 0.0;
for (CrossLaneSnapshotDataDTO dto : dirList) {
overflowNums += dto.getOverflowNums();
vehicleLengthRatio += dto.getVehicleLengthRatio();
meanV += dto.getMeanV();
}
resultPojo.setStartTime(new Date(Long.parseLong(time)));
resultPojo.setEndTime(new Date(Long.parseLong(time)));
resultPojo.setDirName(BaseEnum.SignalDirectionEnum.getNameByCode(dir));
resultPojo.setOverflowId(String.valueOf(dir));
resultPojo.setOverflowNums(overflowNums);
resultPojo.setSpeed(Math.round(meanV / dirList.size() * 100) / 100);
resultPojo.setVehicleLengthRatio(Math.round(vehicleLengthRatio / dirList.size() * 100) / 100);
resultList.add(resultPojo);
}
}
}
}
return resultList;
} catch (Exception e) {
log.error("车道快照数据查询异常:", e);
throw new Exception(e);
}
}
@Override @Override
public List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception { public List<AnalysisRidTurnIndicators> lanePeriodTurnData(LanePeriodTurnVO lanePeriodTurnVO) throws Exception {
try { try {
......
package net.wanji.opt.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author duanruiming
* @date 2024/06/28 17:03
*/
@Data
@NoArgsConstructor
@ApiModel(value = "OverflowEvent", description = "溢出事件实体")
public class OverflowEvent {
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("开始时间")
private Date startTime;
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ExcelProperty("结束时间")
private Date endTime;
@ApiModelProperty(value = "持续时长")
@ExcelProperty("持续时长")
private Integer duration;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@ExcelIgnore
private Integer dir;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
@ExcelProperty("位置")
private String dirName;
@ApiModelProperty(value = "溢出区编号")
@ExcelProperty("溢出区编号")
private String overflowId;
@ApiModelProperty(value = "溢出区车辆数")
@ExcelProperty("溢出区车辆数")
private int overflowNums;
@ApiModelProperty(value = "空间长度占比")
@ExcelProperty("空间占有率%")
private double vehicleLengthRatio;
@ApiModelProperty(value = "平均速度")
@ExcelProperty("平均速度")
private double speed;
}
...@@ -102,7 +102,7 @@ public class TableQueryVO { ...@@ -102,7 +102,7 @@ public class TableQueryVO {
@ApiModelProperty(value = "溢出区车辆数") @ApiModelProperty(value = "溢出区车辆数")
@ExcelProperty("溢出区车辆数") @ExcelProperty("溢出区车辆数")
private String overflowNums; private int overflowNums;
} }
......
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