From 22e1d92a9d8ae6aa257889f882722b8e48648abc Mon Sep 17 00:00:00 2001
From: mk1990 <37614016+mk1990@users.noreply.github.com>
Date: 星期一, 18 四月 2022 09:32:20 +0800
Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java                                               |    6 
 src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java                                                             |   24 +
 src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java                                                 |    7 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java                                                 |   31 +
 bootstrap.sh                                                                                                                    |   91 ++++++
 src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java                                                           |   51 +++
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java                                                    |   46 ++
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java                          |   27 +
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java                                                     |    2 
 src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java                                                               |   10 
 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java                                                  |   13 
 web_src/src/components/dialog/SyncChannelProgress.vue                                                                           |   45 ++-
 src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java                                          |   31 ++
 src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java                                   |   69 ++--
 src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java                                                                       |   56 +++
 src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java                                     |    2 
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java                                                         |   44 +-
 src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java                                                       |   62 ++-
 src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java                                                            |    4 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java |   52 +--
 src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java                                                       |   42 ++
 src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java                                                                 |   13 
 /dev/null                                                                                                                       |   50 ---
 src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java                                                                       |    1 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java                                      |    6 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java                             |    4 
 26 files changed, 543 insertions(+), 246 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..0f3c4c9
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+######################################################
+# Copyright 2019 Pham Ngoc Hoai
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Repo: https://github.com/tyrion9/spring-boot-startup-script
+#
+######### PARAM ######################################
+
+JAVA_OPT=-Xmx1024m
+JARFILE=`ls -1r *.jar 2>/dev/null | head -n 1`
+PID_FILE=pid.file
+RUNNING=N
+PWD=`pwd`
+
+######### DO NOT MODIFY ########
+
+if [ -f $PID_FILE ]; then
+        PID=`cat $PID_FILE`
+        if [ ! -z "$PID" ] && kill -0 $PID 2>/dev/null; then
+                RUNNING=Y
+        fi
+fi
+
+start()
+{
+        if [ $RUNNING == "Y" ]; then
+                echo "Application already started"
+        else
+                if [ -z "$JARFILE" ]
+                then
+                        echo "ERROR: jar file not found"
+                else
+                        nohup java  $JAVA_OPT -Djava.security.egd=file:/dev/./urandom -jar $PWD/$JARFILE > nohup.out 2>&1  &
+                        echo $! > $PID_FILE
+                        echo "Application $JARFILE starting..."
+                        tail -f nohup.out
+                fi
+        fi
+}
+
+stop()
+{
+        if [ $RUNNING == "Y" ]; then
+                kill -9 $PID
+                rm -f $PID_FILE
+                echo "Application stopped"
+        else
+                echo "Application not running"
+        fi
+}
+
+restart()
+{
+        stop
+        start
+}
+
+case "$1" in
+
+        'start')
+                start
+                ;;
+
+        'stop')
+                stop
+                ;;
+
+        'restart')
+                restart
+                ;;
+
+        *)
+                echo "Usage: $0 {  start | stop | restart  }"
+                exit 1
+                ;;
+esac
+exit 0
+
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
index 0c57bde..052f533 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
@@ -1,6 +1,9 @@
 package com.genersoft.iot.vmp.conf;
 
 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
