From 9ce22eba3c561d353e12c66c509fb91ca241409f Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: Tue, 26 Apr 2022 17:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E6=94=BF=E5=8C=BA=E5=88=92=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E7=BA=A7=E8=81=94=E6=95=B0=E6=8D=AE=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86,=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87=E6=A0=91?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/utils/XmlUtil.java | 27 +++++++++++++++---- .../vmp/storager/IVideoManagerStorage.java | 2 +- .../impl/VideoManagerStorageImpl.java | 9 +++++-- .../vmanager/gb28181/device/DeviceQuery.java | 6 +++-- web_src/src/components/common/DeviceTree.vue | 4 +-- web_src/src/components/devicePosition.vue | 19 ++++++++----- .../src/components/service/DeviceService.js | 15 ++++++----- 7 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 6ae09bda..1a879968 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -204,6 +204,7 @@ public class XmlUtil { deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); + String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID"); if (XmlUtil.getText(itemDevice, "Parental") == null || XmlUtil.getText(itemDevice, "Parental") == "") { deviceChannel.setParental(0); @@ -212,11 +213,27 @@ public class XmlUtil { } deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); String parentId = XmlUtil.getText(itemDevice, "ParentID"); - if (parentId != null && parentId.contains("/")) { - String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); - deviceChannel.setParentId(lastParentId); + if (parentId != null) { + if (parentId.contains("/")) { + String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); + deviceChannel.setParentId(lastParentId); + }else { + deviceChannel.setParentId(parentId); + } }else { - deviceChannel.setParentId(parentId); + if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联 + deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2)); + }else if (deviceChannel.getChannelId().length() == 20) { + if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织 + deviceChannel.setParentId(businessGroupID); + }else if (deviceChannel.getCivilCode() != null) { + // 设备, 无parentId的20位是使用CivilCode表示上级的设备, + // 注:215 业务分组是需要有parentId的 + deviceChannel.setParentId(deviceChannel.getCivilCode()); + } + }else { + deviceChannel.setParentId(deviceChannel.getDeviceId()); + } } if (XmlUtil.getText(itemDevice, "SafetyWay") == null @@ -277,4 +294,4 @@ public class XmlUtil { deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC return deviceChannel; } -} +} \ No newline at end of file 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 d3a9ae9e..a29b7ae9 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -89,7 +89,7 @@ public interface IVideoManagerStorage { * @param count 每页数量 * @return */ - public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count); + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); 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 661a69b3..070e3124 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -340,10 +340,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } @Override - public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count) { // 获取到所有正在播放的流 PageHelper.startPage(page, count); - List all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); + List all; + if (catalogUnderDevice != null && catalogUnderDevice) { + all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); + }else { + all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); + } return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index ab153ad4..708008ed 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -128,12 +128,14 @@ public class DeviceQuery { @ApiImplicitParam(name="query", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="online", value = "是否在线" ,dataTypeClass = Boolean.class), @ApiImplicitParam(name="channelType", value = "设备/子目录-> false/true" ,dataTypeClass = Boolean.class), + @ApiImplicitParam(name="catalogUnderDevice", value = "是否直属与设备的目录" ,dataTypeClass = Boolean.class), }) public ResponseEntity channels(@PathVariable String deviceId, int page, int count, @RequestParam(required = false) String query, @RequestParam(required = false) Boolean online, - @RequestParam(required = false) Boolean channelType) { + @RequestParam(required = false) Boolean channelType, + @RequestParam(required = false) Boolean catalogUnderDevice) { // if (logger.isDebugEnabled()) { // logger.debug("查询视频设备通道API调用"); // } @@ -141,7 +143,7 @@ public class DeviceQuery { query = null; } - PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); + PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, catalogUnderDevice, page, count); return new ResponseEntity<>(pageResult,HttpStatus.OK); } diff --git a/web_src/src/components/common/DeviceTree.vue b/web_src/src/components/common/DeviceTree.vue index fab895fd..31e49bdd 100644 --- a/web_src/src/components/common/DeviceTree.vue +++ b/web_src/src/components/common/DeviceTree.vue @@ -89,8 +89,8 @@ export default { }) } if (node.level === 1) { - this.deviceService.getAllChannel(true, node.data.id, (catalogData) => { - this.deviceService.getAllChannel(false, node.data.id, (channelData) => { + this.deviceService.getAllChannel(true, true, node.data.id, (catalogData) => { + this.deviceService.getAllChannel(false, true, node.data.id, (channelData) => { let data = catalogData.concat(channelData) this.channelDataHandler(data, resolve) }) diff --git a/web_src/src/components/devicePosition.vue b/web_src/src/components/devicePosition.vue index a8073638..16675c90 100644 --- a/web_src/src/components/devicePosition.vue +++ b/web_src/src/components/devicePosition.vue @@ -14,13 +14,14 @@
- {{channel.manufacture}} + {{channel.channelId}} {{channel.model}} - {{channel.owner}} + {{channel.longitude}},{{channel.latitude}} + {{channel.manufacture}} {{channel.civilCode}} + {{channel.owner}} {{channel.address == null?'未知': channel.address}} {{channel.ptztypeText}} - {{channel.longitude}},{{channel.latitude}} 在线 离线 @@ -75,7 +76,7 @@ export default { console.log(this.$route.query.deviceId) // this.$refs.deviceTree.openByDeivceId(this.$route.query.deivceId) setTimeout(()=>{ // 延迟以等待地图加载完成 TODO 后续修改为通过是实际这;状态加回调完成 - this.deviceService.getAllChannel(false, this.$route.query.deviceId, this.channelsHandler) + this.deviceService.getAllChannel(false, false, this.$route.query.deviceId, this.channelsHandler) }, 1000) } @@ -141,7 +142,13 @@ export default { zIndex: 3000, // 菜单样式 z-index }); } else { - this.deviceOrSubChannelMenu(event, data) + if (typeof data.channelId === "undefined") { + this.deviceOrSubChannelMenu(event, data) + }else { + // TODO 子目录暂时不支持查询他下面所有设备, 支持支持查询直属于这个目录的设备 + this.deviceOrSubChannelMenu(event, data) + } + } }, @@ -155,7 +162,7 @@ export default { disabled: false, onClick: () => { if (!data.channelId) { - this.deviceService.getAllChannel(false, data.deviceId, this.channelsHandler) + this.deviceService.getAllChannel(false, false, data.deviceId, this.channelsHandler) } if (data.channelId && data.subCount > 0) { // 点击子目录 diff --git a/web_src/src/components/service/DeviceService.js b/web_src/src/components/service/DeviceService.js index 6149579b..dbe10d18 100644 --- a/web_src/src/components/service/DeviceService.js +++ b/web_src/src/components/service/DeviceService.js @@ -45,20 +45,20 @@ class DeviceService{ } - getAllChannel(isCatalog, deviceId, callback, errorCallback) { + getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, errorCallback) { let currentPage = 1; let count = 100; let catalogList = [] - this.getAllChannelIteration(isCatalog, deviceId, catalogList, currentPage, count, callback, errorCallback) + this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) } - getAllChannelIteration(isCatalog, deviceId, catalogList, currentPage, count, callback, errorCallback) { - this.getChanel(isCatalog, deviceId, currentPage, count, (data) => { + getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) { + this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => { if (data.list) { catalogList = catalogList.concat(data.list); if (catalogList.length < data.total) { currentPage ++ - this.getAllChannelIteration(isCatalog, deviceId, catalogList, currentPage, count, callback, errorCallback) + this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) }else { console.log(1) if (typeof (callback) == "function") callback(catalogList) @@ -66,7 +66,7 @@ class DeviceService{ } }, errorCallback) } - getChanel(isCatalog, deviceId, currentPage, count, callback, errorCallback) { + getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, callback, errorCallback) { this.$axios({ method: 'get', url: `/api/device/query/devices/${deviceId}/channels`, @@ -75,7 +75,8 @@ class DeviceService{ count: count, query: "", online: "", - channelType: isCatalog + channelType: isCatalog, + catalogUnderDevice: catalogUnderDevice } }).then((res) =>{ if (typeof (callback) == "function") callback(res.data)