Browse Source

行政区划作为级联数据的处理,修复设备树的显示

pull/457/head
648540858 2 years ago
parent
commit
9ce22eba3c
  1. 19
      src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
  3. 9
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
  4. 6
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
  5. 4
      web_src/src/components/common/DeviceTree.vue
  6. 17
      web_src/src/components/devicePosition.vue
  7. 15
      web_src/src/components/service/DeviceService.js

19
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.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
if (XmlUtil.getText(itemDevice, "Parental") == null if (XmlUtil.getText(itemDevice, "Parental") == null
|| XmlUtil.getText(itemDevice, "Parental") == "") { || XmlUtil.getText(itemDevice, "Parental") == "") {
deviceChannel.setParental(0); deviceChannel.setParental(0);
@ -212,12 +213,28 @@ public class XmlUtil {
} }
deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
String parentId = XmlUtil.getText(itemDevice, "ParentID"); String parentId = XmlUtil.getText(itemDevice, "ParentID");
if (parentId != null && parentId.contains("/")) { if (parentId != null) {
if (parentId.contains("/")) {
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
deviceChannel.setParentId(lastParentId); deviceChannel.setParentId(lastParentId);
}else { }else {
deviceChannel.setParentId(parentId); deviceChannel.setParentId(parentId);
} }
}else {
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 if (XmlUtil.getText(itemDevice, "SafetyWay") == null
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") { || XmlUtil.getText(itemDevice, "SafetyWay") == "") {

2
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java

@ -89,7 +89,7 @@ public interface IVideoManagerStorage {
* @param count 每页数量 * @param count 每页数量
* @return * @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<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);

9
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@ -340,10 +340,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
@Override @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); PageHelper.startPage(page, count);
List<DeviceChannel> all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); List<DeviceChannel> 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); return new PageInfo<>(all);
} }

6
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="query", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线" ,dataTypeClass = Boolean.class), @ApiImplicitParam(name="online", value = "是否在线" ,dataTypeClass = Boolean.class),
@ApiImplicitParam(name="channelType", value = "设备/子目录-> false/true" ,dataTypeClass = Boolean.class), @ApiImplicitParam(name="channelType", value = "设备/子目录-> false/true" ,dataTypeClass = Boolean.class),
@ApiImplicitParam(name="catalogUnderDevice", value = "是否直属与设备的目录" ,dataTypeClass = Boolean.class),
}) })
public ResponseEntity<PageInfo> channels(@PathVariable String deviceId, public ResponseEntity<PageInfo> channels(@PathVariable String deviceId,
int page, int count, int page, int count,
@RequestParam(required = false) String query, @RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online, @RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType) { @RequestParam(required = false) Boolean channelType,
@RequestParam(required = false) Boolean catalogUnderDevice) {
// if (logger.isDebugEnabled()) { // if (logger.isDebugEnabled()) {
// logger.debug("查询视频设备通道API调用"); // logger.debug("查询视频设备通道API调用");
// } // }
@ -141,7 +143,7 @@ public class DeviceQuery {
query = null; 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); return new ResponseEntity<>(pageResult,HttpStatus.OK);
} }

4
web_src/src/components/common/DeviceTree.vue