+import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@@ -18,6 +21,8 @@
 @Component
 public class DynamicTask {
 
+    private Logger logger = LoggerFactory.getLogger(DynamicTask.class);
+
     @Autowired
     private ThreadPoolTaskScheduler threadPoolTaskScheduler;
 
@@ -26,7 +31,12 @@
 
     @Bean
     public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
-        return new ThreadPoolTaskScheduler();
+        ThreadPoolTaskScheduler schedulerPool = new ThreadPoolTaskScheduler();
+        schedulerPool.setPoolSize(300);
+        schedulerPool.setWaitForTasksToCompleteOnShutdown(true);
+        schedulerPool.setAwaitTerminationSeconds(10);
+        return schedulerPool;
+
     }
 
     /**
@@ -37,11 +47,24 @@
      * @return
      */
     public void startCron(String key, Runnable task, int cycleForCatalog) {
-        stop(key);
+        ScheduledFuture future = futureMap.get(key);
+        if (future != null) {
+            if (future.isCancelled()) {
+                logger.info("浠诲姟銆恵}銆戝凡瀛樺湪浣嗘槸鍏抽棴鐘舵�侊紒锛侊紒", key);
+            } else {
+                logger.info("浠诲姟銆恵}銆戝凡瀛樺湪涓斿凡鍚姩锛侊紒锛�", key);
+                return;
+            }
+        }
         // scheduleWithFixedDelay 蹇呴』绛夊緟涓婁竴涓换鍔$粨鏉熸墠寮�濮嬭鏃秔eriod锛� cycleForCatalog琛ㄧず鎵ц鐨勯棿闅�
-        ScheduledFuture future = threadPoolTaskScheduler.scheduleWithFixedDelay(task, cycleForCatalog * 1000L);
-        futureMap.put(key, future);
-        runnableMap.put(key, task);
+        future = threadPoolTaskScheduler.scheduleAtFixedRate(task, cycleForCatalog * 1000L);
+        if (future != null){
+            futureMap.put(key, future);
+            runnableMap.put(key, task);
+            logger.info("浠诲姟銆恵}銆戝惎鍔ㄦ垚鍔燂紒锛侊紒", key);
+        }else {
+            logger.info("浠诲姟銆恵}銆戝惎鍔ㄥけ璐ワ紒锛侊紒", key);
+        }
     }
 
     /**
@@ -54,9 +77,25 @@
     public void startDelay(String key, Runnable task, int delay) {
         stop(key);
         Date starTime = new Date(System.currentTimeMillis() + delay);
+
+        ScheduledFuture future = futureMap.get(key);
+        if (future != null) {
+            if (future.isCancelled()) {
+                logger.info("浠诲姟銆恵}銆戝凡瀛樺湪浣嗘槸鍏抽棴鐘舵�侊紒锛侊紒", key);
+            } else {
+                logger.info("浠诲姟銆恵}銆戝凡瀛樺湪涓斿凡鍚姩锛侊紒锛�", key);
+                return;
+            }
+        }
         // scheduleWithFixedDelay 蹇呴』绛夊緟涓婁竴涓换鍔$粨鏉熸墠寮�濮嬭鏃秔eriod锛� cycleForCatalog琛ㄧず鎵ц鐨勯棿闅�
-        ScheduledFuture future = threadPoolTaskScheduler.schedule(task, starTime);
-        futureMap.put(key, future);
+        future = threadPoolTaskScheduler.schedule(task, starTime);
+        if (future != null){
+            futureMap.put(key, future);
+            runnableMap.put(key, task);
+            logger.info("浠诲姟銆恵}銆戝惎鍔ㄦ垚鍔燂紒锛侊紒", key);
+        }else {
+            logger.info("浠诲姟銆恵}銆戝惎鍔ㄥけ璐ワ紒锛侊紒", key);
+        }
     }
 
     public void stop(String key) {
@@ -78,4 +117,7 @@
         return futureMap.keySet();
     }
 
+    public Runnable get(String key) {
+        return runnableMap.get(key);
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
index 1a5cce5..7b7291c 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
@@ -48,6 +48,7 @@
 		properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP");
 		properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp());
 		properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true");
+		properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); // 鎺ユ敹鎵�鏈塶otify璇锋眰锛屽嵆浣挎病鏈夎闃�
 		/**
 		 * sip_server_log.log 鍜� sip_debug_log.log public static final int TRACE_NONE =
 		 * 0; public static final int TRACE_MESSAGES = 16; public static final int
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java
index 40f676e..338f8ad 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java
@@ -4,6 +4,7 @@
 import java.util.List;
 
 public class CatalogData {
+    private int sn; // 鍛戒护搴忓垪鍙�
     private int total;
     private List<DeviceChannel> channelList;
     private Date lastTime;
@@ -15,6 +16,15 @@
     }
     private CatalogDataStatus status;
 
+
+    public int getSn() {
+        return sn;
+    }
+
+    public void setSn(int sn) {
+        this.sn = sn;
+    }
+
     public int getTotal() {
         return total;
     }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
index 62a45d5..981fe1e 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
@@ -1,5 +1,12 @@
 package com.genersoft.iot.vmp.gb28181.bean;
 
+import com.genersoft.iot.vmp.common.VideoManagerConstants;
+import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -9,12 +16,32 @@
 @Component
 public class SubscribeHolder {
 
+    @Autowired
+    private DynamicTask dynamicTask;
+
+    @Autowired
+    private IRedisCatchStorage redisCatchStorage;
+
+    @Autowired
+    private ISIPCommanderForPlatform sipCommanderForPlatform;
+
+    @Autowired
+    private IVideoManagerStorage storager;
+
+    private final String taskOverduePrefix = "subscribe_overdue_";
+
     private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
     private static ConcurrentHashMap<String, SubscribeInfo> mobilePositionMap = new ConcurrentHashMap<>();
 
 
     public void putCatalogSubscribe(String platformId, SubscribeInfo subscribeInfo) {
         catalogMap.put(platformId, subscribeInfo);
+        // 娣诲姞璁㈤槄鍒版湡
+        String taskOverdueKey = taskOverduePrefix +  "catalog_" + platformId;
+        dynamicTask.stop(taskOverdueKey);
+        // 娣诲姞浠诲姟澶勭悊璁㈤槄杩囨湡
+        dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()),
+                subscribeInfo.getExpires() * 1000);
     }
 
     public SubscribeInfo getCatalogSubscribe(String platformId) {
@@ -23,10 +50,24 @@
 
     public void removeCatalogSubscribe(String platformId) {
         catalogMap.remove(platformId);
+        String taskOverdueKey = taskOverduePrefix +  "catalog_" + platformId;
+        // 娣诲姞浠诲姟澶勭悊璁㈤槄杩囨湡
+        dynamicTask.stop(taskOverdueKey);
     }
 
     public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) {
         mobilePositionMap.put(platformId, subscribeInfo);
+        String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX +  "MobilePosition_" + platformId;
+        // 娣诲姞浠诲姟澶勭悊GPS瀹氭椂鎺ㄩ��
+        dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(redisCatchStorage, sipCommanderForPlatform, storager,  platformId, subscribeInfo.getSn(), key, this), subscribeInfo.getGpsInterval());
+        String taskOverdueKey = taskOverduePrefix +  "MobilePosition_" + platformId;
+        dynamicTask.stop(taskOverdueKey);
+        // 娣诲姞浠诲姟澶勭悊璁㈤槄杩囨湡
+        dynamicTask.startDelay(taskOverdueKey, () -> {
+                    System.out.println("璁㈤槄杩囨湡");
+                    removeMobilePositionSubscribe(subscribeInfo.getId());
+                },
+                subscribeInfo.getExpires() * 1000);
     }
 
     public SubscribeInfo getMobilePositionSubscribe(String platformId) {
@@ -35,6 +76,12 @@
 
     public void removeMobilePositionSubscribe(String platformId) {
         mobilePositionMap.remove(platformId);
+        String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX +  "MobilePosition_" + platformId;
+        // 缁撴潫浠诲姟澶勭悊GPS瀹氭椂鎺ㄩ��
+        dynamicTask.stop(key);
+        String taskOverdueKey = taskOverduePrefix +  "MobilePosition_" + platformId;
+        // 娣诲姞浠诲姟澶勭悊璁㈤槄杩囨湡
+        dynamicTask.stop(taskOverdueKey);
     }
 
     public List<String> getAllCatalogSubscribePlatform() {
@@ -48,7 +95,7 @@
     }
 
     public void removeAllSubscribe(String platformId) {
-        mobilePositionMap.remove(platformId);
-        catalogMap.remove(platformId);
+        removeMobilePositionSubscribe(platformId);
+        removeCatalogSubscribe(platformId);
     }
 }
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 434a639..feb6a72 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
@@ -33,6 +33,14 @@
     private ServerTransaction transaction;
     private Dialog dialog;
 
+    /**
+     * 浠ヤ笅涓哄彲閫夊瓧娈�
+     * @return
+     */
+    private String sn;
+    private int gpsInterval;
+
+
     public String getId() {
         return id;
     }
@@ -88,4 +96,20 @@
     public void setDialog(Dialog dialog) {
         this.dialog = dialog;
     }
