From 241fa9030a1c3171db8296e049244ec74e558a35 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 1 Feb 2024 22:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/service/ICommonGbChannelService.java | 2 + .../vmp/service/IDeviceChannelService.java | 5 ++ .../iot/vmp/service/IStreamPushService.java | 5 ++ .../impl/CommonGbChannelServiceImpl.java | 5 ++ .../impl/DeviceChannelServiceImpl.java | 5 ++ .../channel/CommonChannelController.java | 52 ++++++++++++++----- 6 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java index b5854cbd..ef9a9193 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/ICommonGbChannelService.java @@ -75,4 +75,6 @@ public interface ICommonGbChannelService { PageInfo getShareChannelList(int platformId, int page, int count, String query, String type, Boolean online); void ptzControl(CommonGbChannel channel, PTZCommand ptzCommand); + + CommonGbChannel getChannelById(int id); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index c6313cb0..978525a4 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -90,4 +90,9 @@ public interface IDeviceChannelService { * 根据通道ID获取设备 */ Device getDeviceByChannelCommonGbId(int commonGbId); + + /** + * 根据通用通道ID查询通道 + */ + DeviceChannel getChannelByCommonChannelId(int commonGbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java index a296070e..bbba53d2 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java @@ -117,4 +117,9 @@ public interface IStreamPushService { * 设置推流离线 */ void offline(String app, String stream); + + /** + * + */ + StreamPush getPushByCommonChannelId(int commonGbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index 2ff1d33f..675fe7c4 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -496,4 +496,9 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { assert resourceService != null; resourceService.ptzControl(channel, ptzCommand); } + + @Override + public CommonGbChannel getChannelById(int id) { + return commonGbChannelMapper.getOne(id); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 7bcedcb8..aa286add 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -758,4 +758,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { public Device getDeviceByChannelCommonGbId(int commonGbId) { return channelMapper.getDeviceByChannelCommonGbId(commonGbId); } + + @Override + public DeviceChannel getChannelByCommonChannelId(int commonGbId) { + return channelMapper.getChannelByCommonChannelId(commonGbId); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java index 8169c33a..d1ff9f8d 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelController.java @@ -2,10 +2,18 @@ package com.genersoft.iot.vmp.vmanager.channel; import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy; +import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; import com.genersoft.iot.vmp.service.ICommonGbChannelService; +import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IStreamProxyService; +import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.service.bean.CommonGbChannelType; import com.genersoft.iot.vmp.service.bean.DeviceType; import com.genersoft.iot.vmp.service.bean.IndustryCodeType; import com.genersoft.iot.vmp.service.bean.NetworkIdentificationType; @@ -27,7 +35,9 @@ import org.springframework.web.context.request.async.DeferredResult; import javax.servlet.http.HttpServletRequest; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Tag(name = "通用国标通道") @@ -46,6 +56,15 @@ public class CommonChannelController { @Autowired private UserSetting userSetting; + @Autowired + private IDeviceChannelService deviceChannelService; + + @Autowired + private IStreamPushService streamPushService; + + @Autowired + private IStreamProxyService streamProxyService; + @Operation(summary = "更新通道信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true) @@ -355,16 +374,25 @@ public class CommonChannelController { } // 获取通用通道对应的原始资源信息 -// @Operation(summary = "通用通道对应的原始资源信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) -// @Parameter(name = "param", description = "共享通道参数", required = true) -// @GetMapping("/resource") -// public void removeShareChannel(String id) { -// CommonGbChannel commonGbChannel = commonGbChannelService.getChannelById(id); -// if (commonGbChannel == null) { -// throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道不存在"); -// } -// -// -// commonGbChannelService.removeShareChannel(param); -// } + @Operation(summary = "通用通道对应的原始资源信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "param", description = "共享通道参数", required = true) + @GetMapping("/resource") + public Map removeShareChannel(int id) { + Map resultMap = new HashMap<>(); + CommonGbChannel commonGbChannel = commonGbChannelService.getChannelById(id); + if (commonGbChannel == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道不存在"); + } + if (commonGbChannel.getType().equals(CommonGbChannelType.GB28181)) { + DeviceChannel deviceChannel = deviceChannelService.getChannelByCommonChannelId(commonGbChannel.getCommonGbId()); + resultMap.put(CommonGbChannelType.GB28181, deviceChannel); + }else if (commonGbChannel.getType().equals(CommonGbChannelType.PUSH)) { + StreamPush streamPush = streamPushService.getPushByCommonChannelId(commonGbChannel.getCommonGbId()); + resultMap.put(CommonGbChannelType.PUSH, streamPush); + }else if (commonGbChannel.getType().equals(CommonGbChannelType.PROXY)) { + StreamProxy streamProxy = streamProxyService.getProxyByCommonChnanelId(commonGbChannel.getCommonGbId()); + resultMap.put(CommonGbChannelType.PROXY, streamProxy); + } + return resultMap; + } }