From fe0b5c33f92e11f51574deb2c589a31b34a6e720 Mon Sep 17 00:00:00 2001 From: chenjialing <595168663@qq.com> Date: Wed, 2 Mar 2022 09:18:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E8=BF=87=E7=A8=8B=E4=B8=AD=EF=BC=8CAlarmType?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E5=A4=B1=E8=B4=A5=E7=9A=84=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/message/notify/cmd/AlarmNotifyMessageHandler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index a46b0034..8f412f7d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -22,7 +22,7 @@ import org.springframework.util.StringUtils; import javax.sip.RequestEvent; -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; @Component public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { @@ -105,6 +105,11 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme storager.insertMobilePosition(mobilePosition); } } + if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) { + if (deviceAlarm.getAlarmMethod().equals("5")) { + deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); + } + } logger.debug("存储报警信息、报警分类"); // 存储报警信息、报警分类 deviceAlarmService.add(deviceAlarm); From f5640fddb711cb05defe691e9817057e35c03c6e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 2 Mar 2022 11:48:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=9A=84=E7=9B=AE=E5=BD=95=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 + .../iot/vmp/conf/Swagger3Config.java | 2 +- .../iot/vmp/gb28181/bean/SubscribeInfo.java | 11 +++ .../subscribe/catalog/CatalogEventLister.java | 6 +- .../cmd/ISIPCommanderForPlatform.java | 2 +- .../cmd/SIPRequestHeaderPlarformProvider.java | 12 ++- .../cmd/impl/SIPCommanderFroPlatform.java | 98 +++++++++++-------- .../iot/vmp/gb28181/utils/XmlUtil.java | 13 ++- .../iot/vmp/storager/dao/GbStreamMapper.java | 2 +- .../storager/dao/PlatformChannelMapper.java | 6 +- .../gb28181/platform/PlatformController.java | 29 +++--- 11 files changed, 111 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index cc295d5a..93b3ffba 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,10 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] WEB端支持播放H264与H265,音频支持G.711A/G.711U/AAC,覆盖国标常用编码格式。 # docker快速体验 +目前作者的docker-compose因为时间有限维护不及时,这里提供第三方提供的供大家使用,维护不易,大家记得给这位小伙伴点个star。 +https://github.com/SaltFish001/wvp_pro_compose +[https://github.com/SaltFish001/wvp_pro_compose](https://github.com/SaltFish001/wvp_pro_compose) +这是作者维护的一个镜像,可能存在不及时的问题。 ```shell docker pull 648540858/wvp_pro diff --git a/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java b/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java index 2f0faba7..7ee13f84 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java @@ -14,7 +14,7 @@ import springfox.documentation.spring.web.plugins.Docket; @Configuration public class Swagger3Config { - @Value("${swagger-ui.enabled}") + @Value("${swagger-ui.enabled: true}") private boolean enable; @Bean diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java index 355edcc7..e9d41678 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java @@ -21,6 +21,8 @@ public class SubscribeInfo { EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); this.eventId = eventHeader.getEventId(); this.eventType = eventHeader.getEventType(); + ViaHeader viaHeader = (ViaHeader)request.getHeader(ViaHeader.NAME); + this.branch = viaHeader.getBranch(); } private String id; @@ -30,6 +32,7 @@ public class SubscribeInfo { private String eventType; private String fromTag; private String toTag; + private String branch; public String getId() { return id; @@ -86,4 +89,12 @@ public class SubscribeInfo { public void setEventType(String eventType) { this.eventType = eventType; } + + public String getBranch() { + return branch; + } + + public void setBranch(String branch) { + this.branch = branch; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index fac55cb2..f9593633 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -106,7 +106,7 @@ public class CatalogEventLister implements ApplicationListener { } if (deviceChannelList.size() > 0) { logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe); + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe, null); } }else if (parentPlatformMap.keySet().size() > 0) { for (String gbId : parentPlatformMap.keySet()) { @@ -121,7 +121,7 @@ public class CatalogEventLister implements ApplicationListener { DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setChannelId(gbId); deviceChannelList.add(deviceChannel); - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo); + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); } } } @@ -163,7 +163,7 @@ public class CatalogEventLister implements ApplicationListener { GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), platform.getDeviceGBId()); deviceChannelList.add(deviceChannelByStream); - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo); + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java index feb32fcb..4c97315f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java @@ -85,6 +85,6 @@ public interface ISIPCommanderForPlatform { * @param parentPlatform * @param deviceChannels */ - boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo); + boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java index 0addc576..947dc948 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java @@ -236,19 +236,18 @@ public class SIPRequestHeaderPlarformProvider { // via ArrayList viaHeaders = new ArrayList(); ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), - parentPlatform.getTransport(), viaTag); + parentPlatform.getTransport(), subscribeInfo.getBranch()); viaHeader.setRPort(); viaHeaders.add(viaHeader); // from SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); - String tm = Long.toString(System.currentTimeMillis()); - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, "fromtag" + tm); + FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getToTag()); // to SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getToTag()); + ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getFromTag()); // Forwards MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); @@ -265,7 +264,10 @@ public class SIPRequestHeaderPlarformProvider { request.addHeader(userAgentHeader); EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); - event.setEventId(subscribeInfo.getEventId()); + if (subscribeInfo.getEventId() != null) { + event.setEventId(subscribeInfo.getEventId()); + } + request.addHeader(event); SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index a855c1db..21652624 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -371,10 +371,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } try { - if (index == deviceChannels.size() - 1) { + if (index > deviceChannels.size() - 1) { return true; } - Request request = getCatalogNotifyRequest(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); + Request request = getCatalogNotifyRequestForCatalogAddOrUpdate(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); index += 1; Integer finalIndex = index; transmitRequest(parentPlatform, request, null, (eventResult -> { @@ -387,10 +387,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { return true; } - private Request getCatalogNotifyRequest(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, + private Request getCatalogNotifyRequestForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, SubscribeInfo subscribeInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { - String catalogXmlContent = getCatalogXmlContent(parentPlatform, channel, size, type); + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channel, size, type, subscribeInfo); CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); @@ -400,14 +400,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { return request; } - private String getCatalogXmlContent(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type) { + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type, SubscribeInfo subscribeInfo) { StringBuffer catalogXml = new StringBuffer(600); + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { + channel.setParentId(parentPlatform.getDeviceGBId()); + } catalogXml.append("\r\n"); catalogXml.append("\r\n"); catalogXml.append("Catalog\r\n"); catalogXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); catalogXml.append("" + parentPlatform.getDeviceGBId() + "\r\n"); - catalogXml.append("" + sumNum + "\r\n"); + catalogXml.append("1\r\n"); catalogXml.append("\r\n"); catalogXml.append("\r\n"); catalogXml.append("" + channel.getChannelId() + "\r\n"); @@ -418,11 +421,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { catalogXml.append("CivilCode\r\n"); catalogXml.append("
" + channel.getAddress() + "
\r\n"); catalogXml.append("" + channel.getParental() + "\r\n"); - catalogXml.append("" + channel.getParentId() + "\r\n"); + if (channel.getParentId() != null) { + catalogXml.append("" + channel.getParentId() + "\r\n"); + } catalogXml.append("" + channel.getSecrecy() + "\r\n"); catalogXml.append("" + channel.getRegisterWay() + "\r\n"); catalogXml.append("" + (channel.getStatus() == 0 ? "OFF" : "ON") + "\r\n"); - catalogXml.append("" + type + "\r\n"); + if (!"presence".equals(subscribeInfo.getEventType())) { + catalogXml.append("" + type + "\r\n"); + } catalogXml.append("
\r\n"); catalogXml.append("
\r\n"); catalogXml.append("
\r\n"); @@ -430,7 +437,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo) { + public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) { if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 @@ -438,42 +445,55 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { return false; } - for (DeviceChannel channel : deviceChannels) { - try { - StringBuffer catalogXml = new StringBuffer(600); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("Catalog\r\n"); - catalogXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - catalogXml.append("" + parentPlatform.getDeviceGBId() + "\r\n"); - catalogXml.append("" + deviceChannels.size() + "\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("" + channel.getChannelId() + "\r\n"); - catalogXml.append("" + type + "\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); + if (index == null) { + index = 0; + } - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + if (index > deviceChannels.size() - 1) { + return true; + } + try { + String catalogXml = getCatalogXmlContentForCatalogOther(deviceChannels.get(index), type, parentPlatform); + CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); - callIdHeader.setCallId(subscribeInfo.getCallId()); - - String tm = Long.toString(System.currentTimeMillis()); - - Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml.toString(), + Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml, callIdHeader, "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), subscribeInfo); - transmitRequest(parentPlatform, request); - Thread.sleep(200); - } catch (SipException | ParseException | InvalidArgumentException e) { - e.printStackTrace(); - return false; - } catch (InterruptedException e) { - e.printStackTrace(); - } + index += 1; + Integer finalIndex = index; + transmitRequest(parentPlatform, request, null, eventResult -> { + sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex); + }); + } catch (SipException e) { + e.printStackTrace(); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); } + return true; } + private String getCatalogXmlContentForCatalogOther(DeviceChannel channel, String type, ParentPlatform parentPlatform) { + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { + channel.setParentId(parentPlatform.getDeviceGBId()); + } + StringBuffer catalogXml = new StringBuffer(600); + catalogXml.append("\r\n"); + catalogXml.append("\r\n"); + catalogXml.append("Catalog\r\n"); + catalogXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); + catalogXml.append("" + parentPlatform.getDeviceGBId() + "\r\n"); + catalogXml.append("1\r\n"); + catalogXml.append("\r\n"); + catalogXml.append("\r\n"); + catalogXml.append("" + channel.getChannelId() + "\r\n"); + catalogXml.append("" + type + "\r\n"); + catalogXml.append("\r\n"); + catalogXml.append("\r\n"); + catalogXml.append("\r\n"); + return catalogXml.toString(); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 94e0cd80..ba6eed5f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -191,7 +191,7 @@ public class XmlUtil { String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; deviceChannel.setChannelId(channelId); // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { deviceChannel.setStatus(1); } if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { @@ -255,9 +255,14 @@ public class XmlUtil { } else { deviceChannel.setLatitude(0.00); } - if (XmlUtil.getText(itemDevice, "PTZType") == null - || XmlUtil.getText(itemDevice, "PTZType") == "") { - deviceChannel.setPTZType(0); + if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) { + //兼容INFO中的信息 + Element info = itemDevice.element("Info"); + if(XmlUtil.getText(info, "PTZType") == null || "".equals(XmlUtil.getText(info, "PTZType"))){ + deviceChannel.setPTZType(0); + }else{ + deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(info, "PTZType"))); + } } else { deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); } 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 2c63c82b..b430ebb0 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 @@ -61,7 +61,7 @@ public interface GbStreamMapper { List selectByGBId(String gbId); @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.catalogId " + + "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") GbStream queryStreamInPlatform(String platformId, String gbId); 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 190a7b18..08360013 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,9 +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}'") DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); - @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}") + @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}") List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); @Select("select d.*\n" + 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 c41c1e10..78b5d537 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 @@ -211,26 +211,21 @@ public class PlatformController { if (updateResult) { // 保存时启用就发送注册 if (parentPlatform.isEnable()) { - // 保存时启用就发送注册 - if (parentPlatform.isEnable()) { - if (parentPlatformOld.isStatus()) { - commanderForPlatform.unregister(parentPlatformOld, null, null); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // 只要保存就发送注册 - commanderForPlatform.register(parentPlatform, null, null); - }else { - // 只要保存就发送注册 - commanderForPlatform.register(parentPlatform, null, null); - } - } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 + if (parentPlatformOld.isStatus()) { commanderForPlatform.unregister(parentPlatformOld, null, null); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // 只要保存就发送注册 + commanderForPlatform.register(parentPlatform, null, null); + }else { + // 只要保存就发送注册 + commanderForPlatform.register(parentPlatform, null, null); } } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 - commanderForPlatform.unregister(parentPlatform, null, null); + commanderForPlatform.unregister(parentPlatformOld, null, null); } wvpResult.setCode(0); wvpResult.setMsg("success");