+
+    public String getSn() {
+        return sn;
+    }
+
+    public void setSn(String sn) {
+        this.sn = sn;
+    }
+
+    public int getGpsInterval() {
+        return gpsInterval;
+    }
+
+    public void setGpsInterval(int gpsInterval) {
+        this.gpsInterval = gpsInterval;
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
index fc9eb27..b97457a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
@@ -54,6 +54,7 @@
 	@Autowired
 	private SIPCommander cmder;
 
+
 	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
 	@Override
@@ -76,7 +77,7 @@
 			if (deviceInStore == null) { //绗竴娆′笂绾�
 				logger.info("[{}] 棣栨娉ㄥ唽锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
 				cmder.deviceInfoQuery(device);
-				cmder.catalogQuery(device, null);
+				deviceService.sync(device);
 			}
 			break;
 		// 璁惧涓诲姩鍙戦�佸績璺宠Е鍙戠殑鍦ㄧ嚎浜嬩欢
@@ -99,7 +100,10 @@
 		storager.updateDevice(device);
 		// 涓婄嚎娣诲姞璁㈤槄
 		if (device.getSubscribeCycleForCatalog() > 0) {
+			// 鏌ヨ鍦ㄧ嚎璁惧閭d簺寮�鍚簡璁㈤槄锛屼负璁惧寮�鍚畾鏃剁殑鐩綍璁㈤槄
 			deviceService.addCatalogSubscribe(device);
+		}
+		if (device.getSubscribeCycleForMobilePosition() > 0) {
 			deviceService.addMobilePositionSubscribe(device);
 		}
 	}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java
deleted file mode 100644
index 898e51d..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.subscribe;
-
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.conf.DynamicTask;
-import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
-import com.genersoft.iot.vmp.conf.UserSetting;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.listener.RedisMessageListenerContainer;
-import org.springframework.stereotype.Component;
-
-/**    
- * 骞冲彴璁㈤槄鍒版湡浜嬩欢
- */
-@Component
-public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessageListener {
-
-    private Logger logger = LoggerFactory.getLogger(SubscribeListenerForPlatform.class);
-
-	@Autowired
-	private UserSetting userSetting;
-
-    @Autowired
-    private DynamicTask dynamicTask;
-
-    public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
-        super(listenerContainer, userSetting);
-    }
-
-
-    /**
-     * 鐩戝惉澶辨晥鐨刱ey
-     * @param message
-     * @param pattern
-     */
-    @Override
-    public void onMessage(Message message, byte[] pattern) {
-        //  鑾峰彇澶辨晥鐨刱ey
-        String expiredKey = message.toString();
-        logger.debug(expiredKey);
-        // 璁㈤槄鍒版湡
-        String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_";
-        if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {
-            // 鍙栨秷瀹氭椂浠诲姟
-            dynamicTask.stop(expiredKey);
-        }
-    }
-}
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 f9546f0..f9ef10c 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
@@ -61,8 +61,6 @@
         if (event.getPlatformId() != null) {
             parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
             if (parentPlatform != null && !parentPlatform.isStatus())return;
-            String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_Catalog_" + event.getPlatformId();
-//            subscribe = redisCatchStorage.getSubscribe(key);
             subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
 
             if (subscribe == null) {
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
index fbc2a32..c3de8a2 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
@@ -26,28 +26,35 @@
     @Autowired
     private IVideoManagerStorage storager;
 
-    public void addReady(String key) {
-        CatalogData catalogData = data.get(key);
+    public void addReady(Device device, int sn ) {
+        CatalogData catalogData = data.get(device.getDeviceId());
         if (catalogData == null || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) {
             catalogData = new CatalogData();
             catalogData.setChannelList(new ArrayList<>());
+            catalogData.setDevice(device);
+            catalogData.setSn(sn);
             catalogData.setStatus(CatalogData.CatalogDataStatus.ready);
             catalogData.setLastTime(new Date(System.currentTimeMillis()));
-            data.put(key, catalogData);
+            data.put(device.getDeviceId(), catalogData);
         }
     }
 
-    public void put(String key, int total, Device device, List<DeviceChannel> deviceChannelList) {
-        CatalogData catalogData = data.get(key);
+    public void put(String deviceId, int sn, int total, Device device, List<DeviceChannel> deviceChannelList) {
+        CatalogData catalogData = data.get(deviceId);
         if (catalogData == null) {
             catalogData = new CatalogData();
+            catalogData.setSn(sn);
             catalogData.setTotal(total);
             catalogData.setDevice(device);
             catalogData.setChannelList(new ArrayList<>());
             catalogData.setStatus(CatalogData.CatalogDataStatus.runIng);
             catalogData.setLastTime(new Date(System.currentTimeMillis()));
-            data.put(key, catalogData);
+            data.put(deviceId, catalogData);
         }else {
+            // 鍚屼竴涓澶囩殑閫氶亾鍚屾璇锋眰鍙�冭檻涓�涓紝鍏朵粬鐨勭洿鎺ュ拷鐣�
+            if (catalogData.getSn() != sn) {
+                return;
+            }
             catalogData.setTotal(total);
             catalogData.setDevice(device);
             catalogData.setStatus(CatalogData.CatalogDataStatus.runIng);
@@ -56,30 +63,26 @@
         }
     }
 
-    public List<DeviceChannel> get(String key) {
-        CatalogData catalogData = data.get(key);
+    public List<DeviceChannel> get(String deviceId) {
+        CatalogData catalogData = data.get(deviceId);
         if (catalogData == null) return null;
         return catalogData.getChannelList();
     }
 
-    public int getTotal(String key) {
-        CatalogData catalogData = data.get(key);
+    public int getTotal(String deviceId) {
+        CatalogData catalogData = data.get(deviceId);
         if (catalogData == null) return 0;
         return catalogData.getTotal();
     }
 
-    public SyncStatus getSyncStatus(String key) {
-        CatalogData catalogData = data.get(key);
+    public SyncStatus getSyncStatus(String deviceId) {
+        CatalogData catalogData = data.get(deviceId);
         if (catalogData == null) return null;
         SyncStatus syncStatus = new SyncStatus();
         syncStatus.setCurrent(catalogData.getChannelList().size());
         syncStatus.setTotal(catalogData.getTotal());
         syncStatus.setErrorMsg(catalogData.getErrorMsg());
         return syncStatus;
-    }
-
-    public void del(String key) {
-        data.remove(key);
     }
 
     @Scheduled(fixedRate = 5 * 1000)   //姣�5绉掓墽琛屼竴娆�, 鍙戠幇鏁版嵁5绉掓湭鏇存柊鍒欑Щ闄ゆ暟鎹苟璁や负鏁版嵁鎺ユ敹瓒呮椂
@@ -92,23 +95,30 @@
         Calendar calendarBefore30S = Calendar.getInstance();
         calendarBefore30S.setTime(new Date());
         calendarBefore30S.set(Calendar.SECOND, calendarBefore30S.get(Calendar.SECOND) - 30);
-        for (String key : keys) {
-            CatalogData catalogData = data.get(key);
-            if (catalogData.getLastTime().before(calendarBefore5S.getTime())) { // 瓒呰繃浜旂鏀朵笉鍒版秷鎭换鍔¤秴鏃讹紝 鍙洿鏂拌繖涓�閮ㄥ垎鏁版嵁
-                storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList());
-                String errorMsg = "鏇存柊鎴愬姛锛屽叡" + catalogData.getTotal() + "鏉★紝宸叉洿鏂�" + catalogData.getChannelList().size() + "鏉�";
+        for (String deviceId : keys) {
+            CatalogData catalogData = data.get(deviceId);
+            if ( catalogData.getLastTime().before(calendarBefore5S.getTime())) { // 瓒呰繃浜旂鏀朵笉鍒版秷鎭换鍔¤秴鏃讹紝 鍙洿鏂拌繖涓�閮ㄥ垎鏁版嵁
+                if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) {
+                    storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList());
+                    if (catalogData.getTotal() != catalogData.getChannelList().size()) {
+                        String errorMsg = "鏇存柊鎴愬姛锛屽叡" + catalogData.getTotal() + "鏉★紝宸叉洿鏂�" + catalogData.getChannelList().size() + "鏉�";
+                        catalogData.setErrorMsg(errorMsg);
+                    }
+                }else if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) {
+                    String errorMsg = "鍚屾澶辫触锛岀瓑寰呭洖澶嶈秴鏃�";
+                    catalogData.setErrorMsg(errorMsg);
+                }
                 catalogData.setStatus(CatalogData.CatalogDataStatus.end);
-                catalogData.setErrorMsg(errorMsg);
             }
-            if (catalogData.getLastTime().before(calendarBefore30S.getTime())) { // 瓒呰繃涓夊崄绉掞紝濡傛灉鏍囪涓篹nd鍒欏垹闄�
-                data.remove(key);
+            if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) && catalogData.getLastTime().before(calendarBefore30S.getTime())) { // 瓒呰繃涓夊崄绉掞紝濡傛灉鏍囪涓篹nd鍒欏垹闄�
+                data.remove(deviceId);
             }
         }
     }
 
 
-    public void setChannelSyncEnd(String key, String errorMsg) {
-        CatalogData catalogData = data.get(key);
+    public void setChannelSyncEnd(String deviceId, String errorMsg) {
+        CatalogData catalogData = data.get(deviceId);
         if (catalogData == null)return;
         catalogData.setStatus(CatalogData.CatalogDataStatus.end);
         catalogData.setErrorMsg(errorMsg);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
index 4c6a18a..b6ec451 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
@@ -1,5 +1,9 @@
 package com.genersoft.iot.vmp.gb28181.task;
 
+import javax.sip.DialogState;
+
 public interface ISubscribeTask extends Runnable{
     void stop();
+
+    DialogState getDialogState();
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
index 51356d5..bee5fba 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
@@ -5,6 +5,7 @@
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Async;
 
 import javax.sip.Dialog;
 import javax.sip.DialogState;
@@ -72,4 +73,10 @@
             });
         }
     }
+
+    @Override
+    public DialogState getDialogState() {
+        if (dialog == null) return null;
+        return dialog.getState();
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
index fcac3e9..034f9de 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
@@ -1,16 +1,16 @@
 package com.genersoft.iot.vmp.gb28181.task.impl;
 
-import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
-import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
-import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
+import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Async;
 
-import java.text.SimpleDateFormat;
+import javax.sip.DialogState;
 import java.util.List;
 
 /**
@@ -18,20 +18,21 @@
  */
 public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
 
+    private Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeHandlerTask.class);
+
     private IRedisCatchStorage redisCatchStorage;
     private IVideoManagerStorage storager;
     private ISIPCommanderForPlatform sipCommanderForPlatform;
     private SubscribeHolder subscribeHolder;
-    private String platformId;
+    private ParentPlatform platform;
     private String sn;
     private String key;
 
-    private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
     public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) {
+        System.out.println("MobilePositionSubscribeHandlerTask 鍒濆鍖�");
         this.redisCatchStorage = redisCatchStorage;
         this.storager = storager;
-        this.platformId = platformId;
+        this.platform = storager.queryParentPlatByServerGBId(platformId);
         this.sn = sn;
         this.key = key;
         this.sipCommanderForPlatform = sipCommanderForPlatform;
@@ -41,30 +42,31 @@
     @Override
     public void run() {
 
-        SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platformId);
-
+        if (platform == null) return;
+        SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
         if (subscribe != null) {
-            ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
-            if (parentPlatform == null || parentPlatform.isStatus()) {
-                // TODO 鏆傛椂鍙鐞嗚棰戞祦鐨勫洖澶�,鍚庣画澧炲姞瀵瑰浗鏍囪澶囩殑鏀寔
-                List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platformId);
-                if (gbStreams.size() > 0) {
-                    for (GbStream gbStream : gbStreams) {
-                        String gbId = gbStream.getGbId();
-                        GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
-                        if (gpsMsgInfo != null) {
-                            // 鍙戦�丟PS娑堟伅
-                            sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
-                        }else {
-                            // 娌℃湁鍦╮edis鎵惧埌鏂扮殑娑堟伅灏变娇鐢ㄦ暟鎹簱鐨勬秷鎭�
-                            gpsMsgInfo = new GPSMsgInfo();
-                            gpsMsgInfo.setId(gbId);
-                            gpsMsgInfo.setLat(gbStream.getLongitude());
-                            gpsMsgInfo.setLng(gbStream.getLongitude());
-                            // 鍙戦�丟PS娑堟伅
-                            sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
-                        }
+
+//            if (!parentPlatform.isStatus()) {
+//                logger.info("鍙戦�佽闃呮椂鍙戠幇骞冲彴宸茬粡绂荤嚎锛歿}", platformId);
+//                return;
+//            }
+            // TODO 鏆傛椂鍙鐞嗚棰戞祦鐨勫洖澶�,鍚庣画澧炲姞瀵瑰浗鏍囪澶囩殑鏀寔
+            List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
+            if (gbStreams.size() == 0) {
+                logger.info("鍙戦�佽闃呮椂鍙戠幇骞冲彴宸茬粡娌℃湁鍏宠仈鐨勭洿鎾祦锛歿}", platform.getServerGBId());
+                return;
+            }
+            for (GbStream gbStream : gbStreams) {
+                String gbId = gbStream.getGbId();
+                GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
+                if (gpsMsgInfo != null) { // 鏃犳渶鏂颁綅缃笉鍙戦��
+                    logger.info("鏃犳渶鏂颁綅缃笉鍙戦��");
+                    // 缁忕含搴﹂兘涓�0涓嶅彂閫�
+                    if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) {
+                        continue;
                     }
+                    // 鍙戦�丟PS娑堟伅
+                    sipCommanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, subscribe);
                 }
             }
         }
@@ -74,4 +76,9 @@
     public void stop() {
 
     }
+
+    @Override
+    public DialogState getDialogState() {
+        return null;
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
index e86c601..884f040 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
@@ -6,10 +6,13 @@
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Async;
 
 import javax.sip.Dialog;
 import javax.sip.DialogState;
 import javax.sip.ResponseEvent;
+import java.util.Timer;
+import java.util.TimerTask;
 
 /**
  * 绉诲姩浣嶇疆璁㈤槄鐨勫畾鏃舵洿鏂�
@@ -20,6 +23,8 @@
     private  ISIPCommander sipCommander;
     private Dialog dialog;
 
+    private Timer timer ;
+
     public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander) {
         this.device = device;
         this.sipCommander = sipCommander;
@@ -27,10 +32,14 @@
 
     @Override
     public void run() {
+        if (timer != null ) {
+            timer.cancel();
+            timer = null;
+        }
         sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> {
-            if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
-                dialog = eventResult.dialog;
-            }
+//            if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
+//                dialog = eventResult.dialog;
+//            }
             ResponseEvent event = (ResponseEvent) eventResult.event;
             if (event.getResponse().getRawContent() != null) {
                 // 鎴愬姛
@@ -43,6 +52,13 @@
             dialog = null;
             // 澶辫触
             logger.warn("[绉诲姩浣嶇疆璁㈤槄]澶辫触锛屼俊浠ゅ彂閫佸け璐ワ細 {}-{} ", device.getDeviceId(), eventResult.msg);
+            timer = new Timer();
+            timer.schedule(new TimerTask() {
+                @Override
+                public void run() {
+                    MobilePositionSubscribeTask.this.run();
+                }
+            }, 2000);
         });
 
     }
@@ -56,6 +72,10 @@
          * COMPLETED-> Completed Dialog鐘舵��-宸插畬鎴�
          * TERMINATED-> Terminated Dialog鐘舵��-缁堟
          */
+        if (timer != null ) {
+            timer.cancel();
+            timer = null;
+        }
         if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) {
             logger.info("鍙栨秷绉诲姩璁㈤槄鏃禿ialog鐘舵�佷负{}", dialog.getState());
             device.setSubscribeCycleForMobilePosition(0);
@@ -74,4 +94,9 @@
             });
         }
     }
