| | |
| | | import java.util.*; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.DeviceMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.PatformChannelMapper; |
| | | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * @Description:视频设备数据存储-jdbc实现 |
| | |
| | | |
| | | @Autowired |
| | | private DeviceChannelMapper deviceChannelMapper; |
| | | |
| | | @Autowired |
| | | private ParentPlatformMapper platformMapper; |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private PatformChannelMapper patformChannelMapper; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { |
| | | // 获取到所有正在播放的流 |
| | | PageHelper.startPage(page+1, count); |
| | | PageHelper.startPage(page, count); |
| | | List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, null, query, hasSubChannel, online); |
| | | return new PageInfo<>(all); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) { |
| | | PageHelper.startPage(page+1, count); |
| | | PageHelper.startPage(page, count); |
| | | List<DeviceChannel> all = deviceChannelMapper.queryChannelsByDeviceId(deviceId, parentChannelId, null, null, null); |
| | | return new PageInfo<>(all); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public PageInfo<Device> queryVideoDeviceList(int page, int count) { |
| | | PageHelper.startPage(page+1, count); |
| | | PageHelper.startPage(page, count); |
| | | List<Device> all = deviceMapper.getDevices(); |
| | | return new PageInfo<>(all); |
| | | } |
| | |
| | | int result = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addParentPlatform(ParentPlatform parentPlatform) { |
| | | int result = platformMapper.addParentPlatform(parentPlatform); |
| | | return result > 0; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateParentPlatform(ParentPlatform parentPlatform) { |
| | | int result = 0; |
| | | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); |
| | | if ( platformMapper.getParentPlatById(parentPlatform.getServerGBId()) == null) { |
| | | result = platformMapper.addParentPlatform(parentPlatform); |
| | | |
| | | if (parentPlatformCatch == null) { |
| | | parentPlatformCatch = new ParentPlatformCatch(); |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| | | } |
| | | }else { |
| | | result = platformMapper.updateParentPlatform(parentPlatform); |
| | | } |
| | | // 更新缓存 |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| | | return result > 0; |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public boolean deleteParentPlatform(ParentPlatform parentPlatform) { |
| | | int result = platformMapper.delParentPlatform(parentPlatform); |
| | | // 删除关联的通道 |
| | | patformChannelMapper.cleanChannelForGB(parentPlatform.getDeviceGBId()); |
| | | return result > 0; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) { |
| | | PageHelper.startPage(page, count); |
| | | List<ParentPlatform> all = platformMapper.getParentPlatformList(); |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | | @Override |
| | | public ParentPlatform queryParentPlatById(String platformGbId) { |
| | | return platformMapper.getParentPlatById(platformGbId); |
| | | } |
| | | |
| | | @Override |
| | | public List<ParentPlatform> queryEnableParentPlatformList(boolean enable) { |
| | | return platformMapper.getEnableParentPlatformList(enable); |
| | | } |
| | | |
| | | @Override |
| | | public void outlineForAllParentPlatform() { |
| | | platformMapper.outlineForAllParentPlatform(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, |
| | | Boolean channelType, String platformId, Boolean inPlatform) { |
| | | PageHelper.startPage(page, count); |
| | | List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, inPlatform); |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelReduce> queryChannelListInParentPlatform(String platformId) { |
| | | |
| | | return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, true); |
| | | } |
| | | |
| | | @Override |
| | | public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces) { |
| | | |
| | | Map<String, ChannelReduce> deviceAndChannels = new HashMap<>(); |
| | | for (ChannelReduce channelReduce : channelReduces) { |
| | | deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce); |
| | | } |
| | | List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); |
| | | // 查询当前已经存在的 |
| | | List<String> relatedPlatformchannels = patformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList); |
| | | if (relatedPlatformchannels != null) { |
| | | deviceAndChannelList.removeAll(relatedPlatformchannels); |
| | | } |
| | | for (String relatedPlatformchannel : relatedPlatformchannels) { |
| | | deviceAndChannels.remove(relatedPlatformchannel); |
| | | } |
| | | List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); |
| | | // 对剩下的数据进行存储 |
| | | int result = 0; |
| | | if (channelReducesToAdd.size() > 0) { |
| | | result = patformChannelMapper.addChannels(platformId, channelReducesToAdd); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) { |
| | | |
| | | int result = patformChannelMapper.delChannelForGB(platformId, channelReduces); |
| | | |
| | | return result; |
| | | } |
| | | } |