@ -89,8 +89,8 @@ export default {
}) })
} }
if (node.level === 1) { if (node.level === 1) {
this.deviceService.getAllChannel(true, node.data.id, (catalogData) => { this.deviceService.getAllChannel(true, true, node.data.id, (catalogData) => {
this.deviceService.getAllChannel(false, node.data.id, (channelData) => { this.deviceService.getAllChannel(false, true, node.data.id, (channelData) => {
let data = catalogData.concat(channelData) let data = catalogData.concat(channelData)
this.channelDataHandler(data, resolve) this.channelDataHandler(data, resolve)
}) })

17
web_src/src/components/devicePosition.vue

@ -14,13 +14,14 @@
<div ref="infobox" v-if="channel != null " > <div ref="infobox" v-if="channel != null " >
<div v-if="channel != null" class="infobox-content"> <div v-if="channel != null" class="infobox-content">
<el-descriptions class="margin-top" :title="channel.name" :column="1" :colon="true" size="mini" :labelStyle="labelStyle" > <el-descriptions class="margin-top" :title="channel.name" :column="1" :colon="true" size="mini" :labelStyle="labelStyle" >
<el-descriptions-item label="生产厂商">{{channel.manufacture}}</el-descriptions-item> <el-descriptions-item label="编号" >{{channel.channelId}}</el-descriptions-item>
<el-descriptions-item label="型号">{{channel.model}}</el-descriptions-item> <el-descriptions-item label="型号">{{channel.model}}</el-descriptions-item>
<el-descriptions-item label="设备归属" >{{channel.owner}}</el-descriptions-item> <el-descriptions-item label="经纬度" >{{channel.longitude}},{{channel.latitude}}</el-descriptions-item>
<el-descriptions-item label="生产厂商">{{channel.manufacture}}</el-descriptions-item>
<el-descriptions-item label="行政区域" >{{channel.civilCode}}</el-descriptions-item> <el-descriptions-item label="行政区域" >{{channel.civilCode}}</el-descriptions-item>
<el-descriptions-item label="设备归属" >{{channel.owner}}</el-descriptions-item>
<el-descriptions-item label="安装地址" >{{channel.address == null?'未知': channel.address}}</el-descriptions-item> <el-descriptions-item label="安装地址" >{{channel.address == null?'未知': channel.address}}</el-descriptions-item>
<el-descriptions-item label="云台类型" >{{channel.ptztypeText}}</el-descriptions-item> <el-descriptions-item label="云台类型" >{{channel.ptztypeText}}</el-descriptions-item>
<el-descriptions-item label="经纬度" >{{channel.longitude}},{{channel.latitude}}</el-descriptions-item>
<el-descriptions-item label="状态"> <el-descriptions-item label="状态">
<el-tag size="small" v-if="channel.status === 1">在线</el-tag> <el-tag size="small" v-if="channel.status === 1">在线</el-tag>
<el-tag size="small" type="info" v-if="channel.status === 0">离线</el-tag> <el-tag size="small" type="info" v-if="channel.status === 0">离线</el-tag>
@ -75,7 +76,7 @@ export default {
console.log(this.$route.query.deviceId) console.log(this.$route.query.deviceId)
// this.$refs.deviceTree.openByDeivceId(this.$route.query.deivceId) // this.$refs.deviceTree.openByDeivceId(this.$route.query.deivceId)
setTimeout(()=>{ // TODO setTimeout(()=>{ // TODO
this.deviceService.getAllChannel(false, this.$route.query.deviceId, this.channelsHandler) this.deviceService.getAllChannel(false, false, this.$route.query.deviceId, this.channelsHandler)
}, 1000) }, 1000)
} }
@ -141,9 +142,15 @@ export default {
zIndex: 3000, // z-index zIndex: 3000, // z-index
}); });
} else { } else {
if (typeof data.channelId === "undefined") {
this.deviceOrSubChannelMenu(event, data)
}else {
// TODO ,
this.deviceOrSubChannelMenu(event, data) this.deviceOrSubChannelMenu(event, data)
} }
}
}, },
deviceOrSubChannelMenu: function (event, data) { deviceOrSubChannelMenu: function (event, data) {
// //
@ -155,7 +162,7 @@ export default {
disabled: false, disabled: false,
onClick: () => { onClick: () => {
if (!data.channelId) { 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) { if (data.channelId && data.subCount > 0) {
// //

15
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 currentPage = 1;
let count = 100; let count = 100;
let catalogList = [] 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) { getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) {
this.getChanel(isCatalog, deviceId, currentPage, count, (data) => { this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => {
if (data.list) { if (data.list) {
catalogList = catalogList.concat(data.list); catalogList = catalogList.concat(data.list);
if (catalogList.length < data.total) { if (catalogList.length < data.total) {
currentPage ++ currentPage ++
this.getAllChannelIteration(isCatalog, deviceId, catalogList, currentPage, count, callback, errorCallback) this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback)
}else { }else {
console.log(1) console.log(1)
if (typeof (callback) == "function") callback(catalogList) if (typeof (callback) == "function") callback(catalogList)
@ -66,7 +66,7 @@ class DeviceService{
} }
}, errorCallback) }, errorCallback)
} }
getChanel(isCatalog, deviceId, currentPage, count, callback, errorCallback) { getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, callback, errorCallback) {
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: `/api/device/query/devices/${deviceId}/channels`, url: `/api/device/query/devices/${deviceId}/channels`,
@ -75,7 +75,8 @@ class DeviceService{
count: count, count: count,
query: "", query: "",
online: "", online: "",
channelType: isCatalog channelType: isCatalog,
catalogUnderDevice: catalogUnderDevice
} }
}).then((res) =>{ }).then((res) =>{
if (typeof (callback) == "function") callback(res.data) if (typeof (callback) == "function") callback(res.data)

Loading…
Cancel
Save