From 8f77d0c25cdd37d4cc96c923b46ae28607bae51d Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: 星期四, 18 八月 2022 16:17:23 +0800 Subject: [PATCH] 根据redis消息更新推流列表 --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index b26ae76..7a22693 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; +import com.genersoft.iot.vmp.gb28181.bean.TreeType; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.service.IPlatformChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; @@ -29,7 +32,6 @@ import com.genersoft.iot.vmp.conf.SipConfig; import java.util.List; -import java.util.Locale; /** * 绾ц仈骞冲彴绠$悊 @@ -43,10 +45,13 @@ private final static Logger logger = LoggerFactory.getLogger(PlatformController.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; + + @Autowired + private IPlatformChannelService platformChannelService; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -118,7 +123,7 @@ PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count); if (parentPlatformPageInfo.getList().size() > 0) { for (ParentPlatform platform : parentPlatformPageInfo.getList()) { - platform.setGpsSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); + platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null); } } @@ -170,6 +175,8 @@ wvpResult.setMsg("骞冲彴 " + parentPlatform.getServerGBId() + " 宸插瓨鍦�"); return new ResponseEntity<>(wvpResult, HttpStatus.OK); } + parentPlatform.setCreateTime(DateUtil.getNow()); + parentPlatform.setUpdateTime(DateUtil.getNow()); boolean updateResult = storager.updateParentPlatform(parentPlatform); if (updateResult) { @@ -233,7 +240,13 @@ } parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); + parentPlatform.setUpdateTime(DateUtil.getNow()); + if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) { + // 鐩綍缁撴瀯鍙戠敓鍙樺寲锛屾竻绌轰箣鍓嶇殑鍏宠仈鍏崇郴 + logger.info("淇濆瓨骞冲彴{}鏃跺彂鐜扮洰褰曠粨鏋勫彉鍖栵紝娓呯┖鍏宠仈鍏崇郴", parentPlatform.getDeviceGBId()); + storager.cleanContentForPlatform(parentPlatform.getServerGBId()); + } boolean updateResult = storager.updateParentPlatform(parentPlatform); if (updateResult) { @@ -254,6 +267,8 @@ } } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 鍏抽棴鍚敤鏃舵敞閿� commanderForPlatform.unregister(parentPlatformOld, null, null); + // 鍋滄璁㈤槄鐩稿叧鐨勫畾鏃朵换鍔� + subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); } wvpResult.setCode(0); wvpResult.setMsg("success"); @@ -287,7 +302,9 @@ return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); } ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); - if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK); + if (parentPlatform == null) { + return new ResponseEntity<>("fail", HttpStatus.OK); + } // 鍙戦�佺绾挎秷鎭�,鏃犺鏄惁鎴愬姛閮藉垹闄ょ紦瀛� commanderForPlatform.unregister(parentPlatform, (event -> { // 娓呯┖redis缂撳瓨 @@ -305,7 +322,7 @@ storager.delCatalogByPlatformId(parentPlatform.getServerGBId()); storager.delRelationByPlatformId(parentPlatform.getServerGBId()); // 鍋滄鍙戦�佷綅缃闃呭畾鏃朵换鍔� - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); dynamicTask.stop(key); // 鍒犻櫎缂撳瓨鐨勮闃呬俊鎭� subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); @@ -401,7 +418,7 @@ if (logger.isDebugEnabled()) { logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤"); } - int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); + int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); } @@ -447,13 +464,20 @@ if (logger.isDebugEnabled()) { logger.debug("鏌ヨ鐩綍,platformId: {}, parentId: {}", platformId, parentId); } + ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); + if (platform == null) { + return new ResponseEntity<>(new WVPResult<>(400, "骞冲彴鏈壘鍒�", null), HttpStatus.OK); + } + if (platformId.equals(parentId)) { + parentId = platform.getDeviceGBId(); + } List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); - // 鏌ヨ涓嬪睘鐨勫浗鏍囬�氶亾 -// List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); - // 鏌ヨ涓嬪睘鐨勭洿鎾祦閫氶亾 -// List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); -// platformCatalogList.addAll(catalogsForChannel); -// platformCatalogList.addAll(catalogsForStream); +// if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) { +// platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); +// }else { +// +// } + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); result.setCode(0); result.setMsg("success"); @@ -480,7 +504,6 @@ } PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); - if (platformCatalogInStore != null) { result.setCode(-1); -- Gitblit v1.8.0