From 1e1364e51a66614469b91e396d33a54bdf8f6e98 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 17 十月 2022 14:33:25 +0800
Subject: [PATCH] 修复开始点播功能接口调用返回参数与定义的不符 #635

---
 src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java |  124 ++++++++++++++++++++++++++--------------
 1 files changed, 80 insertions(+), 44 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
index dedc7c1..fe67ede 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -1,6 +1,7 @@
 package com.genersoft.iot.vmp.service.impl;
 
 import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@@ -19,7 +20,10 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.sip.InvalidArgumentException;
+import javax.sip.SipException;
 import javax.sip.TimeoutEvent;
+import java.text.ParseException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -59,6 +63,9 @@
     @Autowired
     private GbStreamMapper gbStreamMapper;
 
+    @Autowired
+    private UserSetting userSetting;
+
 
 
     @Override
@@ -95,9 +102,13 @@
         if (parentPlatform.isEnable()) {
             // 淇濆瓨鏃跺惎鐢ㄥ氨鍙戦�佹敞鍐�
             // 娉ㄥ唽鎴愬姛鏃剁敱绋嬪簭鐩存帴璋冪敤浜唎nline鏂规硶
-            commanderForPlatform.register(parentPlatform, eventResult -> {
-                logger.info("[鍥芥爣绾ц仈] {},娣诲姞鍚戜笂绾ф敞鍐屽け璐ワ紝璇风‘瀹氫笂绾у钩鍙板彲鐢ㄦ椂閲嶆柊淇濆瓨", parentPlatform.getServerGBId());
-            }, null);
+            try {
+                commanderForPlatform.register(parentPlatform, eventResult -> {
+                    logger.info("[鍥芥爣绾ц仈] {},娣诲姞鍚戜笂绾ф敞鍐屽け璐ワ紝璇风‘瀹氫笂绾у钩鍙板彲鐢ㄦ椂閲嶆柊淇濆瓨", parentPlatform.getServerGBId());
+                }, null);
+            } catch (InvalidArgumentException | ParseException | SipException e) {
+                logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈: {}", e.getMessage());
+            }
         }
         return result > 0;
     }
