From 9600c25b9a0b0319f20fb162dd848ba3c19088af Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 12 May 2022 18:15:35 +0800 Subject: [PATCH] #471 --- .../iot/vmp/storager/dao/DeviceChannelMapper.java | 4 ++++ .../vmp/storager/impl/VideoManagerStorageImpl.java | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 312d3e03..c3b94f68 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -257,4 +257,8 @@ public interface DeviceChannelMapper { @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) void updatePotion(String deviceId, String channelId, double longitude, double latitude); + + @Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0") + List getAllChannelInPlay(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index eea07e94..1f359114 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; /** * 视频设备数据存储-jdbc实现 @@ -197,17 +198,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { if (deviceChannelList == null) { return false; } + List allChannelInPlay = deviceChannelMapper.getAllChannelInPlay(); + Map allChannelMapInPlay = new ConcurrentHashMap<>(); + if (allChannelInPlay.size() > 0) { + for (DeviceChannel deviceChannel : allChannelInPlay) { + allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel); + } + } TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); // 数据去重 List channels = new ArrayList<>(); StringBuilder stringBuilder = new StringBuilder(); Map subContMap = new HashMap<>(); - if (deviceChannelList != null && deviceChannelList.size() > 1) { + if (deviceChannelList.size() > 1) { // 数据去重 Set gbIdSet = new HashSet<>(); for (DeviceChannel deviceChannel : deviceChannelList) { if (!gbIdSet.contains(deviceChannel.getChannelId())) { gbIdSet.add(deviceChannel.getChannelId()); + if (allChannelMapInPlay.containsKey(deviceChannel.getChannelId())) { + deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId()); + } channels.add(deviceChannel); if (!StringUtils.isEmpty(deviceChannel.getParentId())) { if (subContMap.get(deviceChannel.getParentId()) == null) {