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 | 257 | |
| 258 | 258 | @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) |
| 259 | 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 | 28 | import org.springframework.util.StringUtils; |
| 29 | 29 | |
| 30 | 30 | import java.util.*; |
| 31 | +import java.util.concurrent.ConcurrentHashMap; | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * 视频设备数据存储-jdbc实现 |
| ... | ... | @@ -197,17 +198,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 197 | 198 | if (deviceChannelList == null) { |
| 198 | 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 | 208 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 201 | 209 | // 数据去重 |
| 202 | 210 | List<DeviceChannel> channels = new ArrayList<>(); |
| 203 | 211 | StringBuilder stringBuilder = new StringBuilder(); |
| 204 | 212 | Map<String, Integer> subContMap = new HashMap<>(); |
| 205 | - if (deviceChannelList != null && deviceChannelList.size() > 1) { | |
| 213 | + if (deviceChannelList.size() > 1) { | |
| 206 | 214 | // 数据去重 |
| 207 | 215 | Set<String> gbIdSet = new HashSet<>(); |
| 208 | 216 | for (DeviceChannel deviceChannel : deviceChannelList) { |
| 209 | 217 | if (!gbIdSet.contains(deviceChannel.getChannelId())) { |
| 210 | 218 | gbIdSet.add(deviceChannel.getChannelId()); |
| 219 | + if (allChannelMapInPlay.containsKey(deviceChannel.getChannelId())) { | |
| 220 | + deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId()); | |
| 221 | + } | |
| 211 | 222 | channels.add(deviceChannel); |
| 212 | 223 | if (!StringUtils.isEmpty(deviceChannel.getParentId())) { |
| 213 | 224 | if (subContMap.get(deviceChannel.getParentId()) == null) { | ... | ... |