@@ -126,46 +137,62 @@
         // 娣诲姞娉ㄥ唽浠诲姟
         dynamicTask.startDelay(registerTaskKey,
                 // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
-                ()->commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null),
+                ()-> {
+                    try {
+                        commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null);
+                    } catch (InvalidArgumentException | ParseException | SipException e) {
+                        logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈瀹氭椂娉ㄥ唽: {}", e.getMessage());
+                    }
+                },
                 (parentPlatform.getExpires() - 10) *1000);
 
         final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId();
         if (!dynamicTask.contains(keepaliveTaskKey)) {
             // 娣诲姞蹇冭烦浠诲姟
             dynamicTask.startCron(keepaliveTaskKey,
-                    ()-> commanderForPlatform.keepalive(parentPlatform, eventResult -> {
-                        // 蹇冭烦澶辫触
-                        if (eventResult.type == SipSubscribe.EventResultType.timeout) {
-                            // 蹇冭烦瓒呮椂
-                            ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
-                            // 姝ゆ椂鏄涓夋蹇冭烦瓒呮椂锛� 骞冲彴绂荤嚎
-                            if (platformCatch.getKeepAliveReply()  == 2) {
-                                // 璁剧疆骞冲彴绂荤嚎锛屽苟閲嶆柊娉ㄥ唽
-                                offline(parentPlatform);
-                                logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽", parentPlatform.getServerGBId());
-                                commanderForPlatform.register(parentPlatform, eventResult1 -> {
-                                    logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽浠嶇劧澶辫触锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
-                                    // 娣诲姞娉ㄥ唽浠诲姟
-                                    dynamicTask.startCron(registerTaskKey,
-                                            // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
-                                            ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
-                                            60*1000);
-                                }, null);
-                            }
+                    ()-> {
+                        try {
+                            commanderForPlatform.keepalive(parentPlatform, eventResult -> {
+                                // 蹇冭烦澶辫触
+                                if (eventResult.type == SipSubscribe.EventResultType.timeout) {
+                                    // 蹇冭烦瓒呮椂
+                                    ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+                                    // 姝ゆ椂鏄涓夋蹇冭烦瓒呮椂锛� 骞冲彴绂荤嚎
+                                    if (platformCatch.getKeepAliveReply()  == 2) {
+                                        // 璁剧疆骞冲彴绂荤嚎锛屽苟閲嶆柊娉ㄥ唽
+                                        offline(parentPlatform);
+                                        logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽", parentPlatform.getServerGBId());
+                                        try {
+                                            commanderForPlatform.register(parentPlatform, eventResult1 -> {
+                                                logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽浠嶇劧澶辫触锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
+                                                // 娣诲姞娉ㄥ唽浠诲姟
+                                                dynamicTask.startCron(registerTaskKey,
+                                                        // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
+                                                        ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
+                                                        60*1000);
+                                            }, null);
+                                        } catch (InvalidArgumentException | ParseException | SipException e) {
+                                            logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 娉ㄥ唽: {}", e.getMessage());
+                                        }
+                                    }
 
-                        }else {
-                            logger.warn("[鍥芥爣绾ц仈]鍙戦�佸績璺虫敹鍒伴敊璇紝code锛� {}, msg: {}", eventResult.statusCode, eventResult.msg);
-                        }
+                                }else {
+                                    logger.warn("[鍥芥爣绾ц仈]鍙戦�佸績璺虫敹鍒伴敊璇紝code锛� {}, msg: {}", eventResult.statusCode, eventResult.msg);
+                                }
 
-                    }, eventResult -> {
-                        // 蹇冭烦鎴愬姛
-                        // 娓呯┖涔嬪墠鐨勫績璺宠秴鏃惰鏁�
-                        ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
-                        if (platformCatch.getKeepAliveReply() > 0) {
-                            platformCatch.setKeepAliveReply(0);
-                            redisCatchStorage.updatePlatformCatchInfo(platformCatch);
+                            }, eventResult -> {
+                                // 蹇冭烦鎴愬姛
+                                // 娓呯┖涔嬪墠鐨勫績璺宠秴鏃惰鏁�
+                                ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+                                if (platformCatch.getKeepAliveReply() > 0) {
+                                    platformCatch.setKeepAliveReply(0);
+                                    redisCatchStorage.updatePlatformCatchInfo(platformCatch);
+                                }
+                            });
+                        } catch (SipException | InvalidArgumentException | ParseException e) {
+                            logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�佸績璺�: {}", e.getMessage());
                         }
-                    }),
+                    },
                     (parentPlatform.getKeepTimeout() - 10)*1000);
         }
     }
@@ -221,14 +248,18 @@
     @Override
     public void login(ParentPlatform parentPlatform) {
         final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId();
-        commanderForPlatform.register(parentPlatform, eventResult1 -> {
-            logger.info("[鍥芥爣绾ц仈] {}锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
-            // 娣诲姞娉ㄥ唽浠诲姟
-            dynamicTask.startCron(registerTaskKey,
-                    // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
-                    ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
-                    60*1000);
-        }, null);
+        try {
+            commanderForPlatform.register(parentPlatform, eventResult1 -> {
+                logger.info("[鍥芥爣绾ц仈] {}锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
+                // 娣诲姞娉ㄥ唽浠诲姟
+                dynamicTask.startCron(registerTaskKey,
+                        // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
+                        ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
+                        60*1000);
+            }, null);
+        } catch (InvalidArgumentException | ParseException | SipException e) {
+            logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈娉ㄥ唽: {}", e.getMessage());
+        }
     }
 
     @Override
@@ -241,7 +272,7 @@
         if (subscribe != null) {
 
             // TODO 鏆傛椂鍙鐞嗚棰戞祦鐨勫洖澶�,鍚庣画澧炲姞瀵瑰浗鏍囪澶囩殑鏀寔
-            List<DeviceChannel> gbStreams = gbStreamMapper.queryGbStreamListInPlatform(platform.getServerGBId());
+            List<DeviceChannel> gbStreams = gbStreamMapper.queryGbStreamListInPlatform(platform.getServerGBId(), userSetting.isUsePushingAsStatus());
             if (gbStreams.size() == 0) {
                 return;
             }
@@ -255,7 +286,12 @@
                         continue;
                     }
                     // 鍙戦�丟PS娑堟伅
-                    commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, subscribe);
+                    try {
+                        commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, subscribe);
+                    } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
+                             IllegalAccessException e) {
+                        logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 绉诲姩浣嶇疆閫氱煡: {}", e.getMessage());
+                    }
                 }
             }
         }

--
Gitblit v1.8.0