From f66bf823fa2b03732858819d9fdf086fb9e0b6a2 Mon Sep 17 00:00:00 2001 From: chenjialing <595168663@qq.com> Date: Wed, 20 Jul 2022 16:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96----=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8B=E7=BA=BF,=E9=80=9A=E9=81=93=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B9=9F=E5=88=87=E6=8D=A2=E8=87=B3=E7=A6=BB=E7=BA=BF=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/RegisterRequestProcessor.java | 1 + .../vmp/service/impl/DeviceServiceImpl.java | 21 +++++++++++++++---- .../vmp/storager/dao/DeviceChannelMapper.java | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 622cf073..351b79cf 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -143,6 +143,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen device.setGeoCoordSys("WGS84"); device.setTreeType("CivilCode"); device.setDeviceId(deviceId); + device.setOnline(0); } device.setIp(received); device.setPort(rPort); 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 579184c9..f7198005 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 @@ -86,10 +86,10 @@ public class DeviceServiceImpl implements IDeviceService { redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); } device.setUpdateTime(now); - device.setOnline(1); - // 第一次上线 + // 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询 if (device.getCreateTime() == null) { + device.setOnline(1); device.setCreateTime(now); logger.info("[设备上线,首次注册]: {},查询设备信息以及通道信息", device.getDeviceId()); deviceMapper.add(device); @@ -97,8 +97,19 @@ public class DeviceServiceImpl implements IDeviceService { commander.deviceInfoQuery(device); sync(device); }else { - deviceMapper.update(device); - redisCatchStorage.updateDevice(device); + if(device.getOnline() == 0){ + device.setOnline(1); + device.setCreateTime(now); + logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); + deviceMapper.update(device); + redisCatchStorage.updateDevice(device); + commander.deviceInfoQuery(device); + sync(device); + }else { + deviceMapper.update(device); + redisCatchStorage.updateDevice(device); + } + } // 上线添加订阅 @@ -125,6 +136,8 @@ public class DeviceServiceImpl implements IDeviceService { device.setOnline(0); redisCatchStorage.updateDevice(device); deviceMapper.update(device); + //进行通道离线 + deviceChannelMapper.offlineByDeviceId(deviceId); // 离线释放所有ssrc List ssrcTransactions = streamSession.getSsrcTransactionForAll(deviceId, null, null, null); if (ssrcTransactions != null && ssrcTransactions.size() > 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 653e39da..bcebb943 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -140,6 +140,9 @@ public interface DeviceChannelMapper { @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) void offline(String deviceId, String channelId); + @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId}"}) + void offlineByDeviceId(String deviceId); + @Update(value = {"UPDATE device_channel SET status=1 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) void online(String deviceId, String channelId);