Browse Source

1.删除无用依赖

2.枚举类重命名
develop
xiepufeng 1 year 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.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.enums.CameraDirectionEnum; 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.IDcDeviceService;
import com.zc.business.service.IMiddleDatabaseService; import com.zc.business.service.IMiddleDatabaseService;
import com.zc.common.core.httpclient.OkHttp; import com.zc.common.core.httpclient.OkHttp;
@ -120,12 +120,12 @@ public class VideoController extends BaseController {
String pileNum = cameraInfo.getString("pileNum"); String pileNum = cameraInfo.getString("pileNum");
// 方向 // 方向
Integer camOrientation = cameraInfo.getInteger("camOrientation"); Integer camOrientation = cameraInfo.getInteger("camOrientation");
LaneDirection laneDirection = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection(); LaneDirectionEnum laneDirectionEnum = CameraDirectionEnum.fromCode(camOrientation).toLaneDirection();
// 是否有云台控制 0 有(球机) 1 ⽆(枪机) // 是否有云台控制 0 有(球机) 1 ⽆(枪机)
String ptzCtrl = cameraInfo.getString("ptzCtrl"); String ptzCtrl = cameraInfo.getString("ptzCtrl");
String key = pileNum + "|" + laneDirection.getValue() + "|" + ptzCtrl; String key = pileNum + "|" + laneDirectionEnum.getValue() + "|" + ptzCtrl;
if (cameraMap.containsKey(key)) { if (cameraMap.containsKey(key)) {
DcDevice dcDevice = cameraMap.get(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) { switch (this) {
case UPWARD: case UPWARD:
return LaneDirection.UPWARD; return LaneDirectionEnum.UPWARD;
case DOWN: case DOWN:
return LaneDirection.DOWNWARD; return LaneDirectionEnum.DOWNWARD;
case BIDIRECTIONAL: case BIDIRECTIONAL:
// 假设摄像机双向就映射为车道双向 // 假设摄像机双向就映射为车道双向
return LaneDirection.BIDIRECTIONAL; return LaneDirectionEnum.BIDIRECTIONAL;
default: default:
throw new IllegalStateException("未知的CameraDirection: " + this); 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 * @author xiepufeng
**/ **/
@Getter @Getter
public enum LaneDirection { public enum LaneDirectionEnum {
UPWARD((byte)1, "上行"), UPWARD((byte)1, "上行"),
BIDIRECTIONAL((byte) 2, "上下行(双向)"), BIDIRECTIONAL((byte) 2, "上下行(双向)"),
@ -17,14 +17,14 @@ public enum LaneDirection {
private final byte value; private final byte value;
private final String description; private final String description;
LaneDirection(byte value, String description) { LaneDirectionEnum(byte value, String description) {
this.value = value; this.value = value;
this.description = description; this.description = description;
} }
public static LaneDirection fromValue(int value) { public static LaneDirectionEnum fromValue(int value) {
for (LaneDirection direction : values()) { for (LaneDirectionEnum direction : values()) {
if (direction.getValue() == value) { if (direction.getValue() == value) {
return direction; 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() { private Map<String, DcTrafficSectionData> getTrafficDataForBothDirections() {
Map<String, DcTrafficSectionData> allData = new HashMap<>(); Map<String, DcTrafficSectionData> allData = new HashMap<>();
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirection.UPWARD.getValue()))); allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirectionEnum.UPWARD.getValue())));
allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirection.DOWNWARD.getValue()))); allData.putAll(redisCache.getCacheMapValue(RedisKeyConstants.getDcDevicesTrafficStatisticsKey(LaneDirectionEnum.DOWNWARD.getValue())));
return allData; 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; List<DcTrafficSectionData> sortedList;
// 根据行驶方向,对交通路段数据进行排序,上行方向逆序,下行方向正序 // 根据行驶方向,对交通路段数据进行排序,上行方向逆序,下行方向正序
if (directionData.equals(LaneDirection.UPWARD.getValue())) { if (directionData.equals(LaneDirectionEnum.UPWARD.getValue())) {
sortedList = trafficSectionList.stream() sortedList = trafficSectionList.stream()
.sorted(Comparator.comparing(DcTrafficSectionData::getStakeMark).reversed()) .sorted(Comparator.comparing(DcTrafficSectionData::getStakeMark).reversed())
.collect(Collectors.toList()); .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.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.zc.business.constant.RedisKeyConstants; import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.constant.StatisticalRecoveryOffsetTime;
import com.zc.business.controller.DcDeviceController; import com.zc.business.controller.DcDeviceController;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcTrafficSectionData; import com.zc.business.domain.DcTrafficSectionData;
@ -247,16 +246,16 @@ public class TrafficStatistics {
* @param reportTime 报告时间标识数据的时间戳 * @param reportTime 报告时间标识数据的时间戳
* @return 返回一个Map包含上行和下行的交通段数据 * @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 upwardData = new DcTrafficSectionData();
DcTrafficSectionData downwardData = new DcTrafficSectionData(); DcTrafficSectionData downwardData = new DcTrafficSectionData();
initializeTrafficSectionData(upwardData, dcDevice, reportTime, LaneDirection.UPWARD); initializeTrafficSectionData(upwardData, dcDevice, reportTime, LaneDirectionEnum.UPWARD);
initializeTrafficSectionData(downwardData, dcDevice, reportTime, LaneDirection.DOWNWARD); initializeTrafficSectionData(downwardData, dcDevice, reportTime, LaneDirectionEnum.DOWNWARD);
// 初始化上行和下行的车流量 // 初始化上行和下行的车流量
int upwardTrafficVolume = 0, downwardTrafficVolume = 0; int upwardTrafficVolume = 0, downwardTrafficVolume = 0;
@ -294,8 +293,8 @@ public class TrafficStatistics {
setTrafficSectionData(downwardData, downwardTrafficVolume, downwardCumulativeAverageSpeed, downwardLargeTrafficVolume); setTrafficSectionData(downwardData, downwardTrafficVolume, downwardCumulativeAverageSpeed, downwardLargeTrafficVolume);
// 将上行和下行的交通段数据放入结果映射中 // 将上行和下行的交通段数据放入结果映射中
resultMap.put(LaneDirection.UPWARD, upwardData); resultMap.put(LaneDirectionEnum.UPWARD, upwardData);
resultMap.put(LaneDirection.DOWNWARD, downwardData); resultMap.put(LaneDirectionEnum.DOWNWARD, downwardData);
return resultMap; return resultMap;
} }
@ -308,7 +307,7 @@ public class TrafficStatistics {
* @param reportTime 数据上报时间 * @param reportTime 数据上报时间
* @param direction 车道方向 * @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 // 设置设备id
data.setDeviceId(dcDevice.getId()); data.setDeviceId(dcDevice.getId());

Loading…
Cancel
Save