From 5ce562aea1ca2a746b5f862d90d941c94c049ace Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 27 Dec 2023 18:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=91=E5=8F=B0=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 2 +- .../vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 4 ++-- .../cmd/DeviceControlQueryMessageHandler.java | 7 ++++++- .../iot/vmp/service/impl/DeviceServiceImpl.java | 13 ++++++++++--- .../vmp/vmanager/gb28181/device/DeviceControl.java | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) 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 f89a2dd2..ebf53d4b 100755 --- 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 @@ -224,7 +224,7 @@ public interface ISIPCommander { * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s) * @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255 */ - void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; + void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; /** * 设备配置命令 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 c4c5a998..ae414b80 100755 --- 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 @@ -846,7 +846,7 @@ public class SIPCommander implements ISIPCommander { * @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255 */ @Override - public void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { + public void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { StringBuffer cmdXml = new StringBuffer(200); String charset = device.getCharset(); @@ -862,7 +862,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); if (enabled) { cmdXml.append("1\r\n"); - if (NumericUtil.isInteger(resetTime)) { + if (resetTime != null) { cmdXml.append("" + resetTime + "\r\n"); } else { cmdXml.append("0\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 4fb88058..9efc191d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -264,7 +264,12 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class); //获取整个消息主体,我们只需要修改请求头即可 HomePositionRequest.HomePosition info = homePosition.getHomePosition(); - cmder.homePositionCmd(device, channelId, info.getEnabled(), info.getResetTime(), info.getPresetIndex(), + if (info.getEnabled() == null) { + return; + } + cmder.homePositionCmd(device, channelId, info.getEnabled().equals("1"), + info.getResetTime() != null ? Integer.parseInt(info.getResetTime()): null, + info.getPresetIndex() != null ? Integer.parseInt(info.getPresetIndex()): null, errorResult -> onError(request, errorResult), okResult -> onOk(request, okResult)); } catch (Exception e) { 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 78a7bed6..20744393 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -154,18 +154,19 @@ public class DeviceServiceImpl implements IDeviceService { logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); } sync(device); - // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 + List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId()); + if (!ids.isEmpty()) { + commonGbChannelService.onlineForList(ids); + } } }else { if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) { logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId()); sync(device); } - deviceMapper.update(device); redisCatchStorage.updateDevice(device); } - } // 上线添加订阅 @@ -207,6 +208,12 @@ public class DeviceServiceImpl implements IDeviceService { } String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId; dynamicTask.stop(registerExpireTaskKey); + if (device.isOnLine()) { + List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId()); + if (!ids.isEmpty()) { + commonGbChannelService.offlineForList(ids); + } + } device.setOnLine(false); redisCatchStorage.updateDevice(device); deviceMapper.update(device); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java index b5e370b5..07796c2b 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java @@ -255,7 +255,7 @@ public class DeviceControl { @GetMapping("/home_position/{deviceId}") public DeferredResult homePositionApi(@PathVariable String deviceId, String command, - @RequestParam(required = false) String resetTime, + @RequestParam(required = false) Integer resetTime, @RequestParam(required = false) Integer presetId, String channelId) { if (logger.isDebugEnabled()) {