From a8aa358d279681d380a2e17e96c5afad6ea628bb Mon Sep 17 00:00:00 2001 From: fangzhe <675599480@qq.com> Date: Wed, 11 Dec 2024 09:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=B1=E9=99=A9=E8=A1=8C=E4=B8=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../carapi/radar/manage/RadarManage.java | 4 ++- .../road/controller/RoadMonitorController.java | 3 +- .../carapi/road/manage/RoadMonitorManage.java | 38 ++++++++++++---------- .../carapi/road/model/req/RoadMonitorReq.java | 3 +- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java index d2bd853..b55fa01 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java @@ -186,7 +186,9 @@ public class RadarManage { .eq(TrafficFlow::getRegion, region1) .orderByDesc(TrafficFlow::getCreateOn) .last("limit 1")); - vo.setRealTimeTrafficFlow(trafficFlow.getTrafficFlow()); + if (Objects.nonNull(trafficFlow)){ + vo.setRealTimeTrafficFlow(trafficFlow.getTrafficFlow()); + } return vo; } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java index 13e797c..38efdb5 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java @@ -1,5 +1,6 @@ package com.ningdatech.carapi.road.controller; +import com.ningdatech.basic.model.PageVo; import com.ningdatech.carapi.road.manage.RoadMonitorManage; import com.ningdatech.carapi.road.model.req.RoadMonitorHandleReq; import com.ningdatech.carapi.road.model.req.RoadMonitorReq; @@ -44,7 +45,7 @@ public class RoadMonitorController { @ApiOperation(value = "危险行为数据", notes = "危险行为数据") @GetMapping("/get-road-danger-behavior-data") - public List getRoadDangerBehaviorData(RoadMonitorReq req) { + public PageVo getRoadDangerBehaviorData(RoadMonitorReq req) { return roadMonitorManage.getRoadDangerBehaviorData(req); } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java index 2994624..1fe21da 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java @@ -10,6 +10,8 @@ import java.util.stream.Collectors; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.model.PageVo; import com.ningdatech.carapi.radar.helper.RadarDataHelper; import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; import com.ningdatech.carapi.road.model.entity.TrafficFlow; @@ -180,11 +182,11 @@ public class RoadMonitorManage { } private void setDefaultScores(ComprehensiveSituationVO vo) { - vo.setRoadScore(100); - vo.setCarScore(100); - vo.setDriverScore(100); - vo.setEnvironmentScore(100); - vo.setRoadSafetyIndex(100); + vo.setRoadScore(85); + vo.setCarScore(85); + vo.setDriverScore(85); + vo.setEnvironmentScore(85); + vo.setRoadSafetyIndex(85); } private void getDataVo(String dataKey, ComprehensiveSituationVO vo, Jedis jedis) { @@ -390,21 +392,22 @@ public class RoadMonitorManage { } } - public List getRoadDangerBehaviorData(RoadMonitorReq req) { + public PageVo getRoadDangerBehaviorData(RoadMonitorReq req) { List regionList = req.getRegionList(); // 从列表中查询数据 - List list = roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class) - .in(RoadBehaviorAnalysis::getRegion, regionList) - .like(StringUtils.isNoneBlank(req.getBehavior()),RoadBehaviorAnalysis::getBehavior, req.getBehavior()) - .eq(Objects.nonNull(req.getType()),RoadBehaviorAnalysis::getType, req.getType()) - .ge(Objects.nonNull(req.getStartTime()), RoadBehaviorAnalysis::getBehaviorTime, req.getStartTime()) - .le(Objects.nonNull(req.getEndTime()), RoadBehaviorAnalysis::getBehaviorTime, req.getEndTime()) - .eq(Objects.nonNull(req.getIsWarn()),RoadBehaviorAnalysis::getIsWarn, req.getIsWarn()) - .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime)); - if (CollUtil.isEmpty(list)){ - return Collections.emptyList(); + Page pageResult = roadBehaviorAnalysisService.page(new Page<>(req.getPageNumber(), req.getPageSize()), + Wrappers.lambdaQuery(RoadBehaviorAnalysis.class) + .in(RoadBehaviorAnalysis::getRegion, regionList) + .like(StringUtils.isNoneBlank(req.getBehavior()), RoadBehaviorAnalysis::getBehavior, req.getBehavior()) + .eq(Objects.nonNull(req.getType()), RoadBehaviorAnalysis::getType, req.getType()) + .ge(Objects.nonNull(req.getStartTime()), RoadBehaviorAnalysis::getBehaviorTime, req.getStartTime()) + .le(Objects.nonNull(req.getEndTime()), RoadBehaviorAnalysis::getBehaviorTime, req.getEndTime()) + .eq(Objects.nonNull(req.getIsWarn()), RoadBehaviorAnalysis::getIsWarn, req.getIsWarn()) + .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime)); + if (CollUtil.isEmpty(pageResult.getRecords())){ + return PageVo.empty(); } - return list.stream().map(roadBehaviorAnalysis -> { + List collect = pageResult.getRecords().stream().map(roadBehaviorAnalysis -> { RoadDangerBehaviorVO vo = new RoadDangerBehaviorVO(); vo.setId(roadBehaviorAnalysis.getId()); vo.setRecord(roadBehaviorAnalysis.getBehavior()); @@ -418,6 +421,7 @@ public class RoadMonitorManage { vo.setIsHandled(roadBehaviorAnalysis.getIsHandled()); return vo; }).collect(Collectors.toList()); + return PageVo.of(collect,pageResult.getTotal()); } public void videoDownload(VideoDownloadReq req, HttpServletResponse response) { diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java index 4fbdb8b..aeede23 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java @@ -3,6 +3,7 @@ package com.ningdatech.carapi.road.model.req; import java.time.LocalDateTime; import java.util.List; +import com.ningdatech.basic.model.PagePo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -17,7 +18,7 @@ import javax.validation.constraints.NotEmpty; * @since 2024/10/23 17:53 */ @Data -public class RoadMonitorReq { +public class RoadMonitorReq extends PagePo { @ApiModelProperty("区域 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向、5 何里隧道兰溪方向、6 何里隧道义乌方向") private String region;