+    @Override
+    public DialogState getDialogState() {
+        if (dialog == null) return null;
+        return dialog.getState();
+    }
 }
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 1de03bd..aea37b6 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
@@ -250,7 +250,7 @@
 	 * 
 	 * @param device 瑙嗛璁惧
 	 */
-	boolean catalogQuery(Device device, SipSubscribe.Event errorEvent);
+	boolean catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent);
 	
 	/**
 	 * 鏌ヨ褰曞儚淇℃伅
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 123d0e7..89e70d0 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
@@ -1208,14 +1208,14 @@
 	 * @param device 瑙嗛璁惧
 	 */ 
 	@Override
-	public boolean catalogQuery(Device device, SipSubscribe.Event errorEvent) {
+	public boolean catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) {
 		try {
 			StringBuffer catalogXml = new StringBuffer(200);
 			String charset = device.getCharset();
 			catalogXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
 			catalogXml.append("<Query>\r\n");
 			catalogXml.append("<CmdType>Catalog</CmdType>\r\n");
-			catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
+			catalogXml.append("<SN>" + sn + "</SN>\r\n");
 			catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
 			catalogXml.append("</Query>\r\n");
 			
@@ -1566,17 +1566,28 @@
 			cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
 			cmdXml.append("</Query>\r\n");
 
-			String tm = Long.toString(System.currentTimeMillis());
 
-			CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
-					: udpSipProvider.getNewCallId();
+			Request request;
+			if (dialog != null) {
+				logger.info("鍙戦�佺洰褰曡闃呮秷鎭椂 dialog鐨勭姸鎬佷负锛� {}", dialog.getState());
+				request = dialog.createRequest(Request.SUBSCRIBE);
+				ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
+				request.setContent(cmdXml.toString(), contentTypeHeader);
+				ExpiresHeader expireHeader = sipFactory.createHeaderFactory().createExpiresHeader(device.getSubscribeCycleForMobilePosition());
+				request.addHeader(expireHeader);
+			}else {
+				String tm = Long.toString(System.currentTimeMillis());
 
-			// 鏈夋晥鏃堕棿榛樿涓�60绉掍互涓�
-			Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "z9hG4bK-viaPos-" + tm,
-					"fromTagPos" + tm, null, device.getSubscribeCycleForCatalog(), "Catalog" ,
-					callIdHeader);
+				CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
+						: udpSipProvider.getNewCallId();
+
+				// 鏈夋晥鏃堕棿榛樿涓�60绉掍互涓�
+				request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "z9hG4bK-viaPos-" + tm,
+						"fromTagPos" + tm, null, device.getSubscribeCycleForCatalog(), "Catalog" ,
+						callIdHeader);
+
+			}
 			transmitRequest(device, request, errorEvent, okEvent);
