为级联平台增加虚拟目录功能
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import javax.sip.Dialog;
|
||||
import java.util.EventObject;
|
||||
|
||||
public class DeviceNotFoundEvent extends EventObject {
|
||||
/**
|
||||
* Constructs a prototypical Event.
|
||||
*
|
||||
* @param dialog
|
||||
* @throws IllegalArgumentException if source is null.
|
||||
*/
|
||||
public DeviceNotFoundEvent(Dialog dialog) {
|
||||
super(dialog);
|
||||
}
|
||||
|
||||
|
||||
public Dialog getDialog() {
|
||||
return (Dialog)super.getSource();
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,11 @@ public class ParentPlatform {
|
||||
*/
|
||||
private boolean shareAllLiveStream;
|
||||
|
||||
/**
|
||||
* 默认目录Id,自动添加的通道多放在这个目录下
|
||||
*/
|
||||
private String catalogId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -277,4 +282,12 @@ public class ParentPlatform {
|
||||
public void setShareAllLiveStream(boolean shareAllLiveStream) {
|
||||
this.shareAllLiveStream = shareAllLiveStream;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
public class PlatformCatalog {
|
||||
private String id;
|
||||
private String name;
|
||||
private String platformId;
|
||||
private String parentId;
|
||||
private int childrenCount; // 子节点数
|
||||
private int type; // 0 目录, 1 国标通道, 2 直播流
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPlatformId() {
|
||||
return platformId;
|
||||
}
|
||||
|
||||
public void setPlatformId(String platformId) {
|
||||
this.platformId = platformId;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public int getChildrenCount() {
|
||||
return childrenCount;
|
||||
}
|
||||
|
||||
public void setChildrenCount(int childrenCount) {
|
||||
this.childrenCount = childrenCount;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setTypeForCatalog() {
|
||||
this.type = 0;
|
||||
}
|
||||
|
||||
public void setTypeForGb() {
|
||||
this.type = 1;
|
||||
}
|
||||
|
||||
public void setTypeForStream() {
|
||||
this.type = 2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ public class PlatformGbStream {
|
||||
private String app;
|
||||
private String stream;
|
||||
private String platformId;
|
||||
private String catalogId;
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
@@ -29,4 +30,11 @@ public class PlatformGbStream {
|
||||
this.platformId = platformId;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@@ -91,6 +92,13 @@ public class SipSubscribe {
|
||||
this.statusCode = -1024;
|
||||
this.callId = dialogTerminatedEvent.getDialog().getCallId().getCallId();
|
||||
this.dialog = dialogTerminatedEvent.getDialog();
|
||||
}else if (event instanceof DeviceNotFoundEvent) {
|
||||
DeviceNotFoundEvent deviceNotFoundEvent = (DeviceNotFoundEvent)event;
|
||||
this.type = "deviceNotFoundEvent";
|
||||
this.msg = "设备未找到";
|
||||
this.statusCode = -1024;
|
||||
this.callId = deviceNotFoundEvent.getDialog().getCallId().getCallId();
|
||||
this.dialog = deviceNotFoundEvent.getDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||
logger.debug(responseEvent.getResponse().toString());
|
||||
int status = response.getStatusCode();
|
||||
if (((status >= 200) && (status < 300)) || status == 401) { // Success!
|
||||
// ISIPResponseProcessor processor = processorFactory.createResponseProcessor(evt);
|
||||
CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
|
||||
String method = cseqHeader.getMethod();
|
||||
ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method);
|
||||
@@ -108,6 +107,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||
if (subscribe != null) {
|
||||
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
|
||||
subscribe.response(eventResult);
|
||||
sipSubscribe.removeOkSubscribe(callIdHeader.getCallId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||
if (subscribe != null) {
|
||||
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
|
||||
subscribe.response(eventResult);
|
||||
sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
// 查询平台下是否有该通道
|
||||
DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
|
||||
List<GbStream> gbStreams = storager.queryStreamInParentPlatform(requesterId, channelId);
|
||||
PlatformCatalog catalog = storager.getCatalog(channelId);
|
||||
GbStream gbStream = gbStreams.size() > 0? gbStreams.get(0):null;
|
||||
MediaServerItem mediaServerItem = null;
|
||||
// 不是通道可能是直播流
|
||||
@@ -132,7 +133,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
return;
|
||||
}
|
||||
responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 通道存在,发181,呼叫转接中
|
||||
}else {
|
||||
}else if (catalog != null) {
|
||||
responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 目录不支持点播
|
||||
return;
|
||||
} else {
|
||||
logger.info("通道不存在,返回404");
|
||||
responseAck(evt, Response.NOT_FOUND); // 通道不存在,发404,资源不存在
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.header.CallIdHeader;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
@@ -39,6 +42,9 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
||||
@Autowired
|
||||
private IVideoManagerStorager storage;
|
||||
|
||||
@Autowired
|
||||
private SipSubscribe sipSubscribe;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@@ -56,6 +62,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
||||
public void process(RequestEvent evt) {
|
||||
logger.debug("接收到消息:" + evt.getRequest());
|
||||
String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
|
||||
CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
|
||||
// 查询设备是否存在
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
// 查询上级平台是否存在
|
||||
@@ -63,7 +70,12 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
||||
try {
|
||||
if (device == null && parentPlatform == null) {
|
||||
// 不存在则回复404
|
||||
responseAck(evt, Response.NOT_FOUND, "device id not found");
|
||||
responseAck(evt, Response.NOT_FOUND, "device "+ deviceId +" not found");
|
||||
logger.warn("[设备未找到 ]: {}", deviceId);
|
||||
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
|
||||
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new DeviceNotFoundEvent(evt.getDialog()));
|
||||
sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
|
||||
};
|
||||
}else {
|
||||
Element rootElement = getRootElement(evt);
|
||||
String name = rootElement.getName();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
@@ -71,11 +68,41 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
|
||||
// 查询关联的直播通道
|
||||
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
int size = channelReduces.size() + gbStreams.size();
|
||||
// 回复目录信息
|
||||
List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
if (catalogs.size() > 0) {
|
||||
for (PlatformCatalog catalog : catalogs) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(catalog.getId());
|
||||
deviceChannel.setName(catalog.getName());
|
||||
deviceChannel.setLongitude(0.0);
|
||||
deviceChannel.setLatitude(0.0);
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(config.getDomain());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setSecrecy("0");
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
// 防止发送过快
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
// 回复级联的通道
|
||||
if (channelReduces.size() > 0) {
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
|
||||
// TODO 目前暂时认为这里只用通道没有目录
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setParentId(channelReduce.getCatalogId());
|
||||
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
// 防止发送过快
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
// 回复直播的通道
|
||||
@@ -89,16 +116,16 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
||||
// deviceChannel.setParentId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setParentId(gbStream.getCatalogId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(config.getDomain());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setSecrecy("0");
|
||||
deviceChannel.setSecrecy("0");
|
||||
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
// 防止发送过快
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
if (size == 0) {
|
||||
@@ -111,6 +138,8 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
@@ -73,12 +70,41 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
||||
List<ChannelReduce> channelReduces = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
|
||||
// 查询关联的直播通道
|
||||
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
int size = channelReduces.size() + gbStreams.size();
|
||||
// 回复目录信息
|
||||
List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
int size = catalogs.size() + channelReduces.size() + gbStreams.size();
|
||||
if (catalogs.size() > 0) {
|
||||
for (PlatformCatalog catalog : catalogs) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(catalog.getId());
|
||||
deviceChannel.setName(catalog.getName());
|
||||
deviceChannel.setLongitude(0.0);
|
||||
deviceChannel.setLatitude(0.0);
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(config.getDomain());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setSecrecy("0");
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
// 防止发送过快
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
// 回复级联的通道
|
||||
if (channelReduces.size() > 0) {
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
|
||||
// TODO 目前暂时认为这里只用通道没有目录
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setParentId(channelReduce.getCatalogId());
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
// 防止发送过快
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}
|
||||
// 回复直播的通道
|
||||
@@ -92,14 +118,13 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
||||
// deviceChannel.setParentId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setParentId(gbStream.getCatalogId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(config.getDomain());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setSecrecy("0");
|
||||
deviceChannel.setSecrecy("0");
|
||||
|
||||
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
|
||||
}
|
||||
@@ -114,6 +139,8 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.MediaConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetup;
|
||||
@@ -302,7 +301,7 @@ public class ZLMHttpHookListener {
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
||||
public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){
|
||||
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item));
|
||||
}
|
||||
@@ -322,10 +321,8 @@ public class ZLMHttpHookListener {
|
||||
String schema = item.getSchema();
|
||||
List<MediaItem.MediaTrack> tracks = item.getTracks();
|
||||
boolean regist = item.isRegist();
|
||||
if (tracks != null) {
|
||||
logger.info("[stream: " + streamId + "] on_stream_changed->>" + schema);
|
||||
}
|
||||
if ("rtmp".equals(schema)){
|
||||
logger.info("on_stream_changed:注册->{}, app->{}, stream->{}", regist, app, streamId);
|
||||
if (regist) {
|
||||
mediaServerService.addCount(mediaServerId);
|
||||
}else {
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IGbStreamService {
|
||||
* 保存国标关联
|
||||
* @param gbStreams
|
||||
*/
|
||||
boolean addPlatformInfo(List<GbStream> gbStreams, String platformId);
|
||||
boolean addPlatformInfo(List<GbStream> gbStreams, String platformId, String catalogId);
|
||||
|
||||
/**
|
||||
* 移除国标关联
|
||||
|
||||
@@ -47,13 +47,15 @@ public class GbStreamServiceImpl implements IGbStreamService {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addPlatformInfo(List<GbStream> gbStreams, String platformId) {
|
||||
public boolean addPlatformInfo(List<GbStream> gbStreams, String platformId, String catalogId) {
|
||||
// 放在事务内执行
|
||||
boolean result = false;
|
||||
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
||||
try {
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
gbStream.setCatalogId(catalogId);
|
||||
gbStream.setPlatformId(platformId);
|
||||
// TODO 修改为批量提交
|
||||
platformGbStreamMapper.add(gbStream);
|
||||
}
|
||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||
|
||||
@@ -130,7 +130,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) {
|
||||
List<GbStream> gbStreams = new ArrayList<>();
|
||||
gbStreams.add(param);
|
||||
if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId())){
|
||||
if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){
|
||||
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]成功");
|
||||
}else {
|
||||
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
|
||||
@@ -141,6 +141,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
if (parentPlatforms.size() > 0) {
|
||||
for (ParentPlatform parentPlatform : parentPlatforms) {
|
||||
param.setPlatformId(parentPlatform.getServerGBId());
|
||||
param.setCatalogId(parentPlatform.getCatalogId());
|
||||
String stream = param.getStream();
|
||||
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
|
||||
if (streamProxyItems == null) {
|
||||
|
||||
@@ -119,6 +119,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
|
||||
if (parentPlatforms.size() > 0) {
|
||||
for (ParentPlatform parentPlatform : parentPlatforms) {
|
||||
stream.setCatalogId(parentPlatform.getCatalogId());
|
||||
stream.setPlatformId(parentPlatform.getServerGBId());
|
||||
String streamId = stream.getStream();
|
||||
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId());
|
||||
|
||||
@@ -185,6 +185,8 @@ public interface IRedisCatchStorage {
|
||||
*/
|
||||
void updateDevice(Device device);
|
||||
|
||||
void removeDevice(String deviceId);
|
||||
|
||||
/**
|
||||
* 获取Device
|
||||
*/
|
||||
|
||||
@@ -243,7 +243,7 @@ public interface IVideoManagerStorager {
|
||||
* @param channelReduces
|
||||
* @return
|
||||
*/
|
||||
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces);
|
||||
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
|
||||
|
||||
/**
|
||||
* 移除上级平台的通道信息
|
||||
@@ -256,6 +256,9 @@ public interface IVideoManagerStorager {
|
||||
|
||||
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
|
||||
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
|
||||
List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId);
|
||||
|
||||
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
|
||||
|
||||
|
||||
@@ -431,4 +434,26 @@ public interface IVideoManagerStorager {
|
||||
* @param deviceChannelList
|
||||
*/
|
||||
boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList);
|
||||
|
||||
/**
|
||||
* 获取目录信息
|
||||
* @param platformId
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId);
|
||||
|
||||
int addCatalog(PlatformCatalog platformCatalog);
|
||||
|
||||
PlatformCatalog getCatalog(String id);
|
||||
|
||||
int delCatalog(String id);
|
||||
|
||||
int updateCatalog(PlatformCatalog platformCatalog);
|
||||
|
||||
int setDefaultCatalog(String platformId, String catalogId);
|
||||
|
||||
List<PlatformCatalog> queryCatalogInPlatform(String serverGBId);
|
||||
|
||||
int delRelation(PlatformCatalog platformCatalog);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,8 @@ public interface DeviceChannelMapper {
|
||||
"SELECT * FROM ( "+
|
||||
" SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " +
|
||||
"(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 ) as platformId, " +
|
||||
"(SELECT pc.catalogId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as catalogId " +
|
||||
"FROM device_channel dc " +
|
||||
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
|
||||
" WHERE 1=1 " +
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface GbStreamMapper {
|
||||
@Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
int del(String app, String stream);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream")
|
||||
@Select("SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream")
|
||||
List<GbStream> selectAll();
|
||||
|
||||
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
@@ -44,12 +44,12 @@ public interface GbStreamMapper {
|
||||
@Select("SELECT * FROM gb_stream WHERE gbId=#{gbId}")
|
||||
List<GbStream> selectByGBId(String gbId);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " +
|
||||
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
|
||||
List<GbStream> queryStreamInPlatform(String platformId, String gbId);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " +
|
||||
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE pgs.platformId = '${platformId}'")
|
||||
List<GbStream> queryGbStreamListInPlatform(String platformId);
|
||||
@@ -59,17 +59,11 @@ public interface GbStreamMapper {
|
||||
"WHERE app=#{app} AND stream=#{stream}")
|
||||
int setStatus(String app, String stream, boolean status);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream WHERE mediaServerId=#{mediaServerId} ")
|
||||
List<GbStream> selectAllByMediaServerId(String mediaServerId);
|
||||
|
||||
@Update("UPDATE gb_stream " +
|
||||
"SET status=${status} " +
|
||||
"WHERE mediaServerId=#{mediaServerId} ")
|
||||
void updateStatusByMediaServerId(String mediaServerId, boolean status);
|
||||
|
||||
@Select("SELECT * FROM gb_stream WHERE mediaServerId=#{mediaServerId}")
|
||||
void delByMediaServerId(String mediaServerId);
|
||||
|
||||
@Delete("DELETE FROM gb_stream WHERE streamType=#{type} AND gbId=NULL AND mediaServerId=#{mediaServerId}")
|
||||
void deleteWithoutGBId(String type, String mediaServerId);
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ public interface ParentPlatformMapper {
|
||||
|
||||
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
|
||||
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
|
||||
" status, shareAllLiveStream) " +
|
||||
" status, shareAllLiveStream, catalogId) " +
|
||||
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
|
||||
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
|
||||
" ${status}, ${shareAllLiveStream})")
|
||||
" ${status}, ${shareAllLiveStream}, #{catalogId})")
|
||||
int addParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
@Update("UPDATE parent_platform " +
|
||||
@@ -40,7 +40,8 @@ public interface ParentPlatformMapper {
|
||||
"ptz=#{ptz}, " +
|
||||
"rtcp=#{rtcp}, " +
|
||||
"status=#{status}, " +
|
||||
"shareAllLiveStream=#{shareAllLiveStream} " +
|
||||
"shareAllLiveStream=#{shareAllLiveStream}, " +
|
||||
"catalogId=#{catalogId} " +
|
||||
"WHERE id=#{id}")
|
||||
int updateParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
@@ -74,4 +75,11 @@ public interface ParentPlatformMapper {
|
||||
|
||||
@Select("SELECT * FROM parent_platform WHERE shareAllLiveStream=true")
|
||||
List<ParentPlatform> selectAllAhareAllLiveStream();
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE parent_platform " +
|
||||
"SET catalogId=#{catalogId}" +
|
||||
"WHERE serverGBId=#{platformId}"+
|
||||
"</script>"})
|
||||
int setDefaultCatalog(String platformId, String catalogId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PlatformCatalogMapper {
|
||||
|
||||
@Insert("INSERT INTO platform_catalog (id, name, platformId, parentId) VALUES" +
|
||||
"(#{id}, #{name}, #{platformId}, #{parentId})")
|
||||
int add(PlatformCatalog platformCatalog);
|
||||
|
||||
@Delete("DELETE FROM platform_catalog WHERE id=#{id}")
|
||||
int del(String id);
|
||||
|
||||
@Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}")
|
||||
int delByPlatformId(String platformId);
|
||||
|
||||
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id AND platformId=#{platformId}) as childrenCount FROM platform_catalog pc WHERE parentId=#{parentId} AND platformId=#{platformId}")
|
||||
List<PlatformCatalog> selectByParentId(String platformId, String parentId);
|
||||
|
||||
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}")
|
||||
PlatformCatalog select(String id);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE platform_catalog " +
|
||||
"SET name=#{name}" +
|
||||
"WHERE id=#{id}"+
|
||||
"</script>"})
|
||||
int update(PlatformCatalog platformCatalog);
|
||||
|
||||
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
|
||||
List<PlatformCatalog> selectByPlatForm(String platformId);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
@@ -25,9 +26,9 @@ public interface PlatformChannelMapper {
|
||||
List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds);
|
||||
|
||||
@Insert("<script> "+
|
||||
"INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId) VALUES" +
|
||||
"INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" +
|
||||
"<foreach collection='channelReducesToAdd' item='item' separator=','>" +
|
||||
" ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' )" +
|
||||
" ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd);
|
||||
@@ -54,6 +55,22 @@ public interface PlatformChannelMapper {
|
||||
"platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'")
|
||||
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
|
||||
|
||||
|
||||
@Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " +
|
||||
"from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " +
|
||||
"where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
|
||||
|
||||
@Select("SELECT * FROM device WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE platformId='${platformId}' AND channelId='${channelId}')")
|
||||
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM platform_gb_channel WHERE catalogId=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogId(String id);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM platform_gb_channel WHERE catalogId=#{parentId} AND platformId=#{platformId} AND channelId=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
@@ -12,8 +14,8 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface PlatformGbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" +
|
||||
"('${app}', '${stream}', '${platformId}')")
|
||||
@Insert("INSERT INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
|
||||
"('${app}', '${stream}', '${platformId}', '${catalogId}')")
|
||||
int add(PlatformGbStream platformGbStream);
|
||||
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
@@ -27,4 +29,22 @@ public interface PlatformGbStreamMapper {
|
||||
|
||||
@Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{serverGBId}")
|
||||
StreamProxyItem selectOne(String app, String stream, String serverGBId);
|
||||
|
||||
@Select("select gs.* \n" +
|
||||
"from gb_stream gs\n" +
|
||||
" left join platform_gb_stream pgs\n" +
|
||||
" on gs.app = pgs.app and gs.stream = pgs.stream\n" +
|
||||
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
|
||||
List<GbStream> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
|
||||
|
||||
@Select("select gs.gbId as id, gs.name as name, pgs.platformId as platformId, pgs.catalogId as catalogId , 0 as childrenCount, 2 as type\n" +
|
||||
"from gb_stream gs\n" +
|
||||
" left join platform_gb_stream pgs\n" +
|
||||
" on gs.app = pgs.app and gs.stream = pgs.stream\n" +
|
||||
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatlog(String platformId, String catalogId);
|
||||
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}")
|
||||
int delByCatalogId(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -406,6 +406,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
redis.set(key, device);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDevice(String deviceId) {
|
||||
String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId;
|
||||
redis.del(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(String deviceId) {
|
||||
String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId;
|
||||
|
||||
@@ -71,6 +71,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
|
||||
@Autowired
|
||||
private GbStreamMapper gbStreamMapper;
|
||||
|
||||
@Autowired
|
||||
private PlatformCatalogMapper catalogMapper;
|
||||
;
|
||||
|
||||
@Autowired
|
||||
@@ -449,6 +452,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
|
||||
@Override
|
||||
public boolean addParentPlatform(ParentPlatform parentPlatform) {
|
||||
if (parentPlatform.getCatalogId() == null) {
|
||||
parentPlatform.setCatalogId(parentPlatform.getServerGBId());
|
||||
}
|
||||
int result = platformMapper.addParentPlatform(parentPlatform);
|
||||
return result > 0;
|
||||
}
|
||||
@@ -458,6 +464,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
int result = 0;
|
||||
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
|
||||
if (parentPlatform.getId() == null ) {
|
||||
if (parentPlatform.getCatalogId() == null) {
|
||||
parentPlatform.setCatalogId(parentPlatform.getServerGBId());
|
||||
}
|
||||
result = platformMapper.addParentPlatform(parentPlatform);
|
||||
if (parentPlatformCatch == null) {
|
||||
parentPlatformCatch = new ParentPlatformCatch();
|
||||
@@ -480,8 +489,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
// 共享所有视频流,需要将现有视频流添加到此平台
|
||||
List<GbStream> gbStreams = gbStreamMapper.selectAll();
|
||||
if (gbStreams.size() > 0) {
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
gbStream.setCatalogId(parentPlatform.getCatalogId());
|
||||
}
|
||||
if (parentPlatform.isShareAllLiveStream()) {
|
||||
gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId());
|
||||
gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId());
|
||||
}else {
|
||||
gbStreamService.delPlatformInfo(gbStreams);
|
||||
}
|
||||
@@ -536,10 +548,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
|
||||
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
|
||||
|
||||
Map<String, ChannelReduce> deviceAndChannels = new HashMap<>();
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
channelReduce.setCatalogId(catalogId);
|
||||
deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce);
|
||||
}
|
||||
List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
|
||||
@@ -576,6 +589,18 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId) {
|
||||
List<PlatformCatalog> catalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId);
|
||||
return catalogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) {
|
||||
List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatlog(platformId, catalogId);
|
||||
return catalogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
|
||||
Device device = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||
@@ -739,6 +764,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
|
||||
if (parentPlatforms.size() > 0) {
|
||||
for (ParentPlatform parentPlatform : parentPlatforms) {
|
||||
streamPushItem.setCatalogId(parentPlatform.getCatalogId());
|
||||
streamPushItem.setPlatformId(parentPlatform.getServerGBId());
|
||||
String stream = streamPushItem.getStream();
|
||||
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, parentPlatform.getServerGBId());
|
||||
@@ -804,4 +830,69 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
return streamProxyMapper.selectOne(app, streamId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId) {
|
||||
return catalogMapper.selectByParentId(platformId, parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addCatalog(PlatformCatalog platformCatalog) {
|
||||
return catalogMapper.add(platformCatalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformCatalog getCatalog(String id) {
|
||||
return catalogMapper.select(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delCatalog(String id) {
|
||||
PlatformCatalog platformCatalog = catalogMapper.select(id);
|
||||
if (platformCatalog.getChildrenCount() > 0) {
|
||||
List<PlatformCatalog> platformCatalogList = catalogMapper.selectByParentId(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
for (PlatformCatalog catalog : platformCatalogList) {
|
||||
if (catalog.getChildrenCount() == 0) {
|
||||
catalogMapper.del(catalog.getId());
|
||||
platformGbStreamMapper.delByCatalogId(catalog.getId());
|
||||
platformChannelMapper.delByCatalogId(catalog.getId());
|
||||
}else {
|
||||
delCatalog(catalog.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
int delresult = catalogMapper.del(id);
|
||||
int delStreamresult = platformGbStreamMapper.delByCatalogId(id);
|
||||
int delChanneresult = platformChannelMapper.delByCatalogId(id);
|
||||
return delresult + delChanneresult + delStreamresult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCatalog(PlatformCatalog platformCatalog) {
|
||||
return catalogMapper.update(platformCatalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setDefaultCatalog(String platformId, String catalogId) {
|
||||
return platformMapper.setDefaultCatalog(platformId, catalogId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatformCatalog> queryCatalogInPlatform(String platformId) {
|
||||
return catalogMapper.selectByPlatForm(platformId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delRelation(PlatformCatalog platformCatalog) {
|
||||
if (platformCatalog.getType() == 1) {
|
||||
return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog);
|
||||
}else if (platformCatalog.getType() == 2) {
|
||||
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId());
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
if (gbStream.getGbId().equals(platformCatalog.getId())) {
|
||||
return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,12 +152,16 @@ public class DeviceQuery {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(15*1000L);
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("设备通道信息同步超时"));
|
||||
logger.warn("设备[{}]通道信息同步超时", deviceId);
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
msg.setId(uuid);
|
||||
msg.setData("Timeout");
|
||||
WVPResult<Object> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(-1);
|
||||
wvpResult.setData(device);
|
||||
wvpResult.setMsg("更新超时");
|
||||
msg.setData(wvpResult);
|
||||
resultHolder.invokeAllResult(msg);
|
||||
});
|
||||
// 等待其他相同请求返回时一起返回
|
||||
@@ -168,7 +172,11 @@ public class DeviceQuery {
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
msg.setId(uuid);
|
||||
msg.setData(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||
WVPResult<Object> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(-1);
|
||||
wvpResult.setData(device);
|
||||
wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||
msg.setData(wvpResult);
|
||||
resultHolder.invokeAllResult(msg);
|
||||
});
|
||||
|
||||
@@ -199,6 +207,7 @@ public class DeviceQuery {
|
||||
boolean isSuccess = storager.delete(deviceId);
|
||||
if (isSuccess) {
|
||||
redisCatchStorage.clearCatchByDeviceId(deviceId);
|
||||
redisCatchStorage.removeDevice(deviceId);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("deviceId", deviceId);
|
||||
return new ResponseEntity<>(json.toString(),HttpStatus.OK);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class GbStreamController {
|
||||
@PostMapping(value = "/add")
|
||||
@ResponseBody
|
||||
public Object add(@RequestBody GbStreamParam gbStreamParam){
|
||||
if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) {
|
||||
if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId())) {
|
||||
return "success";
|
||||
}else {
|
||||
return "fail";
|
||||
|
||||
@@ -8,12 +8,22 @@ public class GbStreamParam {
|
||||
|
||||
private String platformId;
|
||||
|
||||
private String catalogId;
|
||||
|
||||
private List<GbStream> gbStreams;
|
||||
|
||||
public String getPlatformId() {
|
||||
return platformId;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
|
||||
public void setPlatformId(String platformId) {
|
||||
this.platformId = platformId;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.platform;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CatalogData;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -21,6 +26,8 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 级联平台管理
|
||||
*/
|
||||
@@ -253,7 +260,7 @@ public class PlatformController {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台添加国标通道API调用");
|
||||
}
|
||||
int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces());
|
||||
int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
|
||||
|
||||
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
|
||||
}
|
||||
@@ -279,5 +286,197 @@ public class PlatformController {
|
||||
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目录
|
||||
* @param platformId 平台ID
|
||||
* @param parentId 目录父ID
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("获取目录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "platformId", value = "平台ID", dataTypeClass = String.class, required = true),
|
||||
@ApiImplicitParam(name = "parentId", value = "目录父ID", dataTypeClass = String.class, required = true),
|
||||
})
|
||||
@GetMapping("/catalog")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> getCatalogByPlatform(String platformId, String parentId){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
|
||||
}
|
||||
List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId);
|
||||
// 查询下属的国标通道
|
||||
List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId);
|
||||
List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId);
|
||||
platformCatalogList.addAll(catalogsForChannel);
|
||||
platformCatalogList.addAll(catalogsForStream);
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
result.setData(platformCatalogList);
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加目录
|
||||
* @param platformCatalog 目录
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("添加目录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "platformCatalog", value = "目录信息", dataTypeClass = PlatformCatalog.class, required = true),
|
||||
})
|
||||
@PostMapping("/catalog/add")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> addCatalog(@RequestBody PlatformCatalog platformCatalog){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
|
||||
|
||||
if (platformCatalogInStore != null) {
|
||||
result.setCode(-1);
|
||||
result.setMsg( platformCatalog.getId() + " already exists");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
int addResult = storager.addCatalog(platformCatalog);
|
||||
if (addResult > 0) {
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}else {
|
||||
result.setCode(-500);
|
||||
result.setMsg("save error");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑目录
|
||||
* @param platformCatalog 目录
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("编辑目录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "platformCatalog", value = "目录信息", dataTypeClass = PlatformCatalog.class, required = true),
|
||||
})
|
||||
@PostMapping("/catalog/edit")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> editCatalog(@RequestBody PlatformCatalog platformCatalog){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
|
||||
if (platformCatalogInStore == null) {
|
||||
result.setMsg( platformCatalog.getId() + " not exists");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
int addResult = storager.updateCatalog(platformCatalog);
|
||||
if (addResult > 0) {
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}else {
|
||||
result.setMsg("save error");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目录
|
||||
* @param id 目录Id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("删除目录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "目录Id", dataTypeClass = String.class, required = true),
|
||||
})
|
||||
@DeleteMapping("/catalog/del")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> delCatalog(String id){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除目录,{}", id);
|
||||
}
|
||||
int delResult = storager.delCatalog(id);
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
|
||||
if (delResult > 0) {
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}else {
|
||||
result.setMsg("save error");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关联
|
||||
* @param platformCatalog 关联的信息
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("删除关联")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "platformCatalog", value = "关联的信息", dataTypeClass = PlatformCatalog.class, required = true),
|
||||
})
|
||||
@DeleteMapping("/catalog/relation/del")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> delRelation(@RequestBody PlatformCatalog platformCatalog){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
int delResult = storager.delRelation(platformCatalog);
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
|
||||
if (delResult > 0) {
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}else {
|
||||
result.setMsg("save error");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改默认目录
|
||||
* @param platformId 平台Id
|
||||
* @param catalogId 目录Id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("修改默认目录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "platformId", value = "平台Id", dataTypeClass = String.class, required = true),
|
||||
@ApiImplicitParam(name = "catalogId", value = "目录Id", dataTypeClass = String.class, required = true),
|
||||
})
|
||||
@PostMapping("/catalog/default/update")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<String>> setDefaultCatalog(String platformId, String catalogId){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("修改默认目录,{},{}", platformId, catalogId);
|
||||
}
|
||||
int updateResult = storager.setDefaultCatalog(platformId, catalogId);
|
||||
WVPResult<String> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
|
||||
if (updateResult > 0) {
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}else {
|
||||
result.setMsg("save error");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ public class ChannelReduce {
|
||||
*/
|
||||
private String platformId;
|
||||
|
||||
/**
|
||||
* 目录Id
|
||||
*/
|
||||
private String catalogId;
|
||||
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
@@ -96,4 +101,12 @@ public class ChannelReduce {
|
||||
public void setPlatformId(String platformId) {
|
||||
this.platformId = platformId;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
public class UpdateChannelParam {
|
||||
private String platformId;
|
||||
private String catalogId;
|
||||
private List<ChannelReduce> channelReduces;
|
||||
|
||||
public String getPlatformId() {
|
||||
@@ -21,4 +22,12 @@ public class UpdateChannelParam {
|
||||
public void setChannelReduces(List<ChannelReduce> channelReduces) {
|
||||
this.channelReduces = channelReduces;
|
||||
}
|
||||
|
||||
public String getCatalogId() {
|
||||
return catalogId;
|
||||
}
|
||||
|
||||
public void setCatalogId(String catalogId) {
|
||||
this.catalogId = catalogId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user