临时提交
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user