-
 			return true;
 
 		} catch ( NumberFormatException | ParseException | InvalidArgumentException	| SipException e) {
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 0dc11e0..c5cdae0 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
@@ -385,7 +385,7 @@
         if (parentPlatform == null) {
             return false;
         }
-
+        logger.info("[鍙戦�� 绉诲姩浣嶇疆璁㈤槄] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
         try {
             String characterSet = parentPlatform.getCharacterSet();
             StringBuffer deviceStatusXml = new StringBuffer(600);
@@ -405,7 +405,7 @@
             CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
                     : udpSipProvider.getNewCallId();
             callIdHeader.setCallId(subscribeInfo.getCallId());
-            logger.info("[鍙戦�丯otify-MobilePosition] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
+
             sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> {
                 logger.error("鍙戦�丯OTIFY閫氱煡娑堟伅澶辫触銆傞敊璇細{} {}", eventResult.statusCode, eventResult.msg);
             }, null);
@@ -459,7 +459,7 @@
  		// 璁剧疆缂栫爜锛� 闃叉涓枃涔辩爜
 		messageFactory.setDefaultContentEncodingCharset(characterSet);
         Dialog dialog  = subscribeInfo.getDialog();
-        if (dialog == null) return;
+        if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) return;
         SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY);
         ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
         notifyRequest.setContent(catalogXmlContent, contentTypeHeader);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
index 8c87be9..8e03510 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
@@ -146,7 +146,7 @@
 			} else {
 				mobilePosition.setAltitude(0.0);
 			}
