| | |
| | | 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; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.dao.*; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @description:视频设备数据存储-jdbc实现 |
| | |
| | | @Override |
| | | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | // 数据去重 |
| | | List<DeviceChannel> channels = new ArrayList<>(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | if (deviceChannelList.size() > 1) { |
| | | // 数据去重 |
| | | Set<String> gbIdSet = new HashSet<>(); |
| | | for (DeviceChannel deviceChannel : deviceChannelList) { |
| | | if (!gbIdSet.contains(deviceChannel.getChannelId())) { |
| | | gbIdSet.add(deviceChannel.getChannelId()); |
| | | channels.add(deviceChannel); |
| | | }else { |
| | | stringBuilder.append(deviceChannel.getChannelId() + ","); |
| | | } |
| | | } |
| | | }else { |
| | | channels = deviceChannelList; |
| | | } |
| | | if (stringBuilder.length() > 0) { |
| | | logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); |
| | | } |
| | | try { |
| | | int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| | | int limitCount = 300; |
| | | boolean result = cleanChannelsResult <0; |
| | | if (!result && deviceChannelList.size() > 0) { |
| | | if (deviceChannelList.size() > limitCount) { |
| | | for (int i = 0; i < deviceChannelList.size(); i += limitCount) { |
| | | boolean result = cleanChannelsResult < 0; |
| | | if (!result && channels.size() > 0) { |
| | | if (channels.size() > limitCount) { |
| | | for (int i = 0; i < channels.size(); i += limitCount) { |
| | | int toIndex = i + limitCount; |
| | | if (i + limitCount > deviceChannelList.size()) { |
| | | toIndex = deviceChannelList.size(); |
| | | if (i + limitCount > channels.size()) { |
| | | toIndex = channels.size(); |
| | | } |
| | | result = result || deviceChannelMapper.batchAdd(deviceChannelList.subList(i, toIndex)) < 0; |
| | | result = result || deviceChannelMapper.batchAdd(channels.subList(i, toIndex)) < 0; |
| | | } |
| | | }else { |
| | | result = result || deviceChannelMapper.batchAdd(deviceChannelList) < 0; |
| | | result = result || deviceChannelMapper.batchAdd(channels) < 0; |
| | | } |
| | | } |
| | | if (result) { |
| | |
| | | // 更新缓存 |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| | | // 共享所有视频流,需要将现有视频流添加到此平台 |
| | | List<GbStream> gbStreams = gbStreamMapper.selectAll(); |
| | | if (gbStreams.size() > 0) { |
| | | for (GbStream gbStream : gbStreams) { |
| | | gbStream.setCatalogId(parentPlatform.getCatalogId()); |
| | | } |
| | | if (parentPlatform.isShareAllLiveStream()) { |
| | | gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId()); |
| | | }else { |
| | | gbStreamService.delPlatformInfo(gbStreams); |
| | | if (parentPlatform.isEnable()) { |
| | | // 共享所有视频流,需要将现有视频流添加到此平台 |
| | | List<GbStream> gbStreams = gbStreamMapper.queryStreamNotInPlatform(); |
| | | if (gbStreams.size() > 0) { |
| | | for (GbStream gbStream : gbStreams) { |
| | | gbStream.setCatalogId(parentPlatform.getCatalogId()); |
| | | } |
| | | if (parentPlatform.isShareAllLiveStream()) { |
| | | gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId()); |
| | | }else { |
| | | gbStreamService.delPlatformInfo(gbStreams); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return result > 0; |
| | | } |
| | | |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos) { |
| | | return gbStreamMapper.updateStreamGPS(gpsMsgInfos); |
| | | } |
| | | } |