临时提交
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -88,5 +89,5 @@ public interface IPlatformService {
|
||||
|
||||
List<Platform> queryEnablePlatformList();
|
||||
|
||||
|
||||
void delete(Integer platformId, CommonCallback<Object> callback);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.beans.Transient;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
@Transactional
|
||||
public int addAllChannel(Integer platformId) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null);
|
||||
Assert.notEmpty(channelListNotShare, "所有通道已共享");
|
||||
@@ -232,7 +232,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
@Transactional
|
||||
public int addChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelListNotShare, "通道已共享");
|
||||
@@ -308,7 +308,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
@Transactional
|
||||
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelList, "所选通道未共享");
|
||||
@@ -343,7 +343,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
@Transactional
|
||||
public void removeChannels(List<Integer> ids) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(ids);
|
||||
if (platformList.isEmpty()) {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.*;
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionStatus;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
@@ -36,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.sdp.*;
|
||||
@@ -93,6 +93,9 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
@Autowired
|
||||
private IInviteStreamService inviteStreamService;
|
||||
|
||||
@Autowired
|
||||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 流离开的处理
|
||||
@@ -392,6 +395,7 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
subscribeHolder.removeCatalogSubscribe(platform.getServerGBId());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("[平台离线] {}({}), 停止移动位置订阅回复", platform.getName(), platform.getServerGBId());
|
||||
subscribeHolder.removeMobilePositionSubscribe(platform.getServerGBId());
|
||||
// 发起定时自动重新注册
|
||||
@@ -805,4 +809,61 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
public List<Platform> queryEnablePlatformList() {
|
||||
return platformMapper.queryEnablePlatformList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Integer platformId, CommonCallback<Object> callback) {
|
||||
Platform platform = platformMapper.query(platformId);
|
||||
Assert.notNull(platform, "平台不存在");
|
||||
// 发送离线消息,无论是否成功都删除缓存
|
||||
PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId());
|
||||
if (platformCatch != null) {
|
||||
String key = UUID.randomUUID().toString();
|
||||
dynamicTask.startDelay(key, ()->{
|
||||
deletePlatformInfo(platform);
|
||||
if (callback != null) {
|
||||
callback.run(null);
|
||||
}
|
||||
}, 2000);
|
||||
try {
|
||||
commanderForPlatform.unregister(platform, platformCatch.getSipTransactionInfo(), (event -> {
|
||||
dynamicTask.stop(key);
|
||||
// 移除平台相关的信息
|
||||
deletePlatformInfo(platform);
|
||||
if (callback != null) {
|
||||
callback.run(null);
|
||||
}
|
||||
}), (event -> {
|
||||
dynamicTask.stop(key);
|
||||
// 移除平台相关的信息
|
||||
deletePlatformInfo(platform);
|
||||
if (callback != null) {
|
||||
callback.run(null);
|
||||
}
|
||||
}));
|
||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||
log.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||
}
|
||||
}else {
|
||||
deletePlatformInfo(platform);
|
||||
if (callback != null) {
|
||||
callback.run(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deletePlatformInfo(Platform platform) {
|
||||
// 删除关联的通道
|
||||
platformChannelMapper.removeChannelsByPlatformId(platform.getId());
|
||||
// 删除关联的分组
|
||||
platformChannelMapper.removePlatformGroupsByPlatformId(platform.getId());
|
||||
// 删除关联的行政区划
|
||||
platformChannelMapper.removePlatformRegionByPlatformId(platform.getId());
|
||||
// 删除redis缓存
|
||||
redisCatchStorage.delPlatformCatchInfo(platform.getServerGBId());
|
||||
// 删除平台信息
|
||||
platformMapper.delete(platform.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.controller.bean.AudioBroadcastEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.*;
|
||||
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
||||
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
@@ -120,6 +117,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||
@Autowired
|
||||
private SSRCFactory ssrcFactory;
|
||||
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
/**
|
||||
* 流到来的处理
|
||||
*/
|
||||
@@ -1155,7 +1155,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||
if (sendRtpItems.size() > 0) {
|
||||
for (SendRtpItem sendRtpItem : sendRtpItems) {
|
||||
if (sendRtpItem.getMediaServerId().equals(mediaServerId)) {
|
||||
Platform platform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
|
||||
Platform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
|
||||
try {
|
||||
sipCommanderFroPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
|
||||
Reference in New Issue
Block a user