From 946e1dc245ab629b39c1124cbe2f4cc4685b5935 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 18 Nov 2022 17:17:01 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BF=A1=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/README.md | 4 ++-- .../gb28181/transmit/cmd/ISIPCommander.java | 20 ++++++++++------ .../transmit/cmd/impl/SIPCommander.java | 23 +++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/README.md b/doc/README.md index 635a4a53..46b27fb0 100644 --- a/doc/README.md +++ b/doc/README.md @@ -21,7 +21,7 @@ - [X] 实时视音频点播 - [X] 设备控制 - [X] 云台控制 - - [ ] 远程启动 + - [X] 远程启动 - [ ] 录像控制 - [ ] 报警布防/撤防 - [ ] 报警复位 @@ -29,7 +29,7 @@ - [ ] 拉框放大 - [ ] 拉框缩小 - [ ] 看守位控制 - - [ ] 设备配置 + - [X] 设备配置 - [X] 报警事件通知和分发 - [X] 设备目录订阅 - [X] 网络设备信息查询 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index b99286ed..8fcee5a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -2,19 +2,17 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; +import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import gov.nist.javax.sip.message.SIPRequest; -import javax.sip.Dialog; import javax.sip.InvalidArgumentException; -import javax.sip.PeerUnavailableException; import javax.sip.SipException; -import javax.sip.message.Message; -import javax.sip.message.Request; import java.text.ParseException; /** @@ -235,7 +233,7 @@ public interface ISIPCommander { */ void deviceConfigCmd(Device device); - /** + /** * 设备配置命令:basicParam * * @param device 视频设备 @@ -246,7 +244,15 @@ public interface ISIPCommander { * @param heartBeatCount 心跳超时次数(可选) */ void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + + + /** + * 设备配置命令:远程启动 + * + * @param device 视频设备 + */ + void deviceTeleBootCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; + /** * 查询设备状态 * diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index b382b635..55b200cc 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -907,6 +907,29 @@ public class SIPCommander implements ISIPCommander { sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); } + /** + * 设备配置命令:远程启动 + * + * @param device 视频设备 + */ + @Override + public void deviceTeleBootCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { + + StringBuffer cmdXml = new StringBuffer(200); + String charset = device.getCharset(); + cmdXml.append("\r\n"); + cmdXml.append("\r\n"); + cmdXml.append("DeviceControl\r\n"); + cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); + cmdXml.append("" + device.getDeviceId() + "\r\n"); + cmdXml.append("\r\n"); + cmdXml.append("Boot\r\n"); + cmdXml.append("\r\n"); + + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); + } + /** * 查询设备状态 * From a02883b394dc0d53a3e4a6995a75df4d67ed2804 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 18 Nov 2022 17:26:58 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/README.md | 16 ++++++++-------- .../vmp/gb28181/transmit/cmd/ISIPCommander.java | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/README.md b/doc/README.md index 46b27fb0..0fb5b86d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -22,21 +22,21 @@ - [X] 设备控制 - [X] 云台控制 - [X] 远程启动 - - [ ] 录像控制 - - [ ] 报警布防/撤防 - - [ ] 报警复位 + - [X] 录像控制 + - [X] 报警布防/撤防 + - [X] 报警复位 - [X] 强制关键帧 - - [ ] 拉框放大 - - [ ] 拉框缩小 - - [ ] 看守位控制 + - [X] 拉框放大 + - [X] 拉框缩小 + - [X] 看守位控制 - [X] 设备配置 - [X] 报警事件通知和分发 - [X] 设备目录订阅 - [X] 网络设备信息查询 - [X] 设备目录查询 - [X] 设备状态查询 - - [ ] 设备配置查询 - - [ ] 设备预置位查询 + - [X] 设备配置查询 + - [X] 设备预置位查询 - [X] 状态信息报送 - [X] 设备视音频文件检索 - [X] 历史视音频的回放 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 8fcee5a3..59bd49e5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -253,6 +253,7 @@ public interface ISIPCommander { */ void deviceTeleBootCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; + /** * 查询设备状态 * From 86c08db2662672e844028437972dae22dac28645 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 18 Nov 2022 17:29:22 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/cmd/ISIPCommander.java | 9 -------- .../transmit/cmd/impl/SIPCommander.java | 23 ------------------- 2 files changed, 32 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 59bd49e5..eebed4eb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -245,15 +245,6 @@ public interface ISIPCommander { */ void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 设备配置命令:远程启动 - * - * @param device 视频设备 - */ - void deviceTeleBootCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** * 查询设备状态 * diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 55b200cc..b382b635 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -907,29 +907,6 @@ public class SIPCommander implements ISIPCommander { sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); } - /** - * 设备配置命令:远程启动 - * - * @param device 视频设备 - */ - @Override - public void deviceTeleBootCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("Boot\r\n"); - cmdXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - /** * 查询设备状态 * From 8cab9f23b07dca8aa20f117aaf420597f14a0fe3 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 21 Nov 2022 10:07:27 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=9D=A5=E6=BA=90IP=E4=BD=9C=E4=B8=BA=E6=B5=81ip=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmanager/gb28181/play/PlayController.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index 68a8133c..885f121a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -106,22 +106,24 @@ public class PlayController { resultHolder.invokeResult(msg); }); - // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误 - deferredResultEx.setFilter(result1 -> { - WVPResult wvpResult1 = (WVPResult)result1; - WVPResult clone = null; - try { - clone = (WVPResult)wvpResult1.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - if (clone.getCode() == ErrorCode.SUCCESS.getCode()) { - StreamInfo data = clone.getData().clone(); - data.channgeStreamIp(request.getLocalName()); - clone.setData(data); - } - return clone; - }); + if (userSetting.getUseSourceIpAsStreamIp()) { + // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误 + deferredResultEx.setFilter(result1 -> { + WVPResult wvpResult1 = (WVPResult)result1; + WVPResult clone = null; + try { + clone = (WVPResult)wvpResult1.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + if (clone.getCode() == ErrorCode.SUCCESS.getCode()) { + StreamInfo data = clone.getData().clone(); + data.channgeStreamIp(request.getLocalName()); + clone.setData(data); + } + return clone; + }); + } // 录像查询以channelId作为deviceId查询 resultHolder.put(key, uuid, deferredResultEx); From 1983b8b0a705995665dffadf709afd03239c5950 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 22 Nov 2022 12:55:29 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=9B=BD=E6=A0=87=E7=BA=A7=E8=81=94->?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=80=9A=E9=81=93=E6=94=AF=E6=8C=81=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E7=9B=AE=E5=89=8D=E4=B8=8B=E6=89=80=E6=9C=89=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=85=A8=E9=83=A8=E6=B7=BB=E5=8A=A0=E5=88=B0=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/service/IDeviceChannelService.java | 8 +++ .../iot/vmp/service/IGbStreamService.java | 14 ++++++ .../vmp/service/IPlatformChannelService.java | 7 +++ .../impl/DeviceChannelServiceImpl.java | 9 ++++ .../vmp/service/impl/GbStreamServiceImpl.java | 34 ++++++++++++- .../impl/PlatformChannelServiceImpl.java | 23 +++++++++ .../vmp/storager/dao/DeviceChannelMapper.java | 1 - .../iot/vmp/storager/dao/GbStreamMapper.java | 2 +- .../storager/dao/PlatformChannelMapper.java | 8 +++ .../storager/dao/PlatformGbStreamMapper.java | 3 ++ .../impl/VideoManagerStorageImpl.java | 15 ------ .../gb28181/gbStream/GbStreamController.java | 27 ++++++---- .../gb28181/gbStream/bean/GbStreamParam.java | 11 +++++ .../gb28181/platform/PlatformController.java | 31 ++++++++++-- .../platform/bean/UpdateChannelParam.java | 11 +++++ .../vmanager/gb28181/play/PlayController.java | 2 - .../components/dialog/chooseChannelForGb.vue | 49 +++++++++++++------ .../dialog/chooseChannelForStream.vue | 45 +++++++++++------ 18 files changed, 234 insertions(+), 66 deletions(-) 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 3f587358..31e568a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import java.util.List; @@ -38,4 +39,11 @@ public interface IDeviceChannelService { * @return */ ResourceBaceInfo getOverview(); + + /** + * 查询所有未分配的通道 + * @param platformId + * @return + */ + List queryAllChannelList(String platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java index ffbba007..314a3890 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java @@ -55,4 +55,18 @@ public interface IGbStreamService { int updateGbIdOrName(List streamPushItemForUpdate); DeviceChannel getDeviceChannelListByStreamWithStatus(GbStream gbStream, String catalogId, ParentPlatform platform); + + /** + * 查询所有未分配的通道 + * @param platformId + * @return + */ + List getAllGBChannels(String platformId); + + /** + * 移除所有关联的通道 + * @param platformId + * @param catalogId + */ + void delAllPlatformInfo(String platformId, String catalogId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java index 739e6b86..49d74282 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java @@ -19,4 +19,11 @@ public interface IPlatformChannelService { */ int updateChannelForGB(String platformId, List channelReduces, String catalogId); + /** + * 移除目录下的所有通道 + * @param platformId + * @param catalogId + * @return + */ + int delAllChannelForGB(String platformId, String catalogId); } 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 41b55ddc..9db2d683 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -168,4 +169,12 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { public ResourceBaceInfo getOverview() { return channelMapper.getOverview(); } + + + @Override + public List queryAllChannelList(String platformId) { + return channelMapper.queryChannelListInAll(null, null, null, platformId, null); + } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java index da11b164..dc9d927c 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java @@ -4,11 +4,11 @@ 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.StreamPushItem; +import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; -import com.genersoft.iot.vmp.service.IGbStreamService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -19,7 +19,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; @@ -230,4 +229,35 @@ public class GbStreamServiceImpl implements IGbStreamService { deviceChannel.setSecrecy("0"); return deviceChannel; } + + @Override + public List getAllGBChannels(String platformId) { + + return gbStreamMapper.selectAll(platformId, null, null, null); + + } + + @Override + public void delAllPlatformInfo(String platformId, String catalogId) { + if (platformId == null) { + return ; + } + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); + if (platform == null) { + return ; + } + if (ObjectUtils.isEmpty(catalogId)) { + catalogId = platform.getDeviceGBId(); + } + if (platformGbStreamMapper.delByPlatformAndCatalogId(platformId, catalogId) > 0) { + List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId); + List deviceChannelList = new ArrayList<>(); + for (GbStream gbStream : gbStreams) { + DeviceChannel deviceChannel = new DeviceChannel(); + deviceChannel.setChannelId(gbStream.getGbId()); + deviceChannelList.add(deviceChannel); + } + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); + } + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index 22d195ef..601ff5de 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -16,6 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import java.util.ArrayList; import java.util.HashMap; @@ -105,4 +106,26 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { } return deviceChannelList; } + + @Override + public int delAllChannelForGB(String platformId, String catalogId) { + + int result; + if (platformId == null) { + return 0; + } + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); + if (platform == null) { + return 0; + } + if (ObjectUtils.isEmpty(catalogId)) { + catalogId = platform.getDeviceGBId(); + } + + if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { + List deviceChannels = platformChannelMapper.queryAllChannelInCatalog(platformId, catalogId); + eventPublisher.catalogEventPublish(platformId, deviceChannels, CatalogEvent.DEL); + } + return result; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index ff20cef3..53072b2d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.storager.dao; -import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index 8a5d4550..6ea852e4 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -5,7 +5,6 @@ import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -169,4 +168,5 @@ public interface GbStreamMapper { @Select("SELECT status FROM stream_push WHERE app=#{app} AND stream=#{stream}") Boolean selectStatusForPush(String app, String stream); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java index e048f31e..120ecb3e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java @@ -57,6 +57,9 @@ public interface PlatformChannelMapper { @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'") List queryChannelInParentPlatform(String platformId, String channelId); + @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE pgc.platformId='${platformId}' and pgc.catalogId=#{catalogId}") + List queryAllChannelInCatalog(String platformId, String catalogId); + @Select(" select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + " from device_channel dc left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId " + " where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") @@ -99,4 +102,9 @@ public interface PlatformChannelMapper { "DELETE FROM platform_gb_channel WHERE platformId=#{serverGBId}" + "") void delByPlatformId(String serverGBId); + + @Delete("") + int delChannelForGBByCatalogId(String platformId, String catalogId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java index 98afd6b7..13094b98 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java @@ -105,4 +105,7 @@ public interface PlatformGbStreamMapper { "" + "") void delByAppAndStreamsByPlatformId(List gbStreams, String platformId); + + @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId} and catalogId=#{catalogId}") + int delByPlatformAndCatalogId(String platformId, String catalogId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 79edcf85..377b20f2 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -1,13 +1,11 @@ package com.genersoft.iot.vmp.storager.impl; -import com.genersoft.iot.vmp.common.StreamInfo; 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.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; @@ -28,7 +26,6 @@ import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -761,18 +758,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return gbStreamMapper.updateStreamGPS(gpsMsgInfos); } - private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId) { - List deviceChannelList = new ArrayList<>(); - if (channelReduces.size() > 0){ - for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); - deviceChannel.setParental(1); - deviceChannel.setParentId(catalogId); - deviceChannelList.add(deviceChannel); - } - } - return deviceChannelList; - } private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java index 3ba032a9..447944a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java @@ -1,9 +1,9 @@ package com.genersoft.iot.vmp.vmanager.gb28181.gbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream; +import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam; -import com.genersoft.iot.vmp.service.IGbStreamService; import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -12,9 +12,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Tag(name = "视频流关联到级联平台") @CrossOrigin @RestController @@ -76,11 +77,14 @@ public class GbStreamController { @Operation(summary = "移除国标关联") @DeleteMapping(value = "/del") @ResponseBody - public Object del(@RequestBody GbStreamParam gbStreamParam){ - if (gbStreamService.delPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getGbStreams())) { - return "success"; + public void del(@RequestBody GbStreamParam gbStreamParam){ + + if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) { + if (gbStreamParam.isAll()) { + gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); + } }else { - return "fail"; + gbStreamService.delPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getGbStreams()); } } @@ -93,11 +97,14 @@ public class GbStreamController { @Operation(summary = "保存国标关联") @PostMapping(value = "/add") @ResponseBody - public Object add(@RequestBody GbStreamParam gbStreamParam){ - if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId())) { - return "success"; + public void add(@RequestBody GbStreamParam gbStreamParam){ + if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) { + if (gbStreamParam.isAll()) { + List allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId()); + gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); + } }else { - return "fail"; + gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java index 161f2e7f..3705c709 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java @@ -14,6 +14,9 @@ public class GbStreamParam { @Schema(description = "目录ID") private String catalogId; + @Schema(description = "关联所有通道") + private boolean all; + @Schema(description = "流国标信息列表") private List gbStreams; @@ -40,4 +43,12 @@ public class GbStreamParam { public void setGbStreams(List gbStreams) { this.gbStreams = gbStreams; } + + public boolean isAll() { + return all; + } + + public void setAll(boolean all) { + this.all = all; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 3bd8aec9..40b65c33 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -10,8 +10,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IPlatformChannelService; -import com.genersoft.iot.vmp.service.IPlatformService; +import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; @@ -72,6 +71,12 @@ public class PlatformController { @Autowired private IPlatformService platformService; + @Autowired + private IDeviceChannelService deviceChannelService; + + @Autowired + private IGbStreamService gbStreamService; + /** * 获取国标服务的配置 * @@ -379,7 +384,16 @@ public class PlatformController { if (logger.isDebugEnabled()) { logger.debug("给上级平台添加国标通道API调用"); } - int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); + int result = 0; + if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) { + if (param.isAll()) { + logger.info("[国标级联]添加所有通道到上级平台, {}", param.getPlatformId()); + List allChannelForDevice = deviceChannelService.queryAllChannelList(param.getPlatformId()); + result = platformChannelService.updateChannelForGB(param.getPlatformId(), allChannelForDevice, param.getCatalogId()); + } + }else { + result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); + } if (result <= 0) { throw new ControllerException(ErrorCode.ERROR100); } @@ -399,8 +413,15 @@ public class PlatformController { if (logger.isDebugEnabled()) { logger.debug("给上级平台删除国标通道API调用"); } - int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); - + int result = 0; + if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) { + if (param.isAll()) { + logger.info("[国标级联]移除所有通道,上级平台, {}", param.getPlatformId()); + result = platformChannelService.delAllChannelForGB(param.getPlatformId(), param.getCatalogId()); + } + }else { + result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); + } if (result <= 0) { throw new ControllerException(ErrorCode.ERROR100); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java index 01762d9c..2d598e44 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java @@ -17,6 +17,9 @@ public class UpdateChannelParam { @Schema(description = "目录的国标编号") private String catalogId; + @Schema(description = "处理所有通道") + private boolean all; + @Schema(description = "") private List channelReduces; @@ -43,4 +46,12 @@ public class UpdateChannelParam { public void setCatalogId(String catalogId) { this.catalogId = catalogId; } + + public boolean isAll() { + return all; + } + + public void setAll(boolean all) { + this.all = all; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index 885f121a..9fed0c59 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -134,7 +134,6 @@ public class PlayController { return result; } - @Operation(summary = "停止点播") @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true) @@ -171,7 +170,6 @@ public class PlayController { json.put("deviceId", deviceId); json.put("channelId", channelId); return json; - } /** diff --git a/web_src/src/components/dialog/chooseChannelForGb.vue b/web_src/src/components/dialog/chooseChannelForGb.vue index a4dc5e08..fc97b4ce 100644 --- a/web_src/src/components/dialog/chooseChannelForGb.vue +++ b/web_src/src/components/dialog/chooseChannelForGb.vue @@ -18,8 +18,10 @@ - 批量移除 - 批量添加 + 批量移除 + 批量添加 + 全部添加 + 全部移除 @@ -115,13 +117,15 @@ export default { this.initData(); }, add: function (row) { + let all = typeof(row) === "undefined" this.getCatalogFromUser((catalogId)=> { this.$axios({ method:"post", url:"/api/platform/update_channel_for_gb", data:{ platformId: this.platformId, - channelReduces: [row], + all: all, + channelReduces: all?[]:[row], catalogId: catalogId } }).then((res)=>{ @@ -134,21 +138,34 @@ export default { }, remove: function (row) { - console.log(row) + let all = typeof(row) === "undefined" + this.$confirm(`确定移除${all?"所有通道":""}吗?`, '提示', { + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + console.log(row) + + this.$axios({ + method:"delete", + url:"/api/platform/del_channel_for_gb", + data:{ + platformId: this.platformId, + all: all, + channelReduces: all?[]:[row], + } + }).then((res)=>{ + console.log("移除成功") + this.getChannelList(); + }).catch(function (error) { + console.log(error); + }); + }).catch(() => { - this.$axios({ - method:"delete", - url:"/api/platform/del_channel_for_gb", - data:{ - platformId: this.platformId, - channelReduces: [row] - } - }).then((res)=>{ - console.log("移除成功") - this.getChannelList(); - }).catch(function (error) { - console.log(error); }); + + }, // checkedChange: function (val) { // let that = this; diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue index 8d63dbf7..6c4653b5 100644 --- a/web_src/src/components/dialog/chooseChannelForStream.vue +++ b/web_src/src/components/dialog/chooseChannelForStream.vue @@ -24,6 +24,8 @@ 批量移除 批量添加 + 全部添加 + 全部移除 @@ -128,6 +130,7 @@ export default { }, add: function (row, scope) { + let all = typeof(row) === "undefined" this.getCatalogFromUser((catalogId)=>{ this.$axios({ method:"post", @@ -135,7 +138,8 @@ export default { data:{ platformId: this.platformId, catalogId: catalogId, - gbStreams: [row], + all: all, + gbStreams: all?[]:[row], } }).then((res)=>{ console.log("保存成功") @@ -149,20 +153,33 @@ export default { }, remove: function (row, scope) { - this.$axios({ - method:"delete", - url:"/api/gbStream/del", - data:{ - platformId: this.platformId, - gbStreams: [row], - } - }).then((res)=>{ - console.log("移除成功") - // this.gbStreams.splice(scope.$index,1) - this.getChannelList(); - }).catch(function (error) { - console.log(error); + let all = typeof(row) === "undefined" + this.$confirm(`确定移除${all?"所有通道":""}吗?`, '提示', { + dangerouslyUseHTMLString: true, + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + + this.$axios({ + method:"delete", + url:"/api/gbStream/del", + data:{ + platformId: this.platformId, + all: all, + gbStreams: all?[]:[row], + } + }).then((res)=>{ + console.log("移除成功") + // this.gbStreams.splice(scope.$index,1) + this.getChannelList(); + }).catch(function (error) { + console.log(error); + }); + }).catch(() => { + }); + }, getChannelList: function () { let that = this; From 14699711028f0d157eddfb0432e26ab91f1b4493 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 22 Nov 2022 15:02:25 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8A=E7=BA=BF=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9F=A5=E8=AF=A2=E9=80=9A=E9=81=93=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E9=81=93=E5=88=B7=E6=96=B0=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/conf/UserSetting.java | 10 ++++ .../vmp/service/impl/DeviceServiceImpl.java | 20 ++++---- src/main/resources/all-application.yml | 2 + .../components/dialog/SyncChannelProgress.vue | 48 ++++++++----------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index ca204d93..eeee438f 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -41,6 +41,8 @@ public class UserSetting { private Boolean gbSendStreamStrict = Boolean.FALSE; + private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; + private String serverId = "000000"; private String thirdPartyGBIdReg = "[\\s\\S]*"; @@ -186,4 +188,12 @@ public class UserSetting { public void setGbSendStreamStrict(Boolean gbSendStreamStrict) { this.gbSendStreamStrict = gbSendStreamStrict; } + + public Boolean getSyncChannelOnDeviceOnline() { + return syncChannelOnDeviceOnline; + } + + public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) { + this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index ac48e4df..d25e537e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.DynamicTask; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; @@ -12,7 +13,6 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; @@ -78,7 +78,7 @@ public class DeviceServiceImpl implements IDeviceService { TransactionDefinition transactionDefinition; @Autowired - private IVideoManagerStorage storage; + private UserSetting userSetting; @Autowired private ISIPCommander commander; @@ -120,16 +120,18 @@ public class DeviceServiceImpl implements IDeviceService { if(device.getOnline() == 0){ device.setOnline(1); device.setCreateTime(now); - logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); deviceMapper.update(device); redisCatchStorage.updateDevice(device); - try { - commander.deviceInfoQuery(device); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); + if (userSetting.getSyncChannelOnDeviceOnline()) { + logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); + try { + commander.deviceInfoQuery(device); + } catch (InvalidArgumentException | SipException | ParseException e) { + logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); + } + sync(device); + // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 } - sync(device); - // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 }else { if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) { logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId()); diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 33039153..e8b28d0d 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -195,6 +195,8 @@ user-settings: # 国标级联发流严格模式,严格模式会使用与sdp信息中一致的端口发流,端口共享media.rtp.port-range,这会损失一些性能, # 非严格模式使用随机端口发流,性能更好, 默认关闭 gb-send-stream-strict: false + # 设备上线时是否自动同步通道 + sync-channel-on-device-online: false # 关闭在线文档(生产环境建议关闭) springdoc: diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue index c972a46c..e1c9fe01 100644 --- a/web_src/src/components/dialog/SyncChannelProgress.vue +++ b/web_src/src/components/dialog/SyncChannelProgress.vue @@ -63,37 +63,29 @@ export default { } if (res.data.data != null) { - if (res.data.syncIng) { + if (res.data.data.syncIng) { if (res.data.data.total == 0) { - if (res.data.data.errorMsg !== null ){ - this.msg = res.data.data.errorMsg; - this.syncStatus = "exception" - }else { - this.msg = `等待同步中`; - this.timmer = setTimeout(this.getProgress, 300) - } - }else { - if (res.data.data.total == res.data.data.current) { - this.syncStatus = "success" - this.percentage = 100; - this.msg = '同步成功'; - }else { - if (res.data.data.errorMsg !== null ){ - this.msg = res.data.data.errorMsg; - this.syncStatus = "exception" - }else { - this.total = res.data.data.total; - this.current = res.data.data.current; - this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; - this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`; - this.timmer = setTimeout(this.getProgress, 300) - } - } + this.msg = `等待同步中`; + this.timmer = setTimeout(this.getProgress, 300) + }else { + this.total = res.data.data.total; + this.current = res.data.data.current; + this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; + this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`; + this.timmer = setTimeout(this.getProgress, 300) } }else { - this.syncStatus = "success" - this.percentage = 100; - this.msg = '同步成功'; + if (res.data.data.errorMsg){ + this.msg = res.data.data.errorMsg; + this.syncStatus = "exception" + }else { + this.syncStatus = "success" + this.percentage = 100; + this.msg = '同步成功'; + setTimeout(()=>{ + this.showDialog = false; + }, 3000) + } } } }else { From 8ea6e192d9f986045adbaeab54ea062938e9693e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 22 Nov 2022 17:17:35 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8B=89=E6=B5=81?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E8=A1=A8=E5=8D=95=E4=BB=A5=E5=8F=8A=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 2 +- sql/update.sql | 5 ++ .../iot/vmp/conf/GlobalExceptionHandler.java | 10 +-- .../vmp/media/zlm/ZLMHttpHookListener.java | 1 + .../iot/vmp/media/zlm/ZLMRESTfulUtils.java | 12 +-- .../vmp/media/zlm/dto/StreamProxyItem.java | 33 +++----- .../service/impl/StreamProxyServiceImpl.java | 31 ++----- .../vmp/storager/dao/StreamProxyMapper.java | 6 +- web_src/src/components/StreamProxyList.vue | 69 +++++++--------- .../src/components/dialog/StreamProxyEdit.vue | 80 +++++++++---------- 10 files changed, 108 insertions(+), 141 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index b5ca0161..869482cc 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -446,7 +446,7 @@ CREATE TABLE `stream_proxy` ( `ffmpeg_cmd_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `rtp_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `enable_hls` bit(1) DEFAULT NULL, + `enable_audio` bit(1) DEFAULT NULL, `enable_mp4` bit(1) DEFAULT NULL, `enable` bit(1) NOT NULL, `status` bit(1) NOT NULL, diff --git a/sql/update.sql b/sql/update.sql index 405cb3a7..877e2477 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -36,3 +36,8 @@ alter table device alter table device modify hostAddress varchar(50) null; + +alter table stream_proxy + change enable_hls enable_audio bit null; + + diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java index 0c7c3d2f..728afb96 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java @@ -1,12 +1,12 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; @@ -40,8 +40,8 @@ public class GlobalExceptionHandler { */ @ExceptionHandler(ControllerException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult exceptionHandler(ControllerException e) { - return WVPResult.fail(e.getCode(), e.getMsg()); + public ResponseEntity> exceptionHandler(ControllerException e) { + return new ResponseEntity<>(WVPResult.fail(e.getCode(), e.getMsg()), HttpStatus.OK); } /** @@ -51,7 +51,7 @@ public class GlobalExceptionHandler { */ @ExceptionHandler(BadCredentialsException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public WVPResult exceptionHandler(BadCredentialsException e) { - return WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()); + public ResponseEntity> exceptionHandler(BadCredentialsException e) { + return new ResponseEntity<>(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage()), HttpStatus.OK); } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index a3145540..54a28905 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -505,6 +505,7 @@ public class ZLMHttpHookListener { // 修改数据 streamProxyService.stop(param.getApp(), param.getStream()); }else { + // 无人观看不做处理 ret.put("close", false); } return ret; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java index 7d3510ff..bf9551d4 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java @@ -236,14 +236,13 @@ public class ZLMRESTfulUtils { } public JSONObject addFFmpegSource(MediaServerItem mediaServerItem, String src_url, String dst_url, String timeout_ms, - boolean enable_hls, boolean enable_mp4, String ffmpeg_cmd_key){ + boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){ logger.info(src_url); logger.info(dst_url); Map param = new HashMap<>(); param.put("src_url", src_url); param.put("dst_url", dst_url); param.put("timeout_ms", timeout_ms); - param.put("enable_hls", enable_hls); param.put("enable_mp4", enable_mp4); param.put("ffmpeg_cmd_key", ffmpeg_cmd_key); return sendPost(mediaServerItem, "addFFmpegSource",param, null); @@ -287,19 +286,14 @@ public class ZLMRESTfulUtils { return sendPost(mediaServerItem, "restartServer",null, null); } - public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) { + public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type) { Map param = new HashMap<>(); param.put("vhost", "__defaultVhost__"); param.put("app", app); param.put("stream", stream); param.put("url", url); - param.put("enable_hls", enable_hls?1:0); param.put("enable_mp4", enable_mp4?1:0); - param.put("enable_rtmp", 1); - param.put("enable_fmp4", 1); - param.put("enable_audio", 1); - param.put("enable_rtsp", 1); - param.put("add_mute_audio", 1); + param.put("enable_audio", enable_audio?1:0); param.put("rtp_type", rtp_type); return sendPost(mediaServerItem, "addStreamProxy",param, null); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java index ea0bdcaa..b0e74e8f 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java @@ -31,8 +31,8 @@ public class StreamProxyItem extends GbStream { private String rtp_type; @Schema(description = "是否启用") private boolean enable; - @Schema(description = "是否启用HLS") - private boolean enable_hls; + @Schema(description = "是否启用音频") + private boolean enable_audio; @Schema(description = "是否启用MP4") private boolean enable_mp4; @Schema(description = "是否 无人观看时删除") @@ -40,8 +40,6 @@ public class StreamProxyItem extends GbStream { @Schema(description = "是否 无人观看时自动停用") private boolean enable_disable_none_reader; - @Schema(description = "上级平台国标ID") - private String platformGbId; @Schema(description = "创建时间") private String createTime; @@ -139,14 +137,6 @@ public class StreamProxyItem extends GbStream { this.enable = enable; } - public boolean isEnable_hls() { - return enable_hls; - } - - public void setEnable_hls(boolean enable_hls) { - this.enable_hls = enable_hls; - } - public boolean isEnable_mp4() { return enable_mp4; } @@ -155,19 +145,12 @@ public class StreamProxyItem extends GbStream { this.enable_mp4 = enable_mp4; } - - public String getPlatformGbId() { - return platformGbId; - } - - public void setPlatformGbId(String platformGbId) { - this.platformGbId = platformGbId; - } - + @Override public String getCreateTime() { return createTime; } + @Override public void setCreateTime(String createTime) { this.createTime = createTime; } @@ -187,4 +170,12 @@ public class StreamProxyItem extends GbStream { public void setEnable_disable_none_reader(boolean enable_disable_none_reader) { this.enable_disable_none_reader = enable_disable_none_reader; } + + public boolean isEnable_audio() { + return enable_audio; + } + + public void setEnable_audio(boolean enable_audio) { + this.enable_audio = enable_audio; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 3183e3de..7dcd7f2c 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -5,23 +5,22 @@ import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; 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.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaService; +import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; -import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; @@ -35,7 +34,9 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.util.ObjectUtils; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 视频代理业务 @@ -107,7 +108,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { param.getStream() ); param.setDst_url(dstUrl); StringBuffer resultMsg = new StringBuffer(); - boolean streamLive = false; param.setMediaServerId(mediaInfo.getId()); boolean saveResult; // 更新 @@ -124,7 +124,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { if (param.isEnable()) { JSONObject jsonObject = addStreamProxyToZlm(param); if (jsonObject == null || jsonObject.getInteger("code") != 0) { - streamLive = false; resultMsg.append(", 但是启用失败,请检查流地址是否可用"); param.setEnable(false); // 直接移除 @@ -134,28 +133,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService { updateStreamProxy(param); } - }else { - streamLive = true; resultForStreamInfo = mediaService.getStreamInfoByAppAndStream( mediaInfo, param.getApp(), param.getStream(), null, null); } } - if ( !ObjectUtils.isEmpty(param.getPlatformGbId()) && streamLive) { - List gbStreams = new ArrayList<>(); - gbStreams.add(param); - if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){ - return resultForStreamInfo; - }else { - resultMsg.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString()); - } - }else { - if (!streamLive) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString()); - } - } return resultForStreamInfo; } @@ -245,10 +228,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { } if ("default".equals(param.getType())){ result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl(), - param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type()); + param.isEnable_audio(), param.isEnable_mp4(), param.getRtp_type()); }else if ("ffmpeg".equals(param.getType())) { result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrc_url(), param.getDst_url(), - param.getTimeout_ms() + "", param.isEnable_hls(), param.isEnable_mp4(), + param.getTimeout_ms() + "", param.isEnable_audio(), param.isEnable_mp4(), param.getFfmpeg_cmd_key()); } return result; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java index 448a358f..4ed214da 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java @@ -12,9 +12,9 @@ import java.util.List; public interface StreamProxyMapper { @Insert("INSERT INTO stream_proxy (type, name, app, stream,mediaServerId, url, src_url, dst_url, " + - "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_hls, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" + + "timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, enable_remove_none_reader, enable_disable_none_reader, createTime) VALUES" + "('${type}','${name}', '${app}', '${stream}', '${mediaServerId}','${url}', '${src_url}', '${dst_url}', " + - "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_hls}, ${enable_mp4}, ${enable}, ${status}, " + + "'${timeout_ms}', '${ffmpeg_cmd_key}', '${rtp_type}', ${enable_audio}, ${enable_mp4}, ${enable}, ${status}, " + "${enable_remove_none_reader}, ${enable_disable_none_reader}, '${createTime}' )") int add(StreamProxyItem streamProxyDto); @@ -30,7 +30,7 @@ public interface StreamProxyMapper { "timeout_ms=#{timeout_ms}, " + "ffmpeg_cmd_key=#{ffmpeg_cmd_key}, " + "rtp_type=#{rtp_type}, " + - "enable_hls=#{enable_hls}, " + + "enable_audio=#{enable_audio}, " + "enable=#{enable}, " + "status=#{status}, " + "enable_remove_none_reader=#{enable_remove_none_reader}, " + diff --git a/web_src/src/components/StreamProxyList.vue b/web_src/src/components/StreamProxyList.vue index 5eff9d50..47ccde8b 100644 --- a/web_src/src/components/StreamProxyList.vue +++ b/web_src/src/components/StreamProxyList.vue @@ -32,7 +32,7 @@ - {{scope.row.type}} + {{scope.row.type === "default"? "直接代理":"FFMPEG代理"}} @@ -55,15 +55,15 @@ - + - 已启用 - 未启用 + 已启用 + 未启用 - + 已启用 @@ -71,11 +71,12 @@ - + - 已启用 - 未启用 + 移除 + 停用 + 不做处理 @@ -131,7 +132,6 @@ currentPage:1, count:15, total:0, - getListLoading: false, startBtnLoading: false }; }, @@ -139,7 +139,7 @@ }, mounted() { this.initData(); - this.updateLooper = setInterval(this.initData, 1000); + this.startUpdateList() }, destroyed() { this.$destroy('videojs'); @@ -149,6 +149,12 @@ initData: function() { this.getStreamProxyList(); }, + stopUpdateList: function (){ + window.clearInterval(this.updateLooper) + }, + startUpdateList: function (){ + this.updateLooper = setInterval(this.initData, 1000); + }, currentChange: function(val){ this.currentPage = val; this.getStreamProxyList(); @@ -159,7 +165,6 @@ }, getStreamProxyList: function() { let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/proxy/list`, @@ -175,23 +180,18 @@ } that.streamProxyList = res.data.data.list; } - that.getListLoading = false; }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, addStreamProxy: function(){ this.$refs.streamProxyEdit.openDialog(null, this.initData) }, addOnvif: function(){ - this.getListLoading = true; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/onvif/search?timeout=3000`, }).then((res) =>{ - this.getListLoading = false; if (res.data.code === 0 ){ if (res.data.data.length > 0) { this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{ @@ -208,7 +208,6 @@ } }).catch((error)=> { - this.getListLoading = false; this.$message.error(error.response.data.msg); }); @@ -217,7 +216,6 @@ }, play: function(row){ let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/push/getPlayUrl`, @@ -227,7 +225,6 @@ mediaServerId: row.mediaServerId } }).then(function (res) { - that.getListLoading = false; if (res.data.code === 0) { that.$refs.devicePlayer.openDialog("streamPlay", null, null, { streamInfo: res.data.data, @@ -243,13 +240,11 @@ }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, deleteStreamProxy: function(row){ let that = this; - this.getListLoading = true; that.$axios({ method:"delete", url:"/api/proxy/del", @@ -258,16 +253,13 @@ stream: row.stream } }).then((res)=>{ - that.getListLoading = false; that.initData() }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, start: function(row){ - let that = this; - this.getListLoading = true; + this.stopUpdateList() this.$set(row, 'startBtnLoading', true) this.$axios({ method: 'get', @@ -276,28 +268,31 @@ app: row.app, stream: row.stream } - }).then(function (res) { - that.getListLoading = false; - that.$set(row, 'startBtnLoading', false) + }).then((res)=> { if (res.data.code === 0){ - that.initData() + this.initData() }else { - that.$message({ + this.$message({ showClose: true, - message: "保存失败,请检查地址是否可用!", + message: "启动失败,请检查地址是否可用!", type: "error", }); } - - }).catch(function (error) { + this.$set(row, 'startBtnLoading', false) + this.startUpdateList() + }).catch((error)=> { console.log(error); - that.getListLoading = false; - that.$set(row, 'startBtnLoading', false) + this.$message({ + showClose: true, + message: "启动失败,请检查地址是否可用!", + type: "error", + }); + this.$set(row, 'startBtnLoading', false) + this.startUpdateList() }); }, stop: function(row){ let that = this; - this.getListLoading = true; this.$axios({ method: 'get', url:`/api/proxy/stop`, @@ -306,11 +301,9 @@ stream: row.stream } }).then(function (res) { - that.getListLoading = false; that.initData() }).catch(function (error) { console.log(error); - that.getListLoading = false; }); }, refresh: function (){ diff --git a/web_src/src/components/dialog/StreamProxyEdit.vue b/web_src/src/components/dialog/StreamProxyEdit.vue index 1270999f..76011fac 100644 --- a/web_src/src/components/dialog/StreamProxyEdit.vue +++ b/web_src/src/components/dialog/StreamProxyEdit.vue @@ -83,31 +83,23 @@ - - - - - {{ item.name }} - {{ item.serverGBId }} - - - + + + + + + + - - - - - + + @@ -169,10 +161,11 @@ export default { gbId: null, rtp_type: null, enable: true, - enable_hls: true, + enable_audio: true, enable_mp4: false, + none_reader: null, enable_remove_none_reader: false, - enable_disable_none_reader: true, + enable_disable_none_reader: false, platformGbId: null, mediaServerId: null, }, @@ -196,6 +189,7 @@ export default { this.listChangeCallback = callback; if (proxyParam != null) { this.proxyParam = proxyParam; + this.proxyParam.none_reader = null; } let that = this; @@ -233,26 +227,26 @@ export default { }, onSubmit: function () { this.dialogLoading = true; - var that = this; - that.$axios({ + this.noneReaderHandler(); + this.$axios({ method: 'post', url:`/api/proxy/save`, - data: that.proxyParam - }).then(function (res) { - that.dialogLoading = false; + data: this.proxyParam + }).then((res)=> { + this.dialogLoading = false; if (typeof (res.data.code) != "undefined" && res.data.code === 0) { - that.$message({ + this.$message({ showClose: true, message: res.data.msg, type: "success", }); - that.showDialog = false; - if (that.listChangeCallback != null) { - that.listChangeCallback(); - that.dialogLoading = false; + this.showDialog = false; + if (this.listChangeCallback != null) { + this.listChangeCallback(); + this.dialogLoading = false; } } - }).catch(function (error) { + }).catch((error) =>{ console.log(error); this.dialogLoading = false; }); @@ -280,12 +274,18 @@ export default { this.platform.expires = "300"; } }, - removeNoneReader: function(checked) { - this.proxyParam.enable_disable_none_reader = !checked; + noneReaderHandler: function() { + if (this.proxyParam.none_reader === null || this.proxyParam.none_reader === "0") { + this.proxyParam.enable_disable_none_reader = false; + this.proxyParam.enable_remove_none_reader = false; + }else if (this.proxyParam.none_reader === "1"){ + this.proxyParam.enable_disable_none_reader = true; + this.proxyParam.enable_remove_none_reader = false; + }else if (this.proxyParam.none_reader ==="2"){ + this.proxyParam.enable_disable_none_reader = false; + this.proxyParam.enable_remove_none_reader = true; + } }, - disableNoneReaderHandType: function(checked) { - this.proxyParam.enable_remove_none_reader = !checked; - } }, }; From 278264a2c6492d94ffb668cb75c3494f426074ea Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 22 Nov 2022 17:30:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8B=89=E6=B5=81?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 3 +++ .../iot/vmp/vmanager/streamProxy/StreamProxyController.java | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 7dcd7f2c..a2fd0884 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -284,6 +284,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { result = true; streamProxy.setEnable(true); updateStreamProxy(streamProxy); + }else { + logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), + streamProxy.getSrc_url() == null? streamProxy.getUrl():streamProxy.getSrc_url()); } } return result; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java index 95b6cf39..d1368d81 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java @@ -109,7 +109,6 @@ public class StreamProxyController { logger.info("启用代理: " + app + "/" + stream); boolean result = streamProxyService.start(app, stream); if (!result) { - logger.info("启用代理失败: " + app + "/" + stream); throw new ControllerException(ErrorCode.ERROR100); } }