diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index e01c40bd..30fae105 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -2,11 +2,13 @@ package com.genersoft.iot.vmp.gb28181.bean; import com.genersoft.iot.vmp.gb28181.utils.MessageElement; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; +import com.genersoft.iot.vmp.utils.CivilCodeUtil; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; +import org.springframework.util.ObjectUtils; import java.lang.reflect.InvocationTargetException; @@ -218,7 +220,18 @@ public class DeviceChannel extends CommonGBChannel { } public static DeviceChannel decode(Element element) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { - return XmlUtil.elementDecode(element, DeviceChannel.class); + DeviceChannel deviceChannel = XmlUtil.elementDecode(element, DeviceChannel.class); + if(deviceChannel.getCivilCode() != null ) { + if (ObjectUtils.isEmpty(deviceChannel.getCivilCode()) + || deviceChannel.getCivilCode().length() > 8 ){ + deviceChannel.setCivilCode(null); + }else { + if (CivilCodeUtil.INSTANCE.getCivilCodePo(deviceChannel.getCivilCode()) == null) { + deviceChannel.setCivilCode(null); + } + } + } + return XmlUtil.elementDecode(element, DeviceChannel.class); } public static DeviceChannel decodeWithOnlyDeviceId(Element element) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java new file mode 100644 index 00000000..e6a9fd22 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java @@ -0,0 +1,64 @@ +package com.genersoft.iot.vmp.gb28181.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 区域 + */ +@Data +@Schema(description = "区域树") +public class RegionTree { + + /** + * 区域国标编号 + */ + @Schema(description = "区域国标编号") + private String id; + + /** + * 区域名称 + */ + @Schema(description = "区域名称") + private String label; + + /** + * 父区域国标ID + */ + @Schema(description = "父区域国标ID") + private String parentDeviceId; + + @Schema(description = "是否有子节点") + private boolean isLeaf; + + @Schema(description = "类型, 行政区划:0 摄像头: 1") + private int type; + + + + public static RegionTree getInstance(Region region) { + RegionTree regionTree = new RegionTree(); + regionTree.setId(region.getDeviceId()); + regionTree.setLabel(region.getName()); + regionTree.setParentDeviceId(region.getParentDeviceId()); + regionTree.setType(0); + if (region.getDeviceId().length() < 8) { + regionTree.setLeaf(false); + }else { + regionTree.setLeaf(true); + } + return regionTree; + } + + + + public static RegionTree getInstance(CommonGBChannel channel) { + RegionTree regionTree = new RegionTree(); + regionTree.setId(channel.getGbDeviceId()); + regionTree.setLabel(channel.getGbName()); + regionTree.setParentDeviceId(channel.getGbCivilCode()); + regionTree.setType(1); + regionTree.setLeaf(true); + return regionTree; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java index 913dad35..e4368cfe 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.controller; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Region; +import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.service.IRegionService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageInfo; @@ -53,7 +54,7 @@ public class RegionController { @Parameter(name = "parent", description = "所属行政区划编号", required = true) @ResponseBody @GetMapping("/tree/list") - public List queryForTree( + public List queryForTree( @RequestParam(required = false) String query, @RequestParam(required = false) String parent ){ @@ -121,7 +122,7 @@ public class RegionController { @ResponseBody @GetMapping("/base/child/list") public List getAllChild(@RequestParam(required = false) String parent){ - if (ObjectUtils.isEmpty(parent.trim())) { + if (ObjectUtils.isEmpty(parent)) { parent = null; } return regionService.getAllChild(parent); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index aeafd81f..b0096979 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -305,4 +306,17 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryList") List queryList(String query, Boolean online); + + @Select("") + List queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/RegionMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/RegionMapper.java index 3fe80eef..2c9a4381 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/RegionMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/RegionMapper.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.Region; +import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import org.apache.ibatis.annotations.*; import java.util.List; @@ -65,11 +66,17 @@ public interface RegionMapper { int batchAdd(List regionList); @Select(" ") - List queryForTree(@Param("query") String query, @Param("parentId") String parentId); + List queryForTree(@Param("query") String query, @Param("parentId") String parentId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IRegionService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IRegionService.java index 22c46333..c4f00a6b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IRegionService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IRegionService.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.gb28181.bean.Region; +import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.github.pagehelper.PageInfo; import java.util.List; @@ -31,7 +32,7 @@ public interface IRegionService { Region queryRegionByDeviceId(String regionDeviceId); - List queryForTree(String query, String parent); + List queryForTree(String query, String parent); void syncFromChannel(); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java index e360e78f..1dd7d5b9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.genersoft.iot.vmp.common.CivilCodePo; import com.genersoft.iot.vmp.conf.CivilCodeFileConf; import com.genersoft.iot.vmp.gb28181.bean.Region; +import com.genersoft.iot.vmp.gb28181.bean.RegionTree; +import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.RegionMapper; import com.genersoft.iot.vmp.gb28181.service.IRegionService; import com.genersoft.iot.vmp.utils.CivilCodeUtil; @@ -28,7 +30,7 @@ public class RegionServiceImpl implements IRegionService { @Autowired - private GbChannelServiceImpl gbChannelService; + private CommonGBChannelMapper commonGBChannelMapper; @Autowired @@ -87,8 +89,13 @@ public class RegionServiceImpl implements IRegionService { } @Override - public List queryForTree(String query, String parent) { - return regionMapper.queryForTree(query, parent); + public List queryForTree(String query, String parent) { + List regionList = regionMapper.queryForTree(query, parent); + if (parent != null) { + List channelList = commonGBChannelMapper.queryForRegionTreeByCivilCode(query, parent); + regionList.addAll(channelList); + } + return regionList; } @Override diff --git a/web_src/src/components/common/RegionTree.vue b/web_src/src/components/common/RegionTree.vue index 538a20d0..04e67c8e 100755 --- a/web_src/src/components/common/RegionTree.vue +++ b/web_src/src/components/common/RegionTree.vue @@ -10,49 +10,73 @@ - +
+ + + + + {{ node.label }} + + +
+ + + diff --git a/web_src/src/components/region.vue b/web_src/src/components/region.vue index b84df50b..abe39526 100755 --- a/web_src/src/components/region.vue +++ b/web_src/src/components/region.vue @@ -20,8 +20,10 @@ + + 添加 + - - + @@ -102,30 +101,20 @@ export default { methods: { initData: function () { if (typeof (this.parentChannelId) == "undefined" || this.parentChannelId == 0) { - this.channelList(); + this.getChannelList(); } else { this.showSubchannels(); } }, - initParam: function () { - this.deviceId = this.$route.params.deviceId; - this.parentChannelId = this.$route.params.parentChannelId; - this.currentPage = 1; - this.count = 15; - if (this.parentChannelId == "" || this.parentChannelId == 0) { - this.beforeUrl = "/deviceList" - } - - }, currentChange: function (val) { this.currentPage = val; this.initData(); }, handleSizeChange: function (val) { this.count = val; - this.channelList(); + this.getChannelList(); }, - channelList: function () { + getChannelList: function () { let that = this; if (typeof (this.$route.params.deviceId) == "undefined") return; this.$axios({ diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index f9f81931..a3f130fc 100755 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -10,11 +10,11 @@ 电子地图 推流列表 拉流代理 - + - 行政区划 - 业务分组 - 通道列表 + 行政区划 + 业务分组 + 通道列表 云端录像 节点管理 @@ -55,12 +55,15 @@ export default { alarmNotify: false, sseSource: null, username: userService.getUser().username, - activeIndex: this.$route.path, + activeIndex: this.$route.path.indexOf("/", 1)>0?this.$route.path.substring(0, this.$route.path.indexOf("/", 1)):this.$route.path, editUser: userService.getUser() ? userService.getUser().role.id === 1 : false }; }, created() { - console.log(JSON.stringify(userService.getUser())) + console.log(34334) + console.log(this.$route.path) + console.log(this.$route.path.indexOf("/", 1)) + console.log(this.activeIndex) if (this.$route.path.startsWith("/channelList")) { this.activeIndex = "/deviceList" } @@ -182,4 +185,14 @@ export default { color: #fff !important; background-color: #1890ff !important; } +#UiHeader .el-submenu.is-active { + background-color: #1890ff !important; +} +#UiHeader .el-submenu.is-active .el-submenu__title { + color: #fff !important; + background-color: #1890ff !important; +} +#UiHeader .el-submenu.is-active .el-submenu__icon-arrow { + color: #fff !important; +} diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js index 0b9f2a52..a87d747e 100755 --- a/web_src/src/router/index.js +++ b/web_src/src/router/index.js @@ -133,7 +133,7 @@ export default new VueRouter({ component: userApiKeyManager, }, { - path: '/region', + path: '/channel/region', name: 'region', component: region, }