Browse Source

道路安全指数,车流量图表

master
fangzhe 1 week ago
parent
commit
a5a2474996
17 changed files with 430 additions and 5 deletions
  1. +16
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java
  2. +55
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java
  3. +14
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java
  4. +38
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java
  5. +13
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.java
  6. +5
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.xml
  7. +13
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.java
  8. +5
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.xml
  9. +46
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/ComprehensiveSituation.java
  10. +34
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/TrafficFlow.java
  11. +43
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadScoreVO.java
  12. +30
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/TrafficFlowVO.java
  13. +12
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IComprehensiveSituationService.java
  14. +12
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/ITrafficFlowService.java
  15. +16
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ComprehensiveSituationServiceImpl.java
  16. +16
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ITrafficFlowServiceImpl.java
  17. +62
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorRealTimeDataTask.java

+ 16
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java View File

@@ -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;
}



+ 55
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/task/RadarRealTimeDataUpdateTask.java View File

@@ -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<RadarData> 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<RadarData> 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<RadarData> 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);
}
}

}

+ 14
- 2
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java View File

@@ -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<RoadScoreVO> getRealTimeComSitData(RoadMonitorReq req){
return roadMonitorManage.getRealTimeComSitData(req);
}

@ApiOperation(value = "实时车流量数据", notes = "实时车流量数据")
@GetMapping("/get-real-time-traffic-flow-data")
public List<TrafficFlowVO> getRealTimeTrafficFlowData(RoadMonitorReq req){
return roadMonitorManage.getRealTimeTrafficFlowData(req);
}

}

+ 38
- 3
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java View File

@@ -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<RoadScoreVO> getRealTimeComSitData(RoadMonitorReq req) {
List<ComprehensiveSituation> 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<TrafficFlowVO> getRealTimeTrafficFlowData(RoadMonitorReq req) {
List<TrafficFlow> 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());
}
}

+ 13
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.java View File

@@ -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<ComprehensiveSituation> {
}

+ 5
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/ComprehensiveSituationMapper.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.carapi.road.mapper.ComprehensiveSituationMapper">

</mapper>

+ 13
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.java View File

@@ -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<TrafficFlow> {
}

+ 5
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/TrafficFlowMapper.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.carapi.road.mapper.TrafficFlowMapper">

</mapper>

+ 46
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/ComprehensiveSituation.java View File

@@ -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;
}

+ 34
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/TrafficFlow.java View File

@@ -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;
}

+ 43
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadScoreVO.java View File

@@ -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;
}

+ 30
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/TrafficFlowVO.java View File

@@ -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;
}

+ 12
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IComprehensiveSituationService.java View File

@@ -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<ComprehensiveSituation> {
}

+ 12
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/ITrafficFlowService.java View File

@@ -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<TrafficFlow> {
}

+ 16
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ComprehensiveSituationServiceImpl.java View File

@@ -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<ComprehensiveSituationMapper, ComprehensiveSituation> implements IComprehensiveSituationService {
}

+ 16
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/ITrafficFlowServiceImpl.java View File

@@ -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<TrafficFlowMapper, TrafficFlow> implements ITrafficFlowService {
}

+ 62
- 0
ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorRealTimeDataTask.java View File

@@ -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);

}

}

Loading…
Cancel
Save