| | |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | 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; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | |
| | | @Override |
| | | public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { |
| | | if (deviceChannelList == null) { |
| | | return false; |
| | | } |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | // 数据去重 |
| | | List<DeviceChannel> channels = new ArrayList<>(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | Map<String, Integer> subContMap = new HashMap<>(); |
| | | if (deviceChannelList.size() > 1) { |
| | | if (deviceChannelList != null && deviceChannelList.size() > 1) { |
| | | // 数据去重 |
| | | Set<String> gbIdSet = new HashSet<>(); |
| | | for (DeviceChannel deviceChannel : deviceChannelList) { |
| | |
| | | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| | | return true; |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | return false; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { |
| | | public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count) { |
| | | // 获取到所有正在播放的流 |
| | | PageHelper.startPage(page, count); |
| | | List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); |
| | | List<DeviceChannel> all; |
| | | if (catalogUnderDevice != null && catalogUnderDevice) { |
| | | all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); |
| | | }else { |
| | | all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); |
| | | } |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | |
| | | return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceChannelTree> tree(String deviceId) { |
| | | return ForestNodeMerger.merge(deviceChannelMapper.tree(deviceId)); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, String online, int page, int count) { |
| | | public PageInfo<DeviceChannel> querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { |
| | | PageHelper.startPage(page, count); |
| | | List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, null, null, null); |
| | | List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, parentChannelId, query, hasSubChannel, online); |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | boolean result = false; |
| | | try { |
| | | if (platformChannelMapper.delChannelForDeviceId(deviceId) <0 // 删除与国标平台的关联 |
| | | || deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 删除他的通道 |
| | | || deviceMapper.del(deviceId) < 0 // 移除设备信息 |
| | | ) { |
| | | platformChannelMapper.delChannelForDeviceId(deviceId); |
| | | deviceChannelMapper.cleanChannelsByDeviceId(deviceId); |
| | | if ( deviceMapper.del(deviceId) < 0 ) { |
| | | //事务回滚 |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | } |
| | |
| | | device.setOnline(1); |
| | | logger.info("更新设备在线: " + deviceId); |
| | | redisCatchStorage.updateDevice(device); |
| | | List<DeviceChannel> deviceChannelList = deviceChannelMapper.queryOnlineChannelsByDeviceId(deviceId); |
| | | eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON); |
| | | return deviceMapper.update(device) > 0; |
| | | } |
| | | |
| | |
| | | public synchronized boolean outline(String deviceId) { |
| | | logger.info("更新设备离线: " + deviceId); |
| | | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| | | if (device == null) return false; |
| | | if (device == null) { |
| | | return false; |
| | | } |
| | | device.setOnline(0); |
| | | redisCatchStorage.updateDevice(device); |
| | | return deviceMapper.update(device) > 0; |
| | |
| | | * @param endTime |
| | | */ |
| | | @Override |
| | | public synchronized List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime) { |
| | | return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, startTime, endTime); |
| | | public synchronized List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) { |
| | | return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public boolean updateParentPlatform(ParentPlatform parentPlatform) { |
| | | int result = 0; |
| | | if (parentPlatform.getCatalogGroup() == 0) { |
| | | parentPlatform.setCatalogGroup(1); |
| | | } |
| | | if (parentPlatform.getAdministrativeDivision() == null) { |
| | | parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision()); |
| | | } |
| | | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); |
| | | if (parentPlatform.getId() == null ) { |
| | | if (parentPlatform.getCatalogId() == null) { |
| | |
| | | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); |
| | | } |
| | | |
| | | result = platformMapper.updateParentPlatform(parentPlatform); |
| | | } |
| | | // 更新缓存 |
| | |
| | | * 删除指定设备的所有移动位置 |
| | | * @param deviceId |
| | | */ |
| | | @Override |
| | | public int clearMobilePositionsByDeviceId(String deviceId) { |
| | | return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateMediaList(List<StreamPushItem> streamPushItems) { |
| | | if (streamPushItems == null || streamPushItems.size() == 0) return; |
| | | if (streamPushItems == null || streamPushItems.size() == 0) { |
| | | return; |
| | | } |
| | | logger.info("updateMediaList: " + streamPushItems.size()); |
| | | streamPushMapper.addAll(streamPushItems); |
| | | // TODO 待优化 |
| | |
| | | deviceChannel.setParentId(catalog.getParentId()); |
| | | deviceChannel.setRegisterWay(1); |
| | | // 行政区划应该是Domain的前八位 |
| | | deviceChannel.setCivilCode(parentPlatByServerGBId.getDeviceGBId().substring(0,6)); |
| | | deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision()); |
| | | deviceChannel.setModel("live"); |
| | | deviceChannel.setOwner("wvp-pro"); |
| | | deviceChannel.setSecrecy("0"); |