소스 검색

道路驾驶舱修改

master
CMM 4 주 전
부모
커밋
879cd49b29
51개의 변경된 파일1854개의 추가작업 그리고 265개의 파일을 삭제
  1. +3
    -0
      .gitignore
  2. +16
    -0
      ningda-yw-api/pom.xml
  3. +6
    -6
      ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/controller/AnalysisEvalDataViewController.java
  4. +137
    -16
      ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/manage/AnalysisEvalDataViewManage.java
  5. +54
    -19
      ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/manage/PositionMonitorManage.java
  6. +1
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/car/position/model/vo/ResRealTimeMonitorVehicleGisListVO.java
  7. +13
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/common/contants/DefValConstants.java
  8. +2
    -1
      ningda-yw-api/src/main/java/com/ningdatech/carapi/common/handler/GlobalResponseHandler.java
  9. +3
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/common/model/DataChartVo.java
  10. +3
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/BehaviourAnalysisManage.java
  11. +3
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/manage/TrainingOrganizationManage.java
  12. +5
    -4
      ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java
  13. +31
    -30
      ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/manage/GpsDataPullManage.java
  14. +3
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsFullDataPullTask.java
  15. +19
    -20
      ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/task/GpsRealTimeDataPullTask.java
  16. +2
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/industry/manage/OperatorAssessmentManage.java
  17. +14
    -14
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/manage/DataInitManage.java
  18. +5
    -5
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java
  19. +3
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java
  20. +3
    -3
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java
  21. +2
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java
  22. +6
    -6
      ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java
  23. +2
    -1
      ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java
  24. +66
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java
  25. +8
    -9
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java
  26. +7
    -7
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java
  27. +68
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java
  28. +68
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java
  29. +4
    -5
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java
  30. +4
    -4
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java
  31. +70
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java
  32. +70
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java
  33. +5
    -5
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java
  34. +28
    -4
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java
  35. +452
    -38
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java
  36. +2
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java
  37. +1
    -1
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml
  38. +23
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java
  39. +33
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java
  40. +24
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java
  41. +9
    -6
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java
  42. +53
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java
  43. +2
    -2
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java
  44. +4
    -4
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java
  45. +476
    -0
      ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java
  46. +13
    -7
      ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java
  47. +11
    -11
      ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java
  48. +6
    -6
      ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java
  49. +3
    -3
      ningda-yw-api/src/main/resources/application-dev.yml
  50. +6
    -6
      ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java
  51. +2
    -2
      ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java

+ 3
- 0
.gitignore 파일 보기

@@ -7,3 +7,6 @@
/LOG_PATH_IS_UNDEFINED/
logs
/.idea/
driver-real-time-play-back
driver-remote-play-back
tunnel-play-back

+ 16
- 0
ningda-yw-api/pom.xml 파일 보기

@@ -221,6 +221,22 @@
<artifactId>easypoi-base</artifactId>
</dependency>


<!-- Jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.7.0</version>
</dependency>
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.3</version>
</dependency>



</dependencies>
<!-- 打包 -->
<!--配置环境的profile-->


+ 6
- 6
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);
}



