临时提交

pull/1642/head
panlinlin 2024-08-02 23:47:44 +08:00
parent 91b8e7a595
commit 18c51919a3
7 changed files with 66 additions and 7 deletions

View File

@ -52,6 +52,12 @@ public class Group implements Comparable<Group>{
@Schema(description = "更新时间") @Schema(description = "更新时间")
private String updateTime; private String updateTime;
/**
* ID
*/
@Schema(description = "平台ID")
private Integer platformId;
@Override @Override
public int compareTo(@NotNull Group region) { public int compareTo(@NotNull Group region) {
return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId())); return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId()));

View File

@ -36,11 +36,13 @@ public class GroupController {
@Operation(summary = "查询分组") @Operation(summary = "查询分组")
@Parameter(name = "query", description = "要搜索的内容", required = true) @Parameter(name = "query", description = "要搜索的内容", required = true)
@Parameter(name = "parent", description = "所属分组编号", required = true) @Parameter(name = "parent", description = "所属分组编号", required = true)
@Parameter(name = "platformId", description = "上级平台ID", required = true)
@ResponseBody @ResponseBody
@GetMapping("/tree/list") @GetMapping("/tree/list")
public List<GroupTree> queryForTree( public List<GroupTree> queryForTree(
@RequestParam(required = false) String query, @RequestParam(required = false) String query,
@RequestParam(required = false) String parent @RequestParam(required = false) String parent,
@RequestParam(required = false) Integer platformId
){ ){
if (ObjectUtils.isEmpty(parent)) { if (ObjectUtils.isEmpty(parent)) {
parent = null; parent = null;
@ -48,7 +50,7 @@ public class GroupController {
if (ObjectUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
return groupService.queryForTree(query, parent); return groupService.queryForTree(query, parent, platformId);
} }
@Operation(summary = "更新分组") @Operation(summary = "更新分组")

View File

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

View File

@ -82,9 +82,28 @@ public interface GroupMapper {
" where " + " where " +
" <if test='parentId != null'> parent_device_id = #{parentId} </if> " + " <if test='parentId != null'> parent_device_id = #{parentId} </if> " +
" <if test='parentId == null'> parent_device_id is null </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> " + " <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" </script>") " </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}") @Select("SELECT * from wvp_common_group WHERE device_id = #{deviceId} and business_group = #{businessGroup}")
Group queryOneByDeviceId(@Param("deviceId") String deviceId, @Param("businessGroup") String 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}") @Delete("DELETE FROM wvp_common_group WHERE business_group = #{businessGroup}")
int deleteByBusinessGroup(@Param("businessGroup") String businessGroup); int deleteByBusinessGroup(@Param("businessGroup") String businessGroup);
} }

View File

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

View File

@ -137,7 +137,13 @@ public class GroupServiceImpl implements IGroupService {
} }
@Override @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(); return Collections.emptyList();
} }
@ -147,7 +153,29 @@ public class GroupServiceImpl implements IGroupService {
} }
@Override @Override
@Transactional
public boolean delete(int id) { 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;
} }
} }

View File

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