| | |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | /** |
| | | * 视频设备数据存储-jdbc实现 |
| | | * swwheihei |
| | | * 2020年5月6日 下午2:31:42 |
| | |
| | | |
| | | @Override |
| | | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { |
| | | if (deviceChannelList == null) { |
| | | if (CollectionUtils.isEmpty(deviceChannelList)) { |
| | | return false; |
| | | } |
| | | List<DeviceChannel> allChannelInPlay = deviceChannelMapper.getAllChannelInPlay(); |
| | |
| | | } |
| | | if (stringBuilder.length() > 0) { |
| | | logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); |
| | | } |
| | | if(CollectionUtils.isEmpty(channels)){ |
| | | logger.info("通道重设,数据为空={}" , deviceChannelList); |
| | | return false; |
| | | } |
| | | try { |
| | | int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); |
| | |
| | | List<DeviceChannel> all; |
| | | if (catalogUnderDevice != null && catalogUnderDevice) { |
| | | all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); |
| | | // 海康设备的parentId是SIP id |
| | | List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online); |
| | | all.addAll(deviceChannels); |
| | | }else { |
| | | all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) { |
| | | if (mobilePosition.getDeviceId().equals(mobilePosition.getChannelId())) { |
| | | mobilePosition.setChannelId(null); |
| | | } |
| | | return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0; |
| | | } |
| | | |
| | |
| | | streamProxyItem.setStatus(true); |
| | | String now = DateUtil.getNow(); |
| | | streamProxyItem.setCreateTime(now); |
| | | streamProxyItem.setCreateStamp(System.currentTimeMillis()); |
| | | try { |
| | | if (streamProxyMapper.add(streamProxyItem) > 0) { |
| | | if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { |
| | |
| | | streamPushMapper.addAll(streamPushItems); |
| | | // TODO 待优化 |
| | | for (int i = 0; i < streamPushItems.size(); i++) { |
| | | int onlineResult = gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true); |
| | | int onlineResult = mediaOnline(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream()); |
| | | if (onlineResult > 0) { |
| | | // 发送上线通知 |
| | | eventPublisher.catalogEventPublishForStream(null, streamPushItems.get(i), CatalogEvent.ON); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updateMedia(StreamPushItem streamPushItem) { |
| | | streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); |
| | | streamPushMapper.add(streamPushItem); |
| | | gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true); |
| | | mediaOffline(streamPushItem.getApp(), streamPushItem.getStream()); |
| | | |
| | | if(!StringUtils.isEmpty(streamPushItem.getGbId() )){ |
| | | // 查找开启了全部直播流共享的上级平台 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public StreamPushItem getMedia(String app, String stream) { |
| | | return streamPushMapper.selectOne(app, stream); |
| | | } |
| | | |
| | | @Override |
| | | public void clearMediaList() { |
| | | streamPushMapper.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public int mediaOutline(String app, String streamId) { |
| | | return gbStreamMapper.setStatus(app, streamId, false); |
| | | public int mediaOffline(String app, String stream) { |
| | | GbStream gbStream = gbStreamMapper.selectOne(app, stream); |
| | | int result; |
| | | if ("proxy".equals(gbStream.getStreamType())) { |
| | | result = streamProxyMapper.updateStatus(app, stream, false); |
| | | }else { |
| | | result = streamPushMapper.updateStatus(app, stream, false); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public int mediaOnline(String app, String stream) { |
| | | GbStream gbStream = gbStreamMapper.selectOne(app, stream); |
| | | int result; |
| | | if ("proxy".equals(gbStream.getStreamType())) { |
| | | result = streamProxyMapper.updateStatus(app, stream, true); |
| | | }else { |
| | | result = streamPushMapper.updateStatus(app, stream, true); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public int setDefaultCatalog(String platformId, String catalogId) { |
| | | return platformMapper.setDefaultCatalog(platformId, catalogId); |
| | | return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) { |
| | | deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude); |
| | | public void updateChannelPosition(DeviceChannel deviceChannel) { |
| | | if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) { |
| | | deviceChannel.setChannelId(null); |
| | | } |
| | | if (deviceChannel.getGpsTime() == null) { |
| | | deviceChannel.setGpsTime(DateUtil.getNow()); |
| | | } |
| | | |
| | | deviceChannelMapper.updatePosition(deviceChannel); |
| | | } |
| | | } |