| | |
| | | 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.storager.dao.dto.ChannelSourceInfo; |
| | | 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; |
| | |
| | | @Component |
| | | public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); |
| | | private final Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); |
| | | |
| | | @Autowired |
| | | EventPublisher eventPublisher; |
| | |
| | | String now = this.format.format(System.currentTimeMillis()); |
| | | device.setUpdateTime(now); |
| | | Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); |
| | | device.setCharset(device.getCharset().toUpperCase()); |
| | | if (deviceByDeviceId == null) { |
| | | device.setCreateTime(now); |
| | | redisCatchStorage.updateDevice(device); |
| | |
| | | }else { |
| | | deviceChannelMapper.update(channel); |
| | | } |
| | | deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); |
| | | } |
| | | try { |
| | | int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| | | // int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| | | int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); |
| | | int limitCount = 300; |
| | | boolean result = cleanChannelsResult < 0; |
| | | if (!result && channels.size() > 0) { |
| | |
| | | if (parentPlatformCatch == null) { // serverGBId 已变化 |
| | | ParentPlatform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId()); |
| | | // 使用旧的查出缓存ID |
| | | parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatById.getServerGBId()); |
| | | parentPlatformCatch = new ParentPlatformCatch(); |
| | | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelReduce> queryChannelListInParentPlatform(String platformId) { |
| | | public List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId) { |
| | | |
| | | return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, platformId); |
| | | return deviceChannelMapper.queryChannelByPlatformId(platformId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) { |
| | | DeviceChannel channel = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); |
| | | return channel; |
| | | List<DeviceChannel> channels = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); |
| | | if (channels.size() > 1) { |
| | | // 出现长度大于0的时候肯定是国标通道的ID重复了 |
| | | logger.warn("国标ID存在重复:{}", channelId); |
| | | } |
| | | if (channels.size() == 0) { |
| | | return null; |
| | | }else { |
| | | return channels.get(0); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) { |
| | | Device device = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); |
| | | return device; |
| | | List<Device> devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); |
| | | if (devices.size() > 1) { |
| | | // 出现长度大于0的时候肯定是国标通道的ID重复了 |
| | | logger.warn("国标ID存在重复:{}", channelId); |
| | | } |
| | | if (devices.size() == 0) { |
| | | return null; |
| | | }else { |
| | | return devices.get(0); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | try { |
| | | if (streamProxyMapper.add(streamProxyItem) > 0) { |
| | | if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { |
| | | if (gbStreamMapper.add(streamProxyItem) <= 0) { |
| | | if (gbStreamMapper.add(streamProxyItem) < 0) { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | |
| | | try { |
| | | if (streamProxyMapper.update(streamProxyItem) > 0) { |
| | | if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { |
| | | if (gbStreamMapper.update(streamProxyItem) > 0) { |
| | | if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | |
| | | List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); |
| | | if (parentPlatforms.size() > 0) { |
| | | for (ParentPlatform parentPlatform : parentPlatforms) { |
| | | streamPushItem.setCatalogId(parentPlatform.getCatalogId()); |
| | | streamPushItem.setPlatformId(parentPlatform.getServerGBId()); |
| | | String stream = streamPushItem.getStream(); |
| | | StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, |
| | | StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(streamPushItem.getApp(), streamPushItem.getStream(), |
| | | parentPlatform.getServerGBId()); |
| | | if (streamProxyItems == null) { |
| | | if (streamProxyItem == null) { |
| | | streamPushItem.setCatalogId(parentPlatform.getCatalogId()); |
| | | streamPushItem.setPlatformId(parentPlatform.getServerGBId()); |
| | | platformGbStreamMapper.add(streamPushItem); |
| | | eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD); |
| | | } |
| | |
| | | deviceChannel.setParentId(catalog.getParentId()); |
| | | deviceChannel.setRegisterWay(1); |
| | | // 行政区划应该是Domain的前八位 |
| | | deviceChannel.setCivilCode(sipConfig.getDomain().substring(0, sipConfig.getDomain().length() - 2)); |
| | | deviceChannel.setCivilCode(parentPlatByServerGBId.getDeviceGBId().substring(0,6)); |
| | | deviceChannel.setModel("live"); |
| | | deviceChannel.setOwner("wvp-pro"); |
| | | deviceChannel.setSecrecy("0"); |
| | |
| | | |
| | | @Override |
| | | public List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms) { |
| | | if (platforms == null || platforms.size() == 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms); |
| | | } |
| | | |
| | |
| | | public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) { |
| | | return catalogMapper.selectDefaultByPlatFormId(platformId); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) { |
| | | return platformMapper.getChannelSource(platformId, gbId); |
| | | } |
| | | } |