| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.dao.*; |
| | | import com.genersoft.iot.vmp.utils.node.ForestNodeMerger; |
| | | import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | List<DeviceChannel> updateChannels = new ArrayList<>(); |
| | | HashMap<String, DeviceChannel> channelsInStore = new HashMap<>(); |
| | | if (channels != null && channels.size() > 0) { |
| | | List<DeviceChannel> channelList = deviceChannelMapper.queryChannelsByDeviceId(deviceId); |
| | | List<DeviceChannel> channelList = deviceChannelMapper.queryChannels(deviceId, null, null, null, null); |
| | | if (channelList.size() == 0) { |
| | | for (DeviceChannel channel : channels) { |
| | | channel.setDeviceId(deviceId); |
| | |
| | | // 数据去重 |
| | | List<DeviceChannel> channels = new ArrayList<>(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | Map<String, Integer> subContMap = new HashMap<>(); |
| | | if (deviceChannelList.size() > 1) { |
| | | // 数据去重 |
| | | Set<String> gbIdSet = new HashSet<>(); |
| | |
| | | if (!gbIdSet.contains(deviceChannel.getChannelId())) { |
| | | gbIdSet.add(deviceChannel.getChannelId()); |
| | | channels.add(deviceChannel); |
| | | if (!StringUtils.isEmpty(deviceChannel.getParentId())) { |
| | | if (subContMap.get(deviceChannel.getParentId()) == null) { |
| | | subContMap.put(deviceChannel.getParentId(), 1); |
| | | }else { |
| | | Integer count = subContMap.get(deviceChannel.getParentId()); |
| | | subContMap.put(deviceChannel.getParentId(), count++); |
| | | } |
| | | } |
| | | }else { |
| | | stringBuilder.append(deviceChannel.getChannelId() + ","); |
| | | } |
| | | } |
| | | if (channels.size() > 0) { |
| | | for (DeviceChannel channel : channels) { |
| | | if (subContMap.get(channel.getChannelId()) != null){ |
| | | channel.setSubCount(subContMap.get(channel.getChannelId())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | channels = deviceChannelList; |
| | | } |
| | |
| | | @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); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceChannelTree> tree(String deviceId) { |
| | | return ForestNodeMerger.merge(deviceChannelMapper.tree(deviceId)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, |
| | | Boolean channelType, String platformId, Boolean inPlatform) { |
| | | Boolean channelType, String platformId, String catalogId) { |
| | | PageHelper.startPage(page, count); |
| | | List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, inPlatform); |
| | | List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId); |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelReduce> queryChannelListInParentPlatform(String platformId) { |
| | | |
| | | return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, true); |
| | | return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, platformId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { |
| | | List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatlog(platformId, catalogId); |
| | | List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId); |
| | | return catalogs; |
| | | } |
| | | |
| | |
| | | streamProxyItem.setStatus(true); |
| | | String now = this.format.format(System.currentTimeMillis()); |
| | | streamProxyItem.setCreateTime(now); |
| | | streamProxyItem.setCreateStamp(System.currentTimeMillis()); |
| | | try { |
| | | if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) { |
| | | if (streamProxyMapper.add(streamProxyItem) > 0) { |
| | | if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { |
| | | if (gbStreamMapper.add(streamProxyItem) > 0) { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | | } |
| | | } |
| | | }else { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | | } |
| | | result = true; |
| | | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| | |
| | | boolean result = false; |
| | | streamProxyItem.setStreamType("proxy"); |
| | | try { |
| | | if (gbStreamMapper.update(streamProxyItem)<0 || streamProxyMapper.update(streamProxyItem) < 0) { |
| | | if (streamProxyMapper.update(streamProxyItem) > 0) { |
| | | if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { |
| | | if (gbStreamMapper.update(streamProxyItem) > 0) { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | | } |
| | | } |
| | | } else { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | | } |
| | | |
| | | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| | | result = true; |
| | | }catch (Exception e) { |
| | |
| | | streamPushItem.setCatalogId(parentPlatform.getCatalogId()); |
| | | streamPushItem.setPlatformId(parentPlatform.getServerGBId()); |
| | | String stream = streamPushItem.getStream(); |
| | | StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, parentPlatform.getServerGBId()); |
| | | StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, |
| | | parentPlatform.getServerGBId()); |
| | | if (streamProxyItems == null) { |
| | | platformGbStreamMapper.add(streamPushItem); |
| | | eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateMediaServer(MediaServerItem mediaServerItem) { |
| | | String now = this.format.format(System.currentTimeMillis()); |
| | | mediaServerItem.setUpdateTime(now); |
| | | if (mediaServerMapper.queryOne(mediaServerItem.getId()) != null) { |
| | | mediaServerMapper.update(mediaServerItem); |
| | | }else { |
| | | mediaServerItem.setCreateTime(now); |
| | | mediaServerMapper.add(mediaServerItem); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable) { |
| | | return streamProxyMapper.selectForEnableInMediaServer(id, enable); |
| | | public List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable, boolean status) { |
| | | return streamProxyMapper.selectForEnableInMediaServer(id, enable, status); |
| | | } |
| | | |
| | | |
| | |
| | | deviceChannel.setParental(1); |
| | | deviceChannel.setParentId(catalog.getParentId()); |
| | | deviceChannel.setRegisterWay(1); |
| | | deviceChannel.setCivilCode(sipConfig.getDomain()); |
| | | // 行政区划应该是Domain的前八位 |
| | | deviceChannel.setCivilCode(sipConfig.getDomain().substring(0, sipConfig.getDomain().length() - 2)); |
| | | deviceChannel.setModel("live"); |
| | | deviceChannel.setOwner("wvp-pro"); |
| | | deviceChannel.setSecrecy("0"); |
| | |
| | | public GbStream getGbStream(String app, String streamId) { |
| | | return gbStreamMapper.selectOne(app, streamId); |
| | | } |
| | | |
| | | @Override |
| | | public void delCatalogByPlatformId(String serverGBId) { |
| | | catalogMapper.delByPlatformId(serverGBId); |
| | | } |
| | | |
| | | @Override |
| | | public void delRelationByPlatformId(String serverGBId) { |
| | | platformGbStreamMapper.delByPlatformId(serverGBId); |
| | | platformChannelMapper.delByPlatformId(serverGBId); |
| | | } |
| | | |
| | | @Override |
| | | public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) { |
| | | return catalogMapper.selectDefaultByPlatFormId(platformId); |
| | | } |
| | | } |