+ 137
- 16
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<DataChartVo> companyWarnStatisticsByLevel(Long regionId, Integer dangerLevel) {
List<DataChartVo> result = new ArrayList<>();
List<Long> regionIds = regionsCacheHelper.listChildRegionId(regionId);
QueryWrapper<WarnAnalysisCompany> query = buildCountQueryGroupByRegion(regionIds, dangerLevel);
List<Map<String, Object>> analysisCompanies = companyWarnAnalysisService.listMaps(query);
//QueryWrapper<WarnAnalysisCompany> query = buildCountQueryGroupByRegion(regionIds, dangerLevel);
//List<Map<String, Object>> analysisCompanies = companyWarnAnalysisService.listMaps(query);

// 获取红色预警的数据
QueryWrapper<WarnAnalysisCompany> queryRed = buildCountQueryGroupByRegion(regionIds, DangerLevel.RED.getCode());
List<Map<String, Object>> analysisCompaniesRed = companyWarnAnalysisService.listMaps(queryRed);
// 获取橙色预警的数据
QueryWrapper<WarnAnalysisCompany> queryOrange = buildCountQueryGroupByRegion(regionIds, DangerLevel.ORANGE.getCode());
List<Map<String, Object>> analysisCompaniesOrange = companyWarnAnalysisService.listMaps(queryOrange);
// 获取黄色预警的数据
QueryWrapper<WarnAnalysisCompany> queryYellow = buildCountQueryGroupByRegion(regionIds, DangerLevel.YELLOW.getCode());
List<Map<String, Object>> analysisCompaniesYellow = companyWarnAnalysisService.listMaps(queryYellow);
// 获取蓝色预警的数据
QueryWrapper<WarnAnalysisCompany> queryBlue = buildCountQueryGroupByRegion(regionIds, DangerLevel.BLUE.getCode());
List<Map<String, Object>> analysisCompaniesBlue = companyWarnAnalysisService.listMaps(queryBlue);

Map<RegionDTO, List<Long>> 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<DataChartVo> carWarnStatisticsByLevel(Long regionId, Integer dangerLevel) {
List<DataChartVo> result = new ArrayList<>();
List<Long> regionIds = regionsCacheHelper.listChildRegionId(regionId);
QueryWrapper<WarnAnalysisCar> query = buildCountQueryGroupByRegion(regionIds, dangerLevel);
List<Map<String, Object>> analysisCompanies = carWarnAnalysisService.listMaps(query);
List<Map<String, Object>> analysisCompanies = Lists.newArrayList();
// 获取红色预警的数据
QueryWrapper<WarnAnalysisCar> queryRed = buildCountQueryGroupByRegion(regionIds, DangerLevel.RED.getCode());
List<Map<String, Object>> analysisCompaniesRed = carWarnAnalysisService.listMaps(queryRed);
// 获取橙色预警的数据
QueryWrapper<WarnAnalysisCar> queryOrange = buildCountQueryGroupByRegion(regionIds, DangerLevel.ORANGE.getCode());
List<Map<String, Object>> analysisCompaniesOrange = carWarnAnalysisService.listMaps(queryOrange);
// 获取黄色预警的数据
QueryWrapper<WarnAnalysisCar> queryYellow = buildCountQueryGroupByRegion(regionIds, DangerLevel.YELLOW.getCode());
List<Map<String, Object>> analysisCompaniesYellow = carWarnAnalysisService.listMaps(queryYellow);
// 获取蓝色预警的数据
QueryWrapper<WarnAnalysisCar> queryBlue = buildCountQueryGroupByRegion(regionIds, DangerLevel.BLUE.getCode());
List<Map<String, Object>> analysisCompaniesBlue = carWarnAnalysisService.listMaps(queryBlue);
Map<RegionDTO, List<Long>> 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;
}


+ 54
- 19
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<ResTrajectoryDataVO> 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<Long> 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<Long> listChild = regionsCacheHelper.listChildRegionId(userDetailRegionId,true,true);
//// 不在登录用户的区域权限内 返回空数据
//if (!listChild.contains(regionId)){
// return Collections.emptyList();
//}

//判断日期有没有跨天
checkDateExtendIntoNextDay(startTime, endTime);

//动态表名
List<VehiclePositionInfo> vehiclePositionInfoList = iVehiclePositionInfoService
.dynamicGpsTableHistorySearch(carPlate, startTime, endTime,NdDateUtils.format(startTime, "yyyy_MM_dd"));
// 从GPS数据列表中获取查询车牌号 查询时间区间内的数据
List<NdDataAccessGps> 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<VehiclePositionInfo> 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<VehiclePositionInfo> vehiclePositionInfoList = iVehiclePositionInfoService
// .dynamicGpsTableHistorySearch(carPlate, startTime, endTime,NdDateUtils.format(startTime, "yyyy_MM_dd"));


List<ResTrajectoryDataVO> 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<ResRealTimeMonitorVehicleGisListVO> 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<NdDataAccessGps> 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<NdDataAccessGps> 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<String, NdVehicleBaseInfo> 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());


+ 1
- 0
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;


+ 13
- 0
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";
}

+ 2
- 1
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<Object> {



+ 3
- 0
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;


+ 3
- 3
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<BehaviourAnalysisVO> 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()));
//统计该驾驶员当日异常行为告警事件


+ 3
- 3
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());


+ 5
- 4
ningda-yw-api/src/main/java/com/ningdatech/carapi/driver/service/impl/BehaviourAnalysisServiceImpl.java 파일 보기

