From 269ad8cedbb07ca207a6f33af23085894dab4aa6 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期日, 23 四月 2023 14:36:13 +0800 Subject: [PATCH] 修身目录刷新,优化公网下远程IP端口的获取 --- 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