From 59e3175f00191449952d0cc0e641e36ed70d2d0b Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 23 Dec 2024 18:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E5=AF=B9?= =?UTF-8?q?=E9=80=9A=E9=81=93=E7=B1=BB=E5=9E=8B=E7=9A=84=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 2 ++ .../gb28181/dao/provider/ChannelProvider.java | 4 +++ .../service/impl/GbChannelServiceImpl.java | 26 ++++++++----------- .../impl/PlatformChannelServiceImpl.java | 3 +-- .../service/impl/StreamProxyServiceImpl.java | 4 ++- .../controller/StreamPushController.java | 5 ++-- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 64f7dad8..0d61060f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -550,4 +550,6 @@ public interface CommonGBChannelMapper { @Param("channelType") Integer channelType, @Param("online") Boolean online, @Param("hasLink") Boolean hasLink); + @SelectProvider(type = ChannelProvider.class, method = "queryByDataId") + CommonGBChannel queryByDataId(@Param("dataType") Integer dataType, @Param("dataDeviceId") Integer dataDeviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 8a941d3c..16170d76 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -113,6 +113,10 @@ public class ChannelProvider { return BASE_SQL + " where channel_type = 0 and stream_push_id = #{streamPushId}"; } + public String queryByDataId(Map params ){ + return BASE_SQL + " where data_type = #{dataType} and data_device_id = #{dataDeviceId}"; + } + public String queryByStreamProxyId(Map params ){ return BASE_SQL + " where channel_type = 0 and stream_proxy_id = #{streamProxyId}"; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 030253fb..96bda5ce 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; @@ -53,17 +54,12 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public int add(CommonGBChannel commonGBChannel) { - if (commonGBChannel.getDataType() != null && commonGBChannel.getDataDeviceId() > 0) { - CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByStreamPushId(commonGBChannel.getStreamPushId()); - if (commonGBChannelInDb != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "此推流已经关联通道"); - } + if (commonGBChannel.getDataType() == null || commonGBChannel.getDataDeviceId() == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "缺少通道数据类型或通道数据关联设备ID"); } - if (commonGBChannel.getStreamProxyId() != null && commonGBChannel.getStreamProxyId() > 0) { - CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByStreamProxyId(commonGBChannel.getStreamProxyId()); - if (commonGBChannelInDb != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "此代理已经关联通道"); - } + CommonGBChannel commonGBChannelInDb = commonGBChannelMapper.queryByDataId(commonGBChannel.getDataType(), commonGBChannel.getDataDeviceId()); + if (commonGBChannelInDb != null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "此推流已经关联通道"); } commonGBChannel.setCreateTime(DateUtil.getNow()); commonGBChannel.setUpdateTime(DateUtil.getNow()); @@ -113,7 +109,7 @@ public class GbChannelServiceImpl implements IGbChannelService { public int update(CommonGBChannel commonGBChannel) { log.info("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId()); if (commonGBChannel.getGbId() <= 0) { - log.warn("[更新通道] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId()); + log.warn("[更新通道] 未找到数据库ID,更新失败, {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId()); return 0; } commonGBChannel.setUpdateTime(DateUtil.getNow()); @@ -132,7 +128,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public int offline(CommonGBChannel commonGBChannel) { if (commonGBChannel.getGbId() <= 0) { - log.warn("[通道离线] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId()); + log.warn("[通道离线] 未找到数据库ID,更新失败, {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId()); return 0; } int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 0); @@ -186,7 +182,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public int online(CommonGBChannel commonGBChannel) { if (commonGBChannel.getGbId() <= 0) { - log.warn("[通道上线] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId()); + log.warn("[通道上线] 未找到数据库ID,更新失败, {}({})", commonGBChannel.getGbName(), commonGBChannel.getGbDeviceId()); return 0; } int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 1); @@ -371,12 +367,12 @@ public class GbChannelServiceImpl implements IGbChannelService { log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id); throw new ControllerException(ErrorCode.ERROR400); } - if (channel.getGbDeviceDbId() <= 0) { + if (channel.getDataType() == ChannelDataType.GB28181.value) { log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id); throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置"); } // 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生 - commonGBChannelMapper.reset(id, channel.getGbDeviceDbId(), DateUtil.getNow()); + commonGBChannelMapper.reset(id, channel.getDataDeviceId(), DateUtil.getNow()); CommonGBChannel channelNew = getOne(id); // 发送通过更新通知 try { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 2f768f10..15d0142b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.jt1078.proc.request.Re; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -432,7 +431,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { eventPublisher.catalogEventPublish(channel.getPlatformId(), commonGBChannel, CatalogEvent.UPDATE); } catch (Exception e) { log.warn("[自定义通道信息] 发送失败, 平台ID: {}, 通道: {}({})", channel.getPlatformId(), - channel.getGbName(), channel.getGbDeviceDbId(), e); + channel.getGbName(), channel.getId(), e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index cf1818d9..38751123 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.streamProxy.service.impl; import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; @@ -179,7 +180,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { streamProxy.setCreateTime(DateUtil.getNow()); streamProxy.setUpdateTime(DateUtil.getNow()); streamProxyMapper.add(streamProxy); - streamProxy.setStreamProxyId(streamProxy.getId()); + streamProxy.setDataType(ChannelDataType.STREAM_PROXY.value); + streamProxy.setDataDeviceId(streamProxy.getId()); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java index 1331c93a..ecaa92ee 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.streamPush.controller; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; @@ -28,7 +29,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; @@ -215,7 +215,8 @@ public class StreamPushController { if (!streamPushService.add(stream)) { throw new ControllerException(ErrorCode.ERROR100); } - stream.setStreamPushId(stream.getId()); + stream.setDataType(ChannelDataType.STREAM_PUSH.value); + stream.setDataDeviceId(stream.getId()); return stream; }