Commit 7a00fac6 authored by duanruiming's avatar duanruiming

[add] 绿波时序图历史查询

parent 5dd0d883
...@@ -43,6 +43,18 @@ public class StrategyGreenBeltController { ...@@ -43,6 +43,18 @@ public class StrategyGreenBeltController {
return JsonViewObject.newInstance().success(greenBeltChartVO); return JsonViewObject.newInstance().success(greenBeltChartVO);
} }
@ApiOperation(value = "绿波时序图历史查询", notes = "绿波时序图历史查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/greenBeltChartHist")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenBeltInfoVO.class),
})
public JsonViewObject greenBeltChartHist(Integer greenId, String dateStr) throws Exception {
GreenBeltChartVO greenBeltChartVO = strategyGreenBeltService.selectChartHist(greenId, dateStr);
return JsonViewObject.newInstance().success(greenBeltChartVO);
}
@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)
@GetMapping(value = "/greenBeltChartControlTime") @GetMapping(value = "/greenBeltChartControlTime")
......
...@@ -13,6 +13,7 @@ import java.util.List; ...@@ -13,6 +13,7 @@ import java.util.List;
public interface StrategyGreenBeltService { public interface StrategyGreenBeltService {
GreenBeltChartVO selectChart(Integer greenId, String dateStr); GreenBeltChartVO selectChart(Integer greenId, String dateStr);
GreenBeltChartVO selectChartHist(Integer greenId, String dateStr);
List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId); List<GreenBeltStopTimesQueueLengthVO> greenBeltStopTimeQueueLength(Integer greenId);
GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId); GreenBeltAreaIndexVO greenBeltAreaIndex(Integer greenId);
List<String> greenBeltChartControlTime(Integer greenId); List<String> greenBeltChartControlTime(Integer greenId);
......
...@@ -180,6 +180,49 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService { ...@@ -180,6 +180,49 @@ public class StrategyGreenBeltServiceImpl implements StrategyGreenBeltService {
return null; return null;
} }
@Override
public GreenBeltChartVO selectChartHist(Integer greenId, String dateStr) {
try {
ObjectMapper mapper = JacksonUtils.getInstance();
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
// 查询历史时序图
if (StringUtils.isNotBlank(dateStr)) {
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.eq(StrategyGreenOptHistEntity::getControlMethod, 1);
queryWrapper.eq(StrategyGreenOptHistEntity::getControlTime, dateStr);
} else {
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.eq(StrategyGreenOptHistEntity::getControlMethod, 1);
queryWrapper.orderByDesc(StrategyGreenOptHistEntity::getControlTime);
//queryWrapper.last("LIMIT 2");
queryWrapper.last("limit 2");
}
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(entities)) {
Map<String, List<StrategyGreenOptHistEntity>> controlTimeMap = entities.stream().collect(Collectors.groupingBy(StrategyGreenOptHistEntity::getControlTime));
// 判断下发是否是正向还是反向 相同时间两条,双向绿波
GreenBeltInfoVO greenBeltInfoVO = new GreenBeltInfoVO();
List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails = new ArrayList<>();
// 相同时间,双向绿波
if (controlTimeMap.size() == 1) {
setBeltInfo(mapper, entities, greenBeltInfoVO, dirGreenDetails);
} else {
entities.remove(entities.size() - 1);
setBeltInfo(mapper, entities, greenBeltInfoVO, dirGreenDetails);
}
greenBeltInfoVO.setDirGreenDetails(dirGreenDetails);
GreenBeltChartVO greenBeltChartVO = calGreenChart(greenBeltInfoVO);
return greenBeltChartVO;
}
} catch (Exception e) {
log.error("数据转化异常", e);
throw new RuntimeException(e);
}
return null;
}
private static void setBeltInfo(ObjectMapper mapper, List<StrategyGreenOptHistEntity> entities, GreenBeltInfoVO greenBeltInfoVO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) throws JsonProcessingException { private static void setBeltInfo(ObjectMapper mapper, List<StrategyGreenOptHistEntity> entities, GreenBeltInfoVO greenBeltInfoVO, List<GreenBeltInfoVO.DirGreenDetail> dirGreenDetails) throws JsonProcessingException {
for (StrategyGreenOptHistEntity entity : entities) { for (StrategyGreenOptHistEntity entity : entities) {
greenBeltInfoVO.setGreenId(entity.getGreenId()); greenBeltInfoVO.setGreenId(entity.getGreenId());
......
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