carPlateList = Lists.newArrayList();
- CacheKey cacheKey = new CacheKey(TaskContant.RedisKey.VEHICLE_ILLEGAL_QUERY_IRS, Duration.ofDays(20));
+ CacheKey cacheKey = new CacheKey(TaskConstant.RedisKey.VEHICLE_ILLEGAL_QUERY_IRS, Duration.ofDays(20));
Object object = redisOps.get(cacheKey, false);
// key不存在(过期)
if (Objects.isNull(object)) {
@@ -1356,11 +1356,11 @@ public class DataInitManage {
String period = null;
// 时间段暂时设置为违章时间所在小时的前后半小时
if (minute < 30) {
- period = vehicleIllegalTime.minusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_HALF
- + StrPool.DASH + hour + TaskContant.Data.VIOLATION_TIME_HALF;
+ period = vehicleIllegalTime.minusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_HALF
+ + StrPool.DASH + hour + TaskConstant.Data.VIOLATION_TIME_HALF;
} else {
- period = hour + TaskContant.Data.VIOLATION_TIME_START + StrPool.DASH
- + vehicleIllegalTime.plusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_START;
+ period = hour + TaskConstant.Data.VIOLATION_TIME_START + StrPool.DASH
+ + vehicleIllegalTime.plusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_START;
}
vehicleViolation.setViolationPeriod(period);
// if (hour >= TaskContant.Data.VIOLATION_TIME_SEVEN && hour <=
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java
index 9423696..1590892 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/AccidentServieImpl.java
@@ -38,7 +38,7 @@ import com.ningdatech.carapi.safe.entity.NdVehicleAccident;
import com.ningdatech.carapi.safe.entity.NdVehicleAccidentDead;
import com.ningdatech.carapi.safe.service.INdVehicleAccidentDeadService;
import com.ningdatech.carapi.safe.service.INdVehicleAccidentService;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.sys.entity.Company;
import com.ningdatech.carapi.sys.helper.RegionsCacheHelper;
import com.ningdatech.carapi.sys.service.CompanyService;
@@ -354,9 +354,9 @@ public class AccidentServieImpl implements AccidentService {
String hpzl = "01";
// 请求秘钥
- CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET);
+ CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET);
// 刷新密钥
- CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REFRESH_SECRET);
+ CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REFRESH_SECRET);
// 根据key获取缓存中的请求秘钥和刷新密钥
String requestSecret = cachePlusOps.get(requestKey);
String refreshSecret = cachePlusOps.get(refreshKey);
@@ -434,9 +434,9 @@ public class AccidentServieImpl implements AccidentService {
String appSecret = "e07fd4471e92410d9860282d939b1217";
// 请求秘钥
- CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_DUTY_REQUEST_SECRET);
+ CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_DUTY_REQUEST_SECRET);
// 刷新密钥
- CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_DUTY_REFRESH_SECRET);
+ CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_DUTY_REFRESH_SECRET);
// 根据key获取缓存中的请求秘钥和刷新密钥
String requestSecret = cachePlusOps.get(requestKey);
String refreshSecret = cachePlusOps.get(refreshKey);
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java
index 967ba47..a8eeeb9 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/CarServiceImpl.java
@@ -19,7 +19,7 @@ import com.ningdatech.cache.repository.CachePlusOps;
import com.ningdatech.carapi.irs.service.CarService;
import com.ningdatech.carapi.irs.service.RefreshKeyService;
import com.ningdatech.carapi.irs.utils.Md5Utils;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -142,9 +142,9 @@ public class CarServiceImpl implements CarService {
String innerAppKey = "210a2657177f478c808381deb13a4dac";
// 请求秘钥
- CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_ILLEGAL_REQUEST_SECRET);
+ CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_ILLEGAL_REQUEST_SECRET);
// 刷新密钥
- CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_ILLEGAL_REFRESH_SECRET);
+ CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_ILLEGAL_REFRESH_SECRET);
// 根据key获取缓存中的请求秘钥和刷新密钥
String requestSecret = cachePlusOps.get(requestKey);
String refreshSecret = cachePlusOps.get(refreshKey);
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java
index c8f6071..46bc37d 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/service/impl/DriverServiceImpl.java
@@ -15,7 +15,7 @@ import com.ningdatech.cache.repository.CachePlusOps;
import com.ningdatech.carapi.irs.service.DriverService;
import com.ningdatech.carapi.irs.service.RefreshKeyService;
import com.ningdatech.carapi.irs.utils.Md5Utils;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -73,9 +73,9 @@ public class DriverServiceImpl implements DriverService {
String appSecret = "e07fd4471e92410d9860282d939b1217";
// 请求秘钥
- CacheKey requestKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_LICENSE_REQUEST_SECRET);
+ CacheKey requestKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_LICENSE_REQUEST_SECRET);
// 刷新密钥
- CacheKey refreshKey = new CacheKey(TaskContant.RedisKey.IRS_VEHICLE_LICENSE_REFRESH_SECRET);
+ CacheKey refreshKey = new CacheKey(TaskConstant.RedisKey.IRS_VEHICLE_LICENSE_REFRESH_SECRET);
// 根据key获取缓存中的请求秘钥和刷新密钥
String requestSecret = cachePlusOps.get(requestKey);
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java
index 9eaa3a9..c64fc56 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyAccidentQueryTask.java
@@ -34,7 +34,7 @@ import com.ningdatech.carapi.safe.entity.NdVehicleAccident;
import com.ningdatech.carapi.safe.entity.NdVehicleAccidentDead;
import com.ningdatech.carapi.safe.service.INdVehicleAccidentDeadService;
import com.ningdatech.carapi.safe.service.INdVehicleAccidentService;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.sys.entity.Company;
import com.ningdatech.carapi.sys.helper.RegionsCacheHelper;
import com.ningdatech.carapi.sys.service.CompanyService;
@@ -110,7 +110,7 @@ public class MyAccidentQueryTask implements Runnable {
// 判断当前执行任务的时间是否为月初的1号 如果是月初1号,任务应该从下标1重新开始跑
LocalDateTime now = LocalDateTime.now();
int dayOfMonth = now.getDayOfMonth();
- if (TaskContant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){
+ if (TaskConstant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){
// 重置文件中的下标
saveLastIndex(1L, 0);
}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java
index 8ab072e..b6661e7 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/irs/task/MyVehicleIllegalQueryTask.java
@@ -27,7 +27,7 @@ import com.ningdatech.carapi.irs.service.CarService;
import com.ningdatech.carapi.irs.service.IVehicleViolationIrsDataService;
import com.ningdatech.carapi.safe.entity.NdVehicleViolation;
import com.ningdatech.carapi.safe.service.INdVehicleViolationService;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.sys.entity.Company;
import com.ningdatech.carapi.sys.helper.RegionsCacheHelper;
import com.ningdatech.carapi.sys.service.CompanyService;
@@ -130,7 +130,7 @@ public class MyVehicleIllegalQueryTask implements Runnable {
// 判断当前执行任务的时间是否为月初的1号 如果是月初1号,任务应该从下标1重新开始跑
LocalDateTime now = LocalDateTime.now();
int dayOfMonth = now.getDayOfMonth();
- if (TaskContant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){
+ if (TaskConstant.Data.MONTH_VALUE_ONE.equals(dayOfMonth)){
// 重置文件中的下标
saveLastIndex(1L, 0);
}
@@ -460,11 +460,11 @@ public class MyVehicleIllegalQueryTask implements Runnable {
String period = null;
// 时间段暂时设置为违章时间所在小时的前后半小时
if (minute < 30) {
- period = vehicleIllegalTime.minusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_HALF
- + StrPool.DASH + hour + TaskContant.Data.VIOLATION_TIME_HALF;
+ period = vehicleIllegalTime.minusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_HALF
+ + StrPool.DASH + hour + TaskConstant.Data.VIOLATION_TIME_HALF;
} else {
- period = hour + TaskContant.Data.VIOLATION_TIME_START + StrPool.DASH
- + vehicleIllegalTime.plusHours(1).getHour() + TaskContant.Data.VIOLATION_TIME_START;
+ period = hour + TaskConstant.Data.VIOLATION_TIME_START + StrPool.DASH
+ + vehicleIllegalTime.plusHours(1).getHour() + TaskConstant.Data.VIOLATION_TIME_START;
}
vehicleViolation.setViolationPeriod(period);
// if (hour >= TaskContant.Data.VIOLATION_TIME_SEVEN && hour <=
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java
index c5b9076..cc4d727 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/radar/manage/RadarManage.java
@@ -27,7 +27,8 @@ public class RadarManage {
public String getRadarData() {
try {
- ServerSocket serverSocket = new ServerSocket(13000, 600, InetAddress.getByName("192.168.6.42"));
+ // 192.168.6.42
+ ServerSocket serverSocket = new ServerSocket(13000);
// 设置为0表示无限等待,可以根据需要设置超时时间
serverSocket.setSoTimeout(6000);
System.out.println("ServerSocket started on port: " + 13000);
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java
new file mode 100644
index 0000000..da17ef9
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/BicycleStatusTypeEnum.java
@@ -0,0 +1,66 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "BicycleStatusTypeEnum", description = "自行车情况-枚举")
+public enum BicycleStatusTypeEnum {
+ /**
+ * 自行车情况
+ */
+ Bicycle_Collisions(1, "自行车碰撞"),
+ Motorway_Intrusion(2, "自行车误入高速公路");
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (BicycleStatusTypeEnum t : BicycleStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (BicycleStatusTypeEnum t : BicycleStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java
new file mode 100644
index 0000000..2695ad8
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/CongestionStatusTypeEnum.java
@@ -0,0 +1,69 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "CongestionStatusTypeEnum", description = "驾驶员异常情况-枚举")
+public enum CongestionStatusTypeEnum {
+ /**
+ * 驾驶员异常情况
+ */
+ Heavy(1, "严重拥堵"),
+ Medium(2, "中度拥堵"),
+ Light(3, "轻度拥堵");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (CongestionStatusTypeEnum t : CongestionStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java
deleted file mode 100644
index 4d4bdba..0000000
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverAbnormalTypeEnum.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.ningdatech.carapi.road.constant;
-
-import java.util.Objects;
-
-import org.apache.commons.lang3.StringUtils;
-
-import io.swagger.annotations.ApiModel;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-
-/**
- * @return
- * @author CMM
- * @since 2022/12/20 14:10
- */
-@Getter
-@AllArgsConstructor
-@NoArgsConstructor
-@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举")
-public enum DriverAbnormalTypeEnum {
- /**
- * 驾驶员异常行为类型
- */
- FATIGUE(1, "疲劳驾驶"),
-
- POOR_HABITS(2, "不良驾驶习惯");
-
-
-
- private Integer code;
- private String desc;
-
- public String getDesc() {
- return desc;
- }
-
- public void setDesc(String desc) {
- this.desc = desc;
- }
-
- public static String getDescByCode(Integer code) {
- if(Objects.isNull(code)){
- return StringUtils.EMPTY;
- }
- for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) {
- if (code.equals(t.getCode())) {
- return t.desc;
- }
- }
- return StringUtils.EMPTY;
- }
-
- public static Integer getCodeByDesc(String desc) {
- if(StringUtils.isBlank(desc)){
- return null;
- }
- for (DriverAbnormalTypeEnum t : DriverAbnormalTypeEnum.values()) {
- if (desc.equals(t.getDesc())) {
- return t.code;
- }
- }
- return null;
- }
-
- public boolean eq(String val) {
- return this.name().equals(val);
- }
-}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java
new file mode 100644
index 0000000..7e2b3a8
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/DriverStatusTypeEnum.java
@@ -0,0 +1,69 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "DriverStatusTypeEnum", description = "驾驶员异常情况-枚举")
+public enum DriverStatusTypeEnum {
+ /**
+ * 驾驶员异常情况
+ */
+ Fatigue(1, "疲劳驾驶"),
+
+ Poor_habits(2, "不良驾驶习惯");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (DriverStatusTypeEnum t : DriverStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java
new file mode 100644
index 0000000..8f91a76
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/OffenseStatusTypeEnum.java
@@ -0,0 +1,68 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "OffenseStatusTypeEnum", description = "车辆违章情况-枚举")
+public enum OffenseStatusTypeEnum {
+ /**
+ * 车辆违章情况
+ */
+ Running_a_red_light(1, "闯红灯"),
+ Crossing_the_line(2, "越线行驶");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (OffenseStatusTypeEnum t : OffenseStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (OffenseStatusTypeEnum t : OffenseStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java
new file mode 100644
index 0000000..adb54ed
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/PedestrianStatusTypeEnum.java
@@ -0,0 +1,68 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "PedestrianStatusTypeEnum", description = "行人情况-枚举")
+public enum PedestrianStatusTypeEnum {
+ /**
+ * 行人情况
+ */
+ Trespass(1, "擅自进入"),
+ Traverse(2, "横穿道路");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (PedestrianStatusTypeEnum t : PedestrianStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (PedestrianStatusTypeEnum t : PedestrianStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java
index 50da216..c1d9363 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadBehaviorTypeEnum.java
@@ -22,11 +22,10 @@ public enum RoadBehaviorTypeEnum {
/**
* 道路异常行为类型
*/
- DRIVER(1, "驾驶员行为异常"),
-
- SPEED(2, "车辆速度异常"),
-
- VIDEO(3,"道路监控异常");
+ DRIVER(1, "驾驶员异常"),
+ CAR(2, "车辆异常"),
+ ROAD(3,"道路异常"),
+ ENVIRONMENT(4,"环境异常");
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java
index ec6d0f5..aca8fdc 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/RoadStatusTypeEnum.java
@@ -17,14 +17,14 @@ import lombok.NoArgsConstructor;
@Getter
@AllArgsConstructor
@NoArgsConstructor
-@ApiModel(value = "RoadStatusTypeEnum", description = "道路拥堵情况-枚举")
+@ApiModel(value = "RoadStatusTypeEnum", description = "道路情况-枚举")
public enum RoadStatusTypeEnum {
/**
* 道路情况
*/
- HEAVY(1, "严重拥堵"),
- MEDIUM(2, "中度拥堵"),
- LIGHT(3, "轻度拥堵");
+ Damaged(1, "路面损坏"),
+ Debris(2, "路面有杂物"),
+ Slippery(3, "路面湿滑");
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java
new file mode 100644
index 0000000..c6c922c
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/SpeedStatusTypeEnum.java
@@ -0,0 +1,70 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "SpeedStatusTypeEnum", description = "车辆速度情况-枚举")
+public enum SpeedStatusTypeEnum {
+ /**
+ * 车辆速度情况
+ */
+ Over(1, "超速"),
+ Low(2, "低速"),
+ Stop(3, "停车"),
+ Reverse(4, "逆向行驶");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (SpeedStatusTypeEnum t : SpeedStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (SpeedStatusTypeEnum t : SpeedStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java
deleted file mode 100644
index 26f4f2b..0000000
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleSpeedAbnormalTypeEnum.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.ningdatech.carapi.road.constant;
-
-import java.util.Objects;
-
-import org.apache.commons.lang3.StringUtils;
-
-import io.swagger.annotations.ApiModel;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-
-/**
- * @return
- * @author CMM
- * @since 2022/12/20 14:10
- */
-@Getter
-@AllArgsConstructor
-@NoArgsConstructor
-@ApiModel(value = "VehicleDangerLevelEnum", description = "车辆风险等级-枚举")
-public enum VehicleSpeedAbnormalTypeEnum {
- /**
- * 车辆速度异常类型
- */
- OVER(1, "超速"),
- LOW(2, "低速"),
- STOP(3, "停车"),
- REVERSE(4, "逆向行驶");
-
-
-
- private Integer code;
- private String desc;
-
- public String getDesc() {
- return desc;
- }
-
- public void setDesc(String desc) {
- this.desc = desc;
- }
-
- public static String getDescByCode(Integer code) {
- if(Objects.isNull(code)){
- return StringUtils.EMPTY;
- }
- for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) {
- if (code.equals(t.getCode())) {
- return t.desc;
- }
- }
- return StringUtils.EMPTY;
- }
-
- public static Integer getCodeByDesc(String desc) {
- if(StringUtils.isBlank(desc)){
- return null;
- }
- for (VehicleSpeedAbnormalTypeEnum t : VehicleSpeedAbnormalTypeEnum.values()) {
- if (desc.equals(t.getDesc())) {
- return t.code;
- }
- }
- return null;
- }
-
- public boolean eq(String val) {
- return this.name().equals(val);
- }
-}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java
new file mode 100644
index 0000000..dc5bcba
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/VehicleStatusTypeEnum.java
@@ -0,0 +1,70 @@
+package com.ningdatech.carapi.road.constant;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.StringUtils;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+/**
+ * @return
+ * @author CMM
+ * @since 2022/12/20 14:10
+ */
+@Getter
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel(value = "VehicleStatusTypeEnum", description = "车辆情况-枚举")
+public enum VehicleStatusTypeEnum {
+ /**
+ * 车辆情况
+ */
+ Vehicle_Collisions(1, "车辆碰撞"),
+ Overturn(2, "车辆翻车"),
+ Smoke_or_Fire(3, "冒烟/起火"),
+ Dropping(4,"抛洒物品");
+
+
+
+ private Integer code;
+ private String desc;
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public static String getDescByCode(Integer code) {
+ if(Objects.isNull(code)){
+ return StringUtils.EMPTY;
+ }
+ for (VehicleStatusTypeEnum t : VehicleStatusTypeEnum.values()) {
+ if (code.equals(t.getCode())) {
+ return t.desc;
+ }
+ }
+ return StringUtils.EMPTY;
+ }
+
+ public static Integer getCodeByDesc(String desc) {
+ if(StringUtils.isBlank(desc)){
+ return null;
+ }
+ for (VehicleStatusTypeEnum t : VehicleStatusTypeEnum.values()) {
+ if (desc.equals(t.getDesc())) {
+ return t.code;
+ }
+ }
+ return null;
+ }
+
+ public boolean eq(String val) {
+ return this.name().equals(val);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java
index 28bb187..8c3d59b 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/constant/WeatherStatusTypeEnum.java
@@ -22,11 +22,11 @@ public enum WeatherStatusTypeEnum {
/**
* 道路情况
*/
- FOG(1, "雾天"),
- RAIN(2, "雨天"),
- SNOW(3, "雪天"),
- WIND(4, "大风"),
- SANDSTORM(5, "沙尘暴");
+ Fog(1, "雾天"),
+ Rain(2, "雨天"),
+ Snow(3, "雪天"),
+ Wind(4, "大风"),
+ Sandstorm(5, "沙尘暴");
private Integer code;
private String desc;
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java
index 5c6405e..a80f855 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/controller/RoadMonitorController.java
@@ -1,18 +1,23 @@
package com.ningdatech.carapi.road.controller;
import com.ningdatech.carapi.road.manage.RoadMonitorManage;
+import com.ningdatech.carapi.road.model.req.RoadMonitorReq;
+import com.ningdatech.carapi.road.model.req.VideoDownloadReq;
import com.ningdatech.carapi.road.model.vo.ComprehensiveSituationVO;
+import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO;
+import com.ningdatech.log.annotation.WebLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-import com.ningdatech.carapi.gps.manage.GpsDataPullManage;
-
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
/**
*
* 前端控制器
@@ -32,7 +37,26 @@ public class RoadMonitorController {
@ApiOperation(value = "综合态势数据", notes = "综合态势数据")
@GetMapping("/get-comprehensive-situation-data")
- public ComprehensiveSituationVO getComSitData() {
- return roadMonitorManage.getComSitData();
+ public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) {
+ return roadMonitorManage.getComSitData(req);
+ }
+
+ @ApiOperation(value = "危险行为数据", notes = "危险行为数据")
+ @GetMapping("/get-road-danger-behavior-data")
+ public List getRoadDangerBehaviorData(RoadMonitorReq req) {
+ return roadMonitorManage.getRoadDangerBehaviorData(req);
+ }
+
+ @ApiOperation(value = "违法违章与预警记录数据", notes = "违法违章与预警记录列表")
+ @GetMapping("/get-violation-warn-record-data")
+ public List getViolationWarnRecordData(RoadMonitorReq req) {
+ return roadMonitorManage.getViolationWarnRecordData(req);
+ }
+
+ @GetMapping("/video/download")
+ @ApiOperation("视频下载")
+ @WebLog("视频下载")
+ public void downloadOperationManual(VideoDownloadReq req, HttpServletResponse response){
+ roadMonitorManage.videoDownload(req,response);
}
}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java
index 010dd41..ba1e5c1 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/manage/RoadMonitorManage.java
@@ -1,18 +1,38 @@
package com.ningdatech.carapi.road.manage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.ningdatech.cache.model.cache.CacheKey;
-import com.ningdatech.cache.repository.CachePlusOps;
-import com.ningdatech.carapi.road.constant.RoadStatusTypeEnum;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.google.common.collect.Lists;
+import com.ningdatech.basic.exception.BizException;
+import com.ningdatech.carapi.common.contants.DefValConstants;
+import com.ningdatech.carapi.road.constant.*;
+import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
+import com.ningdatech.carapi.road.model.req.RoadMonitorReq;
+import com.ningdatech.carapi.road.model.req.VideoDownloadReq;
import com.ningdatech.carapi.road.model.vo.ComprehensiveSituationVO;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.road.model.vo.RoadDangerBehaviorVO;
+import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
+
+import cn.hutool.core.collection.CollUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Component;
-
-import java.util.Objects;
+import redis.clients.jedis.Jedis;
/**
* @author CMM
@@ -23,45 +43,439 @@ import java.util.Objects;
@RequiredArgsConstructor
public class RoadMonitorManage {
- private final CachePlusOps cachePlusOps;
+ @Value("${spring.redis.host}")
+ private String redisHost;
+
+ @Value("${spring.redis.port}")
+ private Integer redisPort;
+
+ @Value("${spring.redis.password}")
+ private String redisPassword;
- public ComprehensiveSituationVO getComSitData() {
+ private final IRoadBehaviorAnalysisService roadBehaviorAnalysisService;
+
+ public ComprehensiveSituationVO getComSitData(RoadMonitorReq req) {
+ Jedis jedis = new Jedis(redisHost,redisPort);
+ jedis.auth(redisPassword);
+ // 隧道类型
+ Integer tunnel = req.getTunnel();
+ // 根据传入的隧道类型 实时从缓存中获取算法分析的结果
+ // 分区域分别计算4个指标的分值 比例按照1:1:1:1 加权计算道路安全指数
+ // 黄山隧道 包含 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向
+ if (tunnel == 1){
+ List regionList = Lists.newArrayList("1", "2", "3", "4");
+ return getCollectDataVo(regionList,jedis,tunnel);
+ }
+ // 何里隧道 包含 5 何里隧道兰溪方向、6 何里隧道义乌方向
+ else if (tunnel == 2) {
+ List regionList = Lists.newArrayList("5", "6");
+ return getCollectDataVo(regionList,jedis,tunnel);
+ }
+ return new ComprehensiveSituationVO();
+ }
+
+ private ComprehensiveSituationVO getCollectDataVo(List regionList, Jedis jedis, Integer tunnel) {
ComprehensiveSituationVO vo = new ComprehensiveSituationVO();
- // 设置默认值
- vo.setRoadSafetyIndex(100);
- vo.setRoadStatus("通畅");
- vo.setWeatherStatus("良好");
- vo.setDangerousActionCount(0);
- // 实时从缓存中获取算法分析的结果
- String allData = cachePlusOps.get(new CacheKey(TaskContant.RedisKey.ALGORITHM_REDIS_ALL_DATA_KEY));
- JSONObject jsonObject = JSON.parseObject(allData);
- if (Objects.nonNull(jsonObject)) {
- // 道路情况
- String congestion = jsonObject.getString("Congestion");
- RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(congestion);
- if (StringUtils.isNotBlank(congestion)){
- switch (roadStatusTypeEnum){
- case HEAVY:
- vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.HEAVY.getCode()));
+ setDefaultScores(vo);
+
+ // 使用Map来存储不同region对应的ComprehensiveSituationVO对象
+ Map regionVoMap = new HashMap<>();
+ // 初始化所有可能的ComprehensiveSituationVO对象并设置默认值
+ ComprehensiveSituationVO hsDyGoVo;
+ regionVoMap.put("1", hsDyGoVo = new ComprehensiveSituationVO());
+ setDefaultScores(hsDyGoVo);
+ ComprehensiveSituationVO hsDyComeVo;
+ regionVoMap.put("2", hsDyComeVo = new ComprehensiveSituationVO());
+ setDefaultScores(hsDyComeVo);
+ ComprehensiveSituationVO hsYwGoVo;
+ regionVoMap.put("3", hsYwGoVo = new ComprehensiveSituationVO());
+ setDefaultScores(hsYwGoVo);
+ ComprehensiveSituationVO hsYwComeVo;
+ regionVoMap.put("4", hsYwComeVo = new ComprehensiveSituationVO());
+ setDefaultScores(hsYwComeVo);
+ ComprehensiveSituationVO hlLxVo;
+ regionVoMap.put("5", hlLxVo = new ComprehensiveSituationVO());
+ setDefaultScores(hlLxVo);
+ ComprehensiveSituationVO hlYwVo;
+ regionVoMap.put("6", hlYwVo = new ComprehensiveSituationVO());
+ setDefaultScores(hlYwVo);
+
+ // 遍历regionList获取数据
+ for (String region : regionList) {
+ ComprehensiveSituationVO currentVo = regionVoMap.get(region);
+ if (currentVo != null) {
+ switch (region) {
+ case "1":
+ getDataVo(TaskConstant.RedisKey.HS_DY_GO_REDIS_ALL_DATA_KEY, currentVo, jedis);
break;
- case MEDIUM:
- vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.MEDIUM.getCode()));
+ case "2":
+ getDataVo(TaskConstant.RedisKey.HS_DY_COME_REDIS_ALL_DATA_KEY, currentVo, jedis);
break;
- case LIGHT:
- vo.setRoadStatus(RoadStatusTypeEnum.getDescByCode(RoadStatusTypeEnum.LIGHT.getCode()));
+ case "3":
+ getDataVo(TaskConstant.RedisKey.HS_YW_GO_REDIS_ALL_DATA_KEY, currentVo, jedis);
+ break;
+ case "4":
+ getDataVo(TaskConstant.RedisKey.HS_YW_COME_REDIS_ALL_DATA_KEY, currentVo, jedis);
+ break;
+ case "5":
+ getDataVo(TaskConstant.RedisKey.HL_LX_REDIS_ALL_DATA_KEY, currentVo, jedis);
+ break;
+ case "6":
+ getDataVo(TaskConstant.RedisKey.HL_YW_REDIS_ALL_DATA_KEY, currentVo, jedis);
break;
- default:
- vo.setRoadStatus("良好");
}
}
- // 天气情况
- String weather = jsonObject.getString("Weather");
+ }
+ // 汇总数据
+ if (tunnel == 1) {
+ List vos = Lists.newArrayList(hsDyGoVo, hsDyComeVo, hsYwGoVo, hsYwComeVo);
+ vo = averageScores(vos);
+ } else if (tunnel == 2) {
+ List vos = Lists.newArrayList(hlLxVo, hlYwVo);
+ vo = averageScores(vos);
+ }
+ return vo;
+ }
- vo.setWeatherStatus(jsonObject.getString("weatherStatus"));
- vo.setRoadSafetyIndex(jsonObject.getInteger("roadSafetyIndex"));
- vo.setDangerousActionCount(jsonObject.getInteger("dangerousActionCount"));
+ private ComprehensiveSituationVO averageScores(List vos) {
+ ComprehensiveSituationVO resultVo = new ComprehensiveSituationVO();
+ setDefaultScores(resultVo);
+ if (CollUtil.isNotEmpty(vos)) {
+ int roadScore = 0, carScore = 0, driverScore = 0, environmentScore = 0, roadSafetyIndex = 0;
+ for (ComprehensiveSituationVO vo : vos) {
+ roadScore += vo.getRoadScore();
+ carScore += vo.getCarScore();
+ driverScore += vo.getDriverScore();
+ environmentScore += vo.getEnvironmentScore();
+ roadSafetyIndex += vo.getRoadSafetyIndex();
+ }
+ resultVo.setRoadScore(roadScore / vos.size());
+ resultVo.setCarScore(carScore / vos.size());
+ resultVo.setDriverScore(driverScore / vos.size());
+ resultVo.setEnvironmentScore(environmentScore / vos.size());
+ resultVo.setRoadSafetyIndex(roadSafetyIndex / vos.size());
+ return resultVo;
+ }
+ return resultVo;
+ }
+
+ private void setDefaultScores(ComprehensiveSituationVO vo) {
+ vo.setRoadScore(100);
+ vo.setCarScore(100);
+ vo.setDriverScore(100);
+ vo.setEnvironmentScore(100);
+ vo.setRoadSafetyIndex(100);
+ }
+
+ private void getDataVo(String dataKey, ComprehensiveSituationVO vo, Jedis jedis) {
+ String allData = jedis.get(dataKey);
+
+ // 解析获取数据
+ JSONObject jsonObject = JSON.parseObject(allData);
+ if (Objects.nonNull(jsonObject)) {
+
+ JSONArray driver = jsonObject.getJSONArray("Driver");
+ JSONArray speed = jsonObject.getJSONArray("Speed");
+ JSONArray pedestrian = jsonObject.getJSONArray("Pedestrian");
+ JSONArray road = jsonObject.getJSONArray("Road");
+ JSONArray congestion = jsonObject.getJSONArray("Congestion");
+ JSONArray weather = jsonObject.getJSONArray("Weather");
+ JSONArray vehicle = jsonObject.getJSONArray("Vehicle");
+ JSONArray bicycle = jsonObject.getJSONArray("Bicycle");
+ JSONArray offense = jsonObject.getJSONArray("Offense");
+
+ String time = jsonObject.getString("Time");
+ String region = jsonObject.getString("Region");
+
+ // 计算道路评分:
+ // Pedestrian(Trespass -50、Traverse -50)、
+ // Road(Damaged -10、Debris -10、Slippery -5)、
+ // Congestion(Heavy -20、Medium -10、Light -5)、
+ // Bicycle(Bicycle_Collisions -50、Motorway_Intrusion -50)
+ int roadScore = vo.getRoadScore();
+ if (CollUtil.isNotEmpty(pedestrian)){
+ for (int i = 0; i < driver.size(); i++) {
+ String driverString = driver.getString(i);
+ if (driverString.contains("habits")) {
+ driverString = "Poor_habits";
+ }
+ DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString);
+ switch (driverStatusTypeEnum){
+ case Fatigue:
+ case Poor_habits:
+ roadScore -= 50;
+ break;
+ }
+ }
+ }
+ if (CollUtil.isNotEmpty(road)){
+ for (int i = 0; i < road.size(); i++) {
+ String roadString = road.getString(i);
+ RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(roadString);
+ switch (roadStatusTypeEnum){
+ case Damaged:
+ roadScore -= 10;
+ break;
+ case Debris:
+ roadScore -= 10;
+ break;
+ case Slippery:
+ roadScore -= 5;
+ break;
+ }
+ }
+ }
+ if (CollUtil.isNotEmpty(congestion)){
+ for (int i = 0; i < congestion.size(); i++) {
+ String congestionString = congestion.getString(i);
+ CongestionStatusTypeEnum congestionStatusTypeEnum = CongestionStatusTypeEnum.valueOf(congestionString);
+ switch (congestionStatusTypeEnum){
+ case Heavy:
+ roadScore -= 20;
+ break;
+ case Medium:
+ roadScore -= 10;
+ break;
+ case Light:
+ roadScore -= 5;
+ break;
+ }
+ }
+ }
+ if (CollUtil.isNotEmpty(bicycle)){
+ for (int i = 0; i < bicycle.size(); i++) {
+ String bicycleString = bicycle.getString(i);
+ if (bicycleString.contains("Collision")){
+ bicycleString = "Bicycle_Collisions";
+ } else if (bicycleString.contains("Motorway")) {
+ bicycleString = "Motorway_Intrusion";
+ }
+ BicycleStatusTypeEnum bicycleStatusTypeEnum = BicycleStatusTypeEnum.valueOf(bicycleString);
+ switch (bicycleStatusTypeEnum){
+ case Bicycle_Collisions:
+ case Motorway_Intrusion:
+ roadScore -= 50;
+ break;
+ }
+ }
+ }
+ vo.setRoadScore(roadScore);
+
+ // 计算车辆评分
+ // Speed(Over -5、Low -5、Stop -20、Reverse -50)
+ // Vehicle(Vehicle_Collisions -50、Overturn -50、Smoke_or_Fire -50、Dropping -10)
+ // Offense(Running_a_red_light -10、Crossing_the_line -10)
+ int carScore = vo.getCarScore();
+ if (CollUtil.isNotEmpty(speed)){
+ for (int i = 0; i < speed.size(); i++) {
+ String speedString = speed.getString(i);
+ SpeedStatusTypeEnum speedStatusTypeEnum = SpeedStatusTypeEnum.valueOf(speedString);
+ switch (speedStatusTypeEnum){
+ case Over:
+ case Low:
+ carScore -= 5;
+ break;
+ case Stop:
+ carScore -= 20;
+ break;
+ case Reverse:
+ carScore -= 50;
+ break;
+ }
+ }
+ }
+ if (CollUtil.isNotEmpty(vehicle)){
+ for (int i = 0; i < vehicle.size(); i++) {
+ String vehicleString = vehicle.getString(i);
+ if (vehicleString.contains("Collision")){
+ vehicleString = "Vehicle_Collisions";
+ } else if (vehicleString.contains("Smoke")) {
+ vehicleString = "Smoke_or_Fire";
+ }
+ VehicleStatusTypeEnum vehicleStatusTypeEnum = VehicleStatusTypeEnum.valueOf(vehicleString);
+ switch (vehicleStatusTypeEnum){
+ case Vehicle_Collisions:
+ case Overturn:
+ case Smoke_or_Fire:
+ carScore -= 50;
+ break;
+ case Dropping:
+ carScore -= 10;
+ break;
+ }
+ }
+ }
+ if (CollUtil.isNotEmpty(offense)){
+ for (int i = 0; i < offense.size(); i++) {
+ String offenseString = offense.getString(i);
+ if (offenseString.contains("red")){
+ offenseString = "Running_a_red_light";
+ } else if (offenseString.contains("line")) {
+ offenseString = "Crossing_the_line";
+ }
+ OffenseStatusTypeEnum offenseStatusTypeEnum = OffenseStatusTypeEnum.valueOf(offenseString);
+ switch (offenseStatusTypeEnum){
+ case Running_a_red_light:
+ case Crossing_the_line:
+ carScore -= 10;
+ break;
+ }
+ }
+ }
+ vo.setCarScore(carScore);
+
+ // 计算驾驶员评分
+ // Driver(Fatigue -5、Poor_habits -5)
+ int driverScore = vo.getDriverScore();
+ if (CollUtil.isNotEmpty(driver)){
+ for (int i = 0; i < driver.size(); i++) {
+ String driverString = driver.getString(i);
+ if (driverString.contains("habits")) {
+ driverString = "Poor_habits";
+ }
+ DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString);
+ switch (driverStatusTypeEnum){
+ case Fatigue:
+ case Poor_habits:
+ driverScore -= 5;
+ break;
+ }
+ }
+ }
+ vo.setDriverScore(driverScore);
+
+ // 计算环境评分
+ // Weather(Fog -10、Rain -10、Snow -10、Wind -10、Sandstorm -10)
+ int environmentScore = vo.getEnvironmentScore();
+ if (CollUtil.isNotEmpty(weather)){
+ for (int i = 0; i < weather.size(); i++) {
+ String weatherString = weather.getString(i);
+ WeatherStatusTypeEnum weatherStatusTypeEnum = WeatherStatusTypeEnum.valueOf(weatherString);
+ switch (weatherStatusTypeEnum){
+ case Fog:
+ case Rain:
+ case Snow:
+ case Wind:
+ case Sandstorm:
+ environmentScore -= 10;
+ break;
+ }
+ }
+ }
+ vo.setEnvironmentScore(environmentScore);
+
+ // 计算道路安全指数 按照1:1:1:1的比例计算
+ int roadSafetyIndex = (roadScore + carScore + driverScore + environmentScore) / 4;
+ vo.setRoadSafetyIndex(roadSafetyIndex);
+ }
+ }
+
+ public List getRoadDangerBehaviorData(RoadMonitorReq req) {
+ List regionList = req.getRegionList();
+ // 从列表中查询数据
+ List list = roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class)
+ .in(RoadBehaviorAnalysis::getRegion, regionList)
+ .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime));
+ if (CollUtil.isEmpty(list)){
+ return Collections.emptyList();
+ }
+ return list.stream().map(roadBehaviorAnalysis -> {
+ RoadDangerBehaviorVO vo = new RoadDangerBehaviorVO();
+ vo.setRecord(roadBehaviorAnalysis.getBehavior());
+ vo.setRecordCode(roadBehaviorAnalysis.getBehaviorCode());
+ vo.setRecordTime(roadBehaviorAnalysis.getBehaviorTime());
+ vo.setRecordType(RoadBehaviorTypeEnum.getDescByCode(roadBehaviorAnalysis.getType()));
+ vo.setRegion(roadBehaviorAnalysis.getRegion());
+ vo.setPicturePath(roadBehaviorAnalysis.getPicturePath());
+ vo.setVideoPath(roadBehaviorAnalysis.getVideoPath());
+ vo.setLatitude(roadBehaviorAnalysis.getLatitude());
+ vo.setLongitude(roadBehaviorAnalysis.getLongitude());
+ vo.setIsWarn(roadBehaviorAnalysis.getIsWarn());
+ vo.setIsHandled(roadBehaviorAnalysis.getIsHandled());
return vo;
+ }).collect(Collectors.toList());
+ }
+
+ public void videoDownload(VideoDownloadReq req, HttpServletResponse response) {
+
+ String videoType = req.getVideoType();
+ String videoOrder = req.getVideoOrder();
+
+ File directory = new File("");
+ // 拼接对应的filePath
+ String filePath = null;
+ // 设置响应内容类型
+ // 对于MP4文件
+ response.setContentType("video/mp4");
+ // 隧道回放视频
+ if (StringUtils.equals("1", videoType)){
+ filePath = directory.getAbsolutePath() + File.separator + DefValConstants.SUI_DAO_PLAY_BACK + File.separator + videoOrder + ".mp4";
+ }
+ // 驾驶员监控实时视频
+ else if (StringUtils.equals("2", videoType)) {
+ filePath = directory.getAbsolutePath() + File.separator + DefValConstants.DRIVER_REAL_TIME_PLAY_BACK + File.separator + videoOrder + ".mp4";
+ }
+ // 驾驶员监控远程回放
+ else if (StringUtils.equals("3", videoType)) {
+ filePath = directory.getAbsolutePath() + File.separator + DefValConstants.DRIVER_REMOTE_PLAY_BACK + File.separator + videoOrder + ".mp4";
+ }
+
+ assert filePath != null;
+ File file = new File(filePath);
+
+ // 设置文件名(将显示在下载对话框中)
+ response.setHeader("Content-Disposition", "inline;");
+ // 设置文件大小,这样浏览器可以显示下载进度
+ response.setContentLengthLong(file.length());
+
+ // 设置缓存控制头
+ response.setHeader("Cache-Control", "public, max-age=31536000");
+
+ try {
+ FileInputStream fileInputStream = new FileInputStream(file);
+ ServletOutputStream servletOutputStream = response.getOutputStream();
+
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = fileInputStream.read(buffer)) != -1) {
+ servletOutputStream.write(buffer, 0, bytesRead);
+ }
+ fileInputStream.close();
+ servletOutputStream.close();
+ } catch (IOException e) {
+ throw new BizException("文件下载失败! {}",e);
}
- return null;
+ }
+
+ public List getViolationWarnRecordData(RoadMonitorReq req) {
+ // 从列表中查询数据
+ List list = roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class)
+ // 不传类型返回所有需预警数据
+ .eq(Objects.nonNull(req.getType()), RoadBehaviorAnalysis::getType, req.getType())
+ // 所选隧道包含区域
+ .in(RoadBehaviorAnalysis::getRegion, req.getRegionList())
+ // 需要预警的数据
+ .eq(RoadBehaviorAnalysis::getIsWarn, Boolean.TRUE)
+ // 查看某个具体区域的数据
+ .eq(Objects.nonNull(req.getRegion()),RoadBehaviorAnalysis::getRegion, req.getRegion())
+ .orderByDesc(RoadBehaviorAnalysis::getBehaviorTime));
+ if (CollUtil.isEmpty(list)){
+ return Collections.emptyList();
+ }
+ return list.stream().map(roadBehaviorAnalysis -> {
+ RoadDangerBehaviorVO vo = new RoadDangerBehaviorVO();
+ vo.setRecord(roadBehaviorAnalysis.getBehavior());
+ vo.setRecordCode(roadBehaviorAnalysis.getBehaviorCode());
+ vo.setRecordTime(roadBehaviorAnalysis.getBehaviorTime());
+ vo.setRecordType(RoadBehaviorTypeEnum.getDescByCode(roadBehaviorAnalysis.getType()));
+ vo.setRegion(roadBehaviorAnalysis.getRegion());
+ vo.setPicturePath(roadBehaviorAnalysis.getPicturePath());
+ vo.setVideoPath(roadBehaviorAnalysis.getVideoPath());
+ vo.setLatitude(roadBehaviorAnalysis.getLatitude());
+ vo.setLongitude(roadBehaviorAnalysis.getLongitude());
+ vo.setIsWarn(roadBehaviorAnalysis.getIsWarn());
+ vo.setIsHandled(roadBehaviorAnalysis.getIsHandled());
+ return vo;
+ }).collect(Collectors.toList());
}
}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java
new file mode 100644
index 0000000..3fe96fe
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.java
@@ -0,0 +1,16 @@
+package com.ningdatech.carapi.road.mapper;
+
+import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author CMM
+ * @since 2024-10-22
+ */
+public interface RoadBehaviorAnalysisMapper extends BaseMapper {
+
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml
new file mode 100644
index 0000000..33857fb
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/mapper/RoadBehaviorAnalysisMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java
new file mode 100644
index 0000000..5636074
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/entity/RoadBehaviorAnalysis.java
@@ -0,0 +1,69 @@
+package com.ningdatech.carapi.road.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ *
+ *
+ *
+ *
+ * @author CMM
+ * @since 2024-10-22
+ */
+@TableName("nd_road_behavior_analysis")
+@ApiModel(value = "RoadBehaviorAnalysis对象", description = "")
+@Data
+public class RoadBehaviorAnalysis implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("主键")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty("异常行为类型 1 驾驶员异常 2 车辆异常 3 道路异常 4 环境异常")
+ private Integer type;
+
+ @ApiModelProperty("异常行为描述")
+ private String behavior;
+
+ @ApiModelProperty("异常行为码")
+ private String behaviorCode;
+
+ @ApiModelProperty("异常行为时间")
+ private LocalDateTime behaviorTime;
+
+ @ApiModelProperty("区域 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向、5 何里隧道兰溪方向、6 何里隧道义乌方向")
+ private String region;
+
+ @ApiModelProperty("异常记录图片路径")
+ private String picturePath;
+
+ @ApiModelProperty("异常记录视频路径")
+ private String videoPath;
+
+ @ApiModelProperty("异常记录经度")
+ private String longitude;
+
+ @ApiModelProperty("异常记录纬度")
+ private String latitude;
+
+ @ApiModelProperty("是否需要预警")
+ private Boolean isWarn = Boolean.FALSE;
+
+ @ApiModelProperty("是否处理")
+ private Boolean isHandled = Boolean.FALSE;
+
+ @ApiModelProperty("创建时间")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty("更新时间")
+ private LocalDateTime updateTime;
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java
new file mode 100644
index 0000000..4b449dc
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/RoadMonitorReq.java
@@ -0,0 +1,33 @@
+package com.ningdatech.carapi.road.model.req;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+/**
+ * @author CMM
+ * @author CMM
+ * @date 2024/10/23 17:53
+ * /
+ * /**
+ * @since 2024/10/23 17:53
+ */
+@Data
+public class RoadMonitorReq {
+
+ @ApiModelProperty("区域 1 黄山隧道东阳去向、2 黄山隧道东阳来向、3 黄山隧道义乌去向、4 黄山隧道义乌来向、5 何里隧道兰溪方向、6 何里隧道义乌方向")
+ private String region;
+
+ @ApiModelProperty("隧道 1 黄山隧道、2 何里隧道")
+ private Integer tunnel;
+
+ @ApiModelProperty("隧道包含的区域 列表")
+ @NotEmpty(message = "区域不能为空")
+ private List regionList;
+
+ @ApiModelProperty("行为类型 1 驾驶员、2 车辆、3 道路、4 环境")
+ private Integer type;
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java
new file mode 100644
index 0000000..9acd872
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/req/VideoDownloadReq.java
@@ -0,0 +1,24 @@
+package com.ningdatech.carapi.road.model.req;
+
+import javax.validation.constraints.NotBlank;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author CMM
+ * @author CMM
+ * @date 2024/10/23 17:53
+ * /
+ * /**
+ * @since 2024/10/23 17:53
+ */
+@Data
+public class VideoDownloadReq {
+
+ @ApiModelProperty("1 隧道回放 2 驾驶员监控实时视频 3 驾驶员监控")
+ private String videoType;
+
+ @ApiModelProperty("1 2 3 4 5 6")
+ private String videoOrder;
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java
index 69d760a..693d789 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/ComprehensiveSituationVO.java
@@ -19,12 +19,15 @@ public class ComprehensiveSituationVO {
@ApiModelProperty("道路安全指数")
private Integer roadSafetyIndex;
- @ApiModelProperty("当前道路情况")
- private String roadStatus;
+ @ApiModelProperty("道路评分")
+ private Integer roadScore;
- @ApiModelProperty("当前天气情况")
- private String weatherStatus;
+ @ApiModelProperty("车辆评分")
+ private Integer carScore;
- @ApiModelProperty("当前危险行为统计")
- private Integer dangerousActionCount;
+ @ApiModelProperty("驾驶员评分")
+ private Integer driverScore;
+
+ @ApiModelProperty("环境评分")
+ private Integer environmentScore;
}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java
new file mode 100644
index 0000000..3f9f96a
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/model/vo/RoadDangerBehaviorVO.java
@@ -0,0 +1,53 @@
+package com.ningdatech.carapi.road.model.vo;
+
+import java.time.LocalDateTime;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author CMM
+ * @since 2024/10/23 10:49
+ */
+@Data
+@ApiModel(description = "道路安全监综合态势计数据-VO")
+@NoArgsConstructor
+@AllArgsConstructor
+public class RoadDangerBehaviorVO {
+
+ @ApiModelProperty("道路异常分析记录")
+ private String record;
+
+ @ApiModelProperty("道路异常分析记录Code")
+ private String recordCode;
+
+ @ApiModelProperty("道路异常分析类型")
+ private String recordType;
+
+ @ApiModelProperty("异常记录时间")
+ private LocalDateTime recordTime;
+
+ @ApiModelProperty("异常记录区域")
+ private String region;
+
+ @ApiModelProperty("异常记录图片路径")
+ private String picturePath;
+
+ @ApiModelProperty("异常记录视频路径")
+ private String videoPath;
+
+ @ApiModelProperty("异常记录经度")
+ private String longitude;
+
+ @ApiModelProperty("异常记录纬度")
+ private String latitude;
+
+ @ApiModelProperty("是否需要预警")
+ private Boolean isWarn = Boolean.FALSE;
+
+ @ApiModelProperty("是否处理")
+ private Boolean isHandled = Boolean.FALSE;
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java
new file mode 100644
index 0000000..6c8e614
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/IRoadBehaviorAnalysisService.java
@@ -0,0 +1,16 @@
+package com.ningdatech.carapi.road.service;
+
+import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 服务类
+ *
+ *
+ * @author CMM
+ * @since 2024-10-22
+ */
+public interface IRoadBehaviorAnalysisService extends IService {
+
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java
new file mode 100644
index 0000000..6e44ebc
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/service/impl/RoadBehaviorAnalysisServiceImpl.java
@@ -0,0 +1,20 @@
+package com.ningdatech.carapi.road.service.impl;
+
+import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
+import com.ningdatech.carapi.road.mapper.RoadBehaviorAnalysisMapper;
+import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ * 服务实现类
+ *
+ *
+ * @author CMM
+ * @since 2024-10-22
+ */
+@Service
+public class RoadBehaviorAnalysisServiceImpl extends ServiceImpl implements IRoadBehaviorAnalysisService {
+
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java
new file mode 100644
index 0000000..d191d92
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/road/task/RoadMonitorDataPullTask.java
@@ -0,0 +1,476 @@
+package com.ningdatech.carapi.road.task;
+
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import cn.hutool.core.map.MapUtil;
+import com.ningdatech.basic.util.StrPool;
+import org.apache.commons.compress.utils.Lists;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ningdatech.basic.util.NdDateUtils;
+import com.ningdatech.carapi.road.constant.*;
+import com.ningdatech.carapi.road.model.entity.RoadBehaviorAnalysis;
+import com.ningdatech.carapi.road.service.IRoadBehaviorAnalysisService;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.LocalDateTimeUtil;
+import cn.hutool.core.date.StopWatch;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import redis.clients.jedis.Jedis;
+
+/**
+ * @author CMM
+ * 道路监控实时算法分析数据拉取定时任务
+ * @since 2024/10/12 10:39
+ */
+@Component
+@Slf4j
+@RequiredArgsConstructor
+public class RoadMonitorDataPullTask {
+
+ @Value("${spring.redis.host}")
+ private String redisHost;
+
+ @Value("${spring.redis.port}")
+ private Integer redisPort;
+
+ @Value("${spring.redis.password}")
+ private String redisPassword;
+
+ @Value("${task.switch.is-open}")
+ private boolean flag;
+
+ private final IRoadBehaviorAnalysisService roadBehaviorAnalysisService;
+
+ // 定时更新道路监控实时算法分析数据 每10分钟一次
+ @Scheduled(cron = "0 */10 * * * ?")
+ public void doTask() {
+ if (!flag){
+ log.info("道路监控实时算法分析数据拉取定时任务未开启!");
+ return;
+ }
+ log.info("=========== 道路监控实时算法分析数据拉取 ======== 任务开始");
+ StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+
+ List dataList;
+ Map REDIS_KEY_REGION_MAP = getRedisKeyRegionMap();
+ try (Jedis jedis = new Jedis(redisHost, redisPort)) {
+ jedis.auth(redisPassword);
+ dataList = REDIS_KEY_REGION_MAP.keySet().stream().map(jedis::get)
+ .filter(StringUtils::isNotBlank)
+ .collect(Collectors.toList());
+ }
+ if (CollUtil.isNotEmpty(dataList)) {
+ for (String data : dataList) {
+ // 解析获取数据
+ JSONObject jsonObject = JSON.parseObject(data);
+ String time = jsonObject.getString("Time");
+ String region = jsonObject.getString("Region");
+
+ // 转换为LocalDateTime类型
+ LocalDateTime createTime = LocalDateTimeUtil.parse(time, NdDateUtils.DEFAULT_DATE_TIME_FORMAT);
+
+ // 根据时间 判断数据库中是否存在 不存在 入库
+ // 获取当前区域当前数据产生时间 在数据库中是否存入过
+ List list = checkDataExists(createTime, region);
+
+ // 如果没有存入过
+ if (CollUtil.isEmpty(list)) {
+ List saveDataList = assembleData(jsonObject);
+ if (CollUtil.isNotEmpty(saveDataList)){
+ log.info("=========== 保存数据条数:{}",saveDataList.size());
+ roadBehaviorAnalysisService.saveBatch(saveDataList);
+ log.info("=========== 保存成功");
+ }
+ }
+ }
+ }
+ stopWatch.stop();
+ log.info("=========== 道路监控实时算法分析数据拉取 ======== 任务结束 {}s",stopWatch.getTotalTimeSeconds());
+ }
+
+ @FunctionalInterface
+ interface DataAssembler {
+ void assemble(JSONArray dataArray, List saveDataList, JSONObject jsonObject);
+ }
+ private List assembleData(JSONObject jsonObject) {
+ List saveDataList = Lists.newArrayList();
+ // 定义一个映射,关联JSON数组的键和对应的数据处理方法
+ Map assemblerMap = new HashMap<>();
+ assemblerMap.put("Driver", this::assemblyDriverData);
+ assemblerMap.put("Speed", this::assemblySpeedData);
+ assemblerMap.put("Pedestrian", this::assemblyPedestrianData);
+ assemblerMap.put("Road", this::assemblyRoadData);
+ assemblerMap.put("Congestion", this::assemblyCongestionData);
+ assemblerMap.put("Weather", this::assemblyWeatherData);
+ assemblerMap.put("Vehicle", this::assemblyVehicleData);
+ assemblerMap.put("Bicycle", this::assemblyBicycleData);
+ assemblerMap.put("Offense", this::assemblyOffenseData);
+ // 遍历映射,处理每个数据集
+ assemblerMap.forEach((key, assembler) -> {
+ JSONArray dataArray = jsonObject.getJSONArray(key);
+ if (dataArray != null && !dataArray.isEmpty()) {
+ assembler.assemble(dataArray, saveDataList, jsonObject);
+ }
+ });
+ return saveDataList;
+ }
+
+ private List checkDataExists(LocalDateTime createTime, String region) {
+ return roadBehaviorAnalysisService.list(Wrappers.lambdaQuery(RoadBehaviorAnalysis.class)
+ .eq(RoadBehaviorAnalysis::getBehaviorTime, createTime)
+ .eq(RoadBehaviorAnalysis::getRegion, region));
+ }
+
+ private static Map getRedisKeyRegionMap() {
+ Map REDIS_KEY_REGION_MAP = MapUtil.newHashMap();
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_DY_GO_REDIS_ALL_DATA_KEY, "1");
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_DY_COME_REDIS_ALL_DATA_KEY, "2");
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_YW_GO_REDIS_ALL_DATA_KEY, "3");
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HS_YW_COME_REDIS_ALL_DATA_KEY, "4");
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HL_LX_REDIS_ALL_DATA_KEY, "5");
+ REDIS_KEY_REGION_MAP.put(TaskConstant.RedisKey.HL_YW_REDIS_ALL_DATA_KEY, "6");
+ return REDIS_KEY_REGION_MAP;
+ }
+
+ /**
+ * 车辆违章情况
+ * @param offense \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyOffenseData(JSONArray offense, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < offense.size(); i++) {
+ String offenseString = offense.getString(i);
+ if (offenseString.contains("red")){
+ offenseString = "Running_a_red_light";
+ } else if (offenseString.contains("line")) {
+ offenseString = "Crossing_the_line";
+ }
+ OffenseStatusTypeEnum offenseStatusTypeEnum = OffenseStatusTypeEnum.valueOf(offenseString);
+ behaviorBuilder.append(offenseStatusTypeEnum.getDesc());
+ if (i != offense.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(offenseStatusTypeEnum.name());
+ if (i != offense.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 自行车情况
+ * @param bicycle \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyBicycleData(JSONArray bicycle, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < bicycle.size(); i++) {
+ String bicycleString = bicycle.getString(i);
+ if (bicycleString.contains("Collision")){
+ bicycleString = "Bicycle_Collisions";
+ } else if (bicycleString.contains("Motorway")) {
+ bicycleString = "Motorway_Intrusion";
+ }
+ BicycleStatusTypeEnum bicycleStatusTypeEnum = BicycleStatusTypeEnum.valueOf(bicycleString);
+ behaviorBuilder.append(bicycleStatusTypeEnum.getDesc());
+ if (i != bicycle.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(bicycleStatusTypeEnum.name());
+ if (i != bicycle.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 车辆情况
+ * @param vehicle \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyVehicleData(JSONArray vehicle, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < vehicle.size(); i++) {
+ String vehicleString = vehicle.getString(i);
+ if (vehicleString.contains("Collision")){
+ vehicleString = "Vehicle_Collisions";
+ } else if (vehicleString.contains("Smoke")) {
+ vehicleString = "Smoke_or_Fire";
+ }
+ VehicleStatusTypeEnum vehicleStatusTypeEnum = VehicleStatusTypeEnum.valueOf(vehicleString);
+ behaviorBuilder.append(vehicleStatusTypeEnum.getDesc());
+ if (i != vehicle.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(vehicleStatusTypeEnum.name());
+ if (i != vehicle.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 天气情况
+ * @param weather \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyWeatherData(JSONArray weather, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < weather.size(); i++) {
+ String weatherString = weather.getString(i);
+ WeatherStatusTypeEnum weatherStatusTypeEnum = WeatherStatusTypeEnum.valueOf(weatherString);
+ behaviorBuilder.append(weatherStatusTypeEnum.getDesc());
+ if (i != weather.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(weatherStatusTypeEnum.name());
+ if (i != weather.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ENVIRONMENT.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 拥堵情况
+ * @param congestion \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyCongestionData(JSONArray congestion, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < congestion.size(); i++) {
+ String congestionString = congestion.getString(i);
+ CongestionStatusTypeEnum congestionStatusTypeEnum = CongestionStatusTypeEnum.valueOf(congestionString);
+ behaviorBuilder.append(congestionStatusTypeEnum.getDesc());
+ if (i != congestion.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(congestionStatusTypeEnum.name());
+ if (i != congestion.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 道路情况
+ * @param road \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyRoadData(JSONArray road, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < road.size(); i++) {
+ String roadString = road.getString(i);
+ RoadStatusTypeEnum roadStatusTypeEnum = RoadStatusTypeEnum.valueOf(roadString);
+ behaviorBuilder.append(roadStatusTypeEnum.getDesc());
+ if (i != road.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(roadStatusTypeEnum.name());
+ if (i != road.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(),jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 行人情况
+ * @param pedestrian \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyPedestrianData(JSONArray pedestrian, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < pedestrian.size(); i++) {
+ String pedestrianString = pedestrian.getString(i);
+ PedestrianStatusTypeEnum pedestrianStatusTypeEnum = PedestrianStatusTypeEnum.valueOf(pedestrianString);
+ behaviorBuilder.append(pedestrianStatusTypeEnum.getDesc());
+ if (i != pedestrian.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(pedestrianStatusTypeEnum.name());
+ if (i != pedestrian.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.ROAD.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ private RoadBehaviorAnalysis getRoadBehaviorAnalysis(StringBuilder behaviorBuilder, StringBuilder behaviorCodeBuilder, int type, JSONObject jsonObject) {
+ String behavior = behaviorBuilder.toString();
+ String behaviorCode = behaviorCodeBuilder.toString();
+
+ String time = jsonObject.getString("Time");
+ String region = jsonObject.getString("Region");
+
+ JSONArray pictures = jsonObject.getJSONArray("PicturePath");
+ String picturePath = null;
+ if (Objects.nonNull(pictures) && CollUtil.isNotEmpty(pictures)) {
+ picturePath = pictures.getString(0);
+ }
+ JSONArray videos = jsonObject.getJSONArray("VideoPath");
+ String videoPath = null;
+ if (Objects.nonNull(videos) && CollUtil.isNotEmpty(videos)) {
+ videoPath = videos.getString(0);
+ }
+ JSONArray longitudes = jsonObject.getJSONArray("Longitude");
+ String longitude = null;
+ if (Objects.nonNull(longitudes) && CollUtil.isNotEmpty(longitudes)){
+ longitude = longitudes.getString(0);
+ }
+ JSONArray latitudes = jsonObject.getJSONArray("Latitude");
+ String latitude = null;
+ if (Objects.nonNull(latitudes) && CollUtil.isNotEmpty(latitudes)){
+ latitude = latitudes.getString(0);
+ }
+
+ // 转换为LocalDateTime类型
+ LocalDateTime createTime = LocalDateTimeUtil.parse(time, NdDateUtils.DEFAULT_DATE_TIME_FORMAT);
+
+ RoadBehaviorAnalysis roadBehaviorAnalysis = new RoadBehaviorAnalysis();
+ roadBehaviorAnalysis.setBehavior(behavior);
+ roadBehaviorAnalysis.setBehaviorCode(behaviorCode);
+ roadBehaviorAnalysis.setBehaviorTime(createTime);
+ roadBehaviorAnalysis.setCreateTime(LocalDateTime.now());
+ roadBehaviorAnalysis.setUpdateTime(LocalDateTime.now());
+ roadBehaviorAnalysis.setRegion(region);
+ roadBehaviorAnalysis.setType(type);
+ roadBehaviorAnalysis.setPicturePath(picturePath);
+ roadBehaviorAnalysis.setVideoPath(videoPath);
+ roadBehaviorAnalysis.setLongitude(longitude);
+ roadBehaviorAnalysis.setLatitude(latitude);
+ roadBehaviorAnalysis.setIsWarn(judgeIsWarn(behaviorCode));
+ // 首次保存的数据默认未处理
+ roadBehaviorAnalysis.setIsHandled(Boolean.FALSE);
+ return roadBehaviorAnalysis;
+ }
+
+ /**
+ * 判断是否需要预警
+ * @param behaviorCode
+ * @return
+ */
+ private Boolean judgeIsWarn(String behaviorCode) {
+ // 获取需要预警的behaviorCode
+ List needWarnBehaviorCodeList = getNeedWarnBehaviorCode();
+ if (StringUtils.isNotBlank(behaviorCode)){
+ List behaviorCodeList = Arrays.stream(behaviorCode.split(StrPool.COMMA)).collect(Collectors.toList());
+ // 判断是否包含需要预警的behaviorCode
+ return behaviorCodeList.stream().anyMatch(needWarnBehaviorCodeList::contains);
+ }
+ return Boolean.FALSE;
+ }
+
+ private List getNeedWarnBehaviorCode() {
+ List dataList = Lists.newArrayList();
+ // Speed-->Reverse
+ dataList.add(SpeedStatusTypeEnum.Reverse.name());
+ // Pedestrian-->Trespass、Traverse
+ dataList.add(PedestrianStatusTypeEnum.Trespass.name());
+ dataList.add(PedestrianStatusTypeEnum.Traverse.name());
+ // Road-->Damaged
+ dataList.add(RoadStatusTypeEnum.Damaged.name());
+ // Congestion-->Heavy
+ dataList.add(CongestionStatusTypeEnum.Heavy.name());
+ // Vehicle-->Vehicle_Collisions、Overturn、Smoke_or_Fire
+ dataList.add(VehicleStatusTypeEnum.Vehicle_Collisions.name());
+ dataList.add(VehicleStatusTypeEnum.Overturn.name());
+ dataList.add(VehicleStatusTypeEnum.Smoke_or_Fire.name());
+ // Bicycle-->Bicycle_Collisions、Motorway_Intrusion
+ dataList.add(BicycleStatusTypeEnum.Bicycle_Collisions.name());
+ dataList.add(BicycleStatusTypeEnum.Motorway_Intrusion.name());
+ return dataList;
+ }
+
+ /**
+ * 保存车辆速度异常数据
+ * @param speed \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblySpeedData(JSONArray speed, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < speed.size(); i++) {
+ String speedString = speed.getString(i);
+ SpeedStatusTypeEnum speedStatusTypeEnum = SpeedStatusTypeEnum.valueOf(speedString);
+ behaviorBuilder.append(speedStatusTypeEnum.getDesc());
+ if (i != speed.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(speedStatusTypeEnum.name());
+ if (i != speed.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.CAR.getCode(), jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+
+ /**
+ * 保存驾驶员异常行为数据
+ * @param driver \
+ * @param saveDataList \
+ * @param jsonObject \
+ */
+ private void assemblyDriverData(JSONArray driver, List saveDataList, JSONObject jsonObject) {
+ StringBuilder behaviorBuilder = new StringBuilder();
+ StringBuilder behaviorCodeBuilder = new StringBuilder();
+ for (int i = 0; i < driver.size(); i++) {
+ String driverString = driver.getString(i);
+ if (driverString.contains("habits")) {
+ driverString = "Poor_habits";
+ }
+ DriverStatusTypeEnum driverStatusTypeEnum = DriverStatusTypeEnum.valueOf(driverString);
+ behaviorBuilder.append(driverStatusTypeEnum.getDesc());
+ if (i != driver.size() - 1) {
+ behaviorBuilder.append(",");
+ }
+ behaviorCodeBuilder.append(driverStatusTypeEnum.name());
+ if (i != driver.size() - 1) {
+ behaviorCodeBuilder.append(",");
+ }
+ }
+ RoadBehaviorAnalysis roadBehaviorAnalysis = getRoadBehaviorAnalysis(behaviorBuilder, behaviorCodeBuilder, RoadBehaviorTypeEnum.DRIVER.getCode(),jsonObject);
+ saveDataList.add(roadBehaviorAnalysis);
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java
new file mode 100644
index 0000000..3db2b2b
--- /dev/null
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskConstant.java
@@ -0,0 +1,157 @@
+package com.ningdatech.carapi.scheduler.contants;
+
+import java.math.BigDecimal;
+
+/**
+ * @author PoffyZhang
+ * @Classname TaskContant
+ * @Description
+ * @Date 2022/12/7 11:00
+ */
+public interface TaskConstant {
+ class Host {
+ public static final String HOST_ZPF = "LAPTOP-NQGEQP03";
+ public static final String HOST_CMM2 = "DESKTOP-KN1L6HL";
+ public static final String HOST_CMM = "LAPTOP-PCISPN2O";
+
+ public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ";
+ }
+
+ class DataField {
+
+ public static final String GPS = "GPS";
+
+ public static final String ADAS = "ADAS";
+ public static final String ROAD_SIGN_TYPE = "roadSignType";
+ public static final String ROAD_SIGN_DATA = "roadSignData";
+ public static final String LONGITUDE = "longitude";
+
+ public static final String LATITUDE = "latitude";
+ }
+
+ class Data{
+ public static final Integer ROAD_SIGN_TYPE_OVERSPEED = 1;
+ public static final Integer STAR_NUMBER_RANGE_ZERO = 0;
+ public static final Integer STAR_NUMBER_RANGE_TWENTY = 20;
+ public static final Integer STAR_NUMBER_RANGE_FORTY = 40;
+ public static final Integer STAR_NUMBER_RANGE_SIXTY = 60;
+ public static final Integer STAR_NUMBER_RANGE_EIGHTY = 80;
+
+ public static final Integer DRIVER_STAR_DATA_CNT_ONE = 1;
+
+ public static final Integer OPERATOR_ASSESSMENT_SCORE_ZERO = 0;
+ public static final Integer OPERATOR_ASSESSMENT_SCORE_HUNDRED = 100;
+
+ public static final Integer MONTH_VALUE_ONE = 1;
+ public static final Integer MONTH_VALUE_TWO = 2;
+ public static final Integer MONTH_VALUE_THREE = 3;
+ public static final Integer MONTH_VALUE_FOUR = 4;
+ public static final Integer MONTH_VALUE_FIVE = 5;
+ public static final Integer MONTH_VALUE_SIX = 6;
+ public static final Integer MONTH_VALUE_SEVEN = 7;
+ public static final Integer MONTH_VALUE_EIGHT = 8;
+ public static final Integer MONTH_VALUE_NINE = 9;
+ public static final Integer MONTH_VALUE_TEN = 10;
+ public static final Integer MONTH_VALUE_ELEVEN = 11;
+ public static final Integer MONTH_VALUE_TWELVE = 12;
+
+ public static final Integer SUB_LIST_SIZE = 2000;
+ public static final Integer VIOLATION_TIME_SEVEN = 7;
+ public static final Integer VIOLATION_TIME_NINE = 9;
+ public static final Integer VIOLATION_TIME_SIXTEEN = 16;
+ public static final Integer VIOLATION_TIME_EIGHTEEN = 18;
+ public static final String VIOLATION_TIME_AM_START = "7:00";
+ public static final String VIOLATION_TIME_AM_END = "9:00";
+ public static final String VIOLATION_TIME_PM_START = "16:30";
+ public static final String VIOLATION_TIME_PM_END = "18:30";
+ public static final String VIOLATION_TIME_HALF = ":30";
+ public static final String VIOLATION_TIME_START = ":00";
+ public static final Integer GPS_TIME_BUCKET = 5;
+
+ }
+
+ class RedisKey {
+ public static final String OVERSPEED_TASK_LOCK = "cm:task:overspeed:task_lock";
+
+ public static final String OVERSPEED_ALARM_DATA_INDEX = "cm:task:overspeed:alarm_data_index";
+ public static final String OVERSPEED_GPS_DATA_INDEX = "cm:task:overspeed:gps_data_index";
+
+ public static final String DRIVER_STAR_MANAGE_OUT_DANGER = "cm:task:driver:star_manage_out_danger_index";
+
+ public static final String DRIVER_BLACK_LIST = "cm:task:driver:black_list_index";
+
+ public static final String COMPANY_VEHICLE_NOT_GET_ON = "cm:task:company:not_get_on_index";
+
+ public static final String DRIVER_STAR_MANAGE_ACCIDENT = "cm:task:driver:star_manage_accident_index";
+
+ public static final String DRIVER_STAR_MANAGE_DEATH_ACCIDENT = "cm:task:driver:star_manage_death_accident_index";
+
+ public static final String DRIVER_ABNORMAL_BEHAVIOR_ANALYSIS = "cm:task:driver:driver_abnormal_behavior_analysis_index";
+
+ public static final String VEHICLE_ALARM_DATA_INDEX = "cm:task:vehicle:alarm_data_index";
+
+ public static final String OPERATOR_ASSESSMENT_SCORE = "cm:task:operator:operator_assessment_score_index";
+ public static final String ACCIDENT_QUERY_IRS = "cm:task:irs:accident_query_irs_index";
+ public static final String VEHICLE_ILLEGAL_QUERY_IRS = "cm:task:irs:vehicle_illegal_query_irs_index";
+ public static final String DRIVING_LICENCE_IRS = "cm:task:irs:driving_license_irs_index";
+ public static final String VEHICLE_LICENSE_IRS = "cm:task:irs:vehicle_license_irs_index";
+ public static final String IRS_VEHICLE_ILLEGAL_REQUEST_SECRET = "cm:task:irs:irs_vehicle_illegal_request_secret_index";
+ public static final String IRS_VEHICLE_ILLEGAL_REFRESH_SECRET = "cm:task:irs:irs_vehicle_illegal_refresh_secret_index";
+ public static final String IRS_VEHICLE_LICENSE_REQUEST_SECRET = "cm:task:irs:irs_vehicle_license_request_secret_index";
+ public static final String IRS_VEHICLE_LICENSE_REFRESH_SECRET = "cm:task:irs:irs_vehicle_license_refresh_secret_index";
+ public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET = "cm:task:irs:irs_accident_query_request_secret_index";
+ public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET = "cm:task:irs:irs_accident_query_refresh_secret_index";
+ public static final String IRS_ACCIDENT_DUTY_REQUEST_SECRET = "cm:task:irs:irs_accident_duty_request_secret_index";
+ public static final String IRS_ACCIDENT_DUTY_REFRESH_SECRET = "cm:task:irs:irs_accident_duty_refresh_secret_index";
+
+ public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET_TEST = "cm:task:irs:irs_accident_query_request_secret_test_index";
+ public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET_TEST = "cm:task:irs:irs_accident_query_refresh_secret_test_index";
+
+ public static final Integer IRS_SECRET_TIME_INTERVAL = 10;
+
+ public static final String GPS_DATA_PULL_MAX_BIZ_ID = "cm:task:gps:gps_data_pull_max_biz_id";
+
+ // 黄山隧道东阳去向
+ public static final String HS_DY_GO_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_dy_go_all_data_key";
+ // 黄山隧道东阳来向
+ public static final String HS_DY_COME_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_dy_come_all_data_key";
+ // 黄山隧道义乌去向
+ public static final String HS_YW_GO_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_yw_go_all_data_key";
+ // 黄山隧道义乌来向
+ public static final String HS_YW_COME_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hs_yw_come_all_data_key";
+ // 何里隧道兰溪方向
+ public static final String HL_LX_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hl_lx_all_data_key";
+ // 何里隧道义乌方向
+ public static final String HL_YW_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:hl_yw_all_data_key";
+ }
+
+ class Math {
+ public static final BigDecimal LONGITUDE_UNITS = BigDecimal.valueOf(1000000);
+
+ public static final BigDecimal SPEED_UNITS = BigDecimal.valueOf(0.036);
+
+ public static final BigDecimal ALTITUDE_UNITS = BigDecimal.valueOf(100);
+
+ public static final BigDecimal DIRECTION_UNITS = BigDecimal.valueOf(10);
+ }
+
+
+ class Msg {
+ public static final String REDIS_KEY_NOT_FOUND = "redis key {} not found 请查找原因!";
+ public static final String REFRESH_KEY_FREQUENTLY = "请求过于频繁,请稍候再试";
+ }
+
+ class Code {
+ public static final String REFRESH_KEY_FREQUENTLY_CODE = "88";
+ }
+
+ class Star{
+ public static final Double ONE_STAR = 1.0;
+ public static final Double TWO_STAR = 2.0;
+ public static final Double THREE_STAR = 3.0;
+ public static final Double FOUR_STAR = 4.0;
+ public static final Double FIVE_STAR = 5.0;
+
+
+ }
+}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java
deleted file mode 100644
index 86f6591..0000000
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/contants/TaskContant.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package com.ningdatech.carapi.scheduler.contants;
-
-import java.math.BigDecimal;
-
-/**
- * @author PoffyZhang
- * @Classname TaskContant
- * @Description
- * @Date 2022/12/7 11:00
- */
-public interface TaskContant {
- class Host {
- public static final String HOST_ZPF = "LAPTOP-NQGEQP03";
- public static final String HOST_CMM2 = "DESKTOP-KN1L6HL";
- public static final String HOST_CMM = "LAPTOP-PCISPN2O";
-
- public static final String HOST_207 = "iZbp13nwyvib53j4j1p2xoZ";
- }
-
- class DataField {
-
- public static final String GPS = "GPS";
-
- public static final String ADAS = "ADAS";
- public static final String ROAD_SIGN_TYPE = "roadSignType";
- public static final String ROAD_SIGN_DATA = "roadSignData";
- public static final String LONGITUDE = "longitude";
-
- public static final String LATITUDE = "latitude";
- }
-
- class Data{
- public static final Integer ROAD_SIGN_TYPE_OVERSPEED = 1;
- public static final Integer STAR_NUMBER_RANGE_ZERO = 0;
- public static final Integer STAR_NUMBER_RANGE_TWENTY = 20;
- public static final Integer STAR_NUMBER_RANGE_FORTY = 40;
- public static final Integer STAR_NUMBER_RANGE_SIXTY = 60;
- public static final Integer STAR_NUMBER_RANGE_EIGHTY = 80;
-
- public static final Integer DRIVER_STAR_DATA_CNT_ONE = 1;
-
- public static final Integer OPERATOR_ASSESSMENT_SCORE_ZERO = 0;
- public static final Integer OPERATOR_ASSESSMENT_SCORE_HUNDRED = 100;
-
- public static final Integer MONTH_VALUE_ONE = 1;
- public static final Integer MONTH_VALUE_TWO = 2;
- public static final Integer MONTH_VALUE_THREE = 3;
- public static final Integer MONTH_VALUE_FOUR = 4;
- public static final Integer MONTH_VALUE_FIVE = 5;
- public static final Integer MONTH_VALUE_SIX = 6;
- public static final Integer MONTH_VALUE_SEVEN = 7;
- public static final Integer MONTH_VALUE_EIGHT = 8;
- public static final Integer MONTH_VALUE_NINE = 9;
- public static final Integer MONTH_VALUE_TEN = 10;
- public static final Integer MONTH_VALUE_ELEVEN = 11;
- public static final Integer MONTH_VALUE_TWELVE = 12;
-
- public static final Integer SUB_LIST_SIZE = 2000;
- public static final Integer VIOLATION_TIME_SEVEN = 7;
- public static final Integer VIOLATION_TIME_NINE = 9;
- public static final Integer VIOLATION_TIME_SIXTEEN = 16;
- public static final Integer VIOLATION_TIME_EIGHTEEN = 18;
- public static final String VIOLATION_TIME_AM_START = "7:00";
- public static final String VIOLATION_TIME_AM_END = "9:00";
- public static final String VIOLATION_TIME_PM_START = "16:30";
- public static final String VIOLATION_TIME_PM_END = "18:30";
- public static final String VIOLATION_TIME_HALF = ":30";
- public static final String VIOLATION_TIME_START = ":00";
- public static final Integer GPS_TIME_BUCKET = 5;
-
- }
-
- class RedisKey {
- public static final String OVERSPEED_TASK_LOCK = "cm:task:overspeed:task_lock";
-
- public static final String OVERSPEED_ALARM_DATA_INDEX = "cm:task:overspeed:alarm_data_index";
- public static final String OVERSPEED_GPS_DATA_INDEX = "cm:task:overspeed:gps_data_index";
-
- public static final String DRIVER_STAR_MANAGE_OUT_DANGER = "cm:task:driver:star_manage_out_danger_index";
-
- public static final String DRIVER_BLACK_LIST = "cm:task:driver:black_list_index";
-
- public static final String COMPANY_VEHICLE_NOT_GET_ON = "cm:task:company:not_get_on_index";
-
- public static final String DRIVER_STAR_MANAGE_ACCIDENT = "cm:task:driver:star_manage_accident_index";
-
- public static final String DRIVER_STAR_MANAGE_DEATH_ACCIDENT = "cm:task:driver:star_manage_death_accident_index";
-
- public static final String DRIVER_ABNORMAL_BEHAVIOR_ANALYSIS = "cm:task:driver:driver_abnormal_behavior_analysis_index";
-
- public static final String VEHICLE_ALARM_DATA_INDEX = "cm:task:vehicle:alarm_data_index";
-
- public static final String OPERATOR_ASSESSMENT_SCORE = "cm:task:operator:operator_assessment_score_index";
- public static final String ACCIDENT_QUERY_IRS = "cm:task:irs:accident_query_irs_index";
- public static final String VEHICLE_ILLEGAL_QUERY_IRS = "cm:task:irs:vehicle_illegal_query_irs_index";
- public static final String DRIVING_LICENCE_IRS = "cm:task:irs:driving_license_irs_index";
- public static final String VEHICLE_LICENSE_IRS = "cm:task:irs:vehicle_license_irs_index";
- public static final String IRS_VEHICLE_ILLEGAL_REQUEST_SECRET = "cm:task:irs:irs_vehicle_illegal_request_secret_index";
- public static final String IRS_VEHICLE_ILLEGAL_REFRESH_SECRET = "cm:task:irs:irs_vehicle_illegal_refresh_secret_index";
- public static final String IRS_VEHICLE_LICENSE_REQUEST_SECRET = "cm:task:irs:irs_vehicle_license_request_secret_index";
- public static final String IRS_VEHICLE_LICENSE_REFRESH_SECRET = "cm:task:irs:irs_vehicle_license_refresh_secret_index";
- public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET = "cm:task:irs:irs_accident_query_request_secret_index";
- public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET = "cm:task:irs:irs_accident_query_refresh_secret_index";
- public static final String IRS_ACCIDENT_DUTY_REQUEST_SECRET = "cm:task:irs:irs_accident_duty_request_secret_index";
- public static final String IRS_ACCIDENT_DUTY_REFRESH_SECRET = "cm:task:irs:irs_accident_duty_refresh_secret_index";
-
- public static final String IRS_ACCIDENT_QUERY_REQUEST_SECRET_TEST = "cm:task:irs:irs_accident_query_request_secret_test_index";
- public static final String IRS_ACCIDENT_QUERY_REFRESH_SECRET_TEST = "cm:task:irs:irs_accident_query_refresh_secret_test_index";
-
- public static final Integer IRS_SECRET_TIME_INTERVAL = 10;
-
- public static final String GPS_DATA_PULL_MAX_BIZ_ID = "cm:task:gps:gps_data_pull_max_biz_id";
-
- public static final String ALGORITHM_REDIS_DRIVER_DATA_KEY = "yw:algorithm:redis:driver_data_key";
- public static final String ALGORITHM_REDIS_VEHICLE_DATA_KEY = "yw:algorithm:redis:vehicle_data_key";
- public static final String ALGORITHM_REDIS_VIDEO_DATA_KEY = "yw:algorithm:redis:video_data_key";
- public static final String ALGORITHM_REDIS_ALL_DATA_KEY = "yw:algorithm:redis:all_data_key";
-
-
- }
-
- class Math {
- public static final BigDecimal LONGITUDE_UNITS = BigDecimal.valueOf(1000000);
-
- public static final BigDecimal SPEED_UNITS = BigDecimal.valueOf(0.036);
-
- public static final BigDecimal ALTITUDE_UNITS = BigDecimal.valueOf(100);
-
- public static final BigDecimal DIRECTION_UNITS = BigDecimal.valueOf(10);
- }
-
-
- class Msg {
- public static final String REDIS_KEY_NOT_FOUND = "redis key {} not found 请查找原因!";
- public static final String REFRESH_KEY_FREQUENTLY = "请求过于频繁,请稍候再试";
- }
-
- class Code {
- public static final String REFRESH_KEY_FREQUENTLY_CODE = "88";
- }
-
- class Star{
- public static final Double ONE_STAR = 1.0;
- public static final Double TWO_STAR = 2.0;
- public static final Double THREE_STAR = 3.0;
- public static final Double FOUR_STAR = 4.0;
- public static final Double FIVE_STAR = 5.0;
-
-
- }
-}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java
index 0e13ae8..8d56e98 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/DriverScoreUtils.java
@@ -23,7 +23,7 @@ import com.ningdatech.carapi.driver.model.bo.CodingRuleBO;
import com.ningdatech.carapi.driver.service.IDriverInfoService;
import com.ningdatech.carapi.driver.service.IDriverScoreInfoService;
import com.ningdatech.carapi.driver.service.IDriverScoreRecordService;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.sys.entity.enumeration.CodingRuleBehaviorTypeEnum;
import lombok.extern.slf4j.Slf4j;
@@ -114,21 +114,21 @@ public class DriverScoreUtils {
return;
}
Integer driverScore = scoreInfo.getDriverScore();
- if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_ZERO && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_TWENTY){
+ if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_ZERO && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_TWENTY){
starManage.setCurrentScore(driverScore);
- starManage.setCurrentStar(TaskContant.Star.ONE_STAR);
- } else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_TWENTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_FORTY) {
+ starManage.setCurrentStar(TaskConstant.Star.ONE_STAR);
+ } else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_TWENTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_FORTY) {
starManage.setCurrentScore(driverScore);
- starManage.setCurrentStar(TaskContant.Star.TWO_STAR);
- }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_FORTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_SIXTY){
+ starManage.setCurrentStar(TaskConstant.Star.TWO_STAR);
+ }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_FORTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_SIXTY){
starManage.setCurrentScore(driverScore);
- starManage.setCurrentStar(TaskContant.Star.THREE_STAR);
- }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_SIXTY && driverScore < TaskContant.Data.STAR_NUMBER_RANGE_EIGHTY){
+ starManage.setCurrentStar(TaskConstant.Star.THREE_STAR);
+ }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_SIXTY && driverScore < TaskConstant.Data.STAR_NUMBER_RANGE_EIGHTY){
starManage.setCurrentScore(driverScore);
- starManage.setCurrentStar(TaskContant.Star.FOUR_STAR);
- }else if (driverScore >= TaskContant.Data.STAR_NUMBER_RANGE_EIGHTY){
+ starManage.setCurrentStar(TaskConstant.Star.FOUR_STAR);
+ }else if (driverScore >= TaskConstant.Data.STAR_NUMBER_RANGE_EIGHTY){
starManage.setCurrentScore(driverScore);
- starManage.setCurrentStar(TaskContant.Star.FIVE_STAR);
+ starManage.setCurrentStar(TaskConstant.Star.FIVE_STAR);
}
}
}
diff --git a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java
index 9281feb..c1d582a 100644
--- a/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java
+++ b/ningda-yw-api/src/main/java/com/ningdatech/carapi/scheduler/util/GpsUtils.java
@@ -2,7 +2,7 @@ package com.ningdatech.carapi.scheduler.util;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.carapi.common.constant.GPSDataEnum;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.scheduler.entity.GpsData;
import java.math.BigDecimal;
@@ -22,33 +22,33 @@ public class GpsUtils {
public static GpsData getGpsData(JSONObject gpsJson) {
GpsData gpsData = new GpsData();
BigDecimal altitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.ALTITUDE.getDesc());
- Optional altitudeBigDecimal = Optional.ofNullable(altitudeTemp).map(a -> a.divide(TaskContant.Math.ALTITUDE_UNITS, RoundingMode.HALF_UP));
+ Optional altitudeBigDecimal = Optional.ofNullable(altitudeTemp).map(a -> a.divide(TaskConstant.Math.ALTITUDE_UNITS, RoundingMode.HALF_UP));
if (altitudeBigDecimal.isPresent()) {
BigDecimal altitude = altitudeBigDecimal.get().setScale(2, RoundingMode.HALF_UP);
gpsData.setAltitude(altitude);
}
BigDecimal longitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.LONGITUDE.getDesc());
- Optional longitudeOptional = Optional.ofNullable(longitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
+ Optional longitudeOptional = Optional.ofNullable(longitudeTemp).map(l -> l.divide(TaskConstant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
if (longitudeOptional.isPresent()) {
BigDecimal longitude = longitudeOptional.get().setScale(6, RoundingMode.HALF_UP);
gpsData.setLongitude(longitude);
}
BigDecimal latitudeTemp = gpsJson.getBigDecimal(GPSDataEnum.LATITUDE.getDesc());
- Optional latitudeOptional = Optional.ofNullable(latitudeTemp).map(l -> l.divide(TaskContant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
+ Optional latitudeOptional = Optional.ofNullable(latitudeTemp).map(l -> l.divide(TaskConstant.Math.LONGITUDE_UNITS, RoundingMode.HALF_UP));
if (latitudeOptional.isPresent()) {
BigDecimal latitude = latitudeOptional.get().setScale(6, RoundingMode.HALF_UP);
gpsData.setLatitude(latitude);
}
BigDecimal speedTemp = gpsJson.getBigDecimal(GPSDataEnum.SPEED.getDesc());
- Optional speedOptional = Optional.ofNullable(speedTemp).map(s -> s.multiply(TaskContant.Math.SPEED_UNITS));
+ Optional speedOptional = Optional.ofNullable(speedTemp).map(s -> s.multiply(TaskConstant.Math.SPEED_UNITS));
if (speedOptional.isPresent()) {
BigDecimal speed = speedOptional.get().setScale(2, RoundingMode.HALF_UP);
gpsData.setSpeed(speed);
}
BigDecimal directionTemp = gpsJson.getBigDecimal(GPSDataEnum.DIRECTION.getDesc());
- Optional directionOptional = Optional.ofNullable(directionTemp).map(s -> s.divide(TaskContant.Math.DIRECTION_UNITS, RoundingMode.HALF_UP));
+ Optional directionOptional = Optional.ofNullable(directionTemp).map(s -> s.divide(TaskConstant.Math.DIRECTION_UNITS, RoundingMode.HALF_UP));
if (directionOptional.isPresent()) {
BigDecimal direction = directionOptional.get().setScale(2, RoundingMode.HALF_UP);
gpsData.setDirection(direction);
diff --git a/ningda-yw-api/src/main/resources/application-dev.yml b/ningda-yw-api/src/main/resources/application-dev.yml
index afee8a5..309b9b8 100644
--- a/ningda-yw-api/src/main/resources/application-dev.yml
+++ b/ningda-yw-api/src/main/resources/application-dev.yml
@@ -24,7 +24,7 @@ spring:
host: 47.98.125.47
port: 26379
database: 5
- password: Ndkj1234
+ password: Ndkj@1104!
jedis:
pool:
max-active: 200
@@ -42,10 +42,10 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.98.125.47:3306/nd-yw-road?serverTimezone=Asia/Shanghai&characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false
username: root
- password: NingdaKeji123!
+ password: Ndkj@1104
hikari:
minimum-idle: 5
- maximum-pool-size: 50
+ maximum-pool-size: 100
aop:
proxy-target-class: true
auto: true
diff --git a/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java b/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java
index 8414a35..af8665a 100644
--- a/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java
+++ b/ningda-yw-api/src/test/java/com/ningdatech/carapi/alarm/AlarmTest.java
@@ -31,7 +31,7 @@ import com.ningdatech.carapi.common.constant.DeletedEnum;
import com.ningdatech.carapi.common.constant.VehicleTypeEnum;
import com.ningdatech.carapi.common.util.CodeUtil;
import com.ningdatech.carapi.driver.constant.DriverAbnormalBehaviorAppendixTypeEnum;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
import com.ningdatech.carapi.sys.helper.VehiclesCacheHelper;
import cn.hutool.core.collection.CollUtil;
@@ -119,17 +119,17 @@ public class AlarmTest extends AppTests {
}
JSONObject jsonContent = JSON.parseObject(content);
- JSONObject gpsJson = jsonContent.getJSONObject(TaskContant.DataField.GPS);
+ JSONObject gpsJson = jsonContent.getJSONObject(TaskConstant.DataField.GPS);
if(Objects.isNull(gpsJson)){
log.info("此条异常行为数据 GPS 内容有误 {}",JSON.toJSONString(alarm));
continue;
}
- monitor.setLongitude(Optional.of(gpsJson.getBigDecimal(TaskContant.DataField.LONGITUDE))
- .map(c -> c.divide(TaskContant.Math.LONGITUDE_UNITS, BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get());
- monitor.setLatitude(Optional.of(gpsJson.getBigDecimal(TaskContant.DataField.LATITUDE))
- .map(c -> c.divide(TaskContant.Math.LONGITUDE_UNITS,BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get());
+ monitor.setLongitude(Optional.of(gpsJson.getBigDecimal(TaskConstant.DataField.LONGITUDE))
+ .map(c -> c.divide(TaskConstant.Math.LONGITUDE_UNITS, BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get());
+ monitor.setLatitude(Optional.of(gpsJson.getBigDecimal(TaskConstant.DataField.LATITUDE))
+ .map(c -> c.divide(TaskConstant.Math.LONGITUDE_UNITS,BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_HALF_UP)).get());
// 装配告警信息
monitor.setCompanyId(car.getCompanyId());
diff --git a/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java b/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java
index 04ab624..ba584e3 100644
--- a/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java
+++ b/ningda-yw-api/src/test/java/com/ningdatech/carapi/redis/RedisTest.java
@@ -12,7 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.ningdatech.cache.model.cache.CacheKey;
import com.ningdatech.cache.repository.CachePlusOps;
import com.ningdatech.carapi.AppTests;
-import com.ningdatech.carapi.scheduler.contants.TaskContant;
+import com.ningdatech.carapi.scheduler.contants.TaskConstant;
/**
* @Classname RedisTest
@@ -36,7 +36,7 @@ public class RedisTest extends AppTests {
@Test
public void get (){
- CacheKey key = new CacheKey(TaskContant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET);
+ CacheKey key = new CacheKey(TaskConstant.RedisKey.IRS_ACCIDENT_QUERY_REQUEST_SECRET);
String requestSecret = cachePlusOps.get(key);
System.out.println(requestSecret);
requestSecret = "abcdefg123456";