From 26cd7dbaf9394ff26f5229b18cfdb72c203a6bc3 Mon Sep 17 00:00:00 2001 From: gaofw189 <gaofw189@chinatelecom.cn> Date: 星期二, 10 一月 2023 15:55:56 +0800 Subject: [PATCH] 修复WVP作为下级平台接收DeviceStatus指令固定响应的问题 --- src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 149 +++++++++---------------------------------------- 1 files changed, 29 insertions(+), 120 deletions(-) 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 82f0947..c773036 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 @@ -1,12 +1,11 @@ package com.genersoft.iot.vmp.storager.impl; -import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.SipConfig; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; @@ -26,7 +25,7 @@ import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; +import org.springframework.util.ObjectUtils; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -83,6 +82,9 @@ private GbStreamMapper gbStreamMapper; @Autowired + private UserSetting userSetting; + + @Autowired private PlatformCatalogMapper catalogMapper; @Autowired @@ -110,11 +112,11 @@ if (CollectionUtils.isEmpty(deviceChannelList)) { return false; } - List<DeviceChannel> allChannelInPlay = deviceChannelMapper.getAllChannelInPlay(); - Map<String,DeviceChannel> allChannelMapInPlay = new ConcurrentHashMap<>(); - if (allChannelInPlay.size() > 0) { - for (DeviceChannel deviceChannel : allChannelInPlay) { - allChannelMapInPlay.put(deviceChannel.getChannelId(), deviceChannel); + List<DeviceChannel> allChannels = deviceChannelMapper.queryAllChannels(deviceId); + Map<String,DeviceChannel> allChannelMap = new ConcurrentHashMap<>(); + if (allChannels.size() > 0) { + for (DeviceChannel deviceChannel : allChannels) { + allChannelMap.put(deviceChannel.getChannelId(), deviceChannel); } } TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); @@ -122,17 +124,18 @@ List<DeviceChannel> channels = new ArrayList<>(); StringBuilder stringBuilder = new StringBuilder(); Map<String, Integer> subContMap = new HashMap<>(); - if (deviceChannelList.size() > 1) { + if (deviceChannelList.size() > 0) { // 鏁版嵁鍘婚噸 Set<String> 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()); + if (allChannelMap.containsKey(deviceChannel.getChannelId())) { + deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); + deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).isHasAudio()); } channels.add(deviceChannel); - if (!StringUtils.isEmpty(deviceChannel.getParentId())) { + if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { if (subContMap.get(deviceChannel.getParentId()) == null) { subContMap.put(deviceChannel.getParentId(), 1); }else { @@ -152,8 +155,6 @@ } } - }else { - channels = deviceChannelList; } if (stringBuilder.length() > 0) { logger.info("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder); @@ -230,31 +231,31 @@ PageHelper.startPage(page, count); List<DeviceChannel> all; if (catalogUnderDevice != null && catalogUnderDevice) { - all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); + all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null); // 娴峰悍璁惧鐨刾arentId鏄疭IP id - List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online); + List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null); all.addAll(deviceChannels); }else { - all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); + all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online,null); } return new PageInfo<>(all); } @Override - public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit); + public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List<String> channelIds) { + return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds); } @Override - public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { - return deviceChannelMapper.queryChannels(deviceId, null,null, null, null); + public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds) { + return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); } @Override public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { PageHelper.startPage(page, count); - List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online); + List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online,null); return new PageInfo<>(all); } @@ -277,9 +278,9 @@ * @return PageInfo<Device> 鍒嗛〉璁惧瀵硅薄鏁扮粍 */ @Override - public PageInfo<Device> queryVideoDeviceList(int page, int count) { + public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online) { PageHelper.startPage(page, count); - List<Device> all = deviceMapper.getDevices(); + List<Device> all = deviceMapper.getDevices(online); return new PageInfo<>(all); } @@ -289,83 +290,10 @@ * @return List<Device> 璁惧瀵硅薄鏁扮粍 */ @Override - public List<Device> queryVideoDeviceList() { + public List<Device> queryVideoDeviceList(Boolean online) { - List<Device> deviceList = deviceMapper.getDevices(); + List<Device> deviceList = deviceMapper.getDevices(online); return deviceList; - } - - /** - * 鍒犻櫎璁惧 - * - * @param deviceId 璁惧ID - * @return true锛氬垹闄ゆ垚鍔� false锛氬垹闄ゅけ璐� - */ - @Override - public boolean delete(String deviceId) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - try { - platformChannelMapper.delChannelForDeviceId(deviceId); - deviceChannelMapper.cleanChannelsByDeviceId(deviceId); - if ( deviceMapper.del(deviceId) < 0 ) { - //浜嬪姟鍥炴粴 - dataSourceTransactionManager.rollback(transactionStatus); - } - result = true; - dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 - }catch (Exception e) { - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } - - /** - * 鏇存柊璁惧鍦ㄧ嚎 - * - * @param deviceId 璁惧ID - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - @Override - public synchronized boolean online(String deviceId) { - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device == null) { - return false; - } - device.setOnline(1); - logger.info("鏇存柊璁惧鍦ㄧ嚎: " + deviceId); - redisCatchStorage.updateDevice(device); - return deviceMapper.update(device) > 0; - } - - /** - * 鏇存柊璁惧绂荤嚎 - * - * @param deviceId 璁惧ID - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - @Override - public synchronized boolean outline(String deviceId) { - logger.info("鏇存柊璁惧绂荤嚎: " + deviceId); - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device == null) { - return false; - } - device.setOnline(0); - redisCatchStorage.updateDevice(device); - return deviceMapper.update(device) > 0; - } - - /** - * 鏇存柊鎵�鏈夎澶囩绾� - * - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - @Override - public synchronized boolean outlineForAll() { - logger.info("鏇存柊鎵�鏈夎澶囩绾�"); - int result = deviceMapper.outlineForAll(); - return result > 0; } /** @@ -454,13 +382,6 @@ // 鍒犻櫎鍏宠仈鐨勯�氶亾 platformChannelMapper.cleanChannelForGB(parentPlatform.getServerGBId()); return result > 0; - } - - @Override - public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) { - PageHelper.startPage(page, count); - List<ParentPlatform> all = platformMapper.getParentPlatformList(); - return new PageInfo<>(all); } @Override @@ -621,7 +542,7 @@ */ @Override public List<DeviceChannel> queryGbStreamListInPlatform(String platformId) { - return gbStreamMapper.queryGbStreamListInPlatform(platformId); + return gbStreamMapper.queryGbStreamListInPlatform(platformId, userSetting.isUsePushingAsStatus()); } /** @@ -702,7 +623,7 @@ return 0; } if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) { - if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) { + if (platform.getDeviceGBId().equals(platformCatalog.getParentId())) { // 绗竴灞傝妭鐐� platformCatalog.setBusinessGroupId(platformCatalog.getId()); platformCatalog.setParentId(platform.getDeviceGBId()); @@ -837,18 +758,6 @@ return gbStreamMapper.updateStreamGPS(gpsMsgInfos); } - private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId) { - List<DeviceChannel> deviceChannelList = new ArrayList<>(); - if (channelReduces.size() > 0){ - for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); - deviceChannel.setParental(1); - deviceChannel.setParentId(catalogId); - deviceChannelList.add(deviceChannel); - } - } - return deviceChannelList; - } private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); -- Gitblit v1.8.0