优化国标级联中的通道全部导入
parent
c73fe2b0cf
commit
b444585ebe
|
@ -4,3 +4,9 @@ alter table device
|
||||||
alter table parent_platform
|
alter table parent_platform
|
||||||
add asMessageChannel int default 0;
|
add asMessageChannel int default 0;
|
||||||
|
|
||||||
|
alter table device
|
||||||
|
add mediaServerId varchar(50) default null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
alter table device
|
|
||||||
add mediaServerId varchar(50) default null;
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PlatformGbStreamMapper platformGbStreamMapper;
|
private PlatformGbStreamMapper platformGbStreamMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubscribeHolder subscribeHolder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ParentPlatformMapper platformMapper;
|
private ParentPlatformMapper platformMapper;
|
||||||
|
|
||||||
|
@ -73,16 +76,23 @@ public class GbStreamServiceImpl implements IGbStreamService {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||||
for (GbStream gbStream : gbStreams) {
|
|
||||||
|
|
||||||
|
for (int i = 0; i < gbStreams.size(); i++) {
|
||||||
|
GbStream gbStream = gbStreams.get(i);
|
||||||
gbStream.setCatalogId(catalogId);
|
gbStream.setCatalogId(catalogId);
|
||||||
gbStream.setPlatformId(platformId);
|
gbStream.setPlatformId(platformId);
|
||||||
// TODO 修改为批量提交
|
// TODO 修改为批量提交
|
||||||
platformGbStreamMapper.add(gbStream);
|
platformGbStreamMapper.add(gbStream);
|
||||||
|
logger.info("[关联通道]直播流通道 平台:{}, 共需关联通道数:{}, 已关联:{}", platformId, gbStreams.size(), i + 1);
|
||||||
DeviceChannel deviceChannelListByStream = getDeviceChannelListByStreamWithStatus(gbStream, catalogId, parentPlatform);
|
DeviceChannel deviceChannelListByStream = getDeviceChannelListByStreamWithStatus(gbStream, catalogId, parentPlatform);
|
||||||
deviceChannelList.add(deviceChannelListByStream);
|
deviceChannelList.add(deviceChannelListByStream);
|
||||||
}
|
}
|
||||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
if (subscribeHolder.getCatalogSubscribe(platformId) != null) {
|
||||||
|
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
||||||
|
}
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("批量保存流与平台的关系时错误", e);
|
logger.error("批量保存流与平台的关系时错误", e);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.service.impl;
|
package com.genersoft.iot.vmp.service.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||||
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
||||||
|
@ -15,7 +12,10 @@ import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.TransactionDefinition;
|
||||||
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -34,6 +34,16 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PlatformChannelMapper platformChannelMapper;
|
private PlatformChannelMapper platformChannelMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TransactionDefinition transactionDefinition;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DataSourceTransactionManager dataSourceTransactionManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubscribeHolder subscribeHolder;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceChannelMapper deviceChannelMapper;
|
private DeviceChannelMapper deviceChannelMapper;
|
||||||
|
|
||||||
|
@ -69,17 +79,47 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||||
}
|
}
|
||||||
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
|
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
|
||||||
// 对剩下的数据进行存储
|
// 对剩下的数据进行存储
|
||||||
int result = 0;
|
int allCount = 0;
|
||||||
|
boolean result = false;
|
||||||
|
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
||||||
|
int limitCount = 300;
|
||||||
if (channelReducesToAdd.size() > 0) {
|
if (channelReducesToAdd.size() > 0) {
|
||||||
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
if (channelReducesToAdd.size() > limitCount) {
|
||||||
// TODO 后续给平台增加控制开关以控制是否响应目录订阅
|
for (int i = 0; i < channelReducesToAdd.size(); i += limitCount) {
|
||||||
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
|
int toIndex = i + limitCount;
|
||||||
if (deviceChannelList != null) {
|
if (i + limitCount > channelReducesToAdd.size()) {
|
||||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
toIndex = channelReducesToAdd.size();
|
||||||
|
}
|
||||||
|
int count = platformChannelMapper.addChannels(platformId, channelReducesToAdd.subList(i, toIndex));
|
||||||
|
result = result || count < 0;
|
||||||
|
allCount += count;
|
||||||
|
logger.info("[关联通道]国标通道 平台:{}, 共需关联通道数:{}, 已关联:{}", platformId, channelReducesToAdd.size(), toIndex);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
allCount = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
||||||
|
result = result || allCount < 0;
|
||||||
|
logger.info("[关联通道]国标通道 平台:{}, 关联通道数:{}", platformId, channelReducesToAdd.size());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
if (result) {
|
||||||
|
//事务回滚
|
||||||
|
dataSourceTransactionManager.rollback(transactionStatus);
|
||||||
|
allCount = 0;
|
||||||
|
}else {
|
||||||
|
logger.info("[关联通道]国标通道 平台:{}, 正在存入数据库", platformId);
|
||||||
|
dataSourceTransactionManager.commit(transactionStatus);
|
||||||
|
|
||||||
|
}
|
||||||
|
SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platformId);
|
||||||
|
if (catalogSubscribe != null) {
|
||||||
|
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
|
||||||
|
if (deviceChannelList != null) {
|
||||||
|
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("[关联通道]国标通道 平台:{}, 存入数据库成功", platformId);
|
||||||
|
}
|
||||||
|
return allCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
|
private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="chooseChannel" v-loading="isLoging">
|
<div id="chooseChannel" >
|
||||||
|
|
||||||
<el-dialog title="选择通道" v-if="showDialog" top="2rem" width="90%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()">
|
<el-dialog title="选择通道" v-loading="loading" v-if="showDialog" top="2rem" width="90%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="10">
|
<el-col :span="10">
|
||||||
<el-tabs v-model="catalogTabActiveName" >
|
<el-tabs v-model="catalogTabActiveName" >
|
||||||
|
@ -56,7 +56,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isLoging: false,
|
loading: false,
|
||||||
tabActiveName: "gbChannel",
|
tabActiveName: "gbChannel",
|
||||||
catalogTabActiveName: "catalog",
|
catalogTabActiveName: "catalog",
|
||||||
platformId: "",
|
platformId: "",
|
||||||
|
@ -94,18 +94,17 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
var that = this;
|
|
||||||
|
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method:"post",
|
method:"post",
|
||||||
url:"/api/platform/update_channel_for_gb",
|
url:"/api/platform/update_channel_for_gb",
|
||||||
data:{
|
data:{
|
||||||
platformId: that.platformId,
|
platformId: this.platformId,
|
||||||
channelReduces: that.chooseData
|
channelReduces: this.chooseData
|
||||||
}
|
}
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
that.$message({
|
this.$message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
message: '保存成功,',
|
message: '保存成功,',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
|
@ -114,6 +113,7 @@ export default {
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
catalogIdChange: function (id, name) {
|
catalogIdChange: function (id, name) {
|
||||||
this.catalogId = id;
|
this.catalogId = id;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="chooseChannelForGb" >
|
<div id="chooseChannelForGb" v-loading="loading">
|
||||||
<div style="font-size: 17px; color: #606060; white-space: nowrap; line-height: 30px; font-family: monospace;">
|
<div style="font-size: 17px; color: #606060; white-space: nowrap; line-height: 30px; font-family: monospace;">
|
||||||
<span v-if="catalogId == null">{{catalogName}}的国标通道</span>
|
<span v-if="catalogId == null">{{catalogName}}的国标通道</span>
|
||||||
<span v-if="catalogId != null">{{catalogName}}({{catalogId}})的国标通道</span>
|
<span v-if="catalogId != null">{{catalogName}}({{catalogId}})的国标通道</span>
|
||||||
|
@ -79,6 +79,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
gbChannels: [],
|
gbChannels: [],
|
||||||
gbChoosechannel:{},
|
gbChoosechannel:{},
|
||||||
searchSrt: "",
|
searchSrt: "",
|
||||||
|
@ -118,7 +119,9 @@ export default {
|
||||||
},
|
},
|
||||||
add: function (row) {
|
add: function (row) {
|
||||||
let all = typeof(row) === "undefined"
|
let all = typeof(row) === "undefined"
|
||||||
|
|
||||||
this.getCatalogFromUser((catalogId)=> {
|
this.getCatalogFromUser((catalogId)=> {
|
||||||
|
let task = null;
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method:"post",
|
method:"post",
|
||||||
url:"/api/platform/update_channel_for_gb",
|
url:"/api/platform/update_channel_for_gb",
|
||||||
|
@ -130,12 +133,20 @@ export default {
|
||||||
}
|
}
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
console.log("保存成功")
|
console.log("保存成功")
|
||||||
|
window.clearTimeout(task);
|
||||||
|
this.loading = false;
|
||||||
this.getChannelList();
|
this.getChannelList();
|
||||||
}).catch(function (error) {
|
}).catch((error)=> {
|
||||||
|
window.clearTimeout(task);
|
||||||
|
this.loading = false;
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
task= setTimeout(()=>{
|
||||||
|
this.loading = true;
|
||||||
|
}, 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
remove: function (row) {
|
remove: function (row) {
|
||||||
let all = typeof(row) === "undefined"
|
let all = typeof(row) === "undefined"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="chooseChannelFoStream" >
|
<div id="chooseChannelFoStream" v-loading="loading">
|
||||||
<div style="font-size: 17px; color: #606060; white-space: nowrap; line-height: 30px; font-family: monospace;">
|
<div style="font-size: 17px; color: #606060; white-space: nowrap; line-height: 30px; font-family: monospace;">
|
||||||
<span v-if="catalogId == null">{{catalogName}}的直播通道</span>
|
<span v-if="catalogId == null">{{catalogName}}的直播通道</span>
|
||||||
<span v-if="catalogId != null">{{catalogName}}({{catalogId}})的直播通道</span>
|
<span v-if="catalogId != null">{{catalogName}}({{catalogId}})的直播通道</span>
|
||||||
|
@ -85,6 +85,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
gbStreams: [],
|
gbStreams: [],
|
||||||
gbChoosechannel:{},
|
gbChoosechannel:{},
|
||||||
channelType: "",
|
channelType: "",
|
||||||
|
@ -132,6 +133,7 @@ export default {
|
||||||
add: function (row, scope) {
|
add: function (row, scope) {
|
||||||
let all = typeof(row) === "undefined"
|
let all = typeof(row) === "undefined"
|
||||||
this.getCatalogFromUser((catalogId)=>{
|
this.getCatalogFromUser((catalogId)=>{
|
||||||
|
let task = null;
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method:"post",
|
method:"post",
|
||||||
url:"/api/gbStream/add",
|
url:"/api/gbStream/add",
|
||||||
|
@ -143,11 +145,18 @@ export default {
|
||||||
}
|
}
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
console.log("保存成功")
|
console.log("保存成功")
|
||||||
|
window.clearTimeout(task);
|
||||||
|
this.loading = false;
|
||||||
// this.gbStreams.splice(scope.$index,1)
|
// this.gbStreams.splice(scope.$index,1)
|
||||||
this.getChannelList();
|
this.getChannelList();
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
|
window.clearTimeout(task);
|
||||||
|
this.loading = false;
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
task= setTimeout(()=>{
|
||||||
|
this.loading = true;
|
||||||
|
}, 200)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue