Browse Source

优化通道选择是通道的查询

pull/317/head
648540858 3 years ago
parent
commit
46cf650a86
  1. 25
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  3. 77
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
  4. 14
      web_src/src/components/dialog/platformEdit.vue

25
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java

@ -146,20 +146,23 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
} }
} }
// 查找开启了全部直播流共享的上级平台 if (!StringUtils.isEmpty(param.getGbId())) {
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); // 查找开启了全部直播流共享的上级平台
if (parentPlatforms.size() > 0) { List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
for (ParentPlatform parentPlatform : parentPlatforms) { if (parentPlatforms.size() > 0) {
param.setPlatformId(parentPlatform.getServerGBId()); for (ParentPlatform parentPlatform : parentPlatforms) {
param.setCatalogId(parentPlatform.getCatalogId()); param.setPlatformId(parentPlatform.getServerGBId());
String stream = param.getStream(); param.setCatalogId(parentPlatform.getCatalogId());
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); String stream = param.getStream();
if (streamProxyItems == null) { StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
platformGbStreamMapper.add(param); if (streamProxyItems == null) {
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD); platformGbStreamMapper.add(param);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD);
}
} }
} }
} }
wvpResult.setMsg(result.toString()); wvpResult.setMsg(result.toString());
return wvpResult; return wvpResult;
} }

2
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@ -96,7 +96,7 @@ public interface DeviceChannelMapper {
"SELECT * FROM ( "+ "SELECT * FROM ( "+
" SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " + " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " +
"(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " + "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " +
"(SELECT pc.platformId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as platformId, " + "(SELECT pc.platformId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId AND pc.platformId = #{platformId}) as platformId, " +
"(SELECT pc.catalogId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as catalogId " + "(SELECT pc.catalogId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as catalogId " +
"FROM device_channel dc " + "FROM device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " + "LEFT JOIN device de ON dc.deviceId = de.deviceId " +

77
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java

@ -86,6 +86,65 @@ public class PlatformController {
return storager.queryParentPlatformList(page, count); return storager.queryParentPlatformList(page, count);
} }
/**
* 添加上级平台信息
* @param parentPlatform
* @return
*/
@ApiOperation("添加上级平台信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentPlatform", value = "上级平台信息", dataTypeClass = ParentPlatform.class),
})
@PostMapping("/add")
@ResponseBody
public ResponseEntity<WVPResult<String>> addPlatform(@RequestBody ParentPlatform parentPlatform){
if (logger.isDebugEnabled()) {
logger.debug("保存上级平台信息API调用");
}
WVPResult<String> wvpResult = new WVPResult<>();
if (StringUtils.isEmpty(parentPlatform.getName())
||StringUtils.isEmpty(parentPlatform.getServerGBId())
||StringUtils.isEmpty(parentPlatform.getServerGBDomain())
||StringUtils.isEmpty(parentPlatform.getServerIP())
||StringUtils.isEmpty(parentPlatform.getServerPort())
||StringUtils.isEmpty(parentPlatform.getDeviceGBId())
||StringUtils.isEmpty(parentPlatform.getExpires())
||StringUtils.isEmpty(parentPlatform.getKeepTimeout())
||StringUtils.isEmpty(parentPlatform.getTransport())
||StringUtils.isEmpty(parentPlatform.getCharacterSet())
){
wvpResult.setCode(-1);
wvpResult.setMsg("missing parameters");
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
}
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
if (parentPlatformOld != null) {
wvpResult.setCode(-1);
wvpResult.setMsg("平台 "+parentPlatform.getServerGBId()+" 已存在");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {
// 保存时启用就发送注册
if (parentPlatform.isEnable()) {
// 只要保存就发送注册
commanderForPlatform.register(parentPlatform, null, null);
} else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销
commanderForPlatform.unregister(parentPlatform, null, null);
}
wvpResult.setCode(0);
wvpResult.setMsg("success");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} else {
wvpResult.setCode(-1);
wvpResult.setMsg("写入数据库失败");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
}
/** /**
* 保存上级平台信息 * 保存上级平台信息
* @param parentPlatform * @param parentPlatform
@ -97,11 +156,12 @@ public class PlatformController {
}) })
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){ public ResponseEntity<WVPResult<String>> savePlatform(@RequestBody ParentPlatform parentPlatform){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("保存上级平台信息API调用"); logger.debug("保存上级平台信息API调用");
} }
WVPResult<String> wvpResult = new WVPResult<>();
if (StringUtils.isEmpty(parentPlatform.getName()) if (StringUtils.isEmpty(parentPlatform.getName())
||StringUtils.isEmpty(parentPlatform.getServerGBId()) ||StringUtils.isEmpty(parentPlatform.getServerGBId())
||StringUtils.isEmpty(parentPlatform.getServerGBDomain()) ||StringUtils.isEmpty(parentPlatform.getServerGBDomain())
@ -113,11 +173,10 @@ public class PlatformController {
||StringUtils.isEmpty(parentPlatform.getTransport()) ||StringUtils.isEmpty(parentPlatform.getTransport())
||StringUtils.isEmpty(parentPlatform.getCharacterSet()) ||StringUtils.isEmpty(parentPlatform.getCharacterSet())
){ ){
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); wvpResult.setCode(-1);
wvpResult.setMsg("missing parameters");
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
} }
// TODO 检查是否已经存在,且注册成功, 如果注册成功,需要先注销之前再,修改并注册
// ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getDeviceGBId());
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
boolean updateResult = storager.updateParentPlatform(parentPlatform); boolean updateResult = storager.updateParentPlatform(parentPlatform);
@ -130,9 +189,13 @@ public class PlatformController {
} else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销
commanderForPlatform.unregister(parentPlatform, null, null); commanderForPlatform.unregister(parentPlatform, null, null);
} }
return new ResponseEntity<>("success", HttpStatus.OK); wvpResult.setCode(0);
wvpResult.setMsg("success");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} else { } else {
return new ResponseEntity<>("fail", HttpStatus.OK); wvpResult.setCode(0);
wvpResult.setMsg("写入数据库失败");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
} }

14
web_src/src/components/dialog/platformEdit.vue

@ -116,6 +116,7 @@ export default {
showDialog: false, showDialog: false,
isLoging: false, isLoging: false,
onSubmit_text: "立即创建", onSubmit_text: "立即创建",
saveUrl: "/api/platform/save",
platform: { platform: {
id: null, id: null,
@ -163,6 +164,7 @@ export default {
var that = this; var that = this;
if (platform == null) { if (platform == null) {
this.onSubmit_text = "立即创建"; this.onSubmit_text = "立即创建";
this.saveUrl = "/api/platform/add";
this.$axios({ this.$axios({
method: 'get', method: 'get',
url:`/api/platform/server_config` url:`/api/platform/server_config`
@ -198,6 +200,7 @@ export default {
this.platform.shareAllLiveStream = platform.shareAllLiveStream; this.platform.shareAllLiveStream = platform.shareAllLiveStream;
this.platform.catalogId = platform.catalogId; this.platform.catalogId = platform.catalogId;
this.onSubmit_text = "保存"; this.onSubmit_text = "保存";
this.saveUrl = "/api/platform/save";
} }
this.showDialog = true; this.showDialog = true;
this.listChangeCallback = callback; this.listChangeCallback = callback;
@ -212,14 +215,13 @@ export default {
this.platform.username = this.platform.deviceGBId ; this.platform.username = this.platform.deviceGBId ;
}, },
onSubmit: function () { onSubmit: function () {
console.log("onSubmit");
var that = this; var that = this;
that.$axios({ that.$axios({
method: 'post', method: 'post',
url:`/api/platform/save`, url: this.saveUrl,
data: that.platform data: that.platform
}).then(function (res) { }).then(function (res) {
if (res.data == "success") { if (res.data.code === 0) {
that.$message({ that.$message({
showClose: true, showClose: true,
message: "保存成功", message: "保存成功",
@ -229,6 +231,12 @@ export default {
if (that.listChangeCallback != null) { if (that.listChangeCallback != null) {
that.listChangeCallback(); that.listChangeCallback();
} }
}else {
that.$message({
showClose: true,
message: res.data.msg,
type: "error",
});
} }
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);

Loading…
Cancel
Save