From 879cd49b29bd3bf83ecb0159038ef4bf5d7c8bcb Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Tue, 5 Nov 2024 20:16:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=93=E8=B7=AF=E9=A9=BE=E9=A9=B6=E8=88=B1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + ningda-yw-api/pom.xml | 16 + .../controller/AnalysisEvalDataViewController.java | 12 +- .../analysis/entity/RoadBehaviorAnalysis.java | 48 -- .../manage/AnalysisEvalDataViewManage.java | 153 ++++++- .../mapper/RoadBehaviorAnalysisMapper.java | 16 - .../analysis/mapper/RoadBehaviorAnalysisMapper.xml | 5 - .../service/IRoadBehaviorAnalysisService.java | 16 - .../impl/RoadBehaviorAnalysisServiceImpl.java | 20 - .../car/position/manage/PositionMonitorManage.java | 73 ++- .../vo/ResRealTimeMonitorVehicleGisListVO.java | 1 + .../carapi/common/contants/DefValConstants.java | 13 + .../common/handler/GlobalResponseHandler.java | 3 +- .../carapi/common/model/DataChartVo.java | 3 + .../driver/manage/BehaviourAnalysisManage.java | 6 +- .../driver/manage/TrainingOrganizationManage.java | 6 +- .../service/impl/BehaviourAnalysisServiceImpl.java | 9 +- .../carapi/gps/manage/GpsDataPullManage.java | 61 +-- .../carapi/gps/task/GpsFullDataPullTask.java | 6 +- .../carapi/gps/task/GpsRealTimeDataPullTask.java | 39 +- .../industry/manage/OperatorAssessmentManage.java | 4 +- .../carapi/irs/manage/DataInitManage.java | 28 +- .../irs/service/impl/AccidentServieImpl.java | 10 +- .../carapi/irs/service/impl/CarServiceImpl.java | 6 +- .../carapi/irs/service/impl/DriverServiceImpl.java | 6 +- .../carapi/irs/task/MyAccidentQueryTask.java | 4 +- .../carapi/irs/task/MyVehicleIllegalQueryTask.java | 12 +- .../carapi/radar/manage/RadarManage.java | 3 +- .../road/constant/BicycleStatusTypeEnum.java | 66 +++ .../road/constant/CongestionStatusTypeEnum.java | 69 +++ .../road/constant/DriverAbnormalTypeEnum.java | 69 --- .../carapi/road/constant/DriverStatusTypeEnum.java | 69 +++ .../road/constant/OffenseStatusTypeEnum.java | 68 +++ .../road/constant/PedestrianStatusTypeEnum.java | 68 +++ .../carapi/road/constant/RoadBehaviorTypeEnum.java | 9 +- .../carapi/road/constant/RoadStatusTypeEnum.java | 8 +- .../carapi/road/constant/SpeedStatusTypeEnum.java | 70 +++ .../constant/VehicleSpeedAbnormalTypeEnum.java | 70 --- .../road/constant/VehicleStatusTypeEnum.java | 70 +++ .../road/constant/WeatherStatusTypeEnum.java | 10 +- .../road/controller/RoadMonitorController.java | 32 +- .../carapi/road/manage/RoadMonitorManage.java | 490 +++++++++++++++++++-- .../road/mapper/RoadBehaviorAnalysisMapper.java | 16 + .../road/mapper/RoadBehaviorAnalysisMapper.xml | 5 + .../road/model/entity/RoadBehaviorAnalysis.java | 69 +++ .../carapi/road/model/req/RoadMonitorReq.java | 33 ++ .../carapi/road/model/req/VideoDownloadReq.java | 24 + .../road/model/vo/ComprehensiveSituationVO.java | 15 +- .../carapi/road/model/vo/RoadDangerBehaviorVO.java | 53 +++ .../road/service/IRoadBehaviorAnalysisService.java | 16 + .../impl/RoadBehaviorAnalysisServiceImpl.java | 20 + .../carapi/road/task/RoadMonitorDataPullTask.java | 476 ++++++++++++++++++++ .../carapi/scheduler/contants/TaskConstant.java | 157 +++++++ .../carapi/scheduler/contants/TaskContant.java | 151 ------- .../carapi/scheduler/util/DriverScoreUtils.java | 22 +- .../ningdatech/carapi/scheduler/util/GpsUtils.java | 12 +- .../src/main/resources/application-dev.yml | 6 +- .../com/ningdatech/carapi/alarm/AlarmTest.java | 12 +- .../com/ningdatech/carapi/redis/RedisTest.java | 4 +- 59 files changed, 2215 insertions(+), 626 deletions(-) delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/entity/RoadBehaviorAnalysis.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.xml delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/IRoadBehaviorAnalysisService.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/impl/RoadBehaviorAnalysisServiceImpl.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java create mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java delete mode 100644 ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java diff --git a/.gitignore b/.gitignore index eb97fdd..237bf67 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ /LOG_PATH_IS_UNDEFINED/ logs /.idea/ +driver-real-time-play-back +driver-remote-play-back +tunnel-play-back \ No newline at end of file diff --git a/ningda-yw-api/pom.xml b/ningda-yw-api/pom.xml index cf63d76..a51600a 100644 --- a/ningda-yw-api/pom.xml +++ b/ningda-yw-api/pom.xml @@ -221,6 +221,22 @@ easypoi-base + + + + redis.clients + jedis + 3.7.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.12.3 + + + + diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/controller/AnalysisEvalDataViewController.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/controller/AnalysisEvalDataViewController.java index 625f55c..4c9c3ee 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/controller/AnalysisEvalDataViewController.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/controller/AnalysisEvalDataViewController.java @@ -49,9 +49,9 @@ public class AnalysisEvalDataViewController { @RequestParam(value = "dangerLevel", required = false) Integer dangerLevel) { regionId = CodeUtil.convertRegionCodeToId(regionId); // 默认查询最低等级预警即蓝色预警 - if (dangerLevel == null) { - dangerLevel = DangerLevel.BLUE.getCode(); - } + //if (dangerLevel == null) { + // dangerLevel = DangerLevel.BLUE.getCode(); + //} return analysisEvalDataViewManage.companyWarnStatisticsByLevel(regionId, dangerLevel); } @@ -68,9 +68,9 @@ public class AnalysisEvalDataViewController { @RequestParam(value = "dangerLevel", required = false) Integer dangerLevel) { regionId = CodeUtil.convertRegionCodeToId(regionId); // 默认查询红色预警 - if (dangerLevel == null) { - dangerLevel = DangerLevel.RED.getCode(); - } + //if (dangerLevel == null) { + // dangerLevel = DangerLevel.RED.getCode(); + //} return analysisEvalDataViewManage.carWarnStatisticsByLevel(regionId, dangerLevel); } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/entity/RoadBehaviorAnalysis.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/entity/RoadBehaviorAnalysis.java deleted file mode 100644 index 2d361b6..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/entity/RoadBehaviorAnalysis.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.ningdatech.carapi.analysis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.io.Serializable; -import java.time.LocalDateTime; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - *

- * - *

- * - * @author CMM - * @since 2024-10-22 - */ -@TableName("nd_road_behavior_analysis") -@ApiModel(value = "RoadBehaviorAnalysis对象", description = "") -@Data -public class RoadBehaviorAnalysis implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("主键") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("异常行为类型 1 驾驶员异常 2 车辆速度异常 3 监控异常") - private Integer type; - - @ApiModelProperty("异常行为描述") - private String behavior; - - @ApiModelProperty("异常行为码") - private String behaviorCode; - - @ApiModelProperty("异常行为时间") - private LocalDateTime behaviorTime; - - @ApiModelProperty("创建时间") - private LocalDateTime createTime; - - @ApiModelProperty("更新时间") - private LocalDateTime updateTime; -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/manage/AnalysisEvalDataViewManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/manage/AnalysisEvalDataViewManage.java index 1501997..eabfa5e 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/manage/AnalysisEvalDataViewManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/manage/AnalysisEvalDataViewManage.java @@ -3,9 +3,12 @@ package com.ningdatech.carapi.analysis.manage; import cn.hutool.core.map.MapUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.carapi.analysis.common.DangerLevelEnum; import com.ningdatech.carapi.analysis.entity.WarnAnalysisCar; import com.ningdatech.carapi.analysis.entity.WarnAnalysisCompany; +import com.ningdatech.carapi.analysis.entity.enumeration.DangerLevel; import com.ningdatech.carapi.analysis.entity.vo.CompanyWarnStatisticsVo; import com.ningdatech.carapi.analysis.service.IWarnAnalysisCarService; import com.ningdatech.carapi.analysis.service.IWarnAnalysisCompanyService; @@ -141,29 +144,108 @@ public class AnalysisEvalDataViewManage { public List companyWarnStatisticsByLevel(Long regionId, Integer dangerLevel) { List result = new ArrayList<>(); List regionIds = regionsCacheHelper.listChildRegionId(regionId); - QueryWrapper query = buildCountQueryGroupByRegion(regionIds, dangerLevel); - List> analysisCompanies = companyWarnAnalysisService.listMaps(query); + //QueryWrapper query = buildCountQueryGroupByRegion(regionIds, dangerLevel); + //List> analysisCompanies = companyWarnAnalysisService.listMaps(query); + + // 获取红色预警的数据 + QueryWrapper queryRed = buildCountQueryGroupByRegion(regionIds, DangerLevel.RED.getCode()); + List> analysisCompaniesRed = companyWarnAnalysisService.listMaps(queryRed); + // 获取橙色预警的数据 + QueryWrapper queryOrange = buildCountQueryGroupByRegion(regionIds, DangerLevel.ORANGE.getCode()); + List> analysisCompaniesOrange = companyWarnAnalysisService.listMaps(queryOrange); + // 获取黄色预警的数据 + QueryWrapper queryYellow = buildCountQueryGroupByRegion(regionIds, DangerLevel.YELLOW.getCode()); + List> analysisCompaniesYellow = companyWarnAnalysisService.listMaps(queryYellow); + // 获取蓝色预警的数据 + QueryWrapper queryBlue = buildCountQueryGroupByRegion(regionIds, DangerLevel.BLUE.getCode()); + List> analysisCompaniesBlue = companyWarnAnalysisService.listMaps(queryBlue); + Map> childrenMap = regionsCacheHelper.getChildrenMap(regionId, true); // 如果是区县一级的,只返回区县一级的名字和数量 if (childrenMap.size() == 0) { RegionDTO regionDto = regionsCacheHelper.getByRegionId(regionId); String regionName = regionDto.getRegionName(); - DataChartVo vo = new DataChartVo(regionName, 0); - analysisCompanies.forEach(w -> { - vo.setValue(vo.getValue() + MapUtil.getInt(w, "count")); + DataChartVo voRed = new DataChartVo(regionName, 0); + analysisCompaniesRed.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (regionId.equals(currRegionId)) { + voRed.setValue(voRed.getValue() + MapUtil.getInt(w, "count")); + voRed.setDangerLevel(DangerLevel.RED.getCode()); + } }); - result.add(vo); + result.add(voRed); + + DataChartVo voOrange = new DataChartVo(regionName, 0); + analysisCompaniesOrange.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (regionId.equals(currRegionId)) { + voOrange.setValue(voOrange.getValue() + MapUtil.getInt(w, "count")); + voOrange.setDangerLevel(DangerLevel.ORANGE.getCode()); + } + }); + result.add(voOrange); + + DataChartVo voYellow = new DataChartVo(regionName, 0); + analysisCompaniesYellow.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (regionId.equals(currRegionId)) { + voYellow.setValue(voYellow.getValue() + MapUtil.getInt(w, "count")); + voYellow.setDangerLevel(DangerLevel.YELLOW.getCode()); + } + }); + result.add(voYellow); + + DataChartVo voBlue = new DataChartVo(regionName, 0); + analysisCompaniesBlue.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (regionId.equals(currRegionId)) { + voBlue.setValue(voBlue.getValue() + MapUtil.getInt(w, "count")); + voBlue.setDangerLevel(DangerLevel.BLUE.getCode()); + } + }); + result.add(voBlue); return result; } else { childrenMap.forEach((k, v) -> { - DataChartVo vo = new DataChartVo(k.getRegionName(), 0); - analysisCompanies.forEach(w -> { + DataChartVo voRed = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesRed.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voRed.setValue(voRed.getValue() + MapUtil.getInt(w, "count")); + voRed.setDangerLevel(DangerLevel.RED.getCode()); + } + }); + result.add(voRed); + + DataChartVo voOrange = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesOrange.forEach(w -> { Long currRegionId = MapUtil.getLong(w, "regionId"); if (v.contains(currRegionId)) { - vo.setValue(vo.getValue() + MapUtil.getInt(w, "count")); + voOrange.setValue(voOrange.getValue() + MapUtil.getInt(w, "count")); + voOrange.setDangerLevel(DangerLevel.ORANGE.getCode()); } }); - result.add(vo); + result.add(voOrange); + + DataChartVo voYellow = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesYellow.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voYellow.setValue(voYellow.getValue() + MapUtil.getInt(w, "count")); + voYellow.setDangerLevel(DangerLevel.YELLOW.getCode()); + } + }); + result.add(voYellow); + + DataChartVo voBlue = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesBlue.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voBlue.setValue(voBlue.getValue() + MapUtil.getInt(w, "count")); + voBlue.setDangerLevel(DangerLevel.BLUE.getCode()); + } + }); + result.add(voBlue); }); return result; } @@ -172,18 +254,57 @@ public class AnalysisEvalDataViewManage { public List carWarnStatisticsByLevel(Long regionId, Integer dangerLevel) { List result = new ArrayList<>(); List regionIds = regionsCacheHelper.listChildRegionId(regionId); - QueryWrapper query = buildCountQueryGroupByRegion(regionIds, dangerLevel); - List> analysisCompanies = carWarnAnalysisService.listMaps(query); + List> analysisCompanies = Lists.newArrayList(); + // 获取红色预警的数据 + QueryWrapper queryRed = buildCountQueryGroupByRegion(regionIds, DangerLevel.RED.getCode()); + List> analysisCompaniesRed = carWarnAnalysisService.listMaps(queryRed); + // 获取橙色预警的数据 + QueryWrapper queryOrange = buildCountQueryGroupByRegion(regionIds, DangerLevel.ORANGE.getCode()); + List> analysisCompaniesOrange = carWarnAnalysisService.listMaps(queryOrange); + // 获取黄色预警的数据 + QueryWrapper queryYellow = buildCountQueryGroupByRegion(regionIds, DangerLevel.YELLOW.getCode()); + List> analysisCompaniesYellow = carWarnAnalysisService.listMaps(queryYellow); + // 获取蓝色预警的数据 + QueryWrapper queryBlue = buildCountQueryGroupByRegion(regionIds, DangerLevel.BLUE.getCode()); + List> analysisCompaniesBlue = carWarnAnalysisService.listMaps(queryBlue); Map> childrenMap = regionsCacheHelper.getChildrenMap(regionId, true); childrenMap.forEach((k, v) -> { - DataChartVo vo = new DataChartVo(k.getRegionName(), 0); - analysisCompanies.forEach(w -> { + DataChartVo voRed = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesRed.forEach(w -> { Long currRegionId = MapUtil.getLong(w, "regionId"); if (v.contains(currRegionId)) { - vo.setValue(vo.getValue() + MapUtil.getInt(w, "count")); + voRed.setValue(voRed.getValue() + MapUtil.getInt(w, "count")); + voRed.setDangerLevel(DangerLevel.RED.getCode()); } }); - result.add(vo); + result.add(voRed); + DataChartVo voOrange = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesOrange.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voOrange.setValue(voOrange.getValue() + MapUtil.getInt(w, "count")); + voOrange.setDangerLevel(DangerLevel.ORANGE.getCode()); + } + }); + result.add(voOrange); + DataChartVo voYellow = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesYellow.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voYellow.setValue(voYellow.getValue() + MapUtil.getInt(w, "count")); + voYellow.setDangerLevel(DangerLevel.YELLOW.getCode()); + } + }); + result.add(voYellow); + DataChartVo voBlue = new DataChartVo(k.getRegionName(), 0); + analysisCompaniesBlue.forEach(w -> { + Long currRegionId = MapUtil.getLong(w, "regionId"); + if (v.contains(currRegionId)) { + voBlue.setValue(voBlue.getValue() + MapUtil.getInt(w, "count")); + voBlue.setDangerLevel(DangerLevel.BLUE.getCode()); + } + }); + result.add(voBlue); }); return result; } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.java deleted file mode 100644 index eeaf4ab..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.carapi.analysis.mapper; - -import com.ningdatech.carapi.analysis.entity.RoadBehaviorAnalysis; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - *

- * Mapper 接口 - *

- * - * @author CMM - * @since 2024-10-22 - */ -public interface RoadBehaviorAnalysisMapper extends BaseMapper { - -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.xml b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.xml deleted file mode 100644 index 8846a46..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/IRoadBehaviorAnalysisService.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/IRoadBehaviorAnalysisService.java deleted file mode 100644 index 8b6ce06..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/IRoadBehaviorAnalysisService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.ningdatech.carapi.analysis.service; - -import com.ningdatech.carapi.analysis.entity.RoadBehaviorAnalysis; -import com.baomidou.mybatisplus.extension.service.IService; - -/** - *

- * 服务类 - *

- * - * @author CMM - * @since 2024-10-22 - */ -public interface IRoadBehaviorAnalysisService extends IService { - -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/impl/RoadBehaviorAnalysisServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/impl/RoadBehaviorAnalysisServiceImpl.java deleted file mode 100644 index 80b17d2..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/impl/RoadBehaviorAnalysisServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.ningdatech.carapi.analysis.service.impl; - -import com.ningdatech.carapi.analysis.entity.RoadBehaviorAnalysis; -import com.ningdatech.carapi.analysis.mapper.RoadBehaviorAnalysisMapper; -import com.ningdatech.carapi.analysis.service.IRoadBehaviorAnalysisService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 服务实现类 - *

- * - * @author CMM - * @since 2024-10-22 - */ -@Service -public class RoadBehaviorAnalysisServiceImpl extends ServiceImpl implements IRoadBehaviorAnalysisService { - -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/manage/PositionMonitorManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/manage/PositionMonitorManage.java index dd47641..0b6e8e7 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/manage/PositionMonitorManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/manage/PositionMonitorManage.java @@ -100,6 +100,7 @@ public class PositionMonitorManage { private final IDataAccessGpsService dataAccessGpsService; + public List trajectoryDatalist(ReqTrajectoryDataPO po) { String carPlate = po.getCarPlate(); LocalDateTime startTime = po.getStartTime(); @@ -107,35 +108,59 @@ public class PositionMonitorManage { if (Objects.isNull(startTime)) { startTime = LocalDateTime.now().minusHours(2); } - // 默认时间区间为2小时前到现在 + // 默认时间区间为2小时前到现在。 if (Objects.isNull(endTime)) { endTime = LocalDateTime.now(); } // 判断车辆所属区域是否在登录用户的区域权限内 - NdVehicleBaseInfo car = vehiclesCacheHelper.getByCarPlate(carPlate); - Long regionId = car.getRegionId(); - Long companyId = car.getCompanyId(); - UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - Long userDetailRegionId = userDetail.getRegionId(); - List listChild = regionsCacheHelper.listChildRegionId(userDetailRegionId,true,true); - // 不在登录用户的区域权限内 返回空数据 - if (!listChild.contains(regionId)){ - return Collections.emptyList(); - } + //NdVehicleBaseInfo car = vehiclesCacheHelper.getByCarPlate(carPlate); + //Long regionId = car.getRegionId(); + //Long companyId = car.getCompanyId(); + //UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + //Long userDetailRegionId = userDetail.getRegionId(); + //List listChild = regionsCacheHelper.listChildRegionId(userDetailRegionId,true,true); + //// 不在登录用户的区域权限内 返回空数据 + //if (!listChild.contains(regionId)){ + // return Collections.emptyList(); + //} //判断日期有没有跨天 checkDateExtendIntoNextDay(startTime, endTime); - //动态表名 - List vehiclePositionInfoList = iVehiclePositionInfoService - .dynamicGpsTableHistorySearch(carPlate, startTime, endTime,NdDateUtils.format(startTime, "yyyy_MM_dd")); + // 从GPS数据列表中获取查询车牌号 查询时间区间内的数据 + List list = dataAccessGpsService.list(Wrappers.lambdaQuery(NdDataAccessGps.class) + .eq(NdDataAccessGps::getCarPlate, carPlate) + .ge(NdDataAccessGps::getUpdateTime, startTime) + .le(NdDataAccessGps::getUpdateTime, endTime)); + if (CollUtil.isEmpty(list)){ + return Collections.emptyList(); + } + + List vehiclePositionInfoList = list.stream().map(d -> { + VehiclePositionInfo vehiclePositionInfo = new VehiclePositionInfo(); + vehiclePositionInfo.setCarPlate(d.getCarPlate()); + vehiclePositionInfo.setCarAltitude(d.getCarAltitude()); + vehiclePositionInfo.setCarLongitude(d.getCarLongitude()); + vehiclePositionInfo.setCarLatitude(d.getCarLatitude()); + vehiclePositionInfo.setCarDirection(d.getCarDirection()); + vehiclePositionInfo.setCarVelocity(d.getCarVelocity()); + vehiclePositionInfo.setRecordId(d.getRecordId()); + vehiclePositionInfo.setOperatorId(d.getOperatorId()); + vehiclePositionInfo.setOperatorName(d.getOperatorName()); + vehiclePositionInfo.setUpdateTime(NdDateUtils.format(d.getUpdateTime(), DatePattern.NORM_DATETIME_PATTERN)); + return vehiclePositionInfo; + }).collect(Collectors.toList()); + + ////动态表名 + //List vehiclePositionInfoList = iVehiclePositionInfoService + // .dynamicGpsTableHistorySearch(carPlate, startTime, endTime,NdDateUtils.format(startTime, "yyyy_MM_dd")); List resTrajectoryDataVOList = vehiclePositionInfoList.stream().map( r -> { ResTrajectoryDataVO vo = BeanUtil.copyProperties(r, ResTrajectoryDataVO.class); - vo.setIsOverSpeed(checkIsOverSpeed(r,car)); + //vo.setIsOverSpeed(checkIsOverSpeed(r,car)); return vo; }).collect(Collectors.toList()); //连续6次超速 才算超速 @@ -306,13 +331,22 @@ public class PositionMonitorManage { } public List realTimeMonitorVehicleGisList(ReqRealTimeMonitorPO po) { - // 只查询当天最新的数据 - LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0); - LocalDateTime endTime = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59); + // 只查询最新的15分钟内的数据 + LocalDateTime startTime = LocalDateTime.now().minusMinutes(15); + LocalDateTime endTime = LocalDateTime.now(); List data = dataAccessGpsService.list(Wrappers.lambdaQuery(NdDataAccessGps.class) .ge(NdDataAccessGps::getUpdateTime, startTime).le(NdDataAccessGps::getUpdateTime, endTime) .select(NdDataAccessGps::getCarLongitude, NdDataAccessGps::getCarLatitude, NdDataAccessGps::getCarPlate, - NdDataAccessGps::getCarVelocity, NdDataAccessGps::getCarDirection)); + NdDataAccessGps::getCarVelocity, NdDataAccessGps::getCarDirection, NdDataAccessGps::getUpdateTime)); + log.info("最近15分钟 查询到{}条数据", data.size()); + // 如果最近15分钟没有数据(GPS数据不更新了) 取表中最新的10000条数据 + if (CollUtil.isEmpty(data)){ + data = dataAccessGpsService.list(Wrappers.lambdaQuery(NdDataAccessGps.class).orderByDesc(NdDataAccessGps::getUpdateTime).last("limit 10000")); + } + + //List data = dataAccessGpsService.list(Wrappers.lambdaQuery(NdDataAccessGps.class).select(NdDataAccessGps::getCarLongitude, NdDataAccessGps::getCarLatitude, NdDataAccessGps::getCarPlate, + // NdDataAccessGps::getCarVelocity, NdDataAccessGps::getCarDirection, NdDataAccessGps::getUpdateTime)); + if(CollUtil.isEmpty(data)){ return Collections.emptyList(); } @@ -320,6 +354,7 @@ public class PositionMonitorManage { Map map = vehicleBaseInfoService.listByCarNo(plates); return data.stream().map(d -> { ResRealTimeMonitorVehicleGisListVO vo = BeanUtil.copyProperties(d,ResRealTimeMonitorVehicleGisListVO.class); + vo.setUpdateTime(NdDateUtils.format(d.getUpdateTime(), NdDateUtils.DEFAULT_DATE_TIME_FORMAT)); if(map.containsKey(d.getCarPlate())){ NdVehicleBaseInfo car = map.get(d.getCarPlate()); vo.setVehicleType(car.getVehicleType()); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/model/vo/ResRealTimeMonitorVehicleGisListVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/model/vo/ResRealTimeMonitorVehicleGisListVO.java index 80eff72..b4862fa 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/model/vo/ResRealTimeMonitorVehicleGisListVO.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/model/vo/ResRealTimeMonitorVehicleGisListVO.java @@ -1,5 +1,6 @@ package com.ningdatech.carapi.car.position.model.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ningdatech.carapi.common.constant.VehicleTypeEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/contants/DefValConstants.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/contants/DefValConstants.java index 6c9ad50..13de443 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/contants/DefValConstants.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/contants/DefValConstants.java @@ -108,4 +108,17 @@ public interface DefValConstants { * 通道 */ String TONG_DAO = "通道"; + + /** + * 隧道回放 + */ + String SUI_DAO_PLAY_BACK = "tunnel-play-back"; + /** + * 驾驶员实时回放 + */ + String DRIVER_REAL_TIME_PLAY_BACK = "driver-real-time-play-back"; + /** + * 驾驶员远程回放 + */ + String DRIVER_REMOTE_PLAY_BACK = "driver-remote-play-back"; } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/handler/GlobalResponseHandler.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/handler/GlobalResponseHandler.java index 770fb48..eed7d6a 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/handler/GlobalResponseHandler.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/handler/GlobalResponseHandler.java @@ -37,7 +37,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; "com.ningdatech.carapi.industry.controller", "com.ningdatech.carapi.homepage.controller", "com.ningdatech.carapi.radar.controller", - "com.ningdatech.carapi.gps.controller" + "com.ningdatech.carapi.gps.controller", + "com.ningdatech.carapi.road.controller" }) public class GlobalResponseHandler implements ResponseBodyAdvice { diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/model/DataChartVo.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/model/DataChartVo.java index 232f6fc..c54c1c4 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/model/DataChartVo.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/common/model/DataChartVo.java @@ -25,6 +25,9 @@ public class DataChartVo { @ApiModelProperty("百分比") private String percent; + @ApiModelProperty("预警等级") + private Integer dangerLevel; + public DataChartVo(String label, Integer value) { this.label = label; this.value = value; diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/BehaviourAnalysisManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/BehaviourAnalysisManage.java index e78a8dd..1d2b7a5 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/BehaviourAnalysisManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/BehaviourAnalysisManage.java @@ -38,7 +38,7 @@ import com.ningdatech.carapi.driver.model.vo.DriverDailyAlarmEvent; import com.ningdatech.carapi.driver.service.IBehaviorAnalysisProcessingModeService; import com.ningdatech.carapi.driver.service.IBehaviourAnalysisService; import com.ningdatech.carapi.driver.service.IDriverInfoService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.service.CompanyService; import com.ningdatech.carapi.user.util.LoginUserUtil; @@ -99,7 +99,7 @@ public class BehaviourAnalysisManage { List behaviourAnalysisVOList = page.getRecords().stream().map(b -> { BehaviourAnalysisVO resVo = new BehaviourAnalysisVO(); BeanUtil.copyProperties(b, resVo); - BigDecimal speed = BigDecimal.valueOf(b.getSpeed()).multiply(TaskContant.Math.SPEED_UNITS) + BigDecimal speed = BigDecimal.valueOf(b.getSpeed()).multiply(TaskConstant.Math.SPEED_UNITS) .setScale(BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP); resVo.setSpeed(speed); String alarmPictureAppendix = b.getAlarmPictureAppendix(); @@ -162,7 +162,7 @@ public class BehaviourAnalysisManage { } //DriverAbnormalBehaviorAnalysis driverAbnormalBehaviorAnalysis = behaviourAnalysisService.getById(id); DriverAbnormalBehaviorAnalysisDetailVO resVo = BeanUtil.copyProperties(driverAbnormalBehaviorAnalysis, DriverAbnormalBehaviorAnalysisDetailVO.class); - Optional.ofNullable(driverAbnormalBehaviorAnalysis.getSpeed()).ifPresent(c -> resVo.setSpeed(BigDecimal.valueOf(c).multiply(TaskContant.Math.SPEED_UNITS) + Optional.ofNullable(driverAbnormalBehaviorAnalysis.getSpeed()).ifPresent(c -> resVo.setSpeed(BigDecimal.valueOf(c).multiply(TaskConstant.Math.SPEED_UNITS) .setScale(BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP).intValue())); //统计该驾驶员当日异常行为告警事件 diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/TrainingOrganizationManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/TrainingOrganizationManage.java index 885b510..3d4072d 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/TrainingOrganizationManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/TrainingOrganizationManage.java @@ -63,7 +63,7 @@ import com.ningdatech.carapi.driver.model.po.*; import com.ningdatech.carapi.driver.model.query.TrainingOrgTrainersQuery; import com.ningdatech.carapi.driver.model.vo.*; import com.ningdatech.carapi.driver.service.*; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.entity.dto.RegionDTO; import com.ningdatech.carapi.sys.entity.enumeration.CodingRuleBehaviorTypeEnum; @@ -908,7 +908,7 @@ public class TrainingOrganizationManage { //初始化驾驶员星级及分数 StarManage starManage = new StarManage(); starManage.setCurrentScore(DriverRelationConstant.DRIVER_FULL_SCORE); - starManage.setCurrentStar(TaskContant.Star.FIVE_STAR); + starManage.setCurrentStar(TaskConstant.Star.FIVE_STAR); starManage.setRegionId(driverInfo.getRegionId()); starManage.setCompanyId(driverInfo.getCompanyId()); starManage.setCompanyName(driverInfo.getCompanyName()); @@ -1512,7 +1512,7 @@ public class TrainingOrganizationManage { //初始化驾驶员星级及分数 StarManage starManage = new StarManage(); starManage.setCurrentScore(DriverRelationConstant.DRIVER_FULL_SCORE); - starManage.setCurrentStar(TaskContant.Star.FIVE_STAR); + starManage.setCurrentStar(TaskConstant.Star.FIVE_STAR); starManage.setRegionId(driverInfo.getRegionId()); starManage.setCompanyId(driverInfo.getCompanyId()); starManage.setCompanyName(driverInfo.getCompanyName()); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java index 83baa54..6e3fa32 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java @@ -82,11 +82,12 @@ public class BehaviourAnalysisServiceImpl extends ServiceImpl max = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) .select(DataAccessGpsRealTimeData::getUpdateTime)).stream().max(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)); if (max.isPresent()){ maxUpdateTime = max.get().getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); + log.info("当前表中最大更新时间:{}", Instant.ofEpochMilli(maxUpdateTime).atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); } - log.info("当前表中最大更新时间:{}", Instant.ofEpochMilli(maxUpdateTime).atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - try { trustAllCertificates(); - Map requestParams = assemblyParams(maxUpdateTime); + Map requestParams = assemblyParams(); String requestUrl = url + "/talent/gps/datalist"; String response = sendPostRequest(requestUrl, requestParams); if (response == null) { @@ -136,25 +140,27 @@ public class GpsDataPullManage { return "数据为空!"; } - // 获取此次拉取到的数据中上传时间大于上次拉取数据的最大上报时间的数据 - long finalMaxUpdateTime = maxUpdateTime; - dataList = dataList.stream().filter(e -> e.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli() > finalMaxUpdateTime).collect(Collectors.toList()); + // 表中有数据 获取此次拉取到的数据中上传时间大于上次拉取数据的最大上报时间的数据 + if (Objects.nonNull(maxUpdateTime)) { + long finalMaxUpdateTime = maxUpdateTime; + dataList = dataList.stream().filter(e -> e.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli() > finalMaxUpdateTime).collect(Collectors.toList()); + // 将数据库中的数据根据更新时间排序 按更新时间 从小到大 根据对应id删除此次拉取到的数据量 + List dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) + .select(DataAccessGpsRealTimeData::getUpdateTime, DataAccessGpsRealTimeData::getRecordId)) + .stream().sorted(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)).collect(Collectors.toList()); + // 截取dataList.size()条数据 + dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataList.subList(0, dataList.size()); + // 从旧数据中删除这些数据 + List recordIdList = dataAccessGpsRealTimeDataList.stream().map(DataAccessGpsRealTimeData::getRecordId).collect(Collectors.toList()); + String tableName = "nd_data_access_gps_real_time_data"; + dataAccessGpsRealTimeDataService.removeByRecordIds(tableName,recordIdList); + } // 如果没有 说明没有新上报的数据 不更新 if (CollUtil.isEmpty(dataList)){ log.info("没有新上报的数据!"); return "没有新上报的数据!"; } log.info("本次拉取到{}条数据", dataList.size()); - // 将数据库中的数据根据更新时间排序 按更新时间 从小到大 根据对应id删除此次拉取到的数据量 - List dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) - .select(DataAccessGpsRealTimeData::getUpdateTime, DataAccessGpsRealTimeData::getRecordId)) - .stream().sorted(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)).collect(Collectors.toList()); - // 截取dataList.size()条数据 - dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataList.subList(0, dataList.size()); - // 从旧数据中删除这些数据 - List recordIdList = dataAccessGpsRealTimeDataList.stream().map(DataAccessGpsRealTimeData::getRecordId).collect(Collectors.toList()); - String tableName = "nd_data_access_gps_real_time_data"; - dataAccessGpsRealTimeDataService.removeByRecordIds(tableName,recordIdList); // 先清空表中的数据 //truncateTable(); @@ -327,7 +333,7 @@ public class GpsDataPullManage { Map params = new HashMap<>(); params.put("timeNow", String.valueOf(timeNow)); params.put("token", token); - params.put("timeLine", String.valueOf(maxUpdateTime)); + params.put("timeLine", String.valueOf(maxUpdateTime / 1000)); //params.put("Slat", "120.0167"); //params.put("Elat", "120.2337"); @@ -463,7 +469,7 @@ public class GpsDataPullManage { trustAllCertificates(); String requestUrl = url + "/talent/gps/datalist"; // 从缓存中获取业务数据最大id - CacheKey key = new CacheKey(TaskContant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); + CacheKey key = new CacheKey(TaskConstant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); String id = cachePlusOps.get(key); log.info("缓存中已存在id:{}", id); // 如果不存在 从表中数据中获取 @@ -575,7 +581,7 @@ public class GpsDataPullManage { StopWatch stopWatch = new StopWatch(); stopWatch.start(); // 从缓存中获取业务数据最大id - CacheKey key = new CacheKey(TaskContant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); + CacheKey key = new CacheKey(TaskConstant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); Long id = cachePlusOps.get(key); log.info("缓存中已存在id: {}", id); // 缓存中已存在 @@ -632,16 +638,11 @@ public class GpsDataPullManage { } public String getRedisData() { - // 驾驶员行为分析数据 - String driverData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_DRIVER_DATA_KEY)); - // 车辆超速数据 - String speedData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_VEHICLE_DATA_KEY)); - // 视频推理数据 - String videoData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_VIDEO_DATA_KEY)); // 拼接数据 - String allData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_ALL_DATA_KEY)); - log.info("driver:{},speed:{},video:{}", driverData, speedData, videoData); + jedis.auth("Ndkj1234"); + String allData = jedis.get(TaskConstant.RedisKey.HS_YW_COME_REDIS_ALL_DATA_KEY); + //String allData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.HS_DY_GO_REDIS_ALL_DATA_KEY)); log.info("allData:{}", allData); - return "driverData:" + driverData + ",speedData:" + speedData + ",videoData:" + videoData + ",allData:" + allData; + return "allData:" + allData; } } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsFullDataPullTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsFullDataPullTask.java index b6da3bf..d993979 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsFullDataPullTask.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsFullDataPullTask.java @@ -15,7 +15,7 @@ import com.ningdatech.cache.model.cache.CacheKey; import com.ningdatech.cache.repository.CachePlusOps; import com.ningdatech.carapi.homepage.entity.model.NdDataAccessGps; import com.ningdatech.carapi.homepage.service.IDataAccessGpsService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; @@ -70,7 +70,7 @@ public class GpsFullDataPullTask { gpsDataPullManage.trustAllCertificates(); // 从缓存中获取业务数据最大id - CacheKey key = new CacheKey(TaskContant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); + CacheKey key = new CacheKey(TaskConstant.RedisKey.GPS_DATA_PULL_MAX_BIZ_ID); Long id = cachePlusOps.get(key); log.info("从缓存中获取业务数据最大id:{}",id); // 如果不存在 从表中获取 @@ -161,7 +161,7 @@ public class GpsFullDataPullTask { log.info("主线程开始"); } stopWatch.stop(); - log.info("=========== GPS实时数据拉取 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); + log.info("=========== GPS增量数据拉取 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); } private Map assemblyParams(String key, Long id) { diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsRealTimeDataPullTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsRealTimeDataPullTask.java index 3c962d7..65dfd6b 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsRealTimeDataPullTask.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsRealTimeDataPullTask.java @@ -85,14 +85,14 @@ public class GpsRealTimeDataPullTask { String eLat = null; // 获取当前表中的最大更新时间 - long maxUpdateTime = LocalDateTime.now().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); + Long maxUpdateTime = null; Optional max = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) .select(DataAccessGpsRealTimeData::getUpdateTime)).stream().max(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)); if (max.isPresent()){ maxUpdateTime = max.get().getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); + log.info("当前表中最大更新时间:{}", Instant.ofEpochMilli(maxUpdateTime).atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); } - log.info("当前表中最大更新时间:{}", Instant.ofEpochMilli(maxUpdateTime).atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - Map requestParams = assemblyParams(key,String.valueOf(maxUpdateTime), sLon, eLon, sLat, eLat); + Map requestParams = assemblyParams(key,sLon, eLon, sLat, eLat); String requestUrl = domain + realTimeDataUrl; String response = gpsDataPullManage.sendPostRequest(requestUrl, requestParams); if (response == null) { @@ -143,25 +143,27 @@ public class GpsRealTimeDataPullTask { return; } - // 获取此次拉取到的数据中上传时间大于上次拉取数据的最大上报时间的数据 - long finalMaxUpdateTime = maxUpdateTime; - dataList = dataList.stream().filter(e -> e.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli() > finalMaxUpdateTime).collect(Collectors.toList()); + // 表中有数据 获取此次拉取到的数据中上传时间大于上次拉取数据的最大上报时间的数据 + if (Objects.nonNull(maxUpdateTime)) { + long finalMaxUpdateTime = maxUpdateTime; + dataList = dataList.stream().filter(e -> e.getUpdateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli() > finalMaxUpdateTime).collect(Collectors.toList()); + // 将数据库中的数据根据更新时间排序 按更新时间 从小到大 根据对应id删除此次拉取到的数据量 + List dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) + .select(DataAccessGpsRealTimeData::getUpdateTime, DataAccessGpsRealTimeData::getRecordId)) + .stream().sorted(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)).collect(Collectors.toList()); + // 截取dataList.size()条数据 + dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataList.subList(0, dataList.size()); + // 从旧数据中删除这些数据 + List recordIdList = dataAccessGpsRealTimeDataList.stream().map(DataAccessGpsRealTimeData::getRecordId).collect(Collectors.toList()); + String tableName = "nd_data_access_gps_real_time_data"; + dataAccessGpsRealTimeDataService.removeByRecordIds(tableName,recordIdList); + } // 如果没有 说明没有新上报的数据 不更新 if (CollUtil.isEmpty(dataList)){ log.info("没有新上报的数据!"); return; } log.info("本次拉取到{}条数据", dataList.size()); - // 将数据库中的数据根据更新时间排序 按更新时间 从小到大 根据对应id删除此次拉取到的数据量 - List dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataService.list(Wrappers.lambdaQuery(DataAccessGpsRealTimeData.class) - .select(DataAccessGpsRealTimeData::getUpdateTime, DataAccessGpsRealTimeData::getRecordId)) - .stream().sorted(Comparator.comparing(DataAccessGpsRealTimeData::getUpdateTime)).collect(Collectors.toList()); - // 截取dataList.size()条数据 - dataAccessGpsRealTimeDataList = dataAccessGpsRealTimeDataList.subList(0, dataList.size()); - // 从旧数据中删除这些数据 - List recordIdList = dataAccessGpsRealTimeDataList.stream().map(DataAccessGpsRealTimeData::getRecordId).collect(Collectors.toList()); - String tableName = "nd_data_access_gps_real_time_data"; - dataAccessGpsRealTimeDataService.removeByRecordIds(tableName,recordIdList); // 先清空表中的数据 //truncateTable(); @@ -223,16 +225,13 @@ public class GpsRealTimeDataPullTask { } } - private Map assemblyParams(String key, String queryTime, String sLon, String eLon, String sLat, String eLat) { + private Map assemblyParams(String key, String sLon, String eLon, String sLat, String eLat) { long timeNow = System.currentTimeMillis() / 1000; String token = gpsDataPullManage.generateMD5Token(timeNow, key); Map params = new HashMap<>(); params.put("timeNow", String.valueOf(timeNow)); params.put("token", token); - if (StringUtils.isNotBlank(queryTime)) { - params.put("timeLine", queryTime); - } if (StringUtils.isNotBlank(sLon)) { params.put("Slon", sLon); } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/industry/manage/OperatorAssessmentManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/industry/manage/OperatorAssessmentManage.java index 1ad56f6..8116dee 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/industry/manage/OperatorAssessmentManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/industry/manage/OperatorAssessmentManage.java @@ -26,7 +26,7 @@ import com.ningdatech.carapi.industry.model.dto.OperatorAssessmentDTO; import com.ningdatech.carapi.industry.model.dto.OperatorsAssessmentDetailsExportDTO; import com.ningdatech.carapi.industry.model.vo.OperatorScoreDetailVO; import com.ningdatech.carapi.industry.service.IOperatorIndexScoreInfoService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Operator; import com.ningdatech.carapi.sys.service.IOperatorScoreInfoService; import com.ningdatech.carapi.sys.service.OperatorService; @@ -71,7 +71,7 @@ public class OperatorAssessmentManage { // 查询条件下没有该运营商的考核分数信息,各项分数默认显示满分 log.info("未查询到运营商考核分数信息!"); assemblyOperatorInitialScore(operatorScoreDetailVO,operatorIndexScoreInfos); - operatorScoreDetailVO.setTotalScore(TaskContant.Data.OPERATOR_ASSESSMENT_SCORE_HUNDRED); + operatorScoreDetailVO.setTotalScore(TaskConstant.Data.OPERATOR_ASSESSMENT_SCORE_HUNDRED); return operatorScoreDetailVO; } assemblyOperatorScore(operatorScoreDetailVO, operatorScoreInfo); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/manage/DataInitManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/manage/DataInitManage.java index 6c24de8..e341206 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/manage/DataInitManage.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/manage/DataInitManage.java @@ -55,7 +55,7 @@ import com.ningdatech.carapi.safe.entity.NdVehicleViolation; import com.ningdatech.carapi.safe.service.INdVehicleAccidentDeadService; import com.ningdatech.carapi.safe.service.INdVehicleAccidentService; import com.ningdatech.carapi.safe.service.INdVehicleViolationService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.helper.RegionsCacheHelper; import com.ningdatech.carapi.sys.helper.VehiclesCacheHelper; @@ -387,14 +387,14 @@ public class DataInitManage { vehicleViolation.setViolationType(ViolationTypeEnum.PERIOD.getCode()); int hour = vehicleIllegalTime.getHour(); String period = null; - if (hour >= TaskContant.Data.VIOLATION_TIME_SEVEN && hour <= TaskContant.Data.VIOLATION_TIME_NINE) { - period = TaskContant.Data.VIOLATION_TIME_AM_START + StrPool.DASH - + TaskContant.Data.VIOLATION_TIME_AM_END; + if (hour >= TaskConstant.Data.VIOLATION_TIME_SEVEN && hour <= TaskConstant.Data.VIOLATION_TIME_NINE) { + period = TaskConstant.Data.VIOLATION_TIME_AM_START + StrPool.DASH + + TaskConstant.Data.VIOLATION_TIME_AM_END; vehicleViolation.setViolationPeriod(period); - } else if (hour >= TaskContant.Data.VIOLATION_TIME_SIXTEEN - && hour <= TaskContant.Data.VIOLATION_TIME_EIGHTEEN) { - period = TaskContant.Data.VIOLATION_TIME_PM_START + StrPool.DASH - + TaskContant.Data.VIOLATION_TIME_PM_END; + } else if (hour >= TaskConstant.Data.VIOLATION_TIME_SIXTEEN + && hour <= TaskConstant.Data.VIOLATION_TIME_EIGHTEEN) { + period = TaskConstant.Data.VIOLATION_TIME_PM_START + StrPool.DASH + + TaskConstant.Data.VIOLATION_TIME_PM_END; vehicleViolation.setViolationPeriod(period); } } else if (VIOLATION_ROAD_LIST.contains(wfxw)) { @@ -484,7 +484,7 @@ public class DataInitManage { // 获取此次任务要查询的车牌号 List result = new ArrayList<>(); List carPlateList; - String key = TaskContant.RedisKey.ACCIDENT_QUERY_IRS; + String key = TaskConstant.RedisKey.ACCIDENT_QUERY_IRS; List objectList = redisOps.get(key); // 存储的车牌号为空 if (CollUtil.isEmpty(objectList)) { @@ -511,7 +511,7 @@ public class DataInitManage { // 获取此次任务要查询的车牌号 List carPlateList = Lists.newArrayList(); - CacheKey cacheKey = new CacheKey(TaskContant.RedisKey.VEHICLE_ILLEGAL_QUERY_IRS, Duration.ofDays(20)); + CacheKey cacheKey = new CacheKey(TaskConstant.RedisKey.VEHICLE_ILLEGAL_QUERY_IRS, Duration.ofDays(20)); Object object = redisOps.get(cacheKey, false); // key不存在(过期) if (Objects.isNull(object)) { @@ -1356,11 +1356,11 @@ public class DataInitManage { String period = null; // 时间段暂时设置为违章时间所在小时的前后半小时 if (minute < 30) { - period = vehicleIllegalTime.minusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_HALF - + StrPool.DASH + hour + TaskContant.Data.VIOLATION_TIME_HALF; + period = vehicleIllegalTime.minusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_HALF + + StrPool.DASH + hour + TaskConstant.Data.VIOLATION_TIME_HALF; } else { - period = hour + TaskContant.Data.VIOLATION_TIME_START + StrPool.DASH - + vehicleIllegalTime.plusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_START; + period = hour + TaskConstant.Data.VIOLATION_TIME_START + StrPool.DASH + + vehicleIllegalTime.plusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_START; } vehicleViolation.setViolationPeriod(period); // if (hour >= TaskContant.Data.VIOLATION_TIME_SEVEN && hour <= diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java index 9423696..1590892 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java @@ -38,7 +38,7 @@ import com.ningdatech.carapi.safe.entity.NdVehicleAccident; import com.ningdatech.carapi.safe.entity.NdVehicleAccidentDead; import com.ningdatech.carapi.safe.service.INdVehicleAccidentDeadService; import com.ningdatech.carapi.safe.service.INdVehicleAccidentService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.helper.RegionsCacheHelper; import com.ningdatech.carapi.sys.service.CompanyService; @@ -354,9 +354,9 @@ public class AccidentServieImpl implements AccidentService { String hpzl = "01"; // 请求秘钥 - CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET); + CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET); // 刷新密钥 - CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REFRESH_SECRET); + CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REFRESH_SECRET); // 根据key获取缓存中的请求秘钥和刷新密钥 String requestSecret = cachePlusOps.get(requestKey); String refreshSecret = cachePlusOps.get(refreshKey); @@ -434,9 +434,9 @@ public class AccidentServieImpl implements AccidentService { String appSecret = "e07fd4471e92410d9860282d939b1217"; // 请求秘钥 - CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_DUTY_REQUEST_SECRET); + CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_DUTY_REQUEST_SECRET); // 刷新密钥 - CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_DUTY_REFRESH_SECRET); + CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_DUTY_REFRESH_SECRET); // 根据key获取缓存中的请求秘钥和刷新密钥 String requestSecret = cachePlusOps.get(requestKey); String refreshSecret = cachePlusOps.get(refreshKey); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java index 967ba47..a8eeeb9 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java @@ -19,7 +19,7 @@ import com.ningdatech.cache.repository.CachePlusOps; import com.ningdatech.carapi.irs.service.CarService; import com.ningdatech.carapi.irs.service.RefreshKeyService; import com.ningdatech.carapi.irs.utils.Md5Utils; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -142,9 +142,9 @@ public class CarServiceImpl implements CarService { String innerAppKey = "210a2657177f478c808381deb13a4dac"; // 请求秘钥 - CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_ILLEGAL_REQUEST_SECRET); + CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_ILLEGAL_REQUEST_SECRET); // 刷新密钥 - CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_ILLEGAL_REFRESH_SECRET); + CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_ILLEGAL_REFRESH_SECRET); // 根据key获取缓存中的请求秘钥和刷新密钥 String requestSecret = cachePlusOps.get(requestKey); String refreshSecret = cachePlusOps.get(refreshKey); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java index c8f6071..46bc37d 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java @@ -15,7 +15,7 @@ import com.ningdatech.cache.repository.CachePlusOps; import com.ningdatech.carapi.irs.service.DriverService; import com.ningdatech.carapi.irs.service.RefreshKeyService; import com.ningdatech.carapi.irs.utils.Md5Utils; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -73,9 +73,9 @@ public class DriverServiceImpl implements DriverService { String appSecret = "e07fd4471e92410d9860282d939b1217"; // 请求秘钥 - CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_LICENSE_REQUEST_SECRET); + CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_LICENSE_REQUEST_SECRET); // 刷新密钥 - CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_LICENSE_REFRESH_SECRET); + CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_LICENSE_REFRESH_SECRET); // 根据key获取缓存中的请求秘钥和刷新密钥 String requestSecret = cachePlusOps.get(requestKey); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java index 9eaa3a9..c64fc56 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java @@ -34,7 +34,7 @@ import com.ningdatech.carapi.safe.entity.NdVehicleAccident; import com.ningdatech.carapi.safe.entity.NdVehicleAccidentDead; import com.ningdatech.carapi.safe.service.INdVehicleAccidentDeadService; import com.ningdatech.carapi.safe.service.INdVehicleAccidentService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.helper.RegionsCacheHelper; import com.ningdatech.carapi.sys.service.CompanyService; @@ -110,7 +110,7 @@ public class MyAccidentQueryTask implements Runnable { // 判断当前执行任务的时间是否为月初的1号 如果是月初1号,任务应该从下标1重新开始跑 LocalDateTime now = LocalDateTime.now(); int dayOfMonth = now.getDayOfMonth(); - if (TaskContant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){ + if (TaskConstant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){ // 重置文件中的下标 saveLastIndex(1L, 0); } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java index 8ab072e..b6661e7 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java @@ -27,7 +27,7 @@ import com.ningdatech.carapi.irs.service.CarService; import com.ningdatech.carapi.irs.service.IVehicleViolationIrsDataService; import com.ningdatech.carapi.safe.entity.NdVehicleViolation; import com.ningdatech.carapi.safe.service.INdVehicleViolationService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.Company; import com.ningdatech.carapi.sys.helper.RegionsCacheHelper; import com.ningdatech.carapi.sys.service.CompanyService; @@ -130,7 +130,7 @@ public class MyVehicleIllegalQueryTask implements Runnable { // 判断当前执行任务的时间是否为月初的1号 如果是月初1号,任务应该从下标1重新开始跑 LocalDateTime now = LocalDateTime.now(); int dayOfMonth = now.getDayOfMonth(); - if (TaskContant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){ + if (TaskConstant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){ // 重置文件中的下标 saveLastIndex(1L, 0); } @@ -460,11 +460,11 @@ public class MyVehicleIllegalQueryTask implements Runnable { String period = null; // 时间段暂时设置为违章时间所在小时的前后半小时 if (minute < 30) { - period = vehicleIllegalTime.minusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_HALF - + StrPool.DASH + hour + TaskContant.Data.VIOLATION_TIME_HALF; + period = vehicleIllegalTime.minusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_HALF + + StrPool.DASH + hour + TaskConstant.Data.VIOLATION_TIME_HALF; } else { - period = hour + TaskContant.Data.VIOLATION_TIME_START + StrPool.DASH - + vehicleIllegalTime.plusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_START; + period = hour + TaskConstant.Data.VIOLATION_TIME_START + StrPool.DASH + + vehicleIllegalTime.plusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_START; } vehicleViolation.setViolationPeriod(period); // if (hour >= TaskContant.Data.VIOLATION_TIME_SEVEN && hour <= 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 c5b9076..cc4d727 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 @@ -27,7 +27,8 @@ public class RadarManage { public String getRadarData() { try { - ServerSocket serverSocket = new ServerSocket(13000, 600, InetAddress.getByName("192.168.6.42")); + // 192.168.6.42 + ServerSocket serverSocket = new ServerSocket(13000); // 设置为0表示无限等待,可以根据需要设置超时时间 serverSocket.setSoTimeout(6000); System.out.println("ServerSocket started on port: " + 13000); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java new file mode 100644 index 0000000..da17ef9 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java @@ -0,0 +1,66 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "BicycleStatusTypeEnum", description = "自行车情况-枚举") +public enum BicycleStatusTypeEnum { + /** + * 自行车情况 + */ + Bicycle_Collisions(1, "自行车碰撞"), + Motorway_Intrusion(2, "自行车误入高速公路"); + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (BicycleStatusTypeEnum t : BicycleStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (BicycleStatusTypeEnum t : BicycleStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java new file mode 100644 index 0000000..2695ad8 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java @@ -0,0 +1,69 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "CongestionStatusTypeEnum", description = "驾驶员异常情况-枚举") +public enum CongestionStatusTypeEnum { + /** + * 驾驶员异常情况 + */ + Heavy(1, "严重拥堵"), + Medium(2, "中度拥堵"), + Light(3, "轻度拥堵"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java deleted file mode 100644 index 4d4bdba..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.ningdatech.carapi.road.constant; - -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; - -import io.swagger.annotations.ApiModel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -/** - * @return - * @author CMM - * @since 2022/12/20 14:10 - */ -@Getter -@AllArgsConstructor -@NoArgsConstructor -@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举") -public enum DriverAbnormalTypeEnum { - /** - * 驾驶员异常行为类型 - */ - FATIGUE(1, "疲劳驾驶"), - - POOR_HABITS(2, "不良驾驶习惯"); - - - - private Integer code; - private String desc; - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getDescByCode(Integer code) { - if(Objects.isNull(code)){ - return StringUtils.EMPTY; - } - for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) { - if (code.equals(t.getCode())) { - return t.desc; - } - } - return StringUtils.EMPTY; - } - - public static Integer getCodeByDesc(String desc) { - if(StringUtils.isBlank(desc)){ - return null; - } - for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) { - if (desc.equals(t.getDesc())) { - return t.code; - } - } - return null; - } - - public boolean eq(String val) { - return this.name().equals(val); - } -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java new file mode 100644 index 0000000..7e2b3a8 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java @@ -0,0 +1,69 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "DriverStatusTypeEnum", description = "驾驶员异常情况-枚举") +public enum DriverStatusTypeEnum { + /** + * 驾驶员异常情况 + */ + Fatigue(1, "疲劳驾驶"), + + Poor_habits(2, "不良驾驶习惯"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java new file mode 100644 index 0000000..8f91a76 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java @@ -0,0 +1,68 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "OffenseStatusTypeEnum", description = "车辆违章情况-枚举") +public enum OffenseStatusTypeEnum { + /** + * 车辆违章情况 + */ + Running_a_red_light(1, "闯红灯"), + Crossing_the_line(2, "越线行驶"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (OffenseStatusTypeEnum t : OffenseStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (OffenseStatusTypeEnum t : OffenseStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java new file mode 100644 index 0000000..adb54ed --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java @@ -0,0 +1,68 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "PedestrianStatusTypeEnum", description = "行人情况-枚举") +public enum PedestrianStatusTypeEnum { + /** + * 行人情况 + */ + Trespass(1, "擅自进入"), + Traverse(2, "横穿道路"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (PedestrianStatusTypeEnum t : PedestrianStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (PedestrianStatusTypeEnum t : PedestrianStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java index 50da216..c1d9363 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java @@ -22,11 +22,10 @@ public enum RoadBehaviorTypeEnum { /** * 道路异常行为类型 */ - DRIVER(1, "驾驶员行为异常"), - - SPEED(2, "车辆速度异常"), - - VIDEO(3,"道路监控异常"); + DRIVER(1, "驾驶员异常"), + CAR(2, "车辆异常"), + ROAD(3,"道路异常"), + ENVIRONMENT(4,"环境异常"); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java index ec6d0f5..aca8fdc 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java @@ -17,14 +17,14 @@ import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor -@ApiModel(value = "RoadStatusTypeEnum", description = "道路拥堵情况-枚举") +@ApiModel(value = "RoadStatusTypeEnum", description = "道路情况-枚举") public enum RoadStatusTypeEnum { /** * 道路情况 */ - HEAVY(1, "严重拥堵"), - MEDIUM(2, "中度拥堵"), - LIGHT(3, "轻度拥堵"); + Damaged(1, "路面损坏"), + Debris(2, "路面有杂物"), + Slippery(3, "路面湿滑"); diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java new file mode 100644 index 0000000..c6c922c --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java @@ -0,0 +1,70 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "SpeedStatusTypeEnum", description = "车辆速度情况-枚举") +public enum SpeedStatusTypeEnum { + /** + * 车辆速度情况 + */ + Over(1, "超速"), + Low(2, "低速"), + Stop(3, "停车"), + Reverse(4, "逆向行驶"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (SpeedStatusTypeEnum t : SpeedStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (SpeedStatusTypeEnum t : SpeedStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java deleted file mode 100644 index 26f4f2b..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.ningdatech.carapi.road.constant; - -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; - -import io.swagger.annotations.ApiModel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -/** - * @return - * @author CMM - * @since 2022/12/20 14:10 - */ -@Getter -@AllArgsConstructor -@NoArgsConstructor -@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举") -public enum VehicleSpeedAbnormalTypeEnum { - /** - * 车辆速度异常类型 - */ - OVER(1, "超速"), - LOW(2, "低速"), - STOP(3, "停车"), - REVERSE(4, "逆向行驶"); - - - - private Integer code; - private String desc; - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getDescByCode(Integer code) { - if(Objects.isNull(code)){ - return StringUtils.EMPTY; - } - for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) { - if (code.equals(t.getCode())) { - return t.desc; - } - } - return StringUtils.EMPTY; - } - - public static Integer getCodeByDesc(String desc) { - if(StringUtils.isBlank(desc)){ - return null; - } - for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) { - if (desc.equals(t.getDesc())) { - return t.code; - } - } - return null; - } - - public boolean eq(String val) { - return this.name().equals(val); - } -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java new file mode 100644 index 0000000..dc5bcba --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java @@ -0,0 +1,70 @@ +package com.ningdatech.carapi.road.constant; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @return + * @author CMM + * @since 2022/12/20 14:10 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "VehicleStatusTypeEnum", description = "车辆情况-枚举") +public enum VehicleStatusTypeEnum { + /** + * 车辆情况 + */ + Vehicle_Collisions(1, "车辆碰撞"), + Overturn(2, "车辆翻车"), + Smoke_or_Fire(3, "冒烟/起火"), + Dropping(4,"抛洒物品"); + + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (VehicleStatusTypeEnum t : VehicleStatusTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(StringUtils.isBlank(desc)){ + return null; + } + for (VehicleStatusTypeEnum t : VehicleStatusTypeEnum.values()) { + if (desc.equals(t.getDesc())) { + return t.code; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java index 28bb187..8c3d59b 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java @@ -22,11 +22,11 @@ public enum WeatherStatusTypeEnum { /** * 道路情况 */ - FOG(1, "雾天"), - RAIN(2, "雨天"), - SNOW(3, "雪天"), - WIND(4, "大风"), - SANDSTORM(5, "沙尘暴"); + Fog(1, "雾天"), + Rain(2, "雨天"), + Snow(3, "雪天"), + Wind(4, "大风"), + Sandstorm(5, "沙尘暴"); private Integer code; private String desc; 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 5c6405e..a80f855 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,18 +1,23 @@ package com.ningdatech.carapi.road.controller; import com.ningdatech.carapi.road.manage.RoadMonitorManage; +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.log.annotation.WebLog; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ningdatech.carapi.gps.manage.GpsDataPullManage; - import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + /** *

* 前端控制器 @@ -32,7 +37,26 @@ public class RoadMonitorController { @ApiOperation(value = "综合态势数据", notes = "综合态势数据") @GetMapping("/get-comprehensive-situation-data") - public ComprehensiveSituationVO getComSitData() { - return roadMonitorManage.getComSitData(); + public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) { + return roadMonitorManage.getComSitData(req); + } + + @ApiOperation(value = "危险行为数据", notes = "危险行为数据") + @GetMapping("/get-road-danger-behavior-data") + public List getRoadDangerBehaviorData(RoadMonitorReq req) { + return roadMonitorManage.getRoadDangerBehaviorData(req); + } + + @ApiOperation(value = "违法违章与预警记录数据", notes = "违法违章与预警记录列表") + @GetMapping("/get-violation-warn-record-data") + public List getViolationWarnRecordData(RoadMonitorReq req) { + return roadMonitorManage.getViolationWarnRecordData(req); + } + + @GetMapping("/video/download") + @ApiOperation("视频下载") + @WebLog("视频下载") + public void downloadOperationManual(VideoDownloadReq req, HttpServletResponse response){ + roadMonitorManage.videoDownload(req,response); } } 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 010dd41..ba1e5c1 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 @@ -1,18 +1,38 @@ package com.ningdatech.carapi.road.manage; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.ningdatech.cache.model.cache.CacheKey; -import com.ningdatech.cache.repository.CachePlusOps; -import com.ningdatech.carapi.road.constant.RoadStatusTypeEnum; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.carapi.common.contants.DefValConstants; +import com.ningdatech.carapi.road.constant.*; +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; +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.scheduler.contants.TaskContant; +import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO; +import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; + +import cn.hutool.core.collection.CollUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; - -import java.util.Objects; +import redis.clients.jedis.Jedis; /** * @author CMM @@ -23,45 +43,439 @@ import java.util.Objects; @RequiredArgsConstructor public class RoadMonitorManage { - private final CachePlusOps cachePlusOps; + @Value("${spring.redis.host}") + private String redisHost; + + @Value("${spring.redis.port}") + private Integer redisPort; + + @Value("${spring.redis.password}") + private String redisPassword; - public ComprehensiveSituationVO getComSitData() { + private final IRoadBehaviorAnalysisService roadBehaviorAnalysisService; + + public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) { + Jedis jedis = new Jedis(redisHost,redisPort); + jedis.auth(redisPassword); + // 隧道类型 + Integer tunnel = req.getTunnel(); + // 根据传入的隧道类型 实时从缓存中获取算法分析的结果 + // 分区域分别计算4个指标的分值 比例按照1:1:1:1 加权计算道路安全指数 + // 黄山隧道 包含 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向 + if (tunnel == 1){ + List regionList = Lists.newArrayList("1", "2", "3", "4"); + return getCollectDataVo(regionList,jedis,tunnel); + } + // 何里隧道 包含 5 何里隧道兰溪方向、6 何里隧道义乌方向 + else if (tunnel == 2) { + List regionList = Lists.newArrayList("5", "6"); + return getCollectDataVo(regionList,jedis,tunnel); + } + return new ComprehensiveSituationVO(); + } + + private ComprehensiveSituationVO getCollectDataVo(List regionList, Jedis jedis, Integer tunnel) { ComprehensiveSituationVO vo = new ComprehensiveSituationVO(); - // 设置默认值 - vo.setRoadSafetyIndex(100); - vo.setRoadStatus("通畅"); - vo.setWeatherStatus("良好"); - vo.setDangerousActionCount(0); - // 实时从缓存中获取算法分析的结果 - String allData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_ALL_DATA_KEY)); - JSONObject jsonObject = JSON.parseObject(allData); - if (Objects.nonNull(jsonObject)) { - // 道路情况 - String congestion = jsonObject.getString("Congestion"); - RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(congestion); - if (StringUtils.isNotBlank(congestion)){ - switch (roadStatusTypeEnum){ - case HEAVY: - vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.HEAVY.getCode())); + setDefaultScores(vo); + + // 使用Map来存储不同region对应的ComprehensiveSituationVO对象 + Map regionVoMap = new HashMap<>(); + // 初始化所有可能的ComprehensiveSituationVO对象并设置默认值 + ComprehensiveSituationVO hsDyGoVo; + regionVoMap.put("1", hsDyGoVo = new ComprehensiveSituationVO()); + setDefaultScores(hsDyGoVo); + ComprehensiveSituationVO hsDyComeVo; + regionVoMap.put("2", hsDyComeVo = new ComprehensiveSituationVO()); + setDefaultScores(hsDyComeVo); + ComprehensiveSituationVO hsYwGoVo; + regionVoMap.put("3", hsYwGoVo = new ComprehensiveSituationVO()); + setDefaultScores(hsYwGoVo); + ComprehensiveSituationVO hsYwComeVo; + regionVoMap.put("4", hsYwComeVo = new ComprehensiveSituationVO()); + setDefaultScores(hsYwComeVo); + ComprehensiveSituationVO hlLxVo; + regionVoMap.put("5", hlLxVo = new ComprehensiveSituationVO()); + setDefaultScores(hlLxVo); + ComprehensiveSituationVO hlYwVo; + regionVoMap.put("6", hlYwVo = new ComprehensiveSituationVO()); + setDefaultScores(hlYwVo); + + // 遍历regionList获取数据 + for (String region : regionList) { + ComprehensiveSituationVO currentVo = regionVoMap.get(region); + if (currentVo != null) { + switch (region) { + case "1": + getDataVo(TaskConstant.RedisKey.HS_DY_GO_REDIS_ALL_DATA_KEY, currentVo, jedis); break; - case MEDIUM: - vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.MEDIUM.getCode())); + case "2": + getDataVo(TaskConstant.RedisKey.HS_DY_COME_REDIS_ALL_DATA_KEY, currentVo, jedis); break; - case LIGHT: - vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.LIGHT.getCode())); + case "3": + getDataVo(TaskConstant.RedisKey.HS_YW_GO_REDIS_ALL_DATA_KEY, currentVo, jedis); + break; + case "4": + getDataVo(TaskConstant.RedisKey.HS_YW_COME_REDIS_ALL_DATA_KEY, currentVo, jedis); + break; + case "5": + getDataVo(TaskConstant.RedisKey.HL_LX_REDIS_ALL_DATA_KEY, currentVo, jedis); + break; + case "6": + getDataVo(TaskConstant.RedisKey.HL_YW_REDIS_ALL_DATA_KEY, currentVo, jedis); break; - default: - vo.setRoadStatus("良好"); } } - // 天气情况 - String weather = jsonObject.getString("Weather"); + } + // 汇总数据 + if (tunnel == 1) { + List vos = Lists.newArrayList(hsDyGoVo, hsDyComeVo, hsYwGoVo, hsYwComeVo); + vo = averageScores(vos); + } else if (tunnel == 2) { + List vos = Lists.newArrayList(hlLxVo, hlYwVo); + vo = averageScores(vos); + } + return vo; + } - vo.setWeatherStatus(jsonObject.getString("weatherStatus")); - vo.setRoadSafetyIndex(jsonObject.getInteger("roadSafetyIndex")); - vo.setDangerousActionCount(jsonObject.getInteger("dangerousActionCount")); + private ComprehensiveSituationVO averageScores(List vos) { + ComprehensiveSituationVO resultVo = new ComprehensiveSituationVO(); + setDefaultScores(resultVo); + if (CollUtil.isNotEmpty(vos)) { + int roadScore = 0, carScore = 0, driverScore = 0, environmentScore = 0, roadSafetyIndex = 0; + for (ComprehensiveSituationVO vo : vos) { + roadScore += vo.getRoadScore(); + carScore += vo.getCarScore(); + driverScore += vo.getDriverScore(); + environmentScore += vo.getEnvironmentScore(); + roadSafetyIndex += vo.getRoadSafetyIndex(); + } + resultVo.setRoadScore(roadScore / vos.size()); + resultVo.setCarScore(carScore / vos.size()); + resultVo.setDriverScore(driverScore / vos.size()); + resultVo.setEnvironmentScore(environmentScore / vos.size()); + resultVo.setRoadSafetyIndex(roadSafetyIndex / vos.size()); + return resultVo; + } + return resultVo; + } + + private void setDefaultScores(ComprehensiveSituationVO vo) { + vo.setRoadScore(100); + vo.setCarScore(100); + vo.setDriverScore(100); + vo.setEnvironmentScore(100); + vo.setRoadSafetyIndex(100); + } + + private void getDataVo(String dataKey, ComprehensiveSituationVO vo, Jedis jedis) { + String allData = jedis.get(dataKey); + + // 解析获取数据 + JSONObject jsonObject = JSON.parseObject(allData); + if (Objects.nonNull(jsonObject)) { + + JSONArray driver = jsonObject.getJSONArray("Driver"); + JSONArray speed = jsonObject.getJSONArray("Speed"); + JSONArray pedestrian = jsonObject.getJSONArray("Pedestrian"); + JSONArray road = jsonObject.getJSONArray("Road"); + JSONArray congestion = jsonObject.getJSONArray("Congestion"); + JSONArray weather = jsonObject.getJSONArray("Weather"); + JSONArray vehicle = jsonObject.getJSONArray("Vehicle"); + JSONArray bicycle = jsonObject.getJSONArray("Bicycle"); + JSONArray offense = jsonObject.getJSONArray("Offense"); + + String time = jsonObject.getString("Time"); + String region = jsonObject.getString("Region"); + + // 计算道路评分: + // Pedestrian(Trespass -50、Traverse -50)、 + // Road(Damaged -10、Debris -10、Slippery -5)、 + // Congestion(Heavy -20、Medium -10、Light -5)、 + // Bicycle(Bicycle_Collisions -50、Motorway_Intrusion -50) + int roadScore = vo.getRoadScore(); + if (CollUtil.isNotEmpty(pedestrian)){ + for (int i = 0; i < driver.size(); i++) { + String driverString = driver.getString(i); + if (driverString.contains("habits")) { + driverString = "Poor_habits"; + } + DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString); + switch (driverStatusTypeEnum){ + case Fatigue: + case Poor_habits: + roadScore -= 50; + break; + } + } + } + if (CollUtil.isNotEmpty(road)){ + for (int i = 0; i < road.size(); i++) { + String roadString = road.getString(i); + RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(roadString); + switch (roadStatusTypeEnum){ + case Damaged: + roadScore -= 10; + break; + case Debris: + roadScore -= 10; + break; + case Slippery: + roadScore -= 5; + break; + } + } + } + if (CollUtil.isNotEmpty(congestion)){ + for (int i = 0; i < congestion.size(); i++) { + String congestionString = congestion.getString(i); + CongestionStatusTypeEnum congestionStatusTypeEnum = CongestionStatusTypeEnum.valueOf(congestionString); + switch (congestionStatusTypeEnum){ + case Heavy: + roadScore -= 20; + break; + case Medium: + roadScore -= 10; + break; + case Light: + roadScore -= 5; + break; + } + } + } + if (CollUtil.isNotEmpty(bicycle)){ + for (int i = 0; i < bicycle.size(); i++) { + String bicycleString = bicycle.getString(i); + if (bicycleString.contains("Collision")){ + bicycleString = "Bicycle_Collisions"; + } else if (bicycleString.contains("Motorway")) { + bicycleString = "Motorway_Intrusion"; + } + BicycleStatusTypeEnum bicycleStatusTypeEnum = BicycleStatusTypeEnum.valueOf(bicycleString); + switch (bicycleStatusTypeEnum){ + case Bicycle_Collisions: + case Motorway_Intrusion: + roadScore -= 50; + break; + } + } + } + vo.setRoadScore(roadScore); + + // 计算车辆评分 + // Speed(Over -5、Low -5、Stop -20、Reverse -50) + // Vehicle(Vehicle_Collisions -50、Overturn -50、Smoke_or_Fire -50、Dropping -10) + // Offense(Running_a_red_light -10、Crossing_the_line -10) + int carScore = vo.getCarScore(); + if (CollUtil.isNotEmpty(speed)){ + for (int i = 0; i < speed.size(); i++) { + String speedString = speed.getString(i); + SpeedStatusTypeEnum speedStatusTypeEnum = SpeedStatusTypeEnum.valueOf(speedString); + switch (speedStatusTypeEnum){ + case Over: + case Low: + carScore -= 5; + break; + case Stop: + carScore -= 20; + break; + case Reverse: + carScore -= 50; + break; + } + } + } + if (CollUtil.isNotEmpty(vehicle)){ + for (int i = 0; i < vehicle.size(); i++) { + String vehicleString = vehicle.getString(i); + if (vehicleString.contains("Collision")){ + vehicleString = "Vehicle_Collisions"; + } else if (vehicleString.contains("Smoke")) { + vehicleString = "Smoke_or_Fire"; + } + VehicleStatusTypeEnum vehicleStatusTypeEnum = VehicleStatusTypeEnum.valueOf(vehicleString); + switch (vehicleStatusTypeEnum){ + case Vehicle_Collisions: + case Overturn: + case Smoke_or_Fire: + carScore -= 50; + break; + case Dropping: + carScore -= 10; + break; + } + } + } + if (CollUtil.isNotEmpty(offense)){ + for (int i = 0; i < offense.size(); i++) { + String offenseString = offense.getString(i); + if (offenseString.contains("red")){ + offenseString = "Running_a_red_light"; + } else if (offenseString.contains("line")) { + offenseString = "Crossing_the_line"; + } + OffenseStatusTypeEnum offenseStatusTypeEnum = OffenseStatusTypeEnum.valueOf(offenseString); + switch (offenseStatusTypeEnum){ + case Running_a_red_light: + case Crossing_the_line: + carScore -= 10; + break; + } + } + } + vo.setCarScore(carScore); + + // 计算驾驶员评分 + // Driver(Fatigue -5、Poor_habits -5) + int driverScore = vo.getDriverScore(); + if (CollUtil.isNotEmpty(driver)){ + for (int i = 0; i < driver.size(); i++) { + String driverString = driver.getString(i); + if (driverString.contains("habits")) { + driverString = "Poor_habits"; + } + DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString); + switch (driverStatusTypeEnum){ + case Fatigue: + case Poor_habits: + driverScore -= 5; + break; + } + } + } + vo.setDriverScore(driverScore); + + // 计算环境评分 + // Weather(Fog -10、Rain -10、Snow -10、Wind -10、Sandstorm -10) + int environmentScore = vo.getEnvironmentScore(); + if (CollUtil.isNotEmpty(weather)){ + for (int i = 0; i < weather.size(); i++) { + String weatherString = weather.getString(i); + WeatherStatusTypeEnum weatherStatusTypeEnum = WeatherStatusTypeEnum.valueOf(weatherString); + switch (weatherStatusTypeEnum){ + case Fog: + case Rain: + case Snow: + case Wind: + case Sandstorm: + environmentScore -= 10; + break; + } + } + } + vo.setEnvironmentScore(environmentScore); + + // 计算道路安全指数 按照1:1:1:1的比例计算 + int roadSafetyIndex = (roadScore + carScore + driverScore + environmentScore) / 4; + vo.setRoadSafetyIndex(roadSafetyIndex); + } + } + + public List getRoadDangerBehaviorData(RoadMonitorReq req) { + List regionList = req.getRegionList(); + // 从列表中查询数据 + List list = roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class) + .in(RoadBehaviorAnalysis::getRegion, regionList) + .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime)); + if (CollUtil.isEmpty(list)){ + return Collections.emptyList(); + } + return list.stream().map(roadBehaviorAnalysis -> { + RoadDangerBehaviorVO vo = new RoadDangerBehaviorVO(); + vo.setRecord(roadBehaviorAnalysis.getBehavior()); + vo.setRecordCode(roadBehaviorAnalysis.getBehaviorCode()); + vo.setRecordTime(roadBehaviorAnalysis.getBehaviorTime()); + vo.setRecordType(RoadBehaviorTypeEnum.getDescByCode(roadBehaviorAnalysis.getType())); + vo.setRegion(roadBehaviorAnalysis.getRegion()); + vo.setPicturePath(roadBehaviorAnalysis.getPicturePath()); + vo.setVideoPath(roadBehaviorAnalysis.getVideoPath()); + vo.setLatitude(roadBehaviorAnalysis.getLatitude()); + vo.setLongitude(roadBehaviorAnalysis.getLongitude()); + vo.setIsWarn(roadBehaviorAnalysis.getIsWarn()); + vo.setIsHandled(roadBehaviorAnalysis.getIsHandled()); return vo; + }).collect(Collectors.toList()); + } + + public void videoDownload(VideoDownloadReq req, HttpServletResponse response) { + + String videoType = req.getVideoType(); + String videoOrder = req.getVideoOrder(); + + File directory = new File(""); + // 拼接对应的filePath + String filePath = null; + // 设置响应内容类型 + // 对于MP4文件 + response.setContentType("video/mp4"); + // 隧道回放视频 + if (StringUtils.equals("1", videoType)){ + filePath = directory.getAbsolutePath() + File.separator + DefValConstants.SUI_DAO_PLAY_BACK + File.separator + videoOrder + ".mp4"; + } + // 驾驶员监控实时视频 + else if (StringUtils.equals("2", videoType)) { + filePath = directory.getAbsolutePath() + File.separator + DefValConstants.DRIVER_REAL_TIME_PLAY_BACK + File.separator + videoOrder + ".mp4"; + } + // 驾驶员监控远程回放 + else if (StringUtils.equals("3", videoType)) { + filePath = directory.getAbsolutePath() + File.separator + DefValConstants.DRIVER_REMOTE_PLAY_BACK + File.separator + videoOrder + ".mp4"; + } + + assert filePath != null; + File file = new File(filePath); + + // 设置文件名(将显示在下载对话框中) + response.setHeader("Content-Disposition", "inline;"); + // 设置文件大小,这样浏览器可以显示下载进度 + response.setContentLengthLong(file.length()); + + // 设置缓存控制头 + response.setHeader("Cache-Control", "public, max-age=31536000"); + + try { + FileInputStream fileInputStream = new FileInputStream(file); + ServletOutputStream servletOutputStream = response.getOutputStream(); + + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = fileInputStream.read(buffer)) != -1) { + servletOutputStream.write(buffer, 0, bytesRead); + } + fileInputStream.close(); + servletOutputStream.close(); + } catch (IOException e) { + throw new BizException("文件下载失败! {}",e); } - return null; + } + + public List getViolationWarnRecordData(RoadMonitorReq req) { + // 从列表中查询数据 + List list = roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class) + // 不传类型返回所有需预警数据 + .eq(Objects.nonNull(req.getType()), RoadBehaviorAnalysis::getType, req.getType()) + // 所选隧道包含区域 + .in(RoadBehaviorAnalysis::getRegion, req.getRegionList()) + // 需要预警的数据 + .eq(RoadBehaviorAnalysis::getIsWarn, Boolean.TRUE) + // 查看某个具体区域的数据 + .eq(Objects.nonNull(req.getRegion()),RoadBehaviorAnalysis::getRegion, req.getRegion()) + .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime)); + if (CollUtil.isEmpty(list)){ + return Collections.emptyList(); + } + return list.stream().map(roadBehaviorAnalysis -> { + RoadDangerBehaviorVO vo = new RoadDangerBehaviorVO(); + vo.setRecord(roadBehaviorAnalysis.getBehavior()); + vo.setRecordCode(roadBehaviorAnalysis.getBehaviorCode()); + vo.setRecordTime(roadBehaviorAnalysis.getBehaviorTime()); + vo.setRecordType(RoadBehaviorTypeEnum.getDescByCode(roadBehaviorAnalysis.getType())); + vo.setRegion(roadBehaviorAnalysis.getRegion()); + vo.setPicturePath(roadBehaviorAnalysis.getPicturePath()); + vo.setVideoPath(roadBehaviorAnalysis.getVideoPath()); + vo.setLatitude(roadBehaviorAnalysis.getLatitude()); + vo.setLongitude(roadBehaviorAnalysis.getLongitude()); + vo.setIsWarn(roadBehaviorAnalysis.getIsWarn()); + vo.setIsHandled(roadBehaviorAnalysis.getIsHandled()); + return vo; + }).collect(Collectors.toList()); } } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java new file mode 100644 index 0000000..3fe96fe --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.carapi.road.mapper; + +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author CMM + * @since 2024-10-22 + */ +public interface RoadBehaviorAnalysisMapper extends BaseMapper { + +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml new file mode 100644 index 0000000..33857fb --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java new file mode 100644 index 0000000..5636074 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java @@ -0,0 +1,69 @@ +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 java.io.Serializable; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author CMM + * @since 2024-10-22 + */ +@TableName("nd_road_behavior_analysis") +@ApiModel(value = "RoadBehaviorAnalysis对象", description = "") +@Data +public class RoadBehaviorAnalysis implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty("异常行为类型 1 驾驶员异常 2 车辆异常 3 道路异常 4 环境异常") + private Integer type; + + @ApiModelProperty("异常行为描述") + private String behavior; + + @ApiModelProperty("异常行为码") + private String behaviorCode; + + @ApiModelProperty("异常行为时间") + private LocalDateTime behaviorTime; + + @ApiModelProperty("区域 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向、5 何里隧道兰溪方向、6 何里隧道义乌方向") + private String region; + + @ApiModelProperty("异常记录图片路径") + private String picturePath; + + @ApiModelProperty("异常记录视频路径") + private String videoPath; + + @ApiModelProperty("异常记录经度") + private String longitude; + + @ApiModelProperty("异常记录纬度") + private String latitude; + + @ApiModelProperty("是否需要预警") + private Boolean isWarn = Boolean.FALSE; + + @ApiModelProperty("是否处理") + private Boolean isHandled = Boolean.FALSE; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("更新时间") + private LocalDateTime updateTime; +} 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 new file mode 100644 index 0000000..4b449dc --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java @@ -0,0 +1,33 @@ +package com.ningdatech.carapi.road.model.req; + +import java.util.List; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; + +/** + * @author CMM + * @author CMM + * @date 2024/10/23 17:53 + * / + * /** + * @since 2024/10/23 17:53 + */ +@Data +public class RoadMonitorReq { + + @ApiModelProperty("区域 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向、5 何里隧道兰溪方向、6 何里隧道义乌方向") + private String region; + + @ApiModelProperty("隧道 1 黄山隧道、2 何里隧道") + private Integer tunnel; + + @ApiModelProperty("隧道包含的区域 列表") + @NotEmpty(message = "区域不能为空") + private List regionList; + + @ApiModelProperty("行为类型 1 驾驶员、2 车辆、3 道路、4 环境") + private Integer type; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java new file mode 100644 index 0000000..9acd872 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java @@ -0,0 +1,24 @@ +package com.ningdatech.carapi.road.model.req; + +import javax.validation.constraints.NotBlank; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author CMM + * @author CMM + * @date 2024/10/23 17:53 + * / + * /** + * @since 2024/10/23 17:53 + */ +@Data +public class VideoDownloadReq { + + @ApiModelProperty("1 隧道回放 2 驾驶员监控实时视频 3 驾驶员监控") + private String videoType; + + @ApiModelProperty("1 2 3 4 5 6") + private String videoOrder; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java index 69d760a..693d789 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java @@ -19,12 +19,15 @@ public class ComprehensiveSituationVO { @ApiModelProperty("道路安全指数") private Integer roadSafetyIndex; - @ApiModelProperty("当前道路情况") - private String roadStatus; + @ApiModelProperty("道路评分") + private Integer roadScore; - @ApiModelProperty("当前天气情况") - private String weatherStatus; + @ApiModelProperty("车辆评分") + private Integer carScore; - @ApiModelProperty("当前危险行为统计") - private Integer dangerousActionCount; + @ApiModelProperty("驾驶员评分") + private Integer driverScore; + + @ApiModelProperty("环境评分") + private Integer environmentScore; } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java new file mode 100644 index 0000000..3f9f96a --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java @@ -0,0 +1,53 @@ +package com.ningdatech.carapi.road.model.vo; + +import java.time.LocalDateTime; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author CMM + * @since 2024/10/23 10:49 + */ +@Data +@ApiModel(description = "道路安全监综合态势计数据-VO") +@NoArgsConstructor +@AllArgsConstructor +public class RoadDangerBehaviorVO { + + @ApiModelProperty("道路异常分析记录") + private String record; + + @ApiModelProperty("道路异常分析记录Code") + private String recordCode; + + @ApiModelProperty("道路异常分析类型") + private String recordType; + + @ApiModelProperty("异常记录时间") + private LocalDateTime recordTime; + + @ApiModelProperty("异常记录区域") + private String region; + + @ApiModelProperty("异常记录图片路径") + private String picturePath; + + @ApiModelProperty("异常记录视频路径") + private String videoPath; + + @ApiModelProperty("异常记录经度") + private String longitude; + + @ApiModelProperty("异常记录纬度") + private String latitude; + + @ApiModelProperty("是否需要预警") + private Boolean isWarn = Boolean.FALSE; + + @ApiModelProperty("是否处理") + private Boolean isHandled = Boolean.FALSE; +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java new file mode 100644 index 0000000..6c8e614 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java @@ -0,0 +1,16 @@ +package com.ningdatech.carapi.road.service; + +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author CMM + * @since 2024-10-22 + */ +public interface IRoadBehaviorAnalysisService extends IService { + +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java new file mode 100644 index 0000000..6e44ebc --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.carapi.road.service.impl; + +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; +import com.ningdatech.carapi.road.mapper.RoadBehaviorAnalysisMapper; +import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author CMM + * @since 2024-10-22 + */ +@Service +public class RoadBehaviorAnalysisServiceImpl extends ServiceImpl implements IRoadBehaviorAnalysisService { + +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java new file mode 100644 index 0000000..d191d92 --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java @@ -0,0 +1,476 @@ +package com.ningdatech.carapi.road.task; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import cn.hutool.core.map.MapUtil; +import com.ningdatech.basic.util.StrPool; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.carapi.road.constant.*; +import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis; +import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.date.StopWatch; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import redis.clients.jedis.Jedis; + +/** + * @author CMM + * 道路监控实时算法分析数据拉取定时任务 + * @since 2024/10/12 10:39 + */ +@Component +@Slf4j +@RequiredArgsConstructor +public class RoadMonitorDataPullTask { + + @Value("${spring.redis.host}") + private String redisHost; + + @Value("${spring.redis.port}") + private Integer redisPort; + + @Value("${spring.redis.password}") + private String redisPassword; + + @Value("${task.switch.is-open}") + private boolean flag; + + private final IRoadBehaviorAnalysisService roadBehaviorAnalysisService; + + // 定时更新道路监控实时算法分析数据 每10分钟一次 + @Scheduled(cron = "0 */10 * * * ?") + public void doTask() { + if (!flag){ + log.info("道路监控实时算法分析数据拉取定时任务未开启!"); + return; + } + log.info("=========== 道路监控实时算法分析数据拉取 ======== 任务开始"); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + List dataList; + Map REDIS_KEY_REGION_MAP = getRedisKeyRegionMap(); + try (Jedis jedis = new Jedis(redisHost, redisPort)) { + jedis.auth(redisPassword); + dataList = REDIS_KEY_REGION_MAP.keySet().stream().map(jedis::get) + .filter(StringUtils::isNotBlank) + .collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(dataList)) { + for (String data : dataList) { + // 解析获取数据 + JSONObject jsonObject = JSON.parseObject(data); + String time = jsonObject.getString("Time"); + String region = jsonObject.getString("Region"); + + // 转换为LocalDateTime类型 + LocalDateTime createTime = LocalDateTimeUtil.parse(time, NdDateUtils.DEFAULT_DATE_TIME_FORMAT); + + // 根据时间 判断数据库中是否存在 不存在 入库 + // 获取当前区域当前数据产生时间 在数据库中是否存入过 + List list = checkDataExists(createTime, region); + + // 如果没有存入过 + if (CollUtil.isEmpty(list)) { + List saveDataList = assembleData(jsonObject); + if (CollUtil.isNotEmpty(saveDataList)){ + log.info("=========== 保存数据条数:{}",saveDataList.size()); + roadBehaviorAnalysisService.saveBatch(saveDataList); + log.info("=========== 保存成功"); + } + } + } + } + stopWatch.stop(); + log.info("=========== 道路监控实时算法分析数据拉取 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds()); + } + + @FunctionalInterface + interface DataAssembler { + void assemble(JSONArray dataArray, List saveDataList, JSONObject jsonObject); + } + private List assembleData(JSONObject jsonObject) { + List saveDataList = Lists.newArrayList(); + // 定义一个映射,关联JSON数组的键和对应的数据处理方法 + Map assemblerMap = new HashMap<>(); + assemblerMap.put("Driver", this::assemblyDriverData); + assemblerMap.put("Speed", this::assemblySpeedData); + assemblerMap.put("Pedestrian", this::assemblyPedestrianData); + assemblerMap.put("Road", this::assemblyRoadData); + assemblerMap.put("Congestion", this::assemblyCongestionData); + assemblerMap.put("Weather", this::assemblyWeatherData); + assemblerMap.put("Vehicle", this::assemblyVehicleData); + assemblerMap.put("Bicycle", this::assemblyBicycleData); + assemblerMap.put("Offense", this::assemblyOffenseData); + // 遍历映射,处理每个数据集 + assemblerMap.forEach((key, assembler) -> { + JSONArray dataArray = jsonObject.getJSONArray(key); + if (dataArray != null && !dataArray.isEmpty()) { + assembler.assemble(dataArray, saveDataList, jsonObject); + } + }); + return saveDataList; + } + + private List checkDataExists(LocalDateTime createTime, String region) { + return roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class) + .eq(RoadBehaviorAnalysis::getBehaviorTime, createTime) + .eq(RoadBehaviorAnalysis::getRegion, region)); + } + + private static Map getRedisKeyRegionMap() { + Map REDIS_KEY_REGION_MAP = MapUtil.newHashMap(); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_DY_GO_REDIS_ALL_DATA_KEY, "1"); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_DY_COME_REDIS_ALL_DATA_KEY, "2"); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_YW_GO_REDIS_ALL_DATA_KEY, "3"); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_YW_COME_REDIS_ALL_DATA_KEY, "4"); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HL_LX_REDIS_ALL_DATA_KEY, "5"); + REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HL_YW_REDIS_ALL_DATA_KEY, "6"); + return REDIS_KEY_REGION_MAP; + } + + /** + * 车辆违章情况 + * @param offense \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyOffenseData(JSONArray offense, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < offense.size(); i++) { + String offenseString = offense.getString(i); + if (offenseString.contains("red")){ + offenseString = "Running_a_red_light"; + } else if (offenseString.contains("line")) { + offenseString = "Crossing_the_line"; + } + OffenseStatusTypeEnum offenseStatusTypeEnum = OffenseStatusTypeEnum.valueOf(offenseString); + behaviorBuilder.append(offenseStatusTypeEnum.getDesc()); + if (i != offense.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(offenseStatusTypeEnum.name()); + if (i != offense.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 自行车情况 + * @param bicycle \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyBicycleData(JSONArray bicycle, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < bicycle.size(); i++) { + String bicycleString = bicycle.getString(i); + if (bicycleString.contains("Collision")){ + bicycleString = "Bicycle_Collisions"; + } else if (bicycleString.contains("Motorway")) { + bicycleString = "Motorway_Intrusion"; + } + BicycleStatusTypeEnum bicycleStatusTypeEnum = BicycleStatusTypeEnum.valueOf(bicycleString); + behaviorBuilder.append(bicycleStatusTypeEnum.getDesc()); + if (i != bicycle.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(bicycleStatusTypeEnum.name()); + if (i != bicycle.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 车辆情况 + * @param vehicle \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyVehicleData(JSONArray vehicle, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < vehicle.size(); i++) { + String vehicleString = vehicle.getString(i); + if (vehicleString.contains("Collision")){ + vehicleString = "Vehicle_Collisions"; + } else if (vehicleString.contains("Smoke")) { + vehicleString = "Smoke_or_Fire"; + } + VehicleStatusTypeEnum vehicleStatusTypeEnum = VehicleStatusTypeEnum.valueOf(vehicleString); + behaviorBuilder.append(vehicleStatusTypeEnum.getDesc()); + if (i != vehicle.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(vehicleStatusTypeEnum.name()); + if (i != vehicle.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 天气情况 + * @param weather \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyWeatherData(JSONArray weather, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < weather.size(); i++) { + String weatherString = weather.getString(i); + WeatherStatusTypeEnum weatherStatusTypeEnum = WeatherStatusTypeEnum.valueOf(weatherString); + behaviorBuilder.append(weatherStatusTypeEnum.getDesc()); + if (i != weather.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(weatherStatusTypeEnum.name()); + if (i != weather.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ENVIRONMENT.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 拥堵情况 + * @param congestion \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyCongestionData(JSONArray congestion, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < congestion.size(); i++) { + String congestionString = congestion.getString(i); + CongestionStatusTypeEnum congestionStatusTypeEnum = CongestionStatusTypeEnum.valueOf(congestionString); + behaviorBuilder.append(congestionStatusTypeEnum.getDesc()); + if (i != congestion.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(congestionStatusTypeEnum.name()); + if (i != congestion.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 道路情况 + * @param road \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyRoadData(JSONArray road, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < road.size(); i++) { + String roadString = road.getString(i); + RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(roadString); + behaviorBuilder.append(roadStatusTypeEnum.getDesc()); + if (i != road.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(roadStatusTypeEnum.name()); + if (i != road.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(),jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 行人情况 + * @param pedestrian \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyPedestrianData(JSONArray pedestrian, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < pedestrian.size(); i++) { + String pedestrianString = pedestrian.getString(i); + PedestrianStatusTypeEnum pedestrianStatusTypeEnum = PedestrianStatusTypeEnum.valueOf(pedestrianString); + behaviorBuilder.append(pedestrianStatusTypeEnum.getDesc()); + if (i != pedestrian.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(pedestrianStatusTypeEnum.name()); + if (i != pedestrian.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + private RoadBehaviorAnalysis getRoadBehaviorAnalysis(StringBuilder behaviorBuilder, StringBuilder behaviorCodeBuilder, int type, JSONObject jsonObject) { + String behavior = behaviorBuilder.toString(); + String behaviorCode = behaviorCodeBuilder.toString(); + + String time = jsonObject.getString("Time"); + String region = jsonObject.getString("Region"); + + JSONArray pictures = jsonObject.getJSONArray("PicturePath"); + String picturePath = null; + if (Objects.nonNull(pictures) && CollUtil.isNotEmpty(pictures)) { + picturePath = pictures.getString(0); + } + JSONArray videos = jsonObject.getJSONArray("VideoPath"); + String videoPath = null; + if (Objects.nonNull(videos) && CollUtil.isNotEmpty(videos)) { + videoPath = videos.getString(0); + } + JSONArray longitudes = jsonObject.getJSONArray("Longitude"); + String longitude = null; + if (Objects.nonNull(longitudes) && CollUtil.isNotEmpty(longitudes)){ + longitude = longitudes.getString(0); + } + JSONArray latitudes = jsonObject.getJSONArray("Latitude"); + String latitude = null; + if (Objects.nonNull(latitudes) && CollUtil.isNotEmpty(latitudes)){ + latitude = latitudes.getString(0); + } + + // 转换为LocalDateTime类型 + LocalDateTime createTime = LocalDateTimeUtil.parse(time, NdDateUtils.DEFAULT_DATE_TIME_FORMAT); + + RoadBehaviorAnalysis roadBehaviorAnalysis = new RoadBehaviorAnalysis(); + roadBehaviorAnalysis.setBehavior(behavior); + roadBehaviorAnalysis.setBehaviorCode(behaviorCode); + roadBehaviorAnalysis.setBehaviorTime(createTime); + roadBehaviorAnalysis.setCreateTime(LocalDateTime.now()); + roadBehaviorAnalysis.setUpdateTime(LocalDateTime.now()); + roadBehaviorAnalysis.setRegion(region); + roadBehaviorAnalysis.setType(type); + roadBehaviorAnalysis.setPicturePath(picturePath); + roadBehaviorAnalysis.setVideoPath(videoPath); + roadBehaviorAnalysis.setLongitude(longitude); + roadBehaviorAnalysis.setLatitude(latitude); + roadBehaviorAnalysis.setIsWarn(judgeIsWarn(behaviorCode)); + // 首次保存的数据默认未处理 + roadBehaviorAnalysis.setIsHandled(Boolean.FALSE); + return roadBehaviorAnalysis; + } + + /** + * 判断是否需要预警 + * @param behaviorCode + * @return + */ + private Boolean judgeIsWarn(String behaviorCode) { + // 获取需要预警的behaviorCode + List needWarnBehaviorCodeList = getNeedWarnBehaviorCode(); + if (StringUtils.isNotBlank(behaviorCode)){ + List behaviorCodeList = Arrays.stream(behaviorCode.split(StrPool.COMMA)).collect(Collectors.toList()); + // 判断是否包含需要预警的behaviorCode + return behaviorCodeList.stream().anyMatch(needWarnBehaviorCodeList::contains); + } + return Boolean.FALSE; + } + + private List getNeedWarnBehaviorCode() { + List dataList = Lists.newArrayList(); + // Speed-->Reverse + dataList.add(SpeedStatusTypeEnum.Reverse.name()); + // Pedestrian-->Trespass、Traverse + dataList.add(PedestrianStatusTypeEnum.Trespass.name()); + dataList.add(PedestrianStatusTypeEnum.Traverse.name()); + // Road-->Damaged + dataList.add(RoadStatusTypeEnum.Damaged.name()); + // Congestion-->Heavy + dataList.add(CongestionStatusTypeEnum.Heavy.name()); + // Vehicle-->Vehicle_Collisions、Overturn、Smoke_or_Fire + dataList.add(VehicleStatusTypeEnum.Vehicle_Collisions.name()); + dataList.add(VehicleStatusTypeEnum.Overturn.name()); + dataList.add(VehicleStatusTypeEnum.Smoke_or_Fire.name()); + // Bicycle-->Bicycle_Collisions、Motorway_Intrusion + dataList.add(BicycleStatusTypeEnum.Bicycle_Collisions.name()); + dataList.add(BicycleStatusTypeEnum.Motorway_Intrusion.name()); + return dataList; + } + + /** + * 保存车辆速度异常数据 + * @param speed \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblySpeedData(JSONArray speed, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < speed.size(); i++) { + String speedString = speed.getString(i); + SpeedStatusTypeEnum speedStatusTypeEnum = SpeedStatusTypeEnum.valueOf(speedString); + behaviorBuilder.append(speedStatusTypeEnum.getDesc()); + if (i != speed.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(speedStatusTypeEnum.name()); + if (i != speed.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } + + /** + * 保存驾驶员异常行为数据 + * @param driver \ + * @param saveDataList \ + * @param jsonObject \ + */ + private void assemblyDriverData(JSONArray driver, List saveDataList, JSONObject jsonObject) { + StringBuilder behaviorBuilder = new StringBuilder(); + StringBuilder behaviorCodeBuilder = new StringBuilder(); + for (int i = 0; i < driver.size(); i++) { + String driverString = driver.getString(i); + if (driverString.contains("habits")) { + driverString = "Poor_habits"; + } + DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString); + behaviorBuilder.append(driverStatusTypeEnum.getDesc()); + if (i != driver.size() - 1) { + behaviorBuilder.append(","); + } + behaviorCodeBuilder.append(driverStatusTypeEnum.name()); + if (i != driver.size() - 1) { + behaviorCodeBuilder.append(","); + } + } + RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.DRIVER.getCode(),jsonObject); + saveDataList.add(roadBehaviorAnalysis); + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java new file mode 100644 index 0000000..3db2b2b --- /dev/null +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java @@ -0,0 +1,157 @@ +package com.ningdatech.carapi.scheduler.contants; + +import java.math.BigDecimal; + +/** + * @author PoffyZhang + * @Classname TaskContant + * @Description + * @Date 2022/12/7 11:00 + */ +public interface TaskConstant { + class Host { + public static final String HOST_ZPF = "LAPTOP-NQGEQP03"; + public static final String HOST_CMM2 = "DESKTOP-KN1L6HL"; + public static final String HOST_CMM = "LAPTOP-PCISPN2O"; + + public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ"; + } + + class DataField { + + public static final String GPS = "GPS"; + + public static final String ADAS = "ADAS"; + public static final String ROAD_SIGN_TYPE = "roadSignType"; + public static final String ROAD_SIGN_DATA = "roadSignData"; + public static final String LONGITUDE = "longitude"; + + public static final String LATITUDE = "latitude"; + } + + class Data{ + public static final Integer ROAD_SIGN_TYPE_OVERSPEED = 1; + public static final Integer STAR_NUMBER_RANGE_ZERO = 0; + public static final Integer STAR_NUMBER_RANGE_TWENTY = 20; + public static final Integer STAR_NUMBER_RANGE_FORTY = 40; + public static final Integer STAR_NUMBER_RANGE_SIXTY = 60; + public static final Integer STAR_NUMBER_RANGE_EIGHTY = 80; + + public static final Integer DRIVER_STAR_DATA_CNT_ONE = 1; + + public static final Integer OPERATOR_ASSESSMENT_SCORE_ZERO = 0; + public static final Integer OPERATOR_ASSESSMENT_SCORE_HUNDRED = 100; + + public static final Integer MONTH_VALUE_ONE = 1; + public static final Integer MONTH_VALUE_TWO = 2; + public static final Integer MONTH_VALUE_THREE = 3; + public static final Integer MONTH_VALUE_FOUR = 4; + public static final Integer MONTH_VALUE_FIVE = 5; + public static final Integer MONTH_VALUE_SIX = 6; + public static final Integer MONTH_VALUE_SEVEN = 7; + public static final Integer MONTH_VALUE_EIGHT = 8; + public static final Integer MONTH_VALUE_NINE = 9; + public static final Integer MONTH_VALUE_TEN = 10; + public static final Integer MONTH_VALUE_ELEVEN = 11; + public static final Integer MONTH_VALUE_TWELVE = 12; + + public static final Integer SUB_LIST_SIZE = 2000; + public static final Integer VIOLATION_TIME_SEVEN = 7; + public static final Integer VIOLATION_TIME_NINE = 9; + public static final Integer VIOLATION_TIME_SIXTEEN = 16; + public static final Integer VIOLATION_TIME_EIGHTEEN = 18; + public static final String VIOLATION_TIME_AM_START = "7:00"; + public static final String VIOLATION_TIME_AM_END = "9:00"; + public static final String VIOLATION_TIME_PM_START = "16:30"; + public static final String VIOLATION_TIME_PM_END = "18:30"; + public static final String VIOLATION_TIME_HALF = ":30"; + public static final String VIOLATION_TIME_START = ":00"; + public static final Integer GPS_TIME_BUCKET = 5; + + } + + class RedisKey { + public static final String OVERSPEED_TASK_LOCK = "cm:task:overspeed:task_lock"; + + public static final String OVERSPEED_ALARM_DATA_INDEX = "cm:task:overspeed:alarm_data_index"; + public static final String OVERSPEED_GPS_DATA_INDEX = "cm:task:overspeed:gps_data_index"; + + public static final String DRIVER_STAR_MANAGE_OUT_DANGER = "cm:task:driver:star_manage_out_danger_index"; + + public static final String DRIVER_BLACK_LIST = "cm:task:driver:black_list_index"; + + public static final String COMPANY_VEHICLE_NOT_GET_ON = "cm:task:company:not_get_on_index"; + + public static final String DRIVER_STAR_MANAGE_ACCIDENT = "cm:task:driver:star_manage_accident_index"; + + public static final String DRIVER_STAR_MANAGE_DEATH_ACCIDENT = "cm:task:driver:star_manage_death_accident_index"; + + public static final String DRIVER_ABNORMAL_BEHAVIOR_ANALYSIS = "cm:task:driver:driver_abnormal_behavior_analysis_index"; + + public static final String VEHICLE_ALARM_DATA_INDEX = "cm:task:vehicle:alarm_data_index"; + + public static final String OPERATOR_ASSESSMENT_SCORE = "cm:task:operator:operator_assessment_score_index"; + public static final String ACCIDENT_QUERY_IRS = "cm:task:irs:accident_query_irs_index"; + public static final String VEHICLE_ILLEGAL_QUERY_IRS = "cm:task:irs:vehicle_illegal_query_irs_index"; + public static final String DRIVING_LICENCE_IRS = "cm:task:irs:driving_license_irs_index"; + public static final String VEHICLE_LICENSE_IRS = "cm:task:irs:vehicle_license_irs_index"; + public static final String IRS_VEHICLE_ILLEGAL_REQUEST_SECRET = "cm:task:irs:irs_vehicle_illegal_request_secret_index"; + public static final String IRS_VEHICLE_ILLEGAL_REFRESH_SECRET = "cm:task:irs:irs_vehicle_illegal_refresh_secret_index"; + public static final String IRS_VEHICLE_LICENSE_REQUEST_SECRET = "cm:task:irs:irs_vehicle_license_request_secret_index"; + public static final String IRS_VEHICLE_LICENSE_REFRESH_SECRET = "cm:task:irs:irs_vehicle_license_refresh_secret_index"; + public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET = "cm:task:irs:irs_accident_query_request_secret_index"; + public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET = "cm:task:irs:irs_accident_query_refresh_secret_index"; + public static final String IRS_ACCIDENT_DUTY_REQUEST_SECRET = "cm:task:irs:irs_accident_duty_request_secret_index"; + public static final String IRS_ACCIDENT_DUTY_REFRESH_SECRET = "cm:task:irs:irs_accident_duty_refresh_secret_index"; + + public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET_TEST = "cm:task:irs:irs_accident_query_request_secret_test_index"; + public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET_TEST = "cm:task:irs:irs_accident_query_refresh_secret_test_index"; + + public static final Integer IRS_SECRET_TIME_INTERVAL = 10; + + public static final String GPS_DATA_PULL_MAX_BIZ_ID = "cm:task:gps:gps_data_pull_max_biz_id"; + + // 黄山隧道东阳去向 + public static final String HS_DY_GO_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_dy_go_all_data_key"; + // 黄山隧道东阳来向 + public static final String HS_DY_COME_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_dy_come_all_data_key"; + // 黄山隧道义乌去向 + public static final String HS_YW_GO_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_yw_go_all_data_key"; + // 黄山隧道义乌来向 + public static final String HS_YW_COME_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_yw_come_all_data_key"; + // 何里隧道兰溪方向 + public static final String HL_LX_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hl_lx_all_data_key"; + // 何里隧道义乌方向 + public static final String HL_YW_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hl_yw_all_data_key"; + } + + class Math { + public static final BigDecimal LONGITUDE_UNITS = BigDecimal.valueOf(1000000); + + public static final BigDecimal SPEED_UNITS = BigDecimal.valueOf(0.036); + + public static final BigDecimal ALTITUDE_UNITS = BigDecimal.valueOf(100); + + public static final BigDecimal DIRECTION_UNITS = BigDecimal.valueOf(10); + } + + + class Msg { + public static final String REDIS_KEY_NOT_FOUND = "redis key {} not found 请查找原因!"; + public static final String REFRESH_KEY_FREQUENTLY = "请求过于频繁,请稍候再试"; + } + + class Code { + public static final String REFRESH_KEY_FREQUENTLY_CODE = "88"; + } + + class Star{ + public static final Double ONE_STAR = 1.0; + public static final Double TWO_STAR = 2.0; + public static final Double THREE_STAR = 3.0; + public static final Double FOUR_STAR = 4.0; + public static final Double FIVE_STAR = 5.0; + + + } +} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java deleted file mode 100644 index 86f6591..0000000 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.ningdatech.carapi.scheduler.contants; - -import java.math.BigDecimal; - -/** - * @author PoffyZhang - * @Classname TaskContant - * @Description - * @Date 2022/12/7 11:00 - */ -public interface TaskContant { - class Host { - public static final String HOST_ZPF = "LAPTOP-NQGEQP03"; - public static final String HOST_CMM2 = "DESKTOP-KN1L6HL"; - public static final String HOST_CMM = "LAPTOP-PCISPN2O"; - - public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ"; - } - - class DataField { - - public static final String GPS = "GPS"; - - public static final String ADAS = "ADAS"; - public static final String ROAD_SIGN_TYPE = "roadSignType"; - public static final String ROAD_SIGN_DATA = "roadSignData"; - public static final String LONGITUDE = "longitude"; - - public static final String LATITUDE = "latitude"; - } - - class Data{ - public static final Integer ROAD_SIGN_TYPE_OVERSPEED = 1; - public static final Integer STAR_NUMBER_RANGE_ZERO = 0; - public static final Integer STAR_NUMBER_RANGE_TWENTY = 20; - public static final Integer STAR_NUMBER_RANGE_FORTY = 40; - public static final Integer STAR_NUMBER_RANGE_SIXTY = 60; - public static final Integer STAR_NUMBER_RANGE_EIGHTY = 80; - - public static final Integer DRIVER_STAR_DATA_CNT_ONE = 1; - - public static final Integer OPERATOR_ASSESSMENT_SCORE_ZERO = 0; - public static final Integer OPERATOR_ASSESSMENT_SCORE_HUNDRED = 100; - - public static final Integer MONTH_VALUE_ONE = 1; - public static final Integer MONTH_VALUE_TWO = 2; - public static final Integer MONTH_VALUE_THREE = 3; - public static final Integer MONTH_VALUE_FOUR = 4; - public static final Integer MONTH_VALUE_FIVE = 5; - public static final Integer MONTH_VALUE_SIX = 6; - public static final Integer MONTH_VALUE_SEVEN = 7; - public static final Integer MONTH_VALUE_EIGHT = 8; - public static final Integer MONTH_VALUE_NINE = 9; - public static final Integer MONTH_VALUE_TEN = 10; - public static final Integer MONTH_VALUE_ELEVEN = 11; - public static final Integer MONTH_VALUE_TWELVE = 12; - - public static final Integer SUB_LIST_SIZE = 2000; - public static final Integer VIOLATION_TIME_SEVEN = 7; - public static final Integer VIOLATION_TIME_NINE = 9; - public static final Integer VIOLATION_TIME_SIXTEEN = 16; - public static final Integer VIOLATION_TIME_EIGHTEEN = 18; - public static final String VIOLATION_TIME_AM_START = "7:00"; - public static final String VIOLATION_TIME_AM_END = "9:00"; - public static final String VIOLATION_TIME_PM_START = "16:30"; - public static final String VIOLATION_TIME_PM_END = "18:30"; - public static final String VIOLATION_TIME_HALF = ":30"; - public static final String VIOLATION_TIME_START = ":00"; - public static final Integer GPS_TIME_BUCKET = 5; - - } - - class RedisKey { - public static final String OVERSPEED_TASK_LOCK = "cm:task:overspeed:task_lock"; - - public static final String OVERSPEED_ALARM_DATA_INDEX = "cm:task:overspeed:alarm_data_index"; - public static final String OVERSPEED_GPS_DATA_INDEX = "cm:task:overspeed:gps_data_index"; - - public static final String DRIVER_STAR_MANAGE_OUT_DANGER = "cm:task:driver:star_manage_out_danger_index"; - - public static final String DRIVER_BLACK_LIST = "cm:task:driver:black_list_index"; - - public static final String COMPANY_VEHICLE_NOT_GET_ON = "cm:task:company:not_get_on_index"; - - public static final String DRIVER_STAR_MANAGE_ACCIDENT = "cm:task:driver:star_manage_accident_index"; - - public static final String DRIVER_STAR_MANAGE_DEATH_ACCIDENT = "cm:task:driver:star_manage_death_accident_index"; - - public static final String DRIVER_ABNORMAL_BEHAVIOR_ANALYSIS = "cm:task:driver:driver_abnormal_behavior_analysis_index"; - - public static final String VEHICLE_ALARM_DATA_INDEX = "cm:task:vehicle:alarm_data_index"; - - public static final String OPERATOR_ASSESSMENT_SCORE = "cm:task:operator:operator_assessment_score_index"; - public static final String ACCIDENT_QUERY_IRS = "cm:task:irs:accident_query_irs_index"; - public static final String VEHICLE_ILLEGAL_QUERY_IRS = "cm:task:irs:vehicle_illegal_query_irs_index"; - public static final String DRIVING_LICENCE_IRS = "cm:task:irs:driving_license_irs_index"; - public static final String VEHICLE_LICENSE_IRS = "cm:task:irs:vehicle_license_irs_index"; - public static final String IRS_VEHICLE_ILLEGAL_REQUEST_SECRET = "cm:task:irs:irs_vehicle_illegal_request_secret_index"; - public static final String IRS_VEHICLE_ILLEGAL_REFRESH_SECRET = "cm:task:irs:irs_vehicle_illegal_refresh_secret_index"; - public static final String IRS_VEHICLE_LICENSE_REQUEST_SECRET = "cm:task:irs:irs_vehicle_license_request_secret_index"; - public static final String IRS_VEHICLE_LICENSE_REFRESH_SECRET = "cm:task:irs:irs_vehicle_license_refresh_secret_index"; - public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET = "cm:task:irs:irs_accident_query_request_secret_index"; - public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET = "cm:task:irs:irs_accident_query_refresh_secret_index"; - public static final String IRS_ACCIDENT_DUTY_REQUEST_SECRET = "cm:task:irs:irs_accident_duty_request_secret_index"; - public static final String IRS_ACCIDENT_DUTY_REFRESH_SECRET = "cm:task:irs:irs_accident_duty_refresh_secret_index"; - - public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET_TEST = "cm:task:irs:irs_accident_query_request_secret_test_index"; - public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET_TEST = "cm:task:irs:irs_accident_query_refresh_secret_test_index"; - - public static final Integer IRS_SECRET_TIME_INTERVAL = 10; - - public static final String GPS_DATA_PULL_MAX_BIZ_ID = "cm:task:gps:gps_data_pull_max_biz_id"; - - public static final String ALGORITHM_REDIS_DRIVER_DATA_KEY = "yw:algorithm:redis:driver_data_key"; - public static final String ALGORITHM_REDIS_VEHICLE_DATA_KEY = "yw:algorithm:redis:vehicle_data_key"; - public static final String ALGORITHM_REDIS_VIDEO_DATA_KEY = "yw:algorithm:redis:video_data_key"; - public static final String ALGORITHM_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:all_data_key"; - - - } - - class Math { - public static final BigDecimal LONGITUDE_UNITS = BigDecimal.valueOf(1000000); - - public static final BigDecimal SPEED_UNITS = BigDecimal.valueOf(0.036); - - public static final BigDecimal ALTITUDE_UNITS = BigDecimal.valueOf(100); - - public static final BigDecimal DIRECTION_UNITS = BigDecimal.valueOf(10); - } - - - class Msg { - public static final String REDIS_KEY_NOT_FOUND = "redis key {} not found 请查找原因!"; - public static final String REFRESH_KEY_FREQUENTLY = "请求过于频繁,请稍候再试"; - } - - class Code { - public static final String REFRESH_KEY_FREQUENTLY_CODE = "88"; - } - - class Star{ - public static final Double ONE_STAR = 1.0; - public static final Double TWO_STAR = 2.0; - public static final Double THREE_STAR = 3.0; - public static final Double FOUR_STAR = 4.0; - public static final Double FIVE_STAR = 5.0; - - - } -} diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java index 0e13ae8..8d56e98 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java @@ -23,7 +23,7 @@ import com.ningdatech.carapi.driver.model.bo.CodingRuleBO; import com.ningdatech.carapi.driver.service.IDriverInfoService; import com.ningdatech.carapi.driver.service.IDriverScoreInfoService; import com.ningdatech.carapi.driver.service.IDriverScoreRecordService; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.entity.enumeration.CodingRuleBehaviorTypeEnum; import lombok.extern.slf4j.Slf4j; @@ -114,21 +114,21 @@ public class DriverScoreUtils { return; } Integer driverScore = scoreInfo.getDriverScore(); - if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_ZERO && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_TWENTY){ + if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_ZERO && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_TWENTY){ starManage.setCurrentScore(driverScore); - starManage.setCurrentStar(TaskContant.Star.ONE_STAR); - } else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_TWENTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_FORTY) { + starManage.setCurrentStar(TaskConstant.Star.ONE_STAR); + } else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_TWENTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_FORTY) { starManage.setCurrentScore(driverScore); - starManage.setCurrentStar(TaskContant.Star.TWO_STAR); - }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_FORTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_SIXTY){ + starManage.setCurrentStar(TaskConstant.Star.TWO_STAR); + }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_FORTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_SIXTY){ starManage.setCurrentScore(driverScore); - starManage.setCurrentStar(TaskContant.Star.THREE_STAR); - }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_SIXTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_EIGHTY){ + starManage.setCurrentStar(TaskConstant.Star.THREE_STAR); + }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_SIXTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_EIGHTY){ starManage.setCurrentScore(driverScore); - starManage.setCurrentStar(TaskContant.Star.FOUR_STAR); - }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_EIGHTY){ + starManage.setCurrentStar(TaskConstant.Star.FOUR_STAR); + }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_EIGHTY){ starManage.setCurrentScore(driverScore); - starManage.setCurrentStar(TaskContant.Star.FIVE_STAR); + starManage.setCurrentStar(TaskConstant.Star.FIVE_STAR); } } } diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java index 9281feb..c1d582a 100644 --- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java +++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java @@ -2,7 +2,7 @@ package com.ningdatech.carapi.scheduler.util; import com.alibaba.fastjson.JSONObject; import com.ningdatech.carapi.common.constant.GPSDataEnum; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.scheduler.entity.GpsData; import java.math.BigDecimal; @@ -22,33 +22,33 @@ public class GpsUtils { public static GpsData getGpsData(JSONObject gpsJson) { GpsData gpsData = new GpsData(); BigDecimal altitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.ALTITUDE.getDesc()); - Optional altitudeBigDecimal = Optional.ofNullable(altitudeTemp).map(a -> a.divide(TaskContant.Math.ALTITUDE_UNITS, RoundingMode.HALF_UP)); + Optional altitudeBigDecimal = Optional.ofNullable(altitudeTemp).map(a -> a.divide(TaskConstant.Math.ALTITUDE_UNITS, RoundingMode.HALF_UP)); if (altitudeBigDecimal.isPresent()) { BigDecimal altitude = altitudeBigDecimal.get().setScale(2, RoundingMode.HALF_UP); gpsData.setAltitude(altitude); } BigDecimal longitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.LONGITUDE.getDesc()); - Optional longitudeOptional = Optional.ofNullable(longitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP)); + Optional longitudeOptional = Optional.ofNullable(longitudeTemp).map(l -> l.divide(TaskConstant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP)); if (longitudeOptional.isPresent()) { BigDecimal longitude = longitudeOptional.get().setScale(6, RoundingMode.HALF_UP); gpsData.setLongitude(longitude); } BigDecimal latitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.LATITUDE.getDesc()); - Optional latitudeOptional = Optional.ofNullable(latitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP)); + Optional latitudeOptional = Optional.ofNullable(latitudeTemp).map(l -> l.divide(TaskConstant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP)); if (latitudeOptional.isPresent()) { BigDecimal latitude = latitudeOptional.get().setScale(6, RoundingMode.HALF_UP); gpsData.setLatitude(latitude); } BigDecimal speedTemp = gpsJson.getBigDecimal(GPSDataEnum.SPEED.getDesc()); - Optional speedOptional = Optional.ofNullable(speedTemp).map(s -> s.multiply(TaskContant.Math.SPEED_UNITS)); + Optional speedOptional = Optional.ofNullable(speedTemp).map(s -> s.multiply(TaskConstant.Math.SPEED_UNITS)); if (speedOptional.isPresent()) { BigDecimal speed = speedOptional.get().setScale(2, RoundingMode.HALF_UP); gpsData.setSpeed(speed); } BigDecimal directionTemp = gpsJson.getBigDecimal(GPSDataEnum.DIRECTION.getDesc()); - Optional directionOptional = Optional.ofNullable(directionTemp).map(s -> s.divide(TaskContant.Math.DIRECTION_UNITS, RoundingMode.HALF_UP)); + Optional directionOptional = Optional.ofNullable(directionTemp).map(s -> s.divide(TaskConstant.Math.DIRECTION_UNITS, RoundingMode.HALF_UP)); if (directionOptional.isPresent()) { BigDecimal direction = directionOptional.get().setScale(2, RoundingMode.HALF_UP); gpsData.setDirection(direction); diff --git a/ningda-yw-api/src/main/resources/application-dev.yml b/ningda-yw-api/src/main/resources/application-dev.yml index afee8a5..309b9b8 100644 --- a/ningda-yw-api/src/main/resources/application-dev.yml +++ b/ningda-yw-api/src/main/resources/application-dev.yml @@ -24,7 +24,7 @@ spring: host: 47.98.125.47 port: 26379 database: 5 - password: Ndkj1234 + password: Ndkj@1104! jedis: pool: max-active: 200 @@ -42,10 +42,10 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://47.98.125.47:3306/nd-yw-road?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false username: root - password: NingdaKeji123! + password: Ndkj@1104 hikari: minimum-idle: 5 - maximum-pool-size: 50 + maximum-pool-size: 100 aop: proxy-target-class: true auto: true diff --git a/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java b/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java index 8414a35..af8665a 100644 --- a/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java +++ b/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java @@ -31,7 +31,7 @@ import com.ningdatech.carapi.common.constant.DeletedEnum; import com.ningdatech.carapi.common.constant.VehicleTypeEnum; import com.ningdatech.carapi.common.util.CodeUtil; import com.ningdatech.carapi.driver.constant.DriverAbnormalBehaviorAppendixTypeEnum; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; import com.ningdatech.carapi.sys.helper.VehiclesCacheHelper; import cn.hutool.core.collection.CollUtil; @@ -119,17 +119,17 @@ public class AlarmTest extends AppTests { } JSONObject jsonContent = JSON.parseObject(content); - JSONObject gpsJson = jsonContent.getJSONObject(TaskContant.DataField.GPS); + JSONObject gpsJson = jsonContent.getJSONObject(TaskConstant.DataField.GPS); if(Objects.isNull(gpsJson)){ log.info("此条异常行为数据 GPS 内容有误 {}",JSON.toJSONString(alarm)); continue; } - monitor.setLongitude(Optional.of(gpsJson.getBigDecimal(TaskContant.DataField.LONGITUDE)) - .map(c -> c.divide(TaskContant.Math.LONGITUDE_UNITS, BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get()); - monitor.setLatitude(Optional.of(gpsJson.getBigDecimal(TaskContant.DataField.LATITUDE)) - .map(c -> c.divide(TaskContant.Math.LONGITUDE_UNITS,BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get()); + monitor.setLongitude(Optional.of(gpsJson.getBigDecimal(TaskConstant.DataField.LONGITUDE)) + .map(c -> c.divide(TaskConstant.Math.LONGITUDE_UNITS, BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get()); + monitor.setLatitude(Optional.of(gpsJson.getBigDecimal(TaskConstant.DataField.LATITUDE)) + .map(c -> c.divide(TaskConstant.Math.LONGITUDE_UNITS,BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get()); // 装配告警信息 monitor.setCompanyId(car.getCompanyId()); diff --git a/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java b/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java index 04ab624..ba584e3 100644 --- a/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java +++ b/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java @@ -12,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import com.ningdatech.cache.model.cache.CacheKey; import com.ningdatech.cache.repository.CachePlusOps; import com.ningdatech.carapi.AppTests; -import com.ningdatech.carapi.scheduler.contants.TaskContant; +import com.ningdatech.carapi.scheduler.contants.TaskConstant; /** * @Classname RedisTest @@ -36,7 +36,7 @@ public class RedisTest extends AppTests { @Test public void get (){ - CacheKey key = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET); + CacheKey key = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET); String requestSecret = cachePlusOps.get(key); System.out.println(requestSecret); requestSecret = "abcdefg123456";