Commit 4a415b5a authored by duanruiming's avatar duanruiming

[update] 态势监测-路口车道数据

parent 4c6115c8
......@@ -231,15 +231,27 @@ public class TrendController {
return JsonViewObject.newInstance().success(hotspotCrossVOS);
}
@ApiOperation(value = "路口转向排队长度", notes = "路口转向排队长度", response = JsonViewObject.class,
@ApiOperation(value = "路口转向数据", notes = "路口转向数据", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossQueueLength",
@PostMapping(value = "/crossTurnData",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = List.class),
})
public JsonViewObject crossQueueLength(@RequestBody String crossId) throws Exception {
List<HotspotCrossTurnVO> hotspotCrossVOS = trendService.crossQueueLength(crossId);
public JsonViewObject crossTurnData(@RequestBody String crossId) throws Exception {
List<HotspotCrossTurnVO> hotspotCrossVOS = trendService.crossTurnData(crossId);
return JsonViewObject.newInstance().success(hotspotCrossVOS);
}
@ApiOperation(value = "路口车道数据", notes = "路口车道数据", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossLaneData",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = List.class),
})
public JsonViewObject crossLaneData(@RequestBody String crossId) throws Exception {
List<HotspotCrossLaneVO> hotspotCrossVOS = trendService.crossLaneData(crossId);
return JsonViewObject.newInstance().success(hotspotCrossVOS);
}
......
......@@ -49,7 +49,9 @@ public interface TrendService {
List<HotspotCrossVO> hotspotCross(String crossId) throws Exception;
List<HotspotCrossTurnVO> crossQueueLength(String crossId) throws Exception;
List<HotspotCrossTurnVO> crossTurnData(String crossId) throws Exception;
List<HotspotCrossLaneVO> crossLaneData(String crossId) throws Exception;
List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception;
}
......@@ -1710,6 +1710,7 @@ public class TrendServiceImpl implements TrendService {
dirDetail.setDir(crossDirDataHistPO.getDirType());
dirDetail.setInOutType(crossDirDataHistPO.getInOutType());
dirDetail.setQueueLength(crossDirDataHistPO.getQueueLength());
dirDetail.setFlow(crossDirDataHistPO.getFlow());
dirDetails.add(dirDetail);
}
hotspotCrossVO.setDetailList(dirDetails);
......@@ -1730,7 +1731,7 @@ public class TrendServiceImpl implements TrendService {
}
@Override
public List<HotspotCrossTurnVO> crossQueueLength(String crossId) throws Exception {
public List<HotspotCrossTurnVO> crossTurnData(String crossId) throws Exception {
List<HotspotCrossTurnVO> results = new ArrayList<>();
try {
Date date = new Date(1705456500000L);
......@@ -1750,6 +1751,7 @@ public class TrendServiceImpl implements TrendService {
turnDetail.setTurn(crossTurnDataHistPO.getTurnType());
turnDetail.setDir(crossTurnDataHistPO.getInDir());
turnDetail.setQueueLength(crossTurnDataHistPO.getQueueLength());
turnDetail.setFlow(crossTurnDataHistPO.getFlow());
turnDetails.add(turnDetail);
}
HotspotCrossTurnVO hotspotCrossTurnVO = new HotspotCrossTurnVO();
......@@ -1766,6 +1768,48 @@ public class TrendServiceImpl implements TrendService {
return results;
}
@Override
public List<HotspotCrossLaneVO> crossLaneData(String crossId) throws Exception {
List<HotspotCrossLaneVO> results = new ArrayList<>();
try {
Date date = new Date(1705456500000L);
long dateTime = date.getTime() / 1000;
List<CrossLaneDataHistPOExt> crossLaneDataHistPOS =
crossLaneDataHistMapper.selectByCrossIdAndTimeSpan(crossId, (int)(dateTime - 3600), (int)dateTime);
if (!CollectionUtils.isEmpty(crossLaneDataHistPOS)) {
Map<Date, List<CrossLaneDataHistPOExt>> collect = crossLaneDataHistPOS.stream().collect(Collectors.groupingBy(CrossLaneDataHistPOExt::getStartTime));
for (Map.Entry<Date, List<CrossLaneDataHistPOExt>> entry : collect.entrySet()) {
Date timeStamp = entry.getKey();
List<CrossLaneDataHistPOExt> value = entry.getValue();
Map<Integer, List<CrossLaneDataHistPOExt>> dirLaneMap = value.stream().collect(Collectors.groupingBy(CrossLaneDataHistPOExt::getDir));
HotspotCrossLaneVO hotspotCrossLaneVO = new HotspotCrossLaneVO();
for (Map.Entry<Integer, List<CrossLaneDataHistPOExt>> dirEntry : dirLaneMap.entrySet()) {
Integer dir = dirEntry.getKey();
List<CrossLaneDataHistPOExt> dirList = dirEntry.getValue();
List<HotspotCrossLaneVO.LaneDetail> laneDetails = new ArrayList<>();
for (CrossLaneDataHistPOExt crossLaneDataHistPO : dirList) {
HotspotCrossLaneVO.LaneDetail laneDetail = new HotspotCrossLaneVO.LaneDetail();
String poId = crossLaneDataHistPO.getId();
laneDetail.setLaneId(poId.substring(poId.length() - 2));
laneDetail.setFlow(crossLaneDataHistPO.getFlow());
laneDetail.setQueueLength(crossLaneDataHistPO.getQueueLength());
laneDetails.add(laneDetail);
}
hotspotCrossLaneVO.setCrossId(crossId);
hotspotCrossLaneVO.setDir(dir);
hotspotCrossLaneVO.setTimeStamp(timeStamp);
hotspotCrossLaneVO.setTurnList(laneDetails);
results.add(hotspotCrossLaneVO);
}
}
}
} catch (Exception e) {
log.error("路口车道数据异常:", e);
throw new Exception(e);
}
return results;
}
@Override
public List<RunningEvaluateMetricsDetailVO> top5Flow() throws Exception {
List<RunningEvaluateMetricsDetailVO> hotspotCrossVOS = new ArrayList<>();
......
package net.wanji.opt.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author duanruiming
* @date 2024/05/07 16:31
*/
@NoArgsConstructor
@Data
public class HotspotCrossLaneVO {
private String crossId;
private Integer dir;
private Date timeStamp;
private List<HotspotCrossLaneVO.LaneDetail> turnList;
@Data
public static class LaneDetail {
private String laneId;
private Double queueLength;
private Integer flow;
}
}
......@@ -22,5 +22,6 @@ public class HotspotCrossTurnVO {
private String turn;
private Integer dir;
private Double queueLength;
private Integer flow;
}
}
......@@ -23,5 +23,6 @@ public class HotspotCrossVO {
private Integer dir;
private Integer inOutType;
private Double queueLength;
private Integer flow;
}
}
......@@ -97,8 +97,8 @@
</select>
<select id="selectByCrossIdAndTimeSpan" resultType="net.wanji.databus.po.CrossLaneDataHistPOExt">
SELECT t2.dir, t2.sort, t1.flow, t1.speed, t1.queue_length, t1.delay_time, t1.stop_times,
t1.vehhead_time, t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean
SELECT t1.id, t2.dir, t2.sort, t1.flow, t1.speed, t1.queue_length, t1.delay_time, t1.stop_times,
t1.vehhead_time, t1.batch_time, t1.time_occupancy, t1.vehicle_nums_ratio_mean, t1.start_time
FROM t_lane_data_hist t1 JOIN t_base_lane_info t2 ON t1.id = t2.id
where t1.cross_id = #{crossId}
and batch_time <![CDATA[ >= ]]> #{startTimeStamp}
......
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