@@ -82,11 +82,12 @@ public class BehaviourAnalysisServiceImpl extends ServiceImpl<BehaviourAnalysisM
req.setGnssCenterId(driverAbnormalBehaviorAnalysis.getGnssCenterId());
req.setMSgSn(driverAbnormalBehaviorAnalysis.getAlarmMsgSn());
req.setSupervisor(LoginUserUtil.getUsername());
String resultJson = restTemplateToInterface.doPostWith2(sendUrgeWarnUrl, req);
//String resultJson = restTemplateToInterface.doPostWith2(sendUrgeWarnUrl, req);
//保存督办处理结果
driverAbnormalBehaviorAnalysis.setOverseeResult(resultJson);
JSONObject result = JSON.parseObject(resultJson);
String status = result.getString(CommonConstant.CALL_STATUS);
//driverAbnormalBehaviorAnalysis.setOverseeResult(resultJson);
//JSONObject result = JSON.parseObject(resultJson);
//String status = result.getString(CommonConstant.CALL_STATUS);
String status = "ok";
if (CommonConstant.CALL_STATUS_OK_VALUE.equals(status)) {
//设置告警异常行为状态为已督办
driverAbnormalBehaviorAnalysis.setOverseeStatus(param.getOverseeStatus());


+ 31
- 30
ningda-yw-api/src/main/java/com/ningdatech/carapi/gps/manage/GpsDataPullManage.java 파일 보기

@@ -31,10 +31,11 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.ObjectMapper;
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.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.stereotype.Component;
@@ -50,6 +51,7 @@ import cn.hutool.core.date.StopWatch;
import cn.hutool.json.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.Jedis;

/**
* 车辆位置信息
@@ -66,6 +68,9 @@ public class GpsDataPullManage {
private final IDataAccessGpsRealTimeDataService dataAccessGpsRealTimeDataService;
private final CachePlusOps cachePlusOps;

private static final ObjectMapper objectMapper = new ObjectMapper();
private static final Jedis jedis = new Jedis("localhost",6379);

@Value("${spring.datasource.url}")
private String dataBaseUrl;
@Value("${spring.datasource.username}")
@@ -79,17 +84,16 @@ public class GpsDataPullManage {
String url = "https://jtjdhcweb.z1l1.com:7443";

// 获取当前表中的最大更新时间
long maxUpdateTime = LocalDateTime.now().atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
Long maxUpdateTime = null;
Optional<DataAccessGpsRealTimeData> 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<String, String> requestParams = assemblyParams(maxUpdateTime);
Map<String, String> 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<DataAccessGpsRealTimeData> 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<Long> 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<DataAccessGpsRealTimeData> 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<Long> 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<String, String> 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;
}
}

+ 3
- 3
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<String, String> assemblyParams(String key, Long id) {


+ 19
- 20
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<DataAccessGpsRealTimeData> 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<String, String> requestParams = assemblyParams(key,String.valueOf(maxUpdateTime), sLon, eLon, sLat, eLat);
Map<String, String> 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<DataAccessGpsRealTimeData> 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<Long> 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<DataAccessGpsRealTimeData> 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<Long> 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<String, String> assemblyParams(String key, String queryTime, String sLon, String eLon, String sLat, String eLat) {
private Map<String, String> assemblyParams(String key, String sLon, String eLon, String sLat, String eLat) {
long timeNow = System.currentTimeMillis() / 1000;
String token = gpsDataPullManage.generateMD5Token(timeNow, key);

Map<String, String> 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);
}


+ 2
- 2
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);


+ 14
- 14
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<String> result = new ArrayList<>();
List<String> carPlateList;
String key = TaskContant.RedisKey.ACCIDENT_QUERY_IRS;
String key = TaskConstant.RedisKey.ACCIDENT_QUERY_IRS;
List<String> objectList = redisOps.get(key);
// 存储的车牌号为空
if (CollUtil.isEmpty(objectList)) {
@@ -511,7 +511,7 @@ public class DataInitManage {
// 获取此次任务要查询的车牌号
List<String> 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 <=


+ 5
- 5
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);


+ 3
- 3
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);


+ 3
- 3
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);


+ 2
- 2
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);
}


+ 6
- 6
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 <=


+ 2
- 1
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);


+ 66
- 0
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);
}
}

ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java 파일 보기

@@ -17,15 +17,14 @@ import lombok.NoArgsConstructor;
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举")
public enum VehicleSpeedAbnormalTypeEnum {
@ApiModel(value = "CongestionStatusTypeEnum", description = "驾驶员异常情况-枚举")
public enum CongestionStatusTypeEnum {
/**
* 车辆速度异常类型
* 驾驶员异常情况
*/
OVER(1, "超速"),
LOW(2, "低速"),
STOP(3, "停车"),
REVERSE(4, "逆向行驶");
Heavy(1, "严重拥堵"),
Medium(2, "中度拥堵"),
Light(3, "轻度拥堵");



@@ -44,7 +43,7 @@ public enum VehicleSpeedAbnormalTypeEnum {
if(Objects.isNull(code)){
return StringUtils.EMPTY;
}
for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) {
for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
@@ -56,7 +55,7 @@ public enum VehicleSpeedAbnormalTypeEnum {
if(StringUtils.isBlank(desc)){
return null;
}
for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) {
for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) {
if (desc.equals(t.getDesc())) {
return t.code;
}

ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java 파일 보기

@@ -17,14 +17,14 @@ import lombok.NoArgsConstructor;
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举")
public enum DriverAbnormalTypeEnum {
@ApiModel(value = "DriverStatusTypeEnum", description = "驾驶员异常情况-枚举")
public enum DriverStatusTypeEnum {
/**
* 驾驶员异常行为类型
* 驾驶员异常情况
*/
FATIGUE(1, "疲劳驾驶"),
Fatigue(1, "疲劳驾驶"),

POOR_HABITS(2, "不良驾驶习惯");
Poor_habits(2, "不良驾驶习惯");



@@ -43,7 +43,7 @@ public enum DriverAbnormalTypeEnum {
if(Objects.isNull(code)){
return StringUtils.EMPTY;
}
for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) {
for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
@@ -55,7 +55,7 @@ public enum DriverAbnormalTypeEnum {
if(StringUtils.isBlank(desc)){
return null;
}
for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) {
for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) {
if (desc.equals(t.getDesc())) {
return t.code;
}

+ 68
- 0
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);
}
}

+ 68
- 0
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);
}
}

+ 4
- 5
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,"环境异常");





