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 c96c831..d2bd853 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 @@ -17,6 +17,8 @@ import java.util.stream.Collectors; import cn.hutool.socket.SocketUtil; import com.ningdatech.carapi.radar.helper.RadarDataHelper; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; +import com.ningdatech.carapi.road.service.impl.ITrafficFlowServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -49,6 +51,7 @@ public class RadarManage { private final IRadarDataService radarDataService; private final RadarDataHelper radarDataHelper; + private final ITrafficFlowServiceImpl trafficFlowService; public String getRadarDataAsClient() { // 盒子ip地址:192.168.6.42 --> 192.168.6.40(黄山隧道义乌来向雷达)、192.168.6.43(黄山隧道义乌去向雷达) @@ -171,6 +174,19 @@ public class RadarManage { if (Objects.nonNull(radarData)) { BeanUtils.copyProperties(radarData, vo); } + String region1 = null; + if (req.getRegion().equals("1")||req.getRegion().equals("2")){ + region1="1"; + }else if (req.getRegion().equals("3")||req.getRegion().equals("4")){ + region1="2"; + }else if (req.getRegion().equals("5")||req.getRegion().equals("6")){ + region1="3"; + } + TrafficFlow trafficFlow = trafficFlowService.getOne(Wrappers.lambdaQuery(TrafficFlow.class) + .eq(TrafficFlow::getRegion, region1) + .orderByDesc(TrafficFlow::getCreateOn) + .last("limit 1")); + vo.setRealTimeTrafficFlow(trafficFlow.getTrafficFlow()); return vo; } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java index 0f0479f..7fc55b9 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java @@ -15,6 +15,8 @@ import com.ningdatech.carapi.radar.model.entity.RadarOriginalData; import com.ningdatech.carapi.radar.model.vo.RadarDataVO; import com.ningdatech.carapi.radar.service.IRadarDataService; import com.ningdatech.carapi.radar.service.IRadarOriginalDataService; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; +import com.ningdatech.carapi.road.service.impl.ITrafficFlowServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; @@ -43,6 +45,7 @@ public class RadarRealTimeDataUpdateTask { private final IRadarOriginalDataService radarOriginalDataService; private final RadarDataHelper radarDataHelper; private final IRadarDataService radarDataService; + private final ITrafficFlowServiceImpl trafficFlowService; // 定时更新雷达实时数据 每1分钟一次 @Scheduled(cron = "0 */1 * * * ?") @@ -165,9 +168,61 @@ public class RadarRealTimeDataUpdateTask { radarDataService.saveBatch(objects); log.info("=========== 雷达实时数据更新 ======== 插入数据条数:{}",objects.size()); } + List hsyw = radarDataService.list(Wrappers.lambdaQuery(RadarData.class) + .eq(RadarData::getDataType, "2") + .eq(RadarData::getRadarIp,"192.168.6.40")); + Integer sum1 = hsyw.stream().mapToInt(p -> { + return Integer.parseInt(p.getRealTimeTrafficFlow()); + }).sum(); + saveTrafficFlow(1,sum1); + + List hsdy = radarDataService.list(Wrappers.lambdaQuery(RadarData.class) + .eq(RadarData::getDataType, "2") + .eq(RadarData::getRadarIp,"192.168.6.47")); + Integer sum2 = hsdy.stream().mapToInt(p -> { + return Integer.parseInt(p.getRealTimeTrafficFlow()); + }).sum(); + saveTrafficFlow(2,sum2); + + List hlyw = radarDataService.list(Wrappers.lambdaQuery(RadarData.class) + .eq(RadarData::getDataType, "2") + .eq(RadarData::getRadarIp,"192.168.10.60")); + Integer sum3 = hlyw.stream().mapToInt(p -> { + return Integer.parseInt(p.getRealTimeTrafficFlow()); + }).sum(); + saveTrafficFlow(3,sum3); + stopWatch.stop(); log.info("=========== 雷达实时数据更新 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); } + private void saveTrafficFlow(Integer region,Integer sum){ + TrafficFlow trafficFlow = trafficFlowService.getOne(Wrappers.lambdaQuery(TrafficFlow.class) + .eq(TrafficFlow::getRegion, region) + .orderByDesc(TrafficFlow::getCreateOn) + .last("limit 1")); + LocalDateTime createOn = trafficFlow.getCreateOn(); + + if (Objects.nonNull(trafficFlow.getCreateOn())){ + + if (LocalDateTime.now().getHour()==trafficFlow.getCreateOn().getHour()) { + trafficFlow.setTrafficFlow(String.valueOf(Integer.valueOf(trafficFlow.getTrafficFlow()) + Integer.valueOf(sum))); + trafficFlowService.updateById(trafficFlow); + }else { + TrafficFlow newTrafficFlow = new TrafficFlow(); + newTrafficFlow.setTrafficFlow(sum.toString()); + newTrafficFlow.setCreateOn(LocalDateTime.now()); + newTrafficFlow.setRegion(region); + trafficFlowService.save(newTrafficFlow); + } + } + if (Objects.isNull(trafficFlow)){ + TrafficFlow newTrafficFlow = new TrafficFlow(); + newTrafficFlow.setTrafficFlow(sum.toString()); + newTrafficFlow.setCreateOn(LocalDateTime.now()); + newTrafficFlow.setRegion(region); + trafficFlowService.save(newTrafficFlow); + } + } } 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 a95c6f0..13e797c 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 @@ -4,8 +4,7 @@ import com.ningdatech.carapi.road.manage.RoadMonitorManage; import com.ningdatech.carapi.road.model.req.RoadMonitorHandleReq; import com.ningdatech.carapi.road.model.req.RoadMonitorReq; import com.ningdatech.carapi.road.model.req.VideoDownloadReq; -import com.ningdatech.carapi.road.model.vo.ComprehensiveSituationVO; -import com.ningdatech.carapi.radar.model.vo.RadarTrafficFlowDataVO; +import com.ningdatech.carapi.road.model.vo.*; import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO; import com.ningdatech.carapi.road.model.vo.VehicleGpsDataVO; import com.ningdatech.log.annotation.WebLog; @@ -81,4 +80,17 @@ public class RoadMonitorController { public void pictureDownload(VideoDownloadReq req, HttpServletResponse response){ roadMonitorManage.pictureDownload(req,response); } + + @ApiOperation(value = "实施综合态势数据", notes = "实时综合态势数据") + @GetMapping("/get-real-time-comprehensive-situation-data") + public List getRealTimeComSitData(RoadMonitorReq req){ + return roadMonitorManage.getRealTimeComSitData(req); + } + + @ApiOperation(value = "实时车流量数据", notes = "实时车流量数据") + @GetMapping("/get-real-time-traffic-flow-data") + public List getRealTimeTrafficFlowData(RoadMonitorReq req){ + return roadMonitorManage.getRealTimeTrafficFlowData(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 8119386..2994624 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 @@ -11,7 +11,13 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import com.ningdatech.carapi.radar.helper.RadarDataHelper; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; +import com.ningdatech.carapi.road.model.vo.*; +import com.ningdatech.carapi.road.service.IComprehensiveSituationService; +import com.ningdatech.carapi.road.service.impl.ITrafficFlowServiceImpl; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -30,9 +36,6 @@ import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; import com.ningdatech.carapi.road.model.req.RoadMonitorHandleReq; import com.ningdatech.carapi.road.model.req.RoadMonitorReq; import com.ningdatech.carapi.road.model.req.VideoDownloadReq; -import com.ningdatech.carapi.road.model.vo.ComprehensiveSituationVO; -import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO; -import com.ningdatech.carapi.road.model.vo.VehicleGpsDataVO; import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService; import com.ningdatech.carapi.scheduler.contants.TaskConstant; @@ -62,6 +65,8 @@ public class RoadMonitorManage { private final IRoadBehaviorAnalysisService roadBehaviorAnalysisService; private final IDataAccessGpsService dataAccessGpsService; private final RadarDataHelper radarDataHelper; + private final IComprehensiveSituationService comprehensiveSituationService; + private final ITrafficFlowServiceImpl trafficFlowService; public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) { Jedis jedis = new Jedis(redisHost,redisPort); @@ -579,4 +584,34 @@ public class RoadMonitorManage { log.error("文件下载失败! {}",e.getMessage()); } } + + public List getRealTimeComSitData(RoadMonitorReq req) { + List roadScore = comprehensiveSituationService.list(Wrappers.lambdaQuery(ComprehensiveSituation.class) + .eq(ComprehensiveSituation::getTunnel,req.getTunnel()) + .orderByDesc(ComprehensiveSituation::getCreateOn) + .last("limit 60")); + return roadScore.stream().map(p -> { + RoadScoreVO roadScoreVO = new RoadScoreVO(); + BeanUtils.copyProperties(p, roadScoreVO); + return roadScoreVO; + }).collect(Collectors.toList()) + .stream() + .sorted(Comparator.comparing(RoadScoreVO::getCreateOn)) + .collect(Collectors.toList()); + } + + public List getRealTimeTrafficFlowData(RoadMonitorReq req) { + List trafficFlows = trafficFlowService.list(Wrappers.lambdaQuery(TrafficFlow.class) + .in(TrafficFlow::getRegion, req.getRegionList()) + .orderByDesc(TrafficFlow::getCreateOn) + .last("limit 12")); + return trafficFlows.stream().map(p->{ + TrafficFlowVO trafficFlowVO = new TrafficFlowVO(); + BeanUtils.copyProperties(p,trafficFlowVO); + return trafficFlowVO; + }).collect(Collectors.toList()) + .stream() + .sorted(Comparator.comparing(TrafficFlowVO::getCreateOn)) + .collect(Collectors.toList()); + } } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.java new file mode 100644 index 0000000..83fb1bb --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.java @@ -0,0 +1,13 @@ +package com.ningdatech.carapi.road.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +public interface ComprehensiveSituationMapper extends BaseMapper { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.xml b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.xml new file mode 100644 index 0000000..472552c --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.java new file mode 100644 index 0000000..3a05892 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.java @@ -0,0 +1,13 @@ +package com.ningdatech.carapi.road.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +public interface TrafficFlowMapper extends BaseMapper { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.xml b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.xml new file mode 100644 index 0000000..471a0d5 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/ComprehensiveSituation.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/ComprehensiveSituation.java new file mode 100644 index 0000000..bd1da10 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/ComprehensiveSituation.java @@ -0,0 +1,46 @@ +package com.ningdatech.carapi.road.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@TableName("nd_comprehensive_situation") +@ApiModel(value = "ComprehensiveSituation对象", description = "道路综合实时数据表") +@Data +public class ComprehensiveSituation { + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("隧道 1 黄山隧道、2 何里隧道") + private Integer tunnel; + + @ApiModelProperty("道路安全指数") + private Integer roadSafetyIndex; + + @ApiModelProperty("道路评分") + private Integer roadScore; + + @ApiModelProperty("车辆评分") + private Integer carScore; + + @ApiModelProperty("驾驶员评分") + private Integer driverScore; + + @ApiModelProperty("环境评分") + private Integer environmentScore; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/TrafficFlow.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/TrafficFlow.java new file mode 100644 index 0000000..7668a23 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/TrafficFlow.java @@ -0,0 +1,34 @@ +package com.ningdatech.carapi.road.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@TableName("nd_traffic_flow") +@ApiModel(value = "TrafficFlow对象", description = "车流量统计表") +@Data +public class TrafficFlow { + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("区域 (1-黄山隧道义务方向 2-黄山隧道东阳方向 3-何里隧道)") + private Integer region; + + @ApiModelProperty("车流量") + private String trafficFlow; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadScoreVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadScoreVO.java new file mode 100644 index 0000000..63fa993 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadScoreVO.java @@ -0,0 +1,43 @@ +package com.ningdatech.carapi.road.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@Data +@ApiModel(description = "综合态势评分-VO") +@NoArgsConstructor +@AllArgsConstructor +public class RoadScoreVO { + + + @ApiModelProperty("隧道 1 黄山隧道、2 何里隧道") + private Integer tunnel; + + @ApiModelProperty("道路安全指数") + private Integer roadSafetyIndex; + + @ApiModelProperty("道路评分") + private Integer roadScore; + + @ApiModelProperty("车辆评分") + private Integer carScore; + + @ApiModelProperty("驾驶员评分") + private Integer driverScore; + + @ApiModelProperty("环境评分") + private Integer environmentScore; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/TrafficFlowVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/TrafficFlowVO.java new file mode 100644 index 0000000..499c155 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/TrafficFlowVO.java @@ -0,0 +1,30 @@ +package com.ningdatech.carapi.road.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@Data +@ApiModel(description = "车流量-VO") +@NoArgsConstructor +@AllArgsConstructor +public class TrafficFlowVO { + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("区域 (1-黄山隧道义务方向 2-黄山隧道东阳方向 3-何里隧道)") + private Integer region; + + @ApiModelProperty("车流量") + private String trafficFlow; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IComprehensiveSituationService.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IComprehensiveSituationService.java new file mode 100644 index 0000000..c2a4c16 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IComprehensiveSituationService.java @@ -0,0 +1,12 @@ +package com.ningdatech.carapi.road.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +public interface IComprehensiveSituationService extends IService { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/ITrafficFlowService.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/ITrafficFlowService.java new file mode 100644 index 0000000..cc1ee33 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/ITrafficFlowService.java @@ -0,0 +1,12 @@ +package com.ningdatech.carapi.road.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +public interface ITrafficFlowService extends IService { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ComprehensiveSituationServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ComprehensiveSituationServiceImpl.java new file mode 100644 index 0000000..4a6f401 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ComprehensiveSituationServiceImpl.java @@ -0,0 +1,16 @@ +package com.ningdatech.carapi.road.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.carapi.road.mapper.ComprehensiveSituationMapper; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; +import com.ningdatech.carapi.road.service.IComprehensiveSituationService; +import org.springframework.stereotype.Service; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@Service +public class ComprehensiveSituationServiceImpl extends ServiceImpl implements IComprehensiveSituationService { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ITrafficFlowServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ITrafficFlowServiceImpl.java new file mode 100644 index 0000000..6789437 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ITrafficFlowServiceImpl.java @@ -0,0 +1,16 @@ +package com.ningdatech.carapi.road.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.carapi.road.mapper.TrafficFlowMapper; +import com.ningdatech.carapi.road.model.entity.TrafficFlow; +import com.ningdatech.carapi.road.service.ITrafficFlowService; +import org.springframework.stereotype.Service; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@Service +public class ITrafficFlowServiceImpl extends ServiceImpl implements ITrafficFlowService { +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorRealTimeDataTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorRealTimeDataTask.java new file mode 100644 index 0000000..4e2ab2c --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorRealTimeDataTask.java @@ -0,0 +1,62 @@ +package com.ningdatech.carapi.road.task; + +import com.ningdatech.carapi.road.manage.RoadMonitorManage; +import com.ningdatech.carapi.road.model.entity.ComprehensiveSituation; +import com.ningdatech.carapi.road.model.req.RoadMonitorReq; +import com.ningdatech.carapi.road.model.vo.ComprehensiveSituationVO; +import com.ningdatech.carapi.road.service.IComprehensiveSituationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +/** + * @author FangShiBa + * @apiNote + * @since 2024/11/20 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class RoadMonitorRealTimeDataTask { + + @Value("${task.switch.is-open}") + private boolean flag; + + private final RoadMonitorManage roadMonitorManage; + private final IComprehensiveSituationService comprehensiveSituationService; + + //每分钟计算一次综合态势评分 + @Scheduled(cron = "0 */1 * * * ?") + public void doTask(){ + if (!flag){ + log.info("综合态势评定时任务未开启!"); + return; + } + //黄山隧道道路综合数据 + RoadMonitorReq reqHS = new RoadMonitorReq(); + reqHS.setTunnel(1); + ComprehensiveSituationVO comSitHSData = roadMonitorManage.getComSitData(reqHS); + ComprehensiveSituation comprehensiveSituationHS = new ComprehensiveSituation(); + BeanUtils.copyProperties(comSitHSData,comprehensiveSituationHS); + comprehensiveSituationHS.setTunnel(1); + comprehensiveSituationHS.setCreateOn(LocalDateTime.now()); + comprehensiveSituationService.save(comprehensiveSituationHS); + + //何里隧道道路综合数据 + RoadMonitorReq reqHL = new RoadMonitorReq(); + reqHL.setTunnel(2); + ComprehensiveSituationVO comSitHLData = roadMonitorManage.getComSitData(reqHL); + ComprehensiveSituation comprehensiveSituationHL = new ComprehensiveSituation(); + BeanUtils.copyProperties(comSitHLData,comprehensiveSituationHL); + comprehensiveSituationHL.setTunnel(2); + comprehensiveSituationHL.setCreateOn(LocalDateTime.now()); + comprehensiveSituationService.save(comprehensiveSituationHL); + + } + +}