diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java index 9542f5da..d7f1a142 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java @@ -52,6 +52,12 @@ public class Group implements Comparable{ @Schema(description = "更新时间") private String updateTime; + /** + * 平台ID + */ + @Schema(description = "平台ID") + private Integer platformId; + @Override public int compareTo(@NotNull Group region) { return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId())); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java index 77e32bfb..ff93d8bf 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java @@ -36,11 +36,13 @@ public class GroupController { @Operation(summary = "查询分组") @Parameter(name = "query", description = "要搜索的内容", required = true) @Parameter(name = "parent", description = "所属分组编号", required = true) + @Parameter(name = "platformId", description = "上级平台ID", required = true) @ResponseBody @GetMapping("/tree/list") public List queryForTree( @RequestParam(required = false) String query, - @RequestParam(required = false) String parent + @RequestParam(required = false) String parent, + @RequestParam(required = false) Integer platformId ){ if (ObjectUtils.isEmpty(parent)) { parent = null; @@ -48,7 +50,7 @@ public class GroupController { if (ObjectUtils.isEmpty(query)) { query = null; } - return groupService.queryForTree(query, parent); + return groupService.queryForTree(query, parent, platformId); } @Operation(summary = "更新分组") 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 8c30117e..b11c8b35 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 @@ -360,7 +360,7 @@ public interface CommonGBChannelMapper { @Update(value = {" "}) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java index db5872a4..daaa0fda 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java @@ -82,9 +82,28 @@ public interface GroupMapper { " where " + " parent_device_id = #{parentId} " + " parent_device_id is null " + + " platform_id = #{platformId} " + + " platform_id is null " + " AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%')) " + " ") - List queryForTree(@Param("query") String query, @Param("parentId") String parentId); + List queryForTree(@Param("query") String query, @Param("parentId") String parentId, + @Param("platformId") Integer platformId); + + @Select(" ") + List queryBusinessGroupForTree(String query, Integer platformId); @Select("SELECT * from wvp_common_group WHERE device_id = #{deviceId} and business_group = #{businessGroup}") Group queryOneByDeviceId(@Param("deviceId") String deviceId, @Param("businessGroup") String businessGroup); @@ -103,4 +122,6 @@ public interface GroupMapper { @Delete("DELETE FROM wvp_common_group WHERE business_group = #{businessGroup}") int deleteByBusinessGroup(@Param("businessGroup") String businessGroup); + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java index 87195b35..8be65616 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java @@ -14,7 +14,7 @@ public interface IGroupService { Group queryGroupByDeviceId(String regionDeviceId); - List queryForTree(String query, String parent); + List queryForTree(String query, String parent, Integer platformId); void syncFromChannel(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java index 70a898f8..3942c8b7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java @@ -137,7 +137,13 @@ public class GroupServiceImpl implements IGroupService { } @Override - public List queryForTree(String query, String parent) { + public List queryForTree(String query, String parent, Integer platformId) { + if (parent == null) { + // 查询所有业务分组 + return groupManager.queryBusinessGroupForTree(query, platformId); + }else { + List groupTreeList = groupManager.queryForTree(query, parent, platformId); + } return Collections.emptyList(); } @@ -147,7 +153,29 @@ public class GroupServiceImpl implements IGroupService { } @Override + @Transactional public boolean delete(int id) { - return false; + Group group = groupManager.queryOne(id); + Assert.notNull(group, "分组不存在"); + groupManager.delete(id); + GbCode gbCode = GbCode.decode(group.getDeviceId()); + if (gbCode.getTypeCode().equals("215")) { + // 业务分组 + gbChannelService.removeParentIdByBusinessGroup(gbCode.getTypeCode()); + }else { + List groups = queryAllChildren(group.getDeviceId(), group.getPlatformId()); + groups.add(group); + gbChannelService.removeParentIdByGroupList(groups); + } + // 发送分组移除通知 + // 将变化信息发送通知 + CommonGBChannel channel = CommonGBChannel.build(group); + try { + // 发送catalog + eventPublisher.catalogEventPublish(null, channel, CatalogEvent.DEL); + }catch (Exception e) { + log.warn("[业务分组/虚拟组织删除] 发送失败,{}", group.getDeviceId(), e); + } + return true; } } diff --git a/web_src/src/components/region.vue b/web_src/src/components/region.vue index ff97fe56..747196ce 100755 --- a/web_src/src/components/region.vue +++ b/web_src/src/components/region.vue @@ -151,8 +151,10 @@ export default { this.$refs.channelListTable.doLayout(); }) } + yguop }).catch((error)=> { + console.log(error); }); },