From 4677042b12417c2915ca929073224449f4365d36 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期六, 16 三月 2024 21:38:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java                                                       |    5 +
 src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java                                                                   |   37 +-----
 src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java                                                                 |    4 
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java                                                           |    4 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java                     |    2 
 src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java                                                                    |    6 
 src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java                                                             |   32 ++----
 src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java                                                                           |    9 +
 src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java                                                            |    9 +
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java |   12 --
 src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java                                    |   27 ++++-
 pom.xml                                                                                                                           |   38 +++++++
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java   |    6 -
 src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java                                                                      |   50 ++++++++++
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java                               |    5 
 src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java                                                              |    4 
 src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java                                                         |    7 +
 src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java                                                               |    3 
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java                                             |    7 
 19 files changed, 183 insertions(+), 84 deletions(-)

diff --git a/pom.xml b/pom.xml
index b316e98..7ec73b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -382,6 +382,44 @@
                     <skipTests>true</skipTests>
                 </configuration>
             </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.3.0</version>
+                <configuration>
+                    <excludes>
+                        <exclude>**/all-application.yml</exclude>
+                        <exclude>**/application.yml</exclude>
+                        <exclude>**/application-*.yml</exclude>
+                        <exclude>**/local.jks</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution> <!-- 澶嶅埗閰嶇疆鏂囦欢 -->
+                        <id>copy-resources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <resources>
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <includes>
+                                        <include>application.yml</include>
+                                        <include>application-*.yml</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <resources>
             <resource>
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
index 20b6eef..8449ebb 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
@@ -1,7 +1,7 @@
 package com.genersoft.iot.vmp.conf;
 
 import com.genersoft.iot.vmp.common.CivilCodePo;
-import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
+import com.genersoft.iot.vmp.utils.CivilCodeUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +17,8 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.file.Files;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 鍚姩鏃惰鍙栬鏀垮尯鍒掕〃
@@ -27,8 +28,6 @@
 public class CivilCodeFileConf implements CommandLineRunner {
 
     private final static Logger logger = LoggerFactory.getLogger(CivilCodeFileConf.class);
-
-    private final Map<String, CivilCodePo> civilCodeMap= new ConcurrentHashMap<>();
 
     @Autowired
     @Lazy
@@ -62,6 +61,7 @@
         BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream));
         int index = -1;
         String line;
+        List<CivilCodePo> civilCodePoList = new ArrayList<>();
         while ((line = inputStreamReader.readLine()) != null) {
             index ++;
             if (index == 0) {
@@ -69,36 +69,15 @@
             }
             String[] infoArray = line.split(",");
             CivilCodePo civilCodePo = CivilCodePo.getInstance(infoArray);
-            civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
+            civilCodePoList.add(civilCodePo);
         }
+        CivilCodeUtil.INSTANCE.add(civilCodePoList);
         inputStreamReader.close();
         inputStream.close();
-        if (civilCodeMap.size() == 0) {
+        if (civilCodePoList.isEmpty()) {
             logger.warn("[琛屾斂鍖哄垝] 鏂囦欢鍐呭涓虹┖锛屽彲鑳介�犳垚鐩綍鍒锋柊缁撴灉涓嶅畬鏁�");
         }else {
-            logger.info("[琛屾斂鍖哄垝] 鍔犺浇鎴愬姛锛屽叡鍔犺浇鏁版嵁{}鏉�", civilCodeMap.size());
+            logger.info("[琛屾斂鍖哄垝] 鍔犺浇鎴愬姛锛屽叡鍔犺浇鏁版嵁{}鏉�", civilCodePoList.size());
         }
     }
-
-    public CivilCodePo getParentCode(String code) {
-        if (code.length() > 8) {
-            return null;
-        }
-        if (code.length() == 8) {
-            String parentCode = code.substring(0, 6);
-            return civilCodeMap.get(parentCode);
-        }else {
-            CivilCodePo civilCodePo = civilCodeMap.get(code);
-            if (civilCodePo == null){
-                return null;
-            }
-            String parentCode = civilCodePo.getParentCode();
-            if (parentCode == null) {
-                return null;
-            }
-            return civilCodeMap.get(parentCode);
-        }
-
-    }
-
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
index 8084435..3205498 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -498,6 +498,7 @@
                         String endTimeStr = DateUtil.urlFormatter.format(end);
                         String stream = device.getDeviceId() + "_" + channelId + "_" + startTimeStr + "_" + endTimeStr;
                         SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null, device.isSsrcCheck(), true, 0,false, false, device.getStreamModeForParam());