-			logger.info("[鏀跺埌Notify-MobilePosition]锛歿}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
+			logger.info("[鏀跺埌 绉诲姩浣嶇疆璁㈤槄]锛歿}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
 					mobilePosition.getLongitude(), mobilePosition.getLatitude());
 			mobilePosition.setReportSource("Mobile Position");
 			BaiduPoint bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
@@ -281,7 +281,7 @@
 					Element eventElement = itemDevice.element("Event");
 					DeviceChannel channel = XmlUtil.channelContentHander(itemDevice);
 					channel.setDeviceId(device.getDeviceId());
-					logger.info("[鏀跺埌Notify-Catalog]锛歿}/{}", device.getDeviceId(), channel.getChannelId());
+					logger.info("[鏀跺埌 鐩綍璁㈤槄]锛歿}/{}", device.getDeviceId(), channel.getChannelId());
 					switch (eventElement.getText().toUpperCase()) {
 						case CatalogEvent.ON: // 涓婄嚎
 							logger.info("鏀跺埌鏉ヨ嚜璁惧銆恵}銆戠殑閫氶亾銆恵}銆戜笂绾块�氱煡", device.getDeviceId(), channel.getChannelId());
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
index 5ae8053..da1088a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
@@ -149,8 +149,7 @@
 			subscribeInfo.setDialog(dialog);
 		}
 		String sn = XmlUtil.getText(rootElement, "SN");
-		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_MobilePosition_" + platformId;
-		logger.info("[notify-MobilePosition]: {}", platformId);
+		logger.info("[鍥炲 绉诲姩浣嶇疆璁㈤槄]: {}", platformId);
 		StringBuilder resultXml = new StringBuilder(200);
 		resultXml.append("<?xml version=\"1.0\" ?>\r\n")
 				.append("<Response>\r\n")
@@ -161,14 +160,25 @@
 				.append("</Response>\r\n");
 
 		if (subscribeInfo.getExpires() > 0) {
-			if (subscribeHolder.getMobilePositionSubscribe(platformId) != null) {
-				dynamicTask.stop(key);
-			}
 			String interval = XmlUtil.getText(rootElement, "Interval"); // GPS涓婃姤鏃堕棿闂撮殧
-			dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(redisCatchStorage, sipCommanderForPlatform, storager,  platformId, sn, key, subscribeHolder), Integer.parseInt(interval) -1 );
+			if (interval == null) {
+				subscribeInfo.setGpsInterval(5);
+			}else {
+				subscribeInfo.setGpsInterval(Integer.parseInt(interval));
+			}
+
+			subscribeInfo.setSn(sn);
 			subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
+//			if (subscribeHolder.getMobilePositionSubscribe(platformId) == null ) {
+//				subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
+//			}else {
+//				if (subscribeHolder.getMobilePositionSubscribe(platformId).getDialog() != null
+//						&& subscribeHolder.getMobilePositionSubscribe(platformId).getDialog().getState() != null
+//						&& !subscribeHolder.getMobilePositionSubscribe(platformId).getDialog().getState().equals(DialogState.CONFIRMED)) {
+//					subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
+//				}
+//			}
 		}else if (subscribeInfo.getExpires() == 0) {
-			dynamicTask.stop(key);
 			subscribeHolder.removeMobilePositionSubscribe(platformId);
 		}
 
@@ -202,8 +212,7 @@
 			subscribeInfo.setDialog(dialog);
 		}
 		String sn = XmlUtil.getText(rootElement, "SN");
-		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_Catalog_" + platformId;
-		logger.info("[notify-Catalog]: {}", platformId);
+		logger.info("[鍥炲 鐩綍璁㈤槄]: {}/{}", platformId, deviceID);
 		StringBuilder resultXml = new StringBuilder(200);
 		resultXml.append("<?xml version=\"1.0\" ?>\r\n")
 				.append("<Response>\r\n")
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 1bafb59..2ec8047 100644
--- 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
@@ -86,23 +86,17 @@
             rootElement = getRootElement(evt, device.getCharset());
             Element deviceListElement = rootElement.element("DeviceList");
             Element sumNumElement = rootElement.element("SumNum");
-            if (sumNumElement == null || deviceListElement == null) {
+            Element snElement = rootElement.element("SN");
+            if (snElement == null || sumNumElement == null || deviceListElement == null) {
                 responseAck(evt, Response.BAD_REQUEST, "xml error");
                 return;
             }
             int sumNum = Integer.parseInt(sumNumElement.getText());
+
             if (sumNum == 0) {
                 // 鏁版嵁宸茬粡瀹屾暣鎺ユ敹
                 storager.cleanChannelsForDevice(device.getDeviceId());
-                RequestMessage msg = new RequestMessage();
-                msg.setKey(key);
-                WVPResult<Object> result = new WVPResult<>();
-                result.setCode(0);
-                result.setData(device);
-                msg.setData(result);
-                result.setMsg("鏇存柊鎴愬姛锛屽叡0鏉�");
-                deferredResultHolder.invokeAllResult(msg);
-                catalogDataCatch.del(key);
+                catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), null);
             }else {
                 Iterator<Element> deviceListIterator = deviceListElement.elementIterator();
                 if (deviceListIterator != null) {
@@ -123,31 +117,22 @@
 
                         channelList.add(deviceChannel);
                     }
+                    int sn = Integer.parseInt(snElement.getText());
                     logger.info("鏀跺埌鏉ヨ嚜璁惧銆恵}銆戠殑閫氶亾: {}涓紝{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum);
-                    catalogDataCatch.put(key, sumNum, device, channelList);
-                    if (catalogDataCatch.get(key).size() == sumNum) {
+                    catalogDataCatch.put(device.getDeviceId(), sn, sumNum, device, channelList);
+                    if (catalogDataCatch.get(device.getDeviceId()).size() == sumNum) {
                         // 鏁版嵁宸茬粡瀹屾暣鎺ユ敹
-                        boolean resetChannelsResult = storager.resetChannels(device.getDeviceId(), catalogDataCatch.get(key));
-                        RequestMessage msg = new RequestMessage();
-                        msg.setKey(key);
-                        WVPResult<Object> result = new WVPResult<>();
-                        result.setCode(0);
-                        result.setData(device);
-                        if (resetChannelsResult || sumNum ==0) {
-                            result.setMsg("鏇存柊鎴愬姛锛屽叡" + sumNum + "鏉★紝宸叉洿鏂�" + catalogDataCatch.get(key).size() + "鏉�");
+                        boolean resetChannelsResult = storager.resetChannels(device.getDeviceId(), catalogDataCatch.get(device.getDeviceId()));
+                        if (!resetChannelsResult) {
+                            String errorMsg = "鎺ユ敹鎴愬姛锛屽啓鍏ュけ璐ワ紝鍏�" + sumNum + "鏉★紝宸叉帴鏀�" + catalogDataCatch.get(device.getDeviceId()).size() + "鏉�";
+                            catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), errorMsg);
                         }else {
-                            result.setMsg("鎺ユ敹鎴愬姛锛屽啓鍏ュけ璐ワ紝鍏�" + sumNum + "鏉★紝宸叉帴鏀�" + catalogDataCatch.get(key).size() + "鏉�");
+                            catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), null);
                         }
-                        msg.setData(result);
-                        deferredResultHolder.invokeAllResult(msg);
-                        catalogDataCatch.del(key);
                     }
                 }
                 // 鍥炲200 OK
                 responseAck(evt, Response.OK);
