diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java index 22cef671..5d2635e2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java @@ -78,7 +78,7 @@ public class GB28181ResourceServiceImpl implements IResourceService { if (code == InviteErrorCode.SUCCESS.getCode()) { if (data != null) { StreamInfo streamInfo = (StreamInfo)data; - callback.call(commonGbChannel, mediaServerItem, ErrorCode.ERROR100.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); + callback.call(commonGbChannel, mediaServerItem, ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); } }else { callback.call(commonGbChannel, null, code, msg, null); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index 9c9f9a55..9f22defa 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -272,6 +272,9 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { if (code == InviteErrorCode.SUCCESS.getCode()) { // 记录到数据库 } + if (callback == null) { + return; + } callback.call(commonGbChannel, mediaServerItem, code, message, streamInfo); })); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 280dbeaa..98ebec2c 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -189,7 +189,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { param.setEnable(false); // 直接移除 if (param.isEnableRemoveNoneReader()) { - delProxyFromDb(param.getApp(), param.getStream()); + delProxyFromDb(param); }else { updateProxyToDb(param); } @@ -483,20 +483,23 @@ public class StreamProxyServiceImpl implements IStreamProxyService { logger.error("[更新代理存储到数据库] 错误,ID: {} 不在数据库中", param.getId()); return; } - if (!ObjectUtils.isEmpty(streamProxyInDb.getGbId().trim()) && ObjectUtils.isEmpty(param.getGbId().trim())) { + if (!ObjectUtils.isEmpty(streamProxyInDb.getGbId()) + && ObjectUtils.isEmpty(param.getGbId())) { // 国标ID已经移除 if (streamProxyInDb.getCommonGbChannelId() > 0) { commonGbChannelService.deleteById(streamProxyInDb.getCommonGbChannelId()); } } - if (!ObjectUtils.isEmpty(param.getGbId().trim()) && ObjectUtils.isEmpty(streamProxyInDb.getGbId().trim())) { + if (!ObjectUtils.isEmpty(param.getGbId()) + && ObjectUtils.isEmpty(streamProxyInDb.getGbId())) { CommonGbChannel commonGbChannel = CommonGbChannel.getInstance(param); // 国标ID已经添加 if (commonGbChannelService.add(commonGbChannel) > 0) { param.setCommonGbChannelId(commonGbChannel.getCommonGbId()); } } - if (!param.getGbId().equals(streamProxyInDb.getGbId())) { + if (param.getGbId() != null && streamProxyInDb.getGbId() != null + && !param.getGbId().equals(streamProxyInDb.getGbId())) { CommonGbChannel commonGbChannel = CommonGbChannel.getInstance(param); commonGbChannel.setCommonGbId(streamProxyInDb.getCommonGbChannelId()); // 国标ID已经改变 @@ -535,8 +538,13 @@ public class StreamProxyServiceImpl implements IStreamProxyService { return new PageInfo<>(all); } - private void delProxyFromDb(String app, String stream) { - StreamProxy streamProxyItem = streamProxyMapper.selectOne(app, stream); + private void delProxyFromDb(StreamProxy streamProxy) { + StreamProxy streamProxyItem; + if (streamProxy.getId() <= 0) { + streamProxyItem = streamProxyMapper.selectOne(streamProxy.getApp(), streamProxy.getStream()); + }else { + streamProxyItem = streamProxy; + } if (streamProxyItem == null) { return; } @@ -544,7 +552,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { commonGbChannelService.deleteById(streamProxyItem.getCommonGbChannelId()); } streamProxyMapper.delById(streamProxyItem.getId()); - redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PULL", app, stream); + redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PULL", + streamProxy.getApp(), streamProxy.getStream()); } @Override @@ -568,9 +577,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { }); } } - }else { - delProxyFromDb(streamProxy.getApp(), streamProxy.getStream()); } + delProxyFromDb(streamProxy); } @Override