Browse Source

1.删除无用依赖

2.枚举类重命名
develop
xiepufeng 8 months ago
parent
commit
d562fd778d
  1. 6
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  2. 8
      zc-business/src/main/java/com/zc/business/enums/CameraDirectionEnum.java
  3. 8
      zc-business/src/main/java/com/zc/business/enums/LaneDirectionEnum.java
  4. 4
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
  5. 2
      zc-business/src/main/java/com/zc/business/statistics/handler/TrafficAnalysis.java
  6. 15
      zc-business/src/main/java/com/zc/business/statistics/handler/TrafficStatistics.java

6
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -10,7 +10,7 @@ import com.ruoyi.common.core.redis.RedisCache;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.enums.CameraDirectionEnum;
import com.zc.business.enums.LaneDirection;
import com.zc.business.enums.LaneDirectionEnum;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IMiddleDatabaseService;
import com.zc.common.core.httpclient.OkHttp;
@ -120,12 +120,12 @@ public class VideoController extends BaseController {
String pileNum = cameraInfo.getString("pileNum");
// 方向
Integer camOrientation = cameraInfo.getInteger("camOrientation");
LaneDirection laneDirection = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection();
LaneDirectionEnum laneDirectionEnum = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection();
// 是否有云台控制 0 有(球机) 1 ⽆(枪机)
String ptzCtrl = cameraInfo.getString("ptzCtrl");
String key = pileNum + "|" + laneDirection.getValue() + "|" + ptzCtrl;
String key = pileNum + "|" + laneDirectionEnum.getValue() + "|" + ptzCtrl;
if (cameraMap.containsKey(key)) {
DcDevice dcDevice = cameraMap.get(key);

8
zc-business/src/main/java/com/zc/business/enums/CameraDirectionEnum.java

@ -44,15 +44,15 @@ public enum CameraDirectionEnum {
}
public LaneDirection toLaneDirection() {
public LaneDirectionEnum toLaneDirection() {
switch (this) {
case UPWARD:
return LaneDirection.UPWARD;
return LaneDirectionEnum.UPWARD;
case DOWN:
return LaneDirection.DOWNWARD;
return LaneDirectionEnum.DOWNWARD;
case BIDIRECTIONAL:
// 假设摄像机双向就映射为车道双向
return LaneDirection.BIDIRECTIONAL;
return LaneDirectionEnum.BIDIRECTIONAL;
default:
throw new IllegalStateException("未知的CameraDirection: " + this);
}

8
zc-business/src/main/java/com/zc/business/enums/LaneDirection.java → zc-business/src/main/java/com/zc/business/enums/LaneDirectionEnum.java

@ -8,7 +8,7 @@ import lombok.Getter;
* @author xiepufeng
**/
@Getter
public enum LaneDirection {
public enum LaneDirectionEnum {
UPWARD((byte)1, "上行"),
BIDIRECTIONAL((byte) 2, "上下行(双向)"),
@ -17,14 +17,14 @@ public enum LaneDirection {
private final byte value;
private final String description;
LaneDirection(byte value, String description) {
LaneDirectionEnum(byte value, String description) {
this.value = value;
this.description = description;
}
public static LaneDirection fromValue(int value) {
for (LaneDirection direction : values()) {
public static LaneDirectionEnum fromValue(int value) {
for (LaneDirectionEnum direction : values()) {
if (direction.getValue() == value) {
return direction;
}

4
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -282,8 +282,8 @@ public class DcTrafficStatisticsServiceImpl
*/
private Map<String, DcTrafficSectionData> getTrafficDataForBothDirections() {
Map<String, DcTrafficSectionData> allData = new HashMap<>();
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirection.UPWARD.getValue())));
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirection.DOWNWARD.getValue())));
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirectionEnum.UPWARD.getValue())));
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirectionEnum.DOWNWARD.getValue())));
return allData;
}

2
zc-business/src/main/java/com/zc/business/statistics/handler/TrafficAnalysis.java

@ -393,7 +393,7 @@ public class TrafficAnalysis {
List<DcTrafficSectionData> sortedList;
// 根据行驶方向,对交通路段数据进行排序,上行方向逆序,下行方向正序
if (directionData.equals(LaneDirection.UPWARD.getValue())) {
if (directionData.equals(LaneDirectionEnum.UPWARD.getValue())) {
sortedList = trafficSectionList.stream()
.sorted(Comparator.comparing(DcTrafficSectionData::getStakeMark).reversed())
.collect(Collectors.toList());

15
zc-business/src/main/java/com/zc/business/statistics/handler/TrafficStatistics.java

@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.constant.StatisticalRecoveryOffsetTime;
import com.zc.business.controller.DcDeviceController;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcTrafficSectionData;
@ -247,16 +246,16 @@ public class TrafficStatistics {
* @param reportTime 报告时间标识数据的时间戳
* @return 返回一个Map包含上行和下行的交通段数据
*/
private Map<LaneDirection, DcTrafficSectionData> processLaneData(JSONArray lanes, DcDevice dcDevice, Date reportTime) {
private Map<LaneDirectionEnum, DcTrafficSectionData> processLaneData(JSONArray lanes, DcDevice dcDevice, Date reportTime) {
Map<LaneDirection, DcTrafficSectionData> resultMap = new HashMap<>();
Map<LaneDirectionEnum, DcTrafficSectionData> resultMap = new HashMap<>();
// 初始化上行和下行的交通段数据
DcTrafficSectionData upwardData = new DcTrafficSectionData();
DcTrafficSectionData downwardData = new DcTrafficSectionData();
initializeTrafficSectionData(upwardData, dcDevice, reportTime, LaneDirection.UPWARD);
initializeTrafficSectionData(downwardData, dcDevice, reportTime, LaneDirection.DOWNWARD);
initializeTrafficSectionData(upwardData, dcDevice, reportTime, LaneDirectionEnum.UPWARD);
initializeTrafficSectionData(downwardData, dcDevice, reportTime, LaneDirectionEnum.DOWNWARD);
// 初始化上行和下行的车流量
int upwardTrafficVolume = 0, downwardTrafficVolume = 0;
@ -294,8 +293,8 @@ public class TrafficStatistics {
setTrafficSectionData(downwardData, downwardTrafficVolume, downwardCumulativeAverageSpeed, downwardLargeTrafficVolume);
// 将上行和下行的交通段数据放入结果映射中
resultMap.put(LaneDirection.UPWARD, upwardData);
resultMap.put(LaneDirection.DOWNWARD, downwardData);
resultMap.put(LaneDirectionEnum.UPWARD, upwardData);
resultMap.put(LaneDirectionEnum.DOWNWARD, downwardData);
return resultMap;
}
@ -308,7 +307,7 @@ public class TrafficStatistics {
* @param reportTime 数据上报时间
* @param direction 车道方向
*/
private void initializeTrafficSectionData(DcTrafficSectionData data, DcDevice dcDevice, Date reportTime, LaneDirection direction) {
private void initializeTrafficSectionData(DcTrafficSectionData data, DcDevice dcDevice, Date reportTime, LaneDirectionEnum direction) {
// 设置设备id
data.setDeviceId(dcDevice.getId());

Loading…
Cancel
Save