Commit 4199650c20e48cd3cb897a413aec13fa518c81cd
1 parent
0781d9bc
#471
Showing
2 changed files
with
16 additions
and
1 deletions
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| @@ -257,4 +257,8 @@ public interface DeviceChannelMapper { | @@ -257,4 +257,8 @@ public interface DeviceChannelMapper { | ||
| 257 | 257 | ||
| 258 | @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) | 258 | @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) |
| 259 | void updatePotion(String deviceId, String channelId, double longitude, double latitude); | 259 | void updatePotion(String deviceId, String channelId, double longitude, double latitude); |
| 260 | + | ||
| 261 | + @Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0") | ||
| 262 | + List<DeviceChannel> getAllChannelInPlay(); | ||
| 263 | + | ||
| 260 | } | 264 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 28 | import org.springframework.util.StringUtils; | 28 | import org.springframework.util.StringUtils; |
| 29 | 29 | ||
| 30 | import java.util.*; | 30 | import java.util.*; |
| 31 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 31 | 32 | ||
| 32 | /** | 33 | /** |
| 33 | * 视频设备数据存储-jdbc实现 | 34 | * 视频设备数据存储-jdbc实现 |
| @@ -197,17 +198,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -197,17 +198,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 197 | if (deviceChannelList == null) { | 198 | if (deviceChannelList == null) { |
| 198 | return false; | 199 | return false; |
| 199 | } | 200 | } |
| 201 | + List<DeviceChannel> allChannelInPlay = deviceChannelMapper.getAllChannelInPlay(); | ||
| 202 | + Map<String,DeviceChannel> allChannelMapInPlay = new ConcurrentHashMap<>(); | ||
| 203 | + if (allChannelInPlay.size() > 0) { | ||
| 204 | + for (DeviceChannel deviceChannel : allChannelInPlay) { | ||
| 205 | + allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel); | ||
| 206 | + } | ||
| 207 | + } | ||
| 200 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); | 208 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 201 | // 数据去重 | 209 | // 数据去重 |
| 202 | List<DeviceChannel> channels = new ArrayList<>(); | 210 | List<DeviceChannel> channels = new ArrayList<>(); |
| 203 | StringBuilder stringBuilder = new StringBuilder(); | 211 | StringBuilder stringBuilder = new StringBuilder(); |
| 204 | Map<String, Integer> subContMap = new HashMap<>(); | 212 | Map<String, Integer> subContMap = new HashMap<>(); |
| 205 | - if (deviceChannelList != null && deviceChannelList.size() > 1) { | 213 | + if (deviceChannelList.size() > 1) { |
| 206 | // 数据去重 | 214 | // 数据去重 |
| 207 | Set<String> gbIdSet = new HashSet<>(); | 215 | Set<String> gbIdSet = new HashSet<>(); |
| 208 | for (DeviceChannel deviceChannel : deviceChannelList) { | 216 | for (DeviceChannel deviceChannel : deviceChannelList) { |
| 209 | if (!gbIdSet.contains(deviceChannel.getChannelId())) { | 217 | if (!gbIdSet.contains(deviceChannel.getChannelId())) { |
| 210 | gbIdSet.add(deviceChannel.getChannelId()); | 218 | gbIdSet.add(deviceChannel.getChannelId()); |
| 219 | + if (allChannelMapInPlay.containsKey(deviceChannel.getChannelId())) { | ||
| 220 | + deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId()); | ||
| 221 | + } | ||
| 211 | channels.add(deviceChannel); | 222 | channels.add(deviceChannel); |
| 212 | if (!StringUtils.isEmpty(deviceChannel.getParentId())) { | 223 | if (!StringUtils.isEmpty(deviceChannel.getParentId())) { |
| 213 | if (subContMap.get(deviceChannel.getParentId()) == null) { | 224 | if (subContMap.get(deviceChannel.getParentId()) == null) { |