支持清理异常业务分组节点,使通道可被挂载

This commit is contained in:
lin
2025-03-14 15:32:03 +08:00
parent 4dce850aea
commit 867d1bfb9b
7 changed files with 371 additions and 5 deletions

View File

@@ -148,7 +148,6 @@ public class CommonChannelController {
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "online", description = "是否在线")
@Parameter(name = "channelType", description = "通道类型, 0国标设备1推流设备2拉流代理")
@Parameter(name = "civilCode", description = "行政区划")
@GetMapping("/civilCode/unusual/list")
public PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count,
@RequestParam(required = false) String query,
@@ -160,6 +159,24 @@ public class CommonChannelController {
return channelService.queryListByCivilCodeForUnusual(page, count, query, online, channelType);
}
@Operation(summary = "存在父节点编号但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页查询数量", required = true)
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "online", description = "是否在线")
@Parameter(name = "channelType", description = "通道类型, 0国标设备1推流设备2拉流代理")
@GetMapping("/parent/unusual/list")
public PageInfo<CommonGBChannel> queryListByParentForUnusual(int page, int count,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Integer channelType){
if (ObjectUtils.isEmpty(query)){
query = null;
}
return channelService.queryListByParentForUnusual(page, count, query, online, channelType);
}
@Operation(summary = "清除存在行政区划但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "param", description = "清理参数, all为true清理所有异常数据。 否则按照传入的设备Id清理", required = true)
@PostMapping("/civilCode/unusual/clear")
@@ -167,6 +184,13 @@ public class CommonChannelController {
channelService.clearChannelCivilCode(param.getAll(), param.getChannelIds());
}
@Operation(summary = "清除存在分组节点但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "param", description = "清理参数, all为true清理所有异常数据。 否则按照传入的设备Id清理", required = true)
@PostMapping("/parent/unusual/clear")
public void clearChannelParent(@RequestBody ChannelToRegionParam param){
channelService.clearChannelParent(param.getAll(), param.getChannelIds());
}
@Operation(summary = "获取关联业务分组通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页查询数量", required = true)

View File

@@ -556,7 +556,20 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryListByCivilCodeForUnusual")
List<CommonGBChannel> queryListByCivilCodeForUnusual(@Param("query") String query, @Param("online") Boolean online, @Param("dataType")Integer dataType);
@SelectProvider(type = ChannelProvider.class, method = "queryAllForUnusual")
List<Integer> queryAllForUnusual();
@SelectProvider(type = ChannelProvider.class, method = "queryAllForUnusualCivilCode")
List<Integer> queryAllForUnusualCivilCode();
@SelectProvider(type = ChannelProvider.class, method = "queryListByParentForUnusual")
List<CommonGBChannel> queryListByParentForUnusual(@Param("query") String query, @Param("online") Boolean online, @Param("dataType")Integer dataType);
@SelectProvider(type = ChannelProvider.class, method = "queryAllForUnusualParent")
List<Integer> queryAllForUnusualParent();
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_parent_id = null, gb_business_group_id = null, parent_id = null, business_group_id = null" +
" WHERE id in "+
" <foreach collection='channelIdsForClear' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
" </script>"})
void removeParentIdByChannelIds(List<Integer> channelIdsForClear);
}

View File

@@ -432,7 +432,30 @@ public class ChannelProvider {
return sqlBuild.toString();
}
public String queryAllForUnusual(Map<String, Object> params ){
public String queryListByParentForUnusual(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL_TABLE_NAME);
sqlBuild.append(" left join (select wcg.device_id from wvp_common_group wcg) temp on temp.device_id = coalesce(wdc.gb_parent_id, wdc.parent_id)" +
" where coalesce(wdc.gb_parent_id, wdc.parent_id) is not null and temp.device_id is null ");
sqlBuild.append(" AND wdc.channel_type = 0 ");
if (params.get("query") != null) {
sqlBuild.append(" AND (coalesce(wdc.gb_device_id, wdc.device_id) LIKE concat('%',#{query},'%') escape '/'" +
" OR coalesce(wdc.gb_name, wdc.name) LIKE concat('%',#{query},'%') escape '/' )")
;
}
if (params.get("online") != null && (Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(wdc.gb_status, wdc.status) = 'ON'");
}
if (params.get("online") != null && !(Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(wdc.gb_status, wdc.status) = 'OFF'");
}
if (params.get("dataType") != null) {
sqlBuild.append(" AND wdc.data_type = #{dataType}");
}
return sqlBuild.toString();
}
public String queryAllForUnusualCivilCode(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append("select wdc.id from wvp_device_channel wdc ");
sqlBuild.append(" left join (select wcr.device_id from wvp_common_region wcr) temp on temp.device_id = coalesce(wdc.gb_civil_code, wdc.civil_code)" +
@@ -440,4 +463,13 @@ public class ChannelProvider {
sqlBuild.append(" AND wdc.channel_type = 0 ");
return sqlBuild.toString();
}
public String queryAllForUnusualParent(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append("select wdc.id from wvp_device_channel wdc ");
sqlBuild.append(" left join (select wcg.device_id from wvp_common_group wcg) temp on temp.device_id = coalesce(wdc.gb_parent_id, wdc.parent_id)" +
" where coalesce(wdc.gb_parent_id, wdc.parent_id) is not null and temp.device_id is null ");
sqlBuild.append(" AND wdc.channel_type = 0 ");
return sqlBuild.toString();
}
}

View File

@@ -93,4 +93,8 @@ public interface IGbChannelService {
PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count, String query, Boolean online, Integer channelType);
void clearChannelCivilCode(Boolean all, List<Integer> channelIds);
PageInfo<CommonGBChannel> queryListByParentForUnusual(int page, int count, String query, Boolean online, Integer channelType);
void clearChannelParent(Boolean all, List<Integer> channelIds);
}

View File

@@ -768,10 +768,33 @@ public class GbChannelServiceImpl implements IGbChannelService {
List<Integer> channelIdsForClear;
if (all != null && all) {
channelIdsForClear = commonGBChannelMapper.queryAllForUnusual();
channelIdsForClear = commonGBChannelMapper.queryAllForUnusualCivilCode();
}else {
channelIdsForClear = channelIds;
}
commonGBChannelMapper.removeCivilCodeByChannelIds(channelIdsForClear);
}
@Override
public PageInfo<CommonGBChannel> queryListByParentForUnusual(int page, int count, String query, Boolean online, Integer channelType) {
PageHelper.startPage(page, count);
if (query != null) {
query = query.replaceAll("/", "//")
.replaceAll("%", "/%")
.replaceAll("_", "/_");
}
List<CommonGBChannel> all = commonGBChannelMapper.queryListByParentForUnusual(query, online, channelType);
return new PageInfo<>(all);
}
@Override
public void clearChannelParent(Boolean all, List<Integer> channelIds) {
List<Integer> channelIdsForClear;
if (all != null && all) {
channelIdsForClear = commonGBChannelMapper.queryAllForUnusualParent();
}else {
channelIdsForClear = channelIds;
}
commonGBChannelMapper.removeParentIdByChannelIds(channelIdsForClear);
}
}