From 97b673d6ad6c2266a6e26eddf38dae23c00bb855 Mon Sep 17 00:00:00 2001
From: QingObject <1120359293@qq.com>
Date: 星期五, 28 四月 2023 10:10:06 +0800
Subject: [PATCH] 新增JT1078 Template支持

---
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java |   39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

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 f8ac20f..106caec 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
@@ -89,7 +89,7 @@
     private IMediaServerService mediaServerService;
 
     @Override
-    public void online(Device device) {
+    public void online(Device device, SipTransactionInfo sipTransactionInfo) {
         logger.info("[璁惧涓婄嚎] deviceId锛歿}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort());
         Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId());
         Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
@@ -104,6 +104,14 @@
             // 榛樿蹇冭烦闂撮殧60
             device.setKeepaliveIntervalTime(60);
         }
+        if (sipTransactionInfo != null) {
+            device.setSipTransactionInfo(sipTransactionInfo);
+        }else {
+            if (deviceInRedis != null) {
+                device.setSipTransactionInfo(deviceInRedis.getSipTransactionInfo());
+            }
+        }
+
         // 绗竴娆′笂绾� 鎴栧垯璁惧涔嬪墠鏄绾跨姸鎬�--杩涜閫氶亾鍚屾鍜岃澶囦俊鎭煡璇�
         if (device.getCreateTime() == null) {
             device.setOnline(1);
@@ -156,12 +164,17 @@
         // 鍒锋柊杩囨湡浠诲姟
         String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
         // 濡傛灉绗竴娆℃敞鍐岄偅涔堝繀椤诲湪60 * 3鏃堕棿鍐呮敹鍒颁竴涓績璺筹紝鍚﹀垯璁惧绂荤嚎
-        dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getKeepaliveIntervalTime() * 1000 * 3);
+        dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "棣栨娉ㄥ唽鍚庢湭鑳芥敹鍒板績璺�"), device.getKeepaliveIntervalTime() * 1000 * 3);
+        if (userSetting.getDeviceStatusNotify()) {
+            // 鍙戦�乺edis娑堟伅
+            redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, true);
+        }
+
     }
 
     @Override
-    public void offline(String deviceId) {
-        logger.error("[璁惧绂荤嚎]锛� device锛歿}", deviceId);
+    public void offline(String deviceId, String reason) {
+        logger.error("[璁惧绂荤嚎]锛寋}, device锛歿}", reason, deviceId);
         Device device = deviceMapper.getDeviceByDeviceId(deviceId);
         if (device == null) {
             return;
@@ -185,6 +198,11 @@
         // 绉婚櫎璁㈤槄
         removeCatalogSubscribe(device);
         removeMobilePositionSubscribe(device);
+        if (userSetting.getDeviceStatusNotify()) {
+            // 鍙戦�乺edis娑堟伅
+            redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, false);
+        }
+
     }
 
     @Override
@@ -409,7 +427,7 @@
             if (parentId.length() < 14 ) {
                 return null;
             }
-            List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
+            List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
             List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId);
             return trees;
         }
@@ -454,7 +472,7 @@
             if (parentId.length() < 14 ) {
                 return null;
             }
-            List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
+            List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null,null);
             return deviceChannels;
         }
 
@@ -518,7 +536,7 @@
                 }
             }else {
                 if (haveChannel) {
-                    List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null);
+                    List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null,null);
                     if (deviceChannels != null && deviceChannels.size() > 0) {
                         result.addAll(deviceChannels);
                     }
@@ -631,4 +649,11 @@
     public ResourceBaceInfo getOverview() {
         return deviceMapper.getOverview();
     }
+
+    @Override
+    public List<Device> getAll() {
+        return deviceMapper.getAll();
+    }
+
+
 }

--
Gitblit v1.8.0