-                if (offLineDetector.isOnline(device.getDeviceId())) {
-                    publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
-                }
             }
         } catch (DocumentException e) {
             e.printStackTrace();
@@ -231,21 +216,18 @@
     }
 
     public SyncStatus getChannelSyncProgress(String deviceId) {
-        String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
-        if (catalogDataCatch.get(key) == null) {
+        if (catalogDataCatch.get(deviceId) == null) {
             return null;
         }else {
-            return catalogDataCatch.getSyncStatus(key);
+            return catalogDataCatch.getSyncStatus(deviceId);
         }
     }
 
-    public void setChannelSyncReady(String deviceId) {
-        String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
-        catalogDataCatch.addReady(key);
+    public void setChannelSyncReady(Device device, int sn) {
+        catalogDataCatch.addReady(device, sn);
     }
 
     public void setChannelSyncEnd(String deviceId, String errorMsg) {
-        String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
-        catalogDataCatch.setChannelSyncEnd(key, errorMsg);
+        catalogDataCatch.setChannelSyncEnd(deviceId, errorMsg);
     }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
index 17cf7f4..08ccfff 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
@@ -44,15 +44,8 @@
     SyncStatus getChannelSyncStatus(String deviceId);
 
     /**
-     * 璁剧疆閫氶亾鍚屾鐘舵��
-     * @param deviceId 璁惧ID
+     * 閫氶亾鍚屾
+     * @param device
      */
-    void setChannelSyncReady(String deviceId);
-
-    /**
-     * 璁剧疆鍚屾缁撴潫
-     * @param deviceId 璁惧ID
-     * @param errorMsg 閿欒淇℃伅
-     */
-    void setChannelSyncEnd(String deviceId, String errorMsg);
+    void sync(Device device);
 }
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 8cd2c77..f36b3ae 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
@@ -14,6 +14,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.sip.DialogState;
+
 /**
  * 璁惧涓氬姟锛堢洰褰曡闃咃級
  */
@@ -39,19 +41,17 @@
         if (device == null || device.getSubscribeCycleForCatalog() < 0) {
             return false;
         }
-        if (dynamicTask.contains(device.getDeviceId() + "catalog")) {
-            // 瀛樺湪鍒欏仠姝㈢幇鏈夌殑锛屽紑鍚柊鐨�
-            dynamicTask.stop(device.getDeviceId() + "catalog");
+        CatalogSubscribeTask task = (CatalogSubscribeTask)dynamicTask.get(device.getDeviceId() + "catalog");
+        if (task != null && task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 宸插瓨鍦ㄤ笉闇�瑕佸啀娆℃坊鍔�
+            return true;
         }
         logger.info("[娣诲姞鐩綍璁㈤槄] 璁惧{}", device.getDeviceId());
         // 娣诲姞鐩綍璁㈤槄
         CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander);
-        catalogSubscribeTask.run();
         // 鎻愬墠寮�濮嬪埛鏂拌闃�
-        int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
+        int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30);
         // 璁剧疆鏈�灏忓�间负30
-        subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
-        dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, subscribeCycleForCatalog);
+        dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, subscribeCycleForCatalog -1);
         return true;
     }
 
@@ -70,18 +70,16 @@
         if (device == null || device.getSubscribeCycleForMobilePosition() < 0) {
             return false;
         }
-        if (dynamicTask.contains(device.getDeviceId() + "mobile_position")) {
-            // 瀛樺湪鍒欏仠姝㈢幇鏈夌殑锛屽紑鍚柊鐨�
-            dynamicTask.stop(device.getDeviceId() + "mobile_position");
-        }
         logger.info("[娣诲姞绉诲姩浣嶇疆璁㈤槄] 璁惧{}", device.getDeviceId());
+        MobilePositionSubscribeTask task = (MobilePositionSubscribeTask)dynamicTask.get(device.getDeviceId() + "mobile_position");
+        if (task != null &&  task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 宸插瓨鍦ㄤ笉闇�瑕佸啀娆℃坊鍔�
+            return true;
+        }
         // 娣诲姞鐩綍璁㈤槄
         MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander);
-        mobilePositionSubscribeTask.run();
         // 鎻愬墠寮�濮嬪埛鏂拌闃�
-        int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
         // 璁剧疆鏈�灏忓�间负30
-        subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
+        int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30);
         dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog -1 );
         return true;
     }
@@ -102,12 +100,16 @@
     }
 
     @Override
-    public void setChannelSyncReady(String deviceId) {
-        catalogResponseMessageHandler.setChannelSyncReady(deviceId);
-    }
-
-    @Override
-    public void setChannelSyncEnd(String deviceId, String errorMsg) {
-        catalogResponseMessageHandler.setChannelSyncEnd(deviceId, errorMsg);
+    public void sync(Device device) {
+        if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) {
+            logger.info("寮�鍚悓姝ユ椂鍙戠幇鍚屾宸茬粡瀛樺湪");
+            return;
+        }
+        int sn = (int)((Math.random()*9+1)*100000);
+        catalogResponseMessageHandler.setChannelSyncReady(device, sn);
+        sipCommander.catalogQuery(device, sn, event -> {
+            String errorMsg = String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg);
+            catalogResponseMessageHandler.setChannelSyncEnd(device.getDeviceId(), errorMsg);
+        });
     }
 }
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 20e56d9..a3c5c6c 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
@@ -238,12 +238,15 @@
 
 	@Override
 	public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
+		if (deviceChannelList == null) {
+			return false;
+		}
 		TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
 		// 鏁版嵁鍘婚噸
 		List<DeviceChannel> channels = new ArrayList<>();
 		StringBuilder stringBuilder = new StringBuilder();
 		Map<String, Integer> subContMap = new HashMap<>();