+ 4
- 4
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, "路面湿滑");





+ 70
- 0
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);
}
}

+ 70
- 0
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);
}
}

+ 5
- 5
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;


+ 28
- 4
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;

/**
* <p>
* 前端控制器
@@ -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<RoadDangerBehaviorVO> getRoadDangerBehaviorData(RoadMonitorReq req) {
return roadMonitorManage.getRoadDangerBehaviorData(req);
}

@ApiOperation(value = "违法违章与预警记录数据", notes = "违法违章与预警记录列表")
@GetMapping("/get-violation-warn-record-data")
public List<RoadDangerBehaviorVO> getViolationWarnRecordData(RoadMonitorReq req) {
return roadMonitorManage.getViolationWarnRecordData(req);
}

@GetMapping("/video/download")
@ApiOperation("视频下载")
@WebLog("视频下载")
public void downloadOperationManual(VideoDownloadReq req, HttpServletResponse response){
roadMonitorManage.videoDownload(req,response);
}
}

+ 452
- 38
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<String> regionList = Lists.newArrayList("1", "2", "3", "4");
return getCollectDataVo(regionList,jedis,tunnel);
}
// 何里隧道 包含 5 何里隧道兰溪方向、6 何里隧道义乌方向
else if (tunnel == 2) {
List<String> regionList = Lists.newArrayList("5", "6");
return getCollectDataVo(regionList,jedis,tunnel);
}
return new ComprehensiveSituationVO();
}

private ComprehensiveSituationVO getCollectDataVo(List<String> 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<String, ComprehensiveSituationVO> 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<ComprehensiveSituationVO> vos = Lists.newArrayList(hsDyGoVo, hsDyComeVo, hsYwGoVo, hsYwComeVo);
vo = averageScores(vos);
} else if (tunnel == 2) {
List<ComprehensiveSituationVO> 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<ComprehensiveSituationVO> 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<RoadDangerBehaviorVO> getRoadDangerBehaviorData(RoadMonitorReq req) {
List<String> regionList = req.getRegionList();
// 从列表中查询数据
List<RoadBehaviorAnalysis> 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<RoadDangerBehaviorVO> getViolationWarnRecordData(RoadMonitorReq req) {
// 从列表中查询数据
List<RoadBehaviorAnalysis> 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());
}
}

ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java 파일 보기

@@ -1,6 +1,6 @@
package com.ningdatech.carapi.analysis.mapper;
package com.ningdatech.carapi.road.mapper;

import com.ningdatech.carapi.analysis.entity.RoadBehaviorAnalysis;
import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**

ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/mapper/RoadBehaviorAnalysisMapper.xml → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml 파일 보기

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

</mapper>

ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/entity/RoadBehaviorAnalysis.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java 파일 보기

@@ -1,4 +1,4 @@
package com.ningdatech.carapi.analysis.entity;
package com.ningdatech.carapi.road.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -28,7 +28,7 @@ public class RoadBehaviorAnalysis implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Long id;

@ApiModelProperty("异常行为类型 1 驾驶员异常 2 车辆速度异常 3 监控异常")
@ApiModelProperty("异常行为类型 1 驾驶员异常 2 车辆异常 3 道路异常 4 环境异常")
private Integer type;

@ApiModelProperty("异常行为描述")
@@ -40,6 +40,27 @@ public class RoadBehaviorAnalysis implements Serializable {
@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;


+ 33
- 0
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<String> regionList;

@ApiModelProperty("行为类型 1 驾驶员、2 车辆、3 道路、4 环境")
private Integer type;
}

+ 24
- 0
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;
}

+ 9
- 6
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;
}

+ 53
- 0
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;
}

ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/IRoadBehaviorAnalysisService.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java 파일 보기

@@ -1,6 +1,6 @@
package com.ningdatech.carapi.analysis.service;
package com.ningdatech.carapi.road.service;

import com.ningdatech.carapi.analysis.entity.RoadBehaviorAnalysis;
import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
import com.baomidou.mybatisplus.extension.service.IService;

/**

ningda-yw-api/src/main/java/com/ningdatech/carapi/analysis/service/impl/RoadBehaviorAnalysisServiceImpl.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java 파일 보기

@@ -1,8 +1,8 @@
package com.ningdatech.carapi.analysis.service.impl;
package com.ningdatech.carapi.road.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.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;


+ 476
- 0
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<String> dataList;
Map<String, String> 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<RoadBehaviorAnalysis> list = checkDataExists(createTime, region);

// 如果没有存入过
if (CollUtil.isEmpty(list)) {
List<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> saveDataList, JSONObject jsonObject);
}
private List<RoadBehaviorAnalysis> assembleData(JSONObject jsonObject) {
List<RoadBehaviorAnalysis> saveDataList = Lists.newArrayList();
// 定义一个映射,关联JSON数组的键和对应的数据处理方法
Map<String, DataAssembler> 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<RoadBehaviorAnalysis> checkDataExists(LocalDateTime createTime, String region) {
return roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class)
.eq(RoadBehaviorAnalysis::getBehaviorTime, createTime)
.eq(RoadBehaviorAnalysis::getRegion, region));
}

private static Map<String, String> getRedisKeyRegionMap() {
Map<String, String> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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<String> needWarnBehaviorCodeList = getNeedWarnBehaviorCode();
if (StringUtils.isNotBlank(behaviorCode)){
List<String> behaviorCodeList = Arrays.stream(behaviorCode.split(StrPool.COMMA)).collect(Collectors.toList());
// 判断是否包含需要预警的behaviorCode
return behaviorCodeList.stream().anyMatch(needWarnBehaviorCodeList::contains);
}
return Boolean.FALSE;
}

private List<String> getNeedWarnBehaviorCode() {
List<String> 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<RoadBehaviorAnalysis> 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<RoadBehaviorAnalysis> 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);
}
}

ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java → ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java 파일 보기

@@ -8,7 +8,7 @@ import java.math.BigDecimal;
* @Description
* @Date 2022/12/7 11:00
*/
public interface TaskContant {
public interface TaskConstant {
class Host {
public static final String HOST_ZPF = "LAPTOP-NQGEQP03";
public static final String HOST_CMM2 = "DESKTOP-KN1L6HL";
@@ -111,12 +111,18 @@ public interface TaskContant {

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";


// 黄山隧道东阳去向
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 {

+ 11
- 11
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);
}
}
}

+ 6
- 6
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<BigDecimal> altitudeBigDecimal = Optional.ofNullable(altitudeTemp).map(a -> a.divide(TaskContant.Math.ALTITUDE_UNITS, RoundingMode.HALF_UP));
Optional<BigDecimal> 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<BigDecimal> longitudeOptional = Optional.ofNullable(longitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
Optional<BigDecimal> 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<BigDecimal> latitudeOptional = Optional.ofNullable(latitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
Optional<BigDecimal> 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<BigDecimal> speedOptional = Optional.ofNullable(speedTemp).map(s -> s.multiply(TaskContant.Math.SPEED_UNITS));
Optional<BigDecimal> 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<BigDecimal> directionOptional = Optional.ofNullable(directionTemp).map(s -> s.divide(TaskContant.Math.DIRECTION_UNITS, RoundingMode.HALF_UP));
Optional<BigDecimal> 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);


+ 3
- 3
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


+ 6
- 6
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());


+ 2
- 2
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";


불러오는 중...
취소
저장