| | |
| | | package com.genersoft.iot.vmp.storager.impl; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | 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.service.IGbStreamService; |
| | | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | |
| | | import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.sun.org.apache.xml.internal.resolver.Catalog; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | @Component |
| | | @DS("master") |
| | | public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(VideoManagerStorageImpl.class); |
| | |
| | | |
| | | List<DeviceChannel> updateChannels = new ArrayList<>(); |
| | | List<DeviceChannel> addChannels = new ArrayList<>(); |
| | | List<DeviceChannel> deleteChannels = new ArrayList<>(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | Map<String, Integer> subContMap = new HashMap<>(); |
| | | |
| | |
| | | gbIdSet.add(deviceChannel.getChannelId()); |
| | | if (allChannelMap.containsKey(deviceChannel.getChannelId())) { |
| | | deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); |
| | | deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).isHasAudio()); |
| | | deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio()); |
| | | if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ |
| | | List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); |
| | | if (!CollectionUtils.isEmpty(strings)){ |
| | |
| | | deviceChannel.setUpdateTime(DateUtil.getNow()); |
| | | addChannels.add(deviceChannel); |
| | | } |
| | | allChannelMap.remove(deviceChannel.getChannelId()); |
| | | channels.add(deviceChannel); |
| | | if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { |
| | | if (subContMap.get(deviceChannel.getParentId()) == null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | deleteChannels.addAll(allChannelMap.values()); |
| | | if (!channels.isEmpty()) { |
| | | for (DeviceChannel channel : channels) { |
| | | if (subContMap.get(channel.getChannelId()) != null){ |
| | |
| | | try { |
| | | int limitCount = 50; |
| | | boolean result = false; |
| | | if (!result && addChannels.size() > 0) { |
| | | if (!result && !addChannels.isEmpty()) { |
| | | if (addChannels.size() > limitCount) { |
| | | for (int i = 0; i < addChannels.size(); i += limitCount) { |
| | | int toIndex = i + limitCount; |
| | |
| | | result = result || deviceChannelMapper.batchAdd(addChannels) < 0; |
| | | } |
| | | } |
| | | if (!result && updateChannels.size() > 0) { |
| | | if (!result && !updateChannels.isEmpty()) { |
| | | if (updateChannels.size() > limitCount) { |
| | | for (int i = 0; i < updateChannels.size(); i += limitCount) { |
| | | int toIndex = i + limitCount; |
| | |
| | | } |
| | | }else { |
| | | result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; |
| | | } |
| | | } |
| | | if (!result && !deleteChannels.isEmpty()) { |
| | | System.out.println("删除: " + deleteChannels.size()); |
| | | if (deleteChannels.size() > limitCount) { |
| | | for (int i = 0; i < deleteChannels.size(); i += limitCount) { |
| | | int toIndex = i + limitCount; |
| | | if (i + limitCount > deleteChannels.size()) { |
| | | toIndex = deleteChannels.size(); |
| | | } |
| | | result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0; |
| | | } |
| | | }else { |
| | | result = result || deviceChannelMapper.batchDel(deleteChannels) < 0; |
| | | } |
| | | } |
| | | |
| | |
| | | deviceChannel.setUpdateTime(DateUtil.getNow()); |
| | | if (allChannelMap.containsKey(deviceChannel.getChannelId())) { |
| | | deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); |
| | | deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).isHasAudio()); |
| | | deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio()); |
| | | if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ |
| | | List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); |
| | | if (!CollectionUtils.isEmpty(strings)){ |