临时提交

pull/1642/head
648540858 2024-08-28 17:10:53 +08:00
parent 64e9b6674f
commit ddf917d127
22 changed files with 263 additions and 402 deletions

View File

@ -5,11 +5,11 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.github.pagehelper.PageInfo;
@ -44,7 +44,7 @@ public class AlarmController {
private ISIPCommanderForPlatform commanderForPlatform;
@Autowired
private IVideoManagerStorage storage;
private IPlatformService platformService;
@Autowired
private IDeviceService deviceService;
@ -100,7 +100,7 @@ public class AlarmController {
@Parameter(name = "deviceId", description = "设备国标编号")
public void delete(@RequestParam String deviceId) {
Device device = deviceService.getDeviceByDeviceId(deviceId);
Platform platform = storage.queryParentPlatByServerGBId(deviceId);
Platform platform = platformService.queryPlatformByServerGBId(deviceId);
DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setChannelId(deviceId);
deviceAlarm.setAlarmDescription("test");

View File

@ -1,22 +1,18 @@
package com.genersoft.iot.vmp.gb28181.controller;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.controller.bean.UpdateChannelParam;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -27,10 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import org.springframework.web.context.request.async.DeferredResult;
/**
*
@ -41,41 +34,19 @@ import java.text.ParseException;
@RequestMapping("/api/platform")
public class PlatformController {
@Autowired
private UserSetting userSetting;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IPlatformChannelService platformChannelService;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private SubscribeHolder subscribeHolder;
@Autowired
private ISIPCommanderForPlatform commanderForPlatform;
@Autowired
private SipConfig sipConfig;
@Autowired
private DynamicTask dynamicTask;
@Autowired
private IPlatformService platformService;
@Autowired
private IDeviceChannelService deviceChannelService;
/**
*
*
* @return
*/
@Operation(summary = "获取国标服务的配置", security = @SecurityRequirement(name = JwtUtils.HEADER))
@GetMapping("/server_config")
public JSONObject serverConfig() {
@ -87,11 +58,6 @@ public class PlatformController {
return result;
}
/**
*
*
* @return
*/
@Operation(summary = "获取级联服务器信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "平台国标编号", required = true)
@GetMapping("/info/{id}")
@ -104,13 +70,6 @@ public class PlatformController {
}
}
/**
*
*
* @param page
* @param count
* @return
*/
@GetMapping("/query/{count}/{page}")
@Operation(summary = "分页查询级联平台", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@ -118,7 +77,7 @@ public class PlatformController {
public PageInfo<Platform> platforms(@PathVariable int page, @PathVariable int count) {
PageInfo<Platform> parentPlatformPageInfo = platformService.queryPlatformList(page, count);
if (parentPlatformPageInfo.getList().size() > 0) {
if (parentPlatformPageInfo != null && !parentPlatformPageInfo.getList().isEmpty()) {
for (Platform platform : parentPlatformPageInfo.getList()) {
platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null);
platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null);
@ -127,16 +86,10 @@ public class PlatformController {
return parentPlatformPageInfo;
}
/**
*
*
* @param platform
* @return
*/
@Operation(summary = "添加上级平台信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/add")
@ResponseBody
public void addPlatform(@RequestBody Platform platform) {
public void add(@RequestBody Platform platform) {
if (log.isDebugEnabled()) {
log.debug("保存上级平台信息API调用");
@ -180,13 +133,7 @@ public class PlatformController {
}
}
/**
*
*
* @param parentPlatform
* @return
*/
@Operation(summary = "保存上级平台信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Operation(summary = "更新上级平台信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/update")
@ResponseBody
public void updatePlatform(@RequestBody Platform parentPlatform) {
@ -207,83 +154,33 @@ public class PlatformController {
) {
throw new ControllerException(ErrorCode.ERROR400);
}
platformService.update(parentPlatform);
}
/**
*
*
* @param serverGBId ID
* @return
*/
@Operation(summary = "删除上级平台", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "serverGBId", description = "上级平台的国标编号")
@DeleteMapping("/delete/{serverGBId}")
@Parameter(name = "id", description = "上级平台ID")
@DeleteMapping("/delete")
@ResponseBody
public void deletePlatform(@PathVariable String serverGBId) {
public DeferredResult<Object> deletePlatform(Integer id) {
if (log.isDebugEnabled()) {
log.debug("删除上级平台API调用");
}
if (ObjectUtils.isEmpty(serverGBId)
) {
throw new ControllerException(ErrorCode.ERROR400);
}
Platform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
PlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(serverGBId);
if (parentPlatform == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
}
if (parentPlatformCatch == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
}
parentPlatform.setEnable(false);
storager.updateParentPlatform(parentPlatform);
// 发送离线消息,无论是否成功都删除缓存
try {
commanderForPlatform.unregister(parentPlatform, parentPlatformCatch.getSipTransactionInfo(), (event -> {
// 清空redis缓存
redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
}), (event -> {
// 清空redis缓存
redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
}));
} catch (InvalidArgumentException | ParseException | SipException e) {
log.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
}
DeferredResult<Object> deferredResult = new DeferredResult<>();
boolean deleteResult = storager.deleteParentPlatform(parentPlatform);
// storager.delCatalogByPlatformId(parentPlatform.getServerGBId());
// storager.delRelationByPlatformId(parentPlatform.getServerGBId());
// 停止发送位置订阅定时任务
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId();
dynamicTask.stop(key);
// 删除缓存的订阅信息
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
if (!deleteResult) {
throw new ControllerException(ErrorCode.ERROR100);
}
platformService.delete(id, (object)->{
deferredResult.setResult(WVPResult.success());
});
return deferredResult;
}
/**
*
*
* @param serverGBId ID
* @return
*/
@Operation(summary = "查询上级平台是否存在", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "serverGBId", description = "上级平台的国标编号")
@GetMapping("/exit/{serverGBId}")
@ResponseBody
public Boolean exitPlatform(@PathVariable String serverGBId) {
Platform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
return parentPlatform != null;
Platform platform = platformService.queryPlatformByServerGBId(serverGBId);
return platform != null;
}
@Operation(summary = "分页查询级联平台的所有所有通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ -332,12 +229,6 @@ public class PlatformController {
}
}
/**
*
*
* @param param
* @return
*/
@Operation(summary = "从上级平台移除国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@DeleteMapping("/channel/remove")
@ResponseBody

View File

@ -9,18 +9,16 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
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.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
@ -53,15 +51,9 @@ import java.util.UUID;
@RequestMapping("/api/play")
public class PlayController {
@Autowired
private SIPCommander cmder;
@Autowired
private VideoStreamSessionManager streamSession;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IInviteStreamService inviteStreamService;

View File

@ -410,4 +410,19 @@ public interface PlatformChannelMapper {
" pgc.device_channel_id = #{channelId}" +
"</script> ")
List<Platform> queryPlatFormListByChannelId(@Param("channelId") int channelId);
@Delete("<script> "+
"DELETE from wvp_platform_channel WHERE platform_id=#{platformId}" +
"</script>")
void removeChannelsByPlatformId(@Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_group WHERE platform_id=#{platformId}" +
"</script>")
void removePlatformGroupsByPlatformId(@Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_region WHERE platform_id=#{platformId}" +
"</script>")
void removePlatformRegionByPlatformId(@Param("platformId") Integer platformId);
}

View File

@ -59,8 +59,8 @@ public interface PlatformMapper {
"WHERE id=#{id}")
int update(Platform parentPlatform);
@Delete("DELETE FROM wvp_platform WHERE server_gb_id=#{serverGBId}")
int delParentPlatform(Platform parentPlatform);
@Delete("DELETE FROM wvp_platform WHERE id=#{id}")
int delete(@Param("id") Integer id);
@Select(" SELECT pp.*, " +
" (SELECT count(0) FROM wvp_platform_channel pc WHERE pc.platform_id = pp.id ) as channel_count" +

View File

@ -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);
}

View File

@ -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()) {

View File

@ -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());
}
}

View File

@ -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) {

View File

@ -6,16 +6,16 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
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;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
@ -50,6 +50,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IRedisRpcService redisRpcService;
@ -57,7 +58,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
private UserSetting userSetting;
@Autowired
private IVideoManagerStorage storager;
private IPlatformService platformService;
@Autowired
private IDeviceService deviceService;
@ -100,7 +101,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
sendRtpItem.getSsrc(),
sendRtpItem.isTcp()?(sendRtpItem.isTcpActive()?"TCP主动":"TCP被动"):"UDP"
);
Platform parentPlatform = storager.queryParentPlatByServerGBId(fromUserId);
Platform parentPlatform = platformService.queryPlatformByServerGBId(fromUserId);
if (parentPlatform != null) {
if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) {

View File

@ -11,12 +11,12 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@ -104,7 +104,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
private IPlayService playService;
@Autowired
private SIPSender sipSender;
private IPlatformService platformService;
@Autowired
private AudioBroadcastManager audioBroadcastManager;
@ -153,7 +153,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
InviteInfo inviteInfo = decode(evt);
// 查询请求是否来自上级平台\设备
Platform platform = storager.queryParentPlatByServerGBId(inviteInfo.getRequesterId());
Platform platform = platformService.queryPlatformByServerGBId(inviteInfo.getRequesterId());
if (platform == null) {
inviteFromDeviceHandle(request, inviteInfo.getRequesterId(), inviteInfo.getChannelId());
} else {
@ -266,7 +266,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
//
//
// // 查询请求是否来自上级平台\设备
// Platform platform = storager.queryParentPlatByServerGBId(requesterId);
// Platform platform = platformService.queryPlatformByServerGBId(requesterId);
//
// if (platform == null) {
// inviteFromDeviceHandle(request, requesterId, channelId);

View File

@ -108,7 +108,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
}
String platformId = SipUtils.getUserIdFromFromHeader(request);
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
Platform platform = storager.queryParentPlatByServerGBId(platformId);
Platform platform = platformService.queryPlatformByServerGBId(platformId);
SubscribeInfo subscribeInfo = new SubscribeInfo(request, platformId);
if (platform == null) {
return;
@ -137,7 +137,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
}
try {
Platform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
Platform parentPlatform = platformService.queryPlatformByServerGBId(platformId);
SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires());
if (subscribeInfo.getExpires() == 0) {
subscribeHolder.removeMobilePositionSubscribe(platformId);
@ -163,7 +163,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
}
String platformId = SipUtils.getUserIdFromFromHeader(request);
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
Platform platform = storager.queryParentPlatByServerGBId(platformId);
Platform platform = platformService.queryPlatformByServerGBId(platformId);
if (platform == null){
return;
}
@ -186,7 +186,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
subscribeHolder.removeCatalogSubscribe(platformId);
}
try {
Platform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
Platform parentPlatform = platformService.queryPlatformByServerGBId(platformId);
SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires());
if (subscribeInfo.getExpires() == 0) {
subscribeHolder.removeCatalogSubscribe(platformId);

View File

@ -4,15 +4,15 @@ import com.genersoft.iot.vmp.common.InviteInfo;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
@ -40,7 +40,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
private SIPProcessorObserver sipProcessorObserver;
@Autowired
private IVideoManagerStorage storage;
private IPlatformService platformService;
@Autowired
private SipSubscribe sipSubscribe;
@ -77,7 +77,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I
// 查询设备是否存在
Device device = redisCatchStorage.getDevice(ssrcTransaction.getDeviceId());
// 查询上级平台是否存在
Platform parentPlatform = storage.queryParentPlatByServerGBId(ssrcTransaction.getDeviceId());
Platform parentPlatform = platformService.queryPlatformByServerGBId(ssrcTransaction.getDeviceId());
try {
if (device != null && parentPlatform != null) {
log.warn("[重复]平台与设备编号重复:{}", ssrcTransaction.getDeviceId());

View File

@ -2,9 +2,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.Platform;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Element;
@ -26,7 +26,7 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>();
@Autowired
private IVideoManagerStorage storage;
private IPlatformService platformService;
public void addHandler(String cmdType, IMessageHandler messageHandler) {
messageHandlerMap.put(cmdType, messageHandler);
@ -49,7 +49,7 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
//两个国标平台互相级联时由于上一步判断导致本该在平台处理的消息 放到了设备的处理逻辑
//所以对目录查询单独做了校验
if(messageHandler instanceof CatalogQueryMessageHandler){
Platform parentPlatform = storage.queryParentPlatByServerGBId(device.getDeviceId());
Platform parentPlatform = platformService.queryPlatformByServerGBId(device.getDeviceId());
messageHandler.handForPlatform(evt, parentPlatform, element);
return;
}

View File

@ -5,13 +5,13 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
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;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;
@ -41,7 +41,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
private SIPProcessorObserver sipProcessorObserver;
@Autowired
private IVideoManagerStorage storage;
private IPlatformService platformService;
@Autowired
private SipSubscribe sipSubscribe;
@ -78,7 +78,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
// 查询设备是否存在
Device device = redisCatchStorage.getDevice(deviceId);
// 查询上级平台是否存在
Platform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);
Platform parentPlatform = platformService.queryPlatformByServerGBId(deviceId);
try {
if (device != null && parentPlatform != null) {
String hostAddress = request.getRemoteAddress().getHostAddress();

View File

@ -7,6 +7,8 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@ -16,9 +18,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.
import com.genersoft.iot.vmp.media.event.hook.Hook;
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
import com.genersoft.iot.vmp.media.event.hook.HookType;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Element;
@ -57,10 +57,7 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IVideoManagerStorage storage;
@Autowired
private VideoStreamSessionManager sessionManager;
private IPlatformService platformService;
@Autowired
private HookSubscribe subscribe;
@ -110,7 +107,7 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
// 如果级联播放,需要给上级发送此通知 TODO 多个上级同时观看一个下级 可能存在停错的问题需要将点播CallId进行上下级绑定
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, ssrcTransaction.getChannelId(), null, null);
if (sendRtpItem != null) {
Platform parentPlatform = storage.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
Platform parentPlatform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
if (parentPlatform == null) {
log.warn("[级联消息发送]发送MediaStatus发现上级平台{}不存在", sendRtpItem.getPlatformId());
return;

View File

@ -10,15 +10,16 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
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.IPlatformService;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
import com.genersoft.iot.vmp.utils.DateUtil;
@ -66,7 +67,7 @@ public class MediaServiceImpl implements IMediaService {
private VideoStreamSessionManager sessionManager;
@Autowired
private IVideoManagerStorage storager;
private IPlatformService platformService;
@Autowired
private IDeviceService deviceService;
@ -234,7 +235,7 @@ public class MediaServiceImpl implements IMediaService {
inviteInfo.getChannelId());
if (!sendRtpItems.isEmpty()) {
for (SendRtpItem sendRtpItem : sendRtpItems) {
Platform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
Platform parentPlatform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
try {
commanderForPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId());
} catch (SipException | InvalidArgumentException | ParseException e) {

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
@ -47,6 +48,9 @@ public class RedisAlarmMsgListener implements MessageListener {
@Autowired
private IVideoManagerStorage storage;
@Autowired
private IPlatformService platformService;
private ConcurrentLinkedQueue<Message> taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")
@ -89,8 +93,8 @@ public class RedisAlarmMsgListener implements MessageListener {
if (ObjectUtils.isEmpty(gbId)) {
if (userSetting.getSendToPlatformsWhenIdLost()) {
// 发送给所有的上级
List<Platform> parentPlatforms = storage.queryEnableParentPlatformList(true);
if (parentPlatforms.size() > 0) {
List<Platform> parentPlatforms = platformService.queryEnablePlatformList();
if (!parentPlatforms.isEmpty()) {
for (Platform parentPlatform : parentPlatforms) {
try {
deviceAlarm.setChannelId(parentPlatform.getDeviceGBId());
@ -130,7 +134,7 @@ public class RedisAlarmMsgListener implements MessageListener {
}else {
Device device = deviceService.getDeviceByDeviceId(gbId);
Platform platform = storage.queryParentPlatByServerGBId(gbId);
Platform platform = platformService.queryPlatformByServerGBId(gbId);
if (device != null && platform == null) {
try {
commander.sendAlarmMessage(device, deviceAlarm);

View File

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.media.bean.MediaInfo;
@ -20,7 +21,6 @@ import com.genersoft.iot.vmp.media.event.hook.HookType;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import lombok.extern.slf4j.Slf4j;
@ -66,7 +66,7 @@ public class RedisRpcController {
@Autowired
private IVideoManagerStorage storager;
private IPlatformService platformService;
/**
@ -317,7 +317,7 @@ public class RedisRpcController {
}
log.info("[redis-rpc] 推流已经停止: {}/{}, 目标地址: {}{}", sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort() );
String platformId = sendRtpItem.getPlatformId();
Platform platform = storager.queryParentPlatByServerGBId(platformId);
Platform platform = platformService.queryPlatformByServerGBId(platformId);
if (platform == null) {
return response;
}

View File

@ -1,10 +1,8 @@
package com.genersoft.iot.vmp.storager;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import java.util.List;
@ -17,41 +15,6 @@ import java.util.List;
public interface IVideoManagerStorage {
/**
*
* @param parentPlatform
*/
boolean updateParentPlatform(Platform parentPlatform);
/**
*
* @param parentPlatform
*/
boolean deleteParentPlatform(Platform parentPlatform);
/**
*
* @return
*/
List<Platform> queryEnableParentPlatformList(boolean enable);
/**
*
* @param platformGbId
* @return
*/
Platform queryParentPlatByServerGBId(String platformGbId);
/**
*
* @param platformId
* @param channelReduces
* @return
*/
int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);

View File

@ -1,17 +1,17 @@
package com.genersoft.iot.vmp.storager.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.dao.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
@ -56,92 +56,11 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime);
}
@Override
public boolean updateParentPlatform(Platform parentPlatform) {
int result = 0;
if (parentPlatform.getCatalogGroup() == 0) {
parentPlatform.setCatalogGroup(1);
}
PlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
if (parentPlatform.getId() == null ) {
result = platformMapper.add(parentPlatform);
if (parentPlatformCatch == null) {
parentPlatformCatch = new PlatformCatch();
parentPlatformCatch.setPlatform(parentPlatform);
parentPlatformCatch.setId(parentPlatform.getServerGBId());
}
}else {
if (parentPlatformCatch == null) { // serverGBId 已变化
Platform parentPlatById = platformMapper.query(parentPlatform.getId());
// 使用旧的查出缓存ID
parentPlatformCatch = new PlatformCatch();
parentPlatformCatch.setId(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
}
result = platformMapper.update(parentPlatform);
}
// 更新缓存
parentPlatformCatch.setPlatform(parentPlatform);
redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
return result > 0;
}
@Transactional
@Override
public boolean deleteParentPlatform(Platform parentPlatform) {
int result = platformMapper.delParentPlatform(parentPlatform);
// 删除关联的通道
platformChannelMapper.cleanChannelForGB(parentPlatform.getServerGBId());
return result > 0;
}
@Override
public Platform queryParentPlatByServerGBId(String platformGbId) {
return platformMapper.getParentPlatByServerGBId(platformGbId);
}
@Override
public List<Platform> queryEnableParentPlatformList(boolean enable) {
return platformMapper.getEnableParentPlatformList(enable);
}
@Override
public List<Platform> queryEnablePlatformListWithAsMessageChannel() {
return platformMapper.queryEnablePlatformListWithAsMessageChannel();
}
@Override
public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
int result = platformChannelMapper.delChannelForGB(platformId, channelReduces);
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (ChannelReduce channelReduce : channelReduces) {
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(channelReduce.getChannelId());
deviceChannelList.add(deviceChannel);
}
// eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
return result;
}
@Override
public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) {
List<DeviceChannel> channels = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId);
if (channels.size() > 1) {
// 出现长度大于0的时候肯定是国标通道的ID重复了
log.warn("国标ID存在重复{}", channelId);
}
if (channels.size() == 0) {
return null;
}else {
return channels.get(0);
}
}
@Override
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
List<Device> devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);

View File

@ -4,16 +4,18 @@
<div class="page-header">
<div class="page-title">上级平台列表</div>
<div class="page-header-btn">
<el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addParentPlatform"></el-button>
<el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary"
@click="addParentPlatform">添加
</el-button>
<el-button icon="el-icon-refresh-right" circle size="mini" @click="refresh()"></el-button>
</div>
</div>
<!--设备列表-->
<el-table size="medium" :data="platformList" style="width: 100%" :height="winHeight">
<el-table-column prop="name" label="名称" ></el-table-column>
<el-table size="medium" :data="platformList" style="width: 100%" :height="winHeight" :loading="loading">
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="serverGBId" label="平台编号" min-width="200"></el-table-column>
<el-table-column label="是否启用" min-width="80" >
<el-table-column label="是否启用" min-width="80">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.enable"></el-tag>
@ -21,7 +23,7 @@
</div>
</template>
</el-table-column>
<el-table-column label="状态" min-width="80" >
<el-table-column label="状态" min-width="80">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.status">线</el-tag>
@ -29,33 +31,42 @@
</div>
</template>
</el-table-column>
<el-table-column label="地址" min-width="160" >
<el-table-column label="地址" min-width="160">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.serverIp}}:{{scope.row.serverPort }}</el-tag>
<el-tag size="medium">{{ scope.row.serverIp }}:{{ scope.row.serverPort }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column prop="deviceGBId" label="设备国标编号" min-width="200" ></el-table-column>
<el-table-column prop="transport" label="信令传输模式" min-width="120" ></el-table-column>
<el-table-column prop="channelCount" label="通道数" min-width="120" ></el-table-column>
<el-table-column label="订阅信息" min-width="120" fixed="right">
<el-table-column prop="deviceGBId" label="设备国标编号" min-width="200"></el-table-column>
<el-table-column prop="transport" label="信令传输模式" min-width="120"></el-table-column>
<el-table-column prop="channelCount" label="通道数" min-width="120"></el-table-column>
<el-table-column label="订阅信息" min-width="120" fixed="right">
<template slot-scope="scope">
<i v-if="scope.row.alarmSubscribe" style="font-size: 20px" title="报警订阅" class="iconfont icon-gbaojings subscribe-on " ></i>
<i v-if="!scope.row.alarmSubscribe" style="font-size: 20px" title="报警订阅" class="iconfont icon-gbaojings subscribe-off " ></i>
<i v-if="scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-on" ></i>
<i v-if="!scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-off" ></i>
<i v-if="scope.row.mobilePositionSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-on" ></i>
<i v-if="!scope.row.mobilePositionSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-off" ></i>
<i v-if="scope.row.alarmSubscribe" style="font-size: 20px" title="报警订阅"
class="iconfont icon-gbaojings subscribe-on "></i>
<i v-if="!scope.row.alarmSubscribe" style="font-size: 20px" title="报警订阅"
class="iconfont icon-gbaojings subscribe-off "></i>
<i v-if="scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-on"></i>
<i v-if="!scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-off"></i>
<i v-if="scope.row.mobilePositionSubscribe" title="位置订阅"
class="iconfont icon-gxunjians subscribe-on"></i>
<i v-if="!scope.row.mobilePositionSubscribe" title="位置订阅"
class="iconfont icon-gxunjians subscribe-off"></i>
</template>
</el-table-column>
<el-table-column label="操作" min-width="240" fixed="right">
<template slot-scope="scope">
<el-button size="medium" icon="el-icon-edit" type="text" @click="editPlatform(scope.row)"></el-button>
<el-button size="medium" icon="el-icon-share" type="text" @click="chooseChannel(scope.row)"></el-button>
<el-button size="medium" icon="el-icon-top" type="text" :loading="pushChannelLoading" @click="pushChannel(scope.row)"></el-button>
<el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c" @click="deletePlatform(scope.row)"></el-button>
<el-button size="medium" icon="el-icon-share" type="text" @click="chooseChannel(scope.row)">
</el-button>
<el-button size="medium" icon="el-icon-top" type="text" :loading="pushChannelLoading"
@click="pushChannel(scope.row)">推送通道
</el-button>
<el-button size="medium" icon="el-icon-delete" type="text" style="color: #f56c6c"
@click="deletePlatform(scope.row)">删除
</el-button>
</template>
</el-table-column>
</el-table>
@ -71,8 +82,9 @@
</el-pagination>
</div>
<platformEdit ref="platformEdit" v-if="platform" v-model="platform" :closeEdit="closeEdit" :device-ips="deviceIps" ></platformEdit>
<shareChannel ref="shareChannel" ></shareChannel>
<platformEdit ref="platformEdit" v-if="platform" v-model="platform" :closeEdit="closeEdit"
:device-ips="deviceIps"></platformEdit>
<shareChannel ref="shareChannel"></shareChannel>
</div>
</template>
@ -81,6 +93,7 @@ import uiHeader from '../layout/UiHeader.vue'
import shareChannel from './dialog/shareChannel.vue'
import platformEdit from './PlatformEdit.vue'
import streamProxyEdit from "./dialog/StreamProxyEdit.vue";
export default {
name: 'app',
components: {
@ -91,23 +104,19 @@ export default {
},
data() {
return {
loading: false,
platformList: [], //
deviceIps: [], //
defaultPlatform: null,
platform: null,
pushChannelLoading: false,
winHeight: window.innerHeight - 260,
currentPage:1,
count:15,
total:0
currentPage: 1,
count: 15,
total: 0
};
},
computed: {
getcurrentDeviceChannels: function() {
}
},
computed: {},
mounted() {
this.initData();
this.updateLooper = setInterval(this.initData, 10000);
@ -116,48 +125,54 @@ export default {
clearTimeout(this.updateLooper);
},
methods: {
addParentPlatform: function() {
addParentPlatform: function () {
this.platform = this.defaultPlatform;
},
editPlatform: function(platform) {
editPlatform: function (platform) {
this.platform = platform;
},
closeEdit: function() {
closeEdit: function () {
this.platform = null;
this.getPlatformList()
},
deletePlatform: function(platform) {
var that = this;
that.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
that.deletePlatformCommit(platform)
})
deletePlatform: function (platform) {
this.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.deletePlatformCommit(platform)
})
},
deletePlatformCommit: function(platform) {
var that = this;
that.$axios({
method: 'delete',
url:`/api/platform/delete/${platform.serverGBId}`
}).then(function (res) {
if (res.data.code === 0) {
that.$message({
showClose: true,
message: '删除成功',
type: 'success'
});
that.initData()
}
}).catch(function (error) {
console.log(error);
deletePlatformCommit: function (platform) {
this.loading = true;
this.$axios({
method: 'delete',
url: `/api/platform/delete/`,
params: {
id: platform.id
}
}).then((res) => {
this.loading = false;
if (res.data.code === 0) {
this.$message.success({
showClose: true,
message: '删除成功',
});
this.initData()
}
}).catch((error) => {
this.loading = false;
this.$message.error({
showClose: true,
message: error,
});
});
},
chooseChannel: function(platform) {
chooseChannel: function (platform) {
this.$refs.shareChannel.openDialog(platform.id, this.initData)
},
pushChannel: function(row) {
pushChannel: function (row) {
this.pushChannelLoading = true;
this.$axios({
method: 'get',
@ -165,20 +180,20 @@ export default {
params: {
id: row.id,
}
}).then((res)=> {
}).then((res) => {
this.pushChannelLoading = false;
if (res.data.code === 0) {
this.$message.success({
showClose: true,
message: '推送成功',
});
}else {
} else {
this.$message.error({
showClose: true,
message: res.data.msg,
});
}
}).catch((error)=> {
}).catch((error) => {
console.log(error);
this.pushChannelLoading = false;
this.$message.error({
@ -187,11 +202,11 @@ export default {
});
});
},
initData: function() {
initData: function () {
this.$axios({
method: 'get',
url: `/api/platform/server_config`
}).then((res)=> {
}).then((res) => {
if (res.data.code === 0) {
this.deviceIps = res.data.data.deviceIp.split(',');
this.defaultPlatform = {
@ -234,20 +249,20 @@ export default {
});
this.getPlatformList();
},
currentChange: function(val){
currentChange: function (val) {
this.currentPage = val;
this.getPlatformList();
},
handleSizeChange: function(val){
handleSizeChange: function (val) {
this.count = val;
this.getPlatformList();
},
getPlatformList: function() {
getPlatformList: function () {
let that = this;
this.$axios({
method: 'get',
url:`/api/platform/query/${that.count}/${that.currentPage}`
method: 'get',
url: `/api/platform/query/${that.count}/${that.currentPage}`
}).then(function (res) {
if (res.data.code === 0) {
that.total = res.data.data.total;
@ -259,7 +274,7 @@ export default {
});
},
refresh: function (){
refresh: function () {
this.initData();
}
@ -267,11 +282,12 @@ export default {
};
</script>
<style>
.subscribe-on{
.subscribe-on {
color: #409EFF;
font-size: 18px;
}
.subscribe-off{
.subscribe-off {
color: #afafb3;
font-size: 18px;
}