+                        sendRtpItem.setStream(stream);
                         // 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶�
                         redisCatchStorage.updateSendRTPSever(sendRtpItem);
                         playService.playBack(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start),
@@ -1006,7 +1007,7 @@
                     Media media = mediaDescription.getMedia();
 
                     Vector mediaFormats = media.getMediaFormats(false);
-                    if (mediaFormats.contains("8")) {
+//                    if (mediaFormats.contains("8")) {
                         port = media.getMediaPort();
                         String protocol = media.getProtocol();
                         // 鍖哄垎TCP鍙戞祦杩樻槸udp锛� 褰撳墠榛樿udp
@@ -1022,7 +1023,7 @@
                             }
                         }
                         break;
-                    }
+//                    }
                 }
                 if (port == -1) {
                     logger.info("涓嶆敮鎸佺殑濯掍綋鏍煎紡锛岃繑鍥�415");
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
index 4ea7667..cd97786 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
@@ -108,7 +108,7 @@
 					}else {
 						event = eventElement.getText().toUpperCase();
 					}
-					DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf);
+					DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event);
 					if (channel == null) {
 						logger.info("[鏀跺埌鐩綍璁㈤槄]锛氫絾鏄В鏋愬け璐� {}", new String(evt.getRequest().getRawContent()));
 						continue;
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
index 6ab75d2..c910451 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
@@ -1,17 +1,14 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
 
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch;
 import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
-import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import com.genersoft.iot.vmp.service.IPlayService;
 import gov.nist.javax.sip.message.SIPRequest;
 import org.dom4j.Element;
@@ -77,15 +74,6 @@
                 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), channelId);
                 audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.WaiteInvite);
                 audioBroadcastManager.update(audioBroadcastCatch);
-                // 绛夊緟invite娑堟伅锛� 瓒呮椂鍒欑粨鏉�
-                String key = VideoManagerConstants.BROADCAST_WAITE_INVITE +  device.getDeviceId();
-                if (!SipUtils.isFrontEnd(device.getDeviceId())) {
-                    key += audioBroadcastCatch.getChannelId();
-                }
-                dynamicTask.startDelay(key, ()->{
-                    logger.info("[璇煶骞挎挱]绛夊緟invite娑堟伅瓒呮椂锛歿}/{}", device.getDeviceId(), channelId);
-                    playService.stopAudioBroadcast(device.getDeviceId(), channelId);
-                }, 2000);
             }else {
                 playService.stopAudioBroadcast(device.getDeviceId(), channelId);
             }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
index 19dde71..c16d7f5 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
@@ -1,6 +1,5 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
 
-import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch;
@@ -56,9 +55,6 @@
     @Qualifier("taskExecutor")
     @Autowired
     private ThreadPoolTaskExecutor taskExecutor;
-
-    @Autowired
-    private CivilCodeFileConf civilCodeFileConf;
 
     @Autowired
     private SipConfig sipConfig;
@@ -118,7 +114,7 @@
                                     if (channelDeviceElement == null) {
                                         continue;
                                     }
-                                    DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null, civilCodeFileConf);
+                                    DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null);
                                     if (channel == null) {
                                         logger.info("[鏀跺埌鐩綍璁㈤槄]锛氫絾鏄В鏋愬け璐� {}", new String(evt.getRequest().getRawContent()));
                                         continue;
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 41e0570..9de1ef2 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
@@ -3,10 +3,10 @@
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.genersoft.iot.vmp.common.CivilCodePo;
-import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
+import com.genersoft.iot.vmp.utils.CivilCodeUtil;
 import com.genersoft.iot.vmp.utils.DateUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
@@ -240,7 +240,7 @@
         CivilCode, BusinessGroup,VirtualOrganization,Other
     }
 
