Ver código fonte

临时提交

panlinlin 1 ano atrás
pai
commit
18c51919a3

+ 6 - 0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java

@@ -52,6 +52,12 @@ public class Group implements Comparable<Group>{
     @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()));

+ 4 - 2
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<GroupTree> 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 = "更新分组")

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java

@@ -360,7 +360,7 @@ public interface CommonGBChannelMapper {
 
     @Update(value = {" <script>" +
             " UPDATE wvp_device_channel " +
-            " SET gb_parent_id = null" +
+            " SET gb_parent_id = null, gb_business_group_id = null" +
             " WHERE id in "+
             " <foreach collection='channelList'  item='item'  open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
             " </script>"})

+ 22 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java

@@ -82,9 +82,28 @@ public interface GroupMapper {
             " where " +
             " <if test='parentId != null'> parent_device_id = #{parentId} </if> " +
             " <if test='parentId == null'> parent_device_id is null </if> " +
+            " <if test='platformId != null'> platform_id = #{platformId} </if> " +
+            " <if test='platformId == null'> platform_id is null </if> " +
             " <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
             " </script>")
-    List<GroupTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId);
+    List<GroupTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId,
+                                 @Param("platformId") Integer platformId);
+
+    @Select(" <script>" +
+            " SELECT " +
+            " device_id as id," +
+            " name as label, " +
+            " parent_device_id," +
+            " id as db_id," +
+            " 0 as type," +
+            " false as is_leaf" +
+            " from wvp_common_group " +
+            " where device_id=business_group" +
+            " <if test='platformId != null'> platform_id = #{platformId} </if> " +
+            " <if test='platformId == null'> platform_id is null </if> " +
+            " <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
+            " </script>")
+    List<GroupTree> 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);
+
+
 }

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java

@@ -14,7 +14,7 @@ public interface IGroupService {
 
     Group queryGroupByDeviceId(String regionDeviceId);
 
-    List<GroupTree> queryForTree(String query, String parent);
+    List<GroupTree> queryForTree(String query, String parent, Integer platformId);
 
     void syncFromChannel();
 

+ 30 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java

@@ -137,7 +137,13 @@ public class GroupServiceImpl implements IGroupService {
     }
 
     @Override
-    public List<GroupTree> queryForTree(String query, String parent) {
+    public List<GroupTree> queryForTree(String query, String parent, Integer platformId) {
+        if (parent == null) {
+            // 查询所有业务分组
+            return groupManager.queryBusinessGroupForTree(query, platformId);
+        }else {
+            List<GroupTree> 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<Group> 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;
     }
 }

+ 2 - 0
web_src/src/components/region.vue

@@ -151,8 +151,10 @@ export default {
             this.$refs.channelListTable.doLayout();
           })
         }
+ yguop
 
       }).catch((error)=> {
+
         console.log(error);
       });
     },