-		if (deviceChannelList.size() > 1) {
+		if (deviceChannelList != null && deviceChannelList.size() > 1) {
 			// 鏁版嵁鍘婚噸
 			Set<String> gbIdSet = new HashSet<>();
 			for (DeviceChannel deviceChannel : deviceChannelList) {
@@ -300,6 +303,7 @@
 			dataSourceTransactionManager.commit(transactionStatus);     //鎵嬪姩鎻愪氦
 			return true;
 		}catch (Exception e) {
+			e.printStackTrace();
 			dataSourceTransactionManager.rollback(transactionStatus);
 			return false;
 		}
@@ -415,10 +419,9 @@
 		TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
 		boolean result = false;
 		try {
-			if (platformChannelMapper.delChannelForDeviceId(deviceId) <0  // 鍒犻櫎涓庡浗鏍囧钩鍙扮殑鍏宠仈
-					|| deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 鍒犻櫎浠栫殑閫氶亾
-					|| deviceMapper.del(deviceId) < 0 // 绉婚櫎璁惧淇℃伅
-			) {
+			platformChannelMapper.delChannelForDeviceId(deviceId);
+			deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
+			if ( deviceMapper.del(deviceId) < 0 ) {
 				//浜嬪姟鍥炴粴
 				dataSourceTransactionManager.rollback(transactionStatus);
 			}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
index 1b6d31e..cbcb4ff 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -4,8 +4,13 @@
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
 import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
 import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
+import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
+import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
+import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
+import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
@@ -29,9 +34,8 @@
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
+import javax.sip.DialogState;
+import java.util.*;
 
 @Api(tags = "鍥芥爣璁惧鏌ヨ", value = "鍥芥爣璁惧鏌ヨ")
 @SuppressWarnings("rawtypes")
@@ -62,6 +66,9 @@
 
 	@Autowired
 	private DynamicTask dynamicTask;
+
+	@Autowired
+	private SubscribeHolder subscribeHolder;
 
 	/**
 	 * 浣跨敤ID鏌ヨ鍥芥爣璁惧
@@ -165,12 +172,8 @@
 			wvpResult.setData(syncStatus);
 			return wvpResult;
 		}
-		SyncStatus syncStatusReady = new SyncStatus();
-		deviceService.setChannelSyncReady(deviceId);
-		cmder.catalogQuery(device, event -> {
-			String errorMsg = String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg);
-			deviceService.setChannelSyncEnd(deviceId, errorMsg);
-		});
+		deviceService.sync(device);
+
 		WVPResult<SyncStatus> wvpResult = new WVPResult<>();
 		wvpResult.setCode(0);
 		wvpResult.setMsg("寮�濮嬪悓姝�");
@@ -469,4 +472,29 @@
 		}
 		return wvpResult;
 	}
+
+	@GetMapping("/{deviceId}/subscribe_info")
+	@ApiOperation(value = "鑾峰彇璁惧鐨勮闃呯姸鎬�", notes = "鑾峰彇璁惧鐨勮闃呯姸鎬�")
+	public WVPResult<Map<String, String>> getSubscribeInfo(@PathVariable String deviceId) {
+		Set<String> allKeys = dynamicTask.getAllKeys();
+		Map<String, String> dialogStateMap = new HashMap<>();
+		for (String key : allKeys) {
+			if (key.startsWith(deviceId)) {
+				ISubscribeTask subscribeTask = (ISubscribeTask)dynamicTask.get(key);
+				DialogState dialogState = subscribeTask.getDialogState();
+				if (dialogState == null) {
+					continue;
+				}
+				if (subscribeTask instanceof CatalogSubscribeTask) {
+					dialogStateMap.put("catalog", dialogState.toString());
+				}else if (subscribeTask instanceof MobilePositionSubscribeTask) {
+					dialogStateMap.put("mobilePosition", dialogState.toString());
+				}
+			}
+		}
+		WVPResult<Map<String, String>> wvpResult = new WVPResult<>();
+		wvpResult.setCode(0);
+		wvpResult.setData(dialogStateMap);
+		return wvpResult;
+	}
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
index a0e7a73..faed2c8 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
@@ -4,6 +4,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.VManageBootstrap;
 import com.genersoft.iot.vmp.common.VersionPo;
+import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.conf.VersionInfo;
@@ -27,6 +28,7 @@
 import javax.sip.SipProvider;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 @SuppressWarnings("rawtypes")
 @Api(tags = "鏈嶅姟鎺у埗")
@@ -42,13 +44,16 @@
     private IMediaServerService mediaServerService;
 
     @Autowired
-    VersionInfo versionInfo;
+    private VersionInfo versionInfo;
 
     @Autowired
-    SipConfig sipConfig;
+    private SipConfig sipConfig;
 
     @Autowired
-    UserSetting userSetting;
+    private UserSetting userSetting;
+
+    @Autowired
+    private DynamicTask dynamicTask;
 
     @Value("${server.port}")
     private int serverPort;
@@ -248,4 +253,35 @@
         result.setData(jsonObject);
         return result;
     }
+
+//    @ApiOperation("褰撳墠杩涜涓殑鍔ㄦ�佷换鍔�")
+//    @GetMapping(value = "/dynamicTask")
+//    @ResponseBody
+//    public WVPResult<JSONObject> getDynamicTask(){
+//        WVPResult<JSONObject> result = new WVPResult<>();
+//        result.setCode(0);
+//        result.setMsg("success");
+//
+//        JSONObject jsonObject = new JSONObject();
+//
+//        Set<String> allKeys = dynamicTask.getAllKeys();
+//        jsonObject.put("server.port", serverPort);
+//        if (StringUtils.isEmpty(type)) {
+//            jsonObject.put("sip", JSON.toJSON(sipConfig));
+//            jsonObject.put("base", JSON.toJSON(userSetting));
+//        }else {
+//            switch (type){
+//                case "sip":
+//                    jsonObject.put("sip", sipConfig);
+//                    break;
+//                case "base":
+//                    jsonObject.put("base", userSetting);
+//                    break;
+//                default:
+//                    break;
+//            }
+//        }
+//        result.setData(jsonObject);
+//        return result;
+//    }
 }
diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue
index 1ec16f4..246f1ae 100644
--- a/web_src/src/components/dialog/SyncChannelProgress.vue
+++ b/web_src/src/components/dialog/SyncChannelProgress.vue
@@ -61,23 +61,36 @@
           if (!this.syncFlag) {
             this.syncFlag = true;
           }
-          if (res.data.data == null) {
-            this.syncStatus = "success"
-            this.percentage = 100;
-            this.msg = '鍚屾鎴愬姛';
-          }else if (res.data.data.total == 0){
-            this.msg = `绛夊緟鍚屾涓璥;
-            this.timmer = setTimeout(this.getProgress, 300)
-          }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)
+
+          if (res.data.data != null) {
+            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)
+                }
+              }
+            }
           }
+
         }else {
           if (this.syncFlag) {
             this.syncStatus = "success"

--
Gitblit v1.8.0