diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java index de75437a6..fdde8bf57 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java @@ -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"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java index f91d16625..5b13b30e2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java @@ -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 platforms(@PathVariable int page, @PathVariable int count) { PageInfo 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 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 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 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java index aca17d9ec..28900e59a 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlayController.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java index 80466cc68..9537b428f 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java @@ -410,4 +410,19 @@ public interface PlatformChannelMapper { " pgc.device_channel_id = #{channelId}" + " ") List queryPlatFormListByChannelId(@Param("channelId") int channelId); + + @Delete("") + void removeChannelsByPlatformId(@Param("platformId") Integer platformId); + + @Delete("") + void removePlatformGroupsByPlatformId(@Param("platformId") Integer platformId); + + @Delete("") + void removePlatformRegionByPlatformId(@Param("platformId") Integer platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java index 647ad7983..90d94a92e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java @@ -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" + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java index 501887600..a91a7b28a 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java @@ -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 queryEnablePlatformList(); - + void delete(Integer platformId, CommonCallback callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index a9d6a7c2a..5c7b40811 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -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 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 channelIds) { List 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 channelIds) { List channelList = platformChannelMapper.queryShare(platformId, channelIds); Assert.notEmpty(channelList, "所选通道未共享"); @@ -343,7 +343,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { } @Override - @Transient + @Transactional public void removeChannels(List ids) { List platformList = platformChannelMapper.queryPlatFormListByChannelList(ids); if (platformList.isEmpty()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java index 42f0bc958..7f47232f8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java @@ -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 queryEnablePlatformList() { return platformMapper.queryEnablePlatformList(); } + + @Override + @Transactional + public void delete(Integer platformId, CommonCallback 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()); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 227431b9e..c91e6cc78 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -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) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java index 52976144e..a3c0675f3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java @@ -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())) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 061a9eaea..c6d69beb4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -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); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 262abf381..ca05fe308 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -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); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index 3cdbbfe3c..8027ef5e2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -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()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java index e694db2b6..9dbf4a4ed 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java @@ -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 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; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 8af2fd89d..a18363ab4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -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(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java index 24f9e0203..4ef74c5fa 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 1e75b4343..6f122e7b3 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -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) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 670f8556c..ecfe56762 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -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 taskQueue = new ConcurrentLinkedQueue<>(); @Qualifier("taskExecutor") @@ -89,8 +93,8 @@ public class RedisAlarmMsgListener implements MessageListener { if (ObjectUtils.isEmpty(gbId)) { if (userSetting.getSendToPlatformsWhenIdLost()) { // 发送给所有的上级 - List parentPlatforms = storage.queryEnableParentPlatformList(true); - if (parentPlatforms.size() > 0) { + List 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); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java index b00c272b3..43b8bf3a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcController.java @@ -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; } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 8c7e87f91..c62d45cd8 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -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 queryEnableParentPlatformList(boolean enable); - - /** - * 获取上级平台 - * @param platformGbId - * @return - */ - Platform queryParentPlatByServerGBId(String platformGbId); - - /** - * 移除上级平台的通道信息 - * @param platformId - * @param channelReduces - * @return - */ - int delChannelForGB(String platformId, List channelReduces); - - - DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index acda619da..726da75e4 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -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 queryEnableParentPlatformList(boolean enable) { - return platformMapper.getEnableParentPlatformList(enable); - } - @Override public List queryEnablePlatformListWithAsMessageChannel() { return platformMapper.queryEnablePlatformListWithAsMessageChannel(); } - - - @Override - public int delChannelForGB(String platformId, List channelReduces) { - - int result = platformChannelMapper.delChannelForGB(platformId, channelReduces); - List 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 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 devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); diff --git a/web_src/src/components/PlatformList.vue b/web_src/src/components/PlatformList.vue index f72cbcf31..9d1ac90d7 100755 --- a/web_src/src/components/PlatformList.vue +++ b/web_src/src/components/PlatformList.vue @@ -4,16 +4,18 @@ - - + + - + - + - + - - - - + + + + @@ -71,8 +82,9 @@ - - + + @@ -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 { };