-    public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event, CivilCodeFileConf civilCodeFileConf){
+    public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event){
         DeviceChannel deviceChannel = new DeviceChannel();
         deviceChannel.setDeviceId(device.getDeviceId());
         Element channdelIdElement = itemDevice.element("DeviceID");
@@ -267,7 +267,7 @@
         }
         if(channelId.length() <= 8) {
             deviceChannel.setHasAudio(false);
-            CivilCodePo parentCode = civilCodeFileConf.getParentCode(channelId);
+            CivilCodePo parentCode = CivilCodeUtil.INSTANCE.getParentCode(channelId);
             if (parentCode != null) {
                 deviceChannel.setParentId(parentCode.getCode());
                 deviceChannel.setCivilCode(parentCode.getCode());
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 43f1a8a..e409097 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
@@ -7,6 +7,7 @@
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 绾ц仈鍥芥爣骞冲彴鍏宠仈娴佷笟鍔℃帴鍙�
@@ -71,4 +72,7 @@
     void delAllPlatformInfo(String platformId, String catalogId);
 
     List<GbStream> getGbChannelWithGbid(String gbId);
+
+    Map<String, GbStream> getAllGBId();
+
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
index 333b7b3..10b1eff 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
@@ -115,4 +115,7 @@
      */
     ResourceBaseInfo getOverview();
 
+    Map<String, StreamPushItem> getAllAppAndStreamMap();
+
+
 }
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 3da2845..1dc7db4 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -575,8 +575,8 @@
 
             }else if (device.getSubscribeCycleForMobilePosition() == 0) {
                 // 鍙栨秷璁㈤槄
-                deviceInStore.setSubscribeCycleForCatalog(0);
-                removeCatalogSubscribe(deviceInStore, null);
+                deviceInStore.setSubscribeCycleForMobilePosition(0);
+                removeMobilePositionSubscribe(deviceInStore, null);
             }
         }
         if (deviceInStore.getGeoCoordSys() != 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 9fcbb40..c2c9d72 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
@@ -19,11 +19,11 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Service
 @DS("master")
@@ -268,4 +268,9 @@
     public List<GbStream> getGbChannelWithGbid(String gbId) {
         return gbStreamMapper.selectByGBId(gbId);
     }
+
+    @Override
+    public Map<String, GbStream> getAllGBId() {
+        return gbStreamMapper.getAllGBId();
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index fc9318b..0df0d4d 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -3,10 +3,7 @@
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
-import com.genersoft.iot.vmp.common.InviteInfo;
-import com.genersoft.iot.vmp.common.InviteSessionStatus;
-import com.genersoft.iot.vmp.common.InviteSessionType;
-import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.common.*;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.conf.UserSetting;
@@ -18,19 +15,13 @@
 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
 import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
+import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
 import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
-import com.genersoft.iot.vmp.media.zlm.dto.*;
-import com.genersoft.iot.vmp.media.zlm.*;
-import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
-import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRecordMp4;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
@@ -40,15 +31,7 @@
 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
 import com.genersoft.iot.vmp.service.*;
 import com.genersoft.iot.vmp.service.bean.*;
-import com.genersoft.iot.vmp.service.bean.ErrorCallback;
-import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
-import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg;
-import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
-import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
-import com.genersoft.iot.vmp.service.bean.ErrorCallback;
-import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
-import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper;
@@ -1179,6 +1162,15 @@
             // 鍙戦�佹垚鍔�
             AudioBroadcastCatch audioBroadcastCatch = new AudioBroadcastCatch(device.getDeviceId(), channelId, mediaServerItem, app, stream, event, AudioBroadcastCatchStatus.Ready, isFromPlatform);
             audioBroadcastManager.update(audioBroadcastCatch);
+            // 绛夊緟invite娑堟伅锛� 瓒呮椂鍒欑粨鏉�
+            String key = VideoManagerConstants.BROADCAST_WAITE_INVITE +  device.getDeviceId();
+            if (!SipUtils.isFrontEnd(device.getDeviceId())) {
+                key += audioBroadcastCatch.getChannelId();
+            }
+            dynamicTask.startDelay(key, ()->{
+                logger.info("[璇煶骞挎挱]绛夊緟invite娑堟伅瓒呮椂锛歿}/{}", device.getDeviceId(), channelId);
+                stopAudioBroadcast(device.getDeviceId(), channelId);
+            }, 2000);
         }, eventResultForError -> {
             // 鍙戦�佸け璐�
             logger.error("璇煶骞挎挱鍙戦�佸け璐ワ細 {}:{}", channelId, eventResultForError.msg);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
index 13c452c..e2d7e68 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
@@ -548,4 +548,9 @@
 
         return new ResourceBaseInfo(total, online);
     }
+
+    @Override
+    public Map<String, StreamPushItem> getAllAppAndStreamMap() {
+        return streamPushMapper.getAllAppAndStreamMap();
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java
index cb34ff5..65239c8 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.genersoft.iot.vmp.gb28181.bean.GbStream;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -19,6 +20,7 @@
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 /**
@@ -57,7 +59,8 @@
                     try {
                         List<StreamPushItem> streamPushItems = JSON.parseArray(new String(msg.getBody()), StreamPushItem.class);
                         //鏌ヨ鍏ㄩ儴鐨刟pp+stream 鐢ㄤ簬鍒ゆ柇鏄坊鍔犺繕鏄慨鏀�
-                        List<String> allAppAndStream = streamPushService.getAllAppAndStream();
+                        Map<String, StreamPushItem> allAppAndStream = streamPushService.getAllAppAndStreamMap();
+                        Map<String, GbStream> allGBId = gbStreamService.getAllGBId();
 
                         /**
                          * 鐢ㄤ簬瀛樺偍鏇村叿APP+Stream杩囨护鍚庣殑鏁版嵁锛屽彲浠ョ洿鎺ュ瓨鍏tream_push琛ㄤ笌gb_stream琛�
@@ -67,9 +70,15 @@
                         for (StreamPushItem streamPushItem : streamPushItems) {
                             String app = streamPushItem.getApp();
                             String stream = streamPushItem.getStream();
-                            boolean contains = allAppAndStream.contains(app + stream);
+                            boolean contains = allAppAndStream.containsKey(app + stream);
                             //涓嶅瓨鍦ㄥ氨娣诲姞
                             if (!contains) {
+                                if (allGBId.containsKey(streamPushItem.getGbId())) {
+                                    GbStream gbStream = allGBId.get(streamPushItem.getGbId());
+                                    logger.warn("[REDIS娑堟伅-鎺ㄦ祦璁惧鍒楄〃鏇存柊-INSERT] 鍥芥爣缂栧彿閲嶅: {}, 宸插垎閰嶇粰{}/{}",
+                                            streamPushItem.getGbId(), gbStream.getApp(), gbStream.getStream());
+                                    continue;
+                                }
                                 streamPushItem.setStreamType("push");
                                 streamPushItem.setCreateTime(DateUtil.getNow());
                                 streamPushItem.setMediaServerId(mediaServerService.getDefaultMediaServer().getId());
@@ -77,25 +86,31 @@
                                 streamPushItem.setOriginTypeStr("rtsp_push");
                                 streamPushItem.setTotalReaderCount("0");
                                 streamPushItemForSave.add(streamPushItem);
+                                allGBId.put(streamPushItem.getGbId(), streamPushItem);
                             } else {
+                                if (allGBId.containsKey(streamPushItem.getGbId())) {
+                                    GbStream gbStream = allGBId.get(streamPushItem.getGbId());
+                                    logger.warn("[REDIS娑堟伅-鎺ㄦ祦璁惧鍒楄〃鏇存柊-UPDATE] 鍥芥爣缂栧彿閲嶅: {}, 宸插垎閰嶇粰{}/{}",
+                                            streamPushItem.getGbId(), gbStream.getApp(), gbStream.getStream());
+                                    continue;
+                                }
                                 //瀛樺湪灏卞彧淇敼 name鍜実bId
                                 streamPushItemForUpdate.add(streamPushItem);
                             }
                         }
-                        if (streamPushItemForSave.size() > 0) {
-
+                        if (!streamPushItemForSave.isEmpty()) {
                             logger.info("娣诲姞{}鏉�",streamPushItemForSave.size());
                             logger.info(JSONObject.toJSONString(streamPushItemForSave));
                             streamPushService.batchAdd(streamPushItemForSave);
 
                         }
-                        if(streamPushItemForUpdate.size()>0){
+                        if(!streamPushItemForUpdate.isEmpty()){
                             logger.info("淇敼{}鏉�",streamPushItemForUpdate.size());
                             logger.info(JSONObject.toJSONString(streamPushItemForUpdate));
                             gbStreamService.updateGbIdOrName(streamPushItemForUpdate);
                         }
                     }catch (Exception e) {
-                        logger.warn("[REDIS娑堟伅-鎺ㄦ祦璁惧鍒楄〃鏇存柊] 鍙戠幇鏈鐞嗙殑寮傚父, \r\n{}", JSON.toJSONString(message));
+                        logger.warn("[REDIS娑堟伅-鎺ㄦ祦璁惧鍒楄〃鏇存柊] 鍙戠幇鏈鐞嗙殑寮傚父, \r\n{}", new String(message.getBody()));
                         logger.error("[REDIS娑堟伅-鎺ㄦ祦璁惧鍒楄〃鏇存柊] 寮傚父鍐呭锛� ", e);
                     }
                 }
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 6591e3f..3790bda 100755
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
@@ -10,6 +10,7 @@
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 @Repository
@@ -170,4 +171,7 @@
     @Select("SELECT status FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
     Boolean selectStatusForPush(@Param("app") String app, @Param("stream") String stream);
 
+    @MapKey("gbId")
+    @Select("SELECT * from wvp_gb_stream")
+    Map<String, GbStream> getAllGBId();
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
index 682f07c..daf21ef 100755
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
@@ -7,6 +7,7 @@
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 @Repository
@@ -195,4 +196,12 @@
             "</foreach>" +
             "</script>")
     List<StreamPushItem> getListIn(List<StreamPushItem> streamPushItems);
+
+    @MapKey("vhost")
+    @Select("SELECT CONCAT(wsp.app, wsp.stream) as vhost, wsp.app, wsp.stream, wgs.gb_id, wgs.name " +
+            " from wvp_stream_push wsp " +
+            " left join wvp_gb_stream  wgs  on wgs.app = wsp.app and wgs.stream = wsp.stream")
+    Map<String, StreamPushItem> getAllAppAndStreamMap();
+
+
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java
new file mode 100644
index 0000000..ba23ab2
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java
@@ -0,0 +1,50 @@
+package com.genersoft.iot.vmp.utils;
+
+import com.genersoft.iot.vmp.common.CivilCodePo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public enum CivilCodeUtil {
+
+    INSTANCE;
+    private final static Logger log = LoggerFactory.getLogger(CivilCodeUtil.class);
+
+    // 鐢ㄤ笌娑堟伅鐨勭紦瀛�
+    private final Map<String, CivilCodePo> civilCodeMap = new ConcurrentHashMap<>();
+
+    CivilCodeUtil() {
+    }
+
+    public void add(List<CivilCodePo> civilCodePoList) {
+        if (!civilCodePoList.isEmpty()) {
+            for (CivilCodePo civilCodePo : civilCodePoList) {
+                civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
+            }
+        }
+    }
+
+    public CivilCodePo getParentCode(String code) {
+        if (code.length() > 8) {
+            return null;
+        }
+        if (code.length() == 8) {
+            String parentCode = code.substring(0, 6);
+            return civilCodeMap.get(parentCode);
+        }else {
+            CivilCodePo civilCodePo = civilCodeMap.get(code);
+            if (civilCodePo == null){
+                return null;
+            }
+            String parentCode = civilCodePo.getParentCode();
+            if (parentCode == null) {
+                return null;
+            }
+            return civilCodeMap.get(parentCode);
+        }
+
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
index f8ba4f2..2bb9bfb 100755
--- a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -36,6 +36,11 @@
     private static final String ISO8601_ZONE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssXXX";
 
     /**
+     * 鍏煎鐨勬椂闂存牸寮� iso8601鏃堕棿鏍煎紡甯︽绉�
+     */
+    private static final String ISO8601_MILLISECOND_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS";
+
+    /**
      * wvp鍐呴儴缁熶竴鏃堕棿鏍煎紡
      */
     public static final String PATTERN = "yyyy-MM-dd HH:mm:ss";
@@ -55,6 +60,8 @@
     public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
     public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
     public static final DateTimeFormatter formatterZoneISO8601 = DateTimeFormatter.ofPattern(ISO8601_ZONE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
+    public static final DateTimeFormatter formatterMillisecondISO8601 = DateTimeFormatter.ofPattern(ISO8601_MILLISECOND_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
+
     public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
     public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
     public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
@@ -70,6 +77,8 @@
             return formatter.format(formatterCompatibleISO8601.parse(formatTime));
         } else if (verification(formatTime, formatterZoneISO8601)) {
             return formatter.format(formatterZoneISO8601.parse(formatTime));
+        } else if (verification(formatTime, formatterMillisecondISO8601)) {
+            return formatter.format(formatterMillisecondISO8601.parse(formatTime));
         }
         return formatter.format(formatterISO8601.parse(formatTime));
     }
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 d479180..e65a579 100755
--- 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
@@ -3,10 +3,9 @@
 import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.conf.security.JwtUtils;
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.genersoft.iot.vmp.service.IPlatformService;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.service.IStreamPushService;
 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam;
 import com.github.pagehelper.PageInfo;
@@ -20,7 +19,6 @@
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
 import java.util.List;
 
 @Tag(name  = "瑙嗛娴佸叧鑱斿埌绾ц仈骞冲彴")
@@ -35,6 +33,9 @@
     private IGbStreamService gbStreamService;
 
     @Autowired
+    private IStreamPushService service;
+
+    @Autowired
     private IPlatformService platformService;
 
 

--
Gitblit v1.8.0