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

master
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);
}
}

View File

@ -0,0 +1,261 @@
<template>
<div id="gbChannelSelect" v-loading="getChannelListLoading">
<el-dialog
title="异常挂载通道"
width="60%"
top="2rem"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
append-to-body
@close="close()"
>
<div class="page-header" style="width: 100%">
<div class="page-header-btn" style="width: 100%; text-align: left">
搜索:
<el-input @input="getChannelList" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
在线状态:
<el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="online" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="在线" value="true"></el-option>
<el-option label="离线" value="false"></el-option>
</el-select>
类型:
<el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="国标设备" :value="1"></el-option>
<el-option label="推流设备" :value="2"></el-option>
<el-option label="拉流代理" :value="3"></el-option>
</el-select>
<el-button size="mini" type="primary" :loading="getChannelListLoading" :disabled="multipleSelection.length ===0"
@click="clearUnusualRegion()">清除</el-button>
<el-button size="mini" :loading="getChannelListLoading"
@click="clearUnusualRegion(true)">全部清除</el-button>
<el-button size="mini" :loading="getChannelListLoading"
@click="getChannelList()">刷新</el-button>
</div>
</div>
<!--通道列表-->
<el-table size="small" ref="channelListTable" :data="channelList" :height="winHeight" style="width: 100%;"
header-row-class-name="table-header" @selection-change="handleSelectionChange" >
<el-table-column type="selection" width="55" >
</el-table-column>
<el-table-column prop="gbName" label="名称" min-width="180">
</el-table-column>
<el-table-column prop="gbDeviceId" label="编号" min-width="180">
</el-table-column>
<el-table-column prop="gbManufacturer" label="厂家" min-width="100">
</el-table-column>
<el-table-column prop="gbCivilCode" label="行政区划" min-width="100">
</el-table-column>
<el-table-column label="类型" min-width="100">
<template v-slot:default="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1"></el-tag>
<el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag>
<el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="状态" min-width="100">
<template v-slot:default="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.gbStatus === 'ON'">线</el-tag>
<el-tag size="medium" type="info" v-if="scope.row.gbStatus !== 'ON'">线</el-tag>
</div>
</template>
</el-table-column>
</el-table>
<div style="display: grid; grid-template-columns: 1fr 1fr">
<div style="text-align: left; line-height: 32px">
<i class="el-icon-info"></i> 清除后通道可正常添加到分组节点
</div>
<el-pagination
style="text-align: right"
@size-change="handleSizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-size="count"
:page-sizes="[10, 25, 35, 50, 200, 1000, 50000]"
layout="total, sizes, prev, pager, next"
:total="total">
</el-pagination>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: "UnusualGroupChannelSelect",
props: [],
computed: {},
data() {
return {
showDialog: false,
channelList: [], //
searchSrt: "",
online: null,
channelType: "",
winHeight: 580,
currentPage: 1,
count: 10,
total: 0,
getChannelListLoading: false,
multipleSelection: [],
};
},
methods: {
initData: function () {
this.getChannelList();
},
currentChange: function (val) {
this.currentPage = val;
this.getChannelList();
},
handleSizeChange: function (val) {
this.count = val;
this.getChannelList();
},
handleSelectionChange: function (val){
this.multipleSelection = val;
},
getChannelList: function () {
this.getChannelListLoading = true;
this.$axios({
method: 'get',
url: `/api/common/channel/parent/unusual/list`,
params: {
page: this.currentPage,
count: this.count,
channelType: this.channelType,
query: this.searchSrt,
online: this.online,
}
}).then( (res)=> {
if (res.data.code === 0) {
this.total = res.data.data.total;
for (let i = 0; i < res.data.data.list.length; i++) {
res.data.data.list[i]["addRegionLoading"] = false
}
this.channelList = res.data.data.list;
}
}).catch( (error)=> {
console.error(error);
}).finally(()=>{
this.getChannelListLoading = false;
})
},
openDialog: function () {
this.showDialog = true;
this.initData();
},
close: function () {
this.showDialog = false;
},
clearUnusualRegion: function (all) {
let channels = null
if (all || this.multipleSelection.length > 0 ) {
channels = []
for (let i = 0; i < this.multipleSelection.length; i++) {
channels.push(this.multipleSelection[i].gbId)
}
}
this.$axios({
method: 'post',
url: `/api/common/channel/parent/unusual/clear`,
data: {
all: all,
channelIds: channels
}
}).then((res) => {
if (res.data.code === 0) {
this.$message.success({
showClose: true,
message: "清除成功"
})
this.getChannelList()
} else {
this.$message.error({
showClose: true,
message: res.data.msg
})
}
}).catch((error) => {
this.$message.error({
showClose: true,
message: error
})
}).finally(()=>{
this.loading = false
})
},
addRegion: function (row) {
row.addRegionLoading = true;
this.$axios({
method: 'get',
url: `/api/region/description`,
params: {
civilCode: row.gbCivilCode,
}
}).then((res) => {
if (res.data.code === 0) {
this.$confirm(`确定添加: ${res.data.data}`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
this.$axios({
method: 'get',
url: `/api/region/addByCivilCode`,
params: {
civilCode: row.gbCivilCode,
}
}).then((res) => {
if (res.data.code === 0) {
this.$message.success({
showClose: true,
message: "添加成功"
})
this.initData()
}else {
this.$message.error({
showClose: true,
message: res.data.msg
})
}
}).catch((error) => {
console.error(error);
});
}).catch(() => {
});
} else {
this.$message.error({
showClose: true,
message: res.data.msg
})
}
}).catch((error) => {
this.$message.error({
showClose: true,
message: error
})
}).finally(()=>{
row.addRegionLoading = false;
})
},
}
};
</script>

View File

@ -42,6 +42,9 @@
<el-button v-bind:disabled="multipleSelection.length === 0" size="mini" type="danger" @click="remove()">
移除通道
</el-button>
<el-button plain size="mini" type="warning" @click="showUnusualChanel()">
异常挂载通道
</el-button>
<el-button icon="el-icon-refresh-right" circle size="mini" @click="getChannelList()"></el-button>
</div>
</div>
@ -88,6 +91,7 @@
</el-main>
</el-container>
<GbChannelSelect ref="gbChannelSelect" dataType="group"></GbChannelSelect>
<UnusualGroupChannelSelect ref="unusualGroupChannelSelect" ></UnusualGroupChannelSelect>
</div>
</template>
@ -96,6 +100,7 @@ import uiHeader from '../layout/UiHeader.vue'
import DeviceService from "./service/DeviceService";
import GroupTree from "./common/GroupTree.vue";
import GbChannelSelect from "./dialog/GbChannelSelect.vue";
import UnusualGroupChannelSelect from "./dialog/UnusualGroupChannelSelect.vue";
import RegionTree from "./common/RegionTree.vue";
export default {
@ -103,6 +108,7 @@ export default {
components: {
RegionTree,
GbChannelSelect,
UnusualGroupChannelSelect,
uiHeader,
GroupTree,
},
@ -323,6 +329,9 @@ export default {
onChannelChange: function (deviceId) {
//
},
showUnusualChanel: function () {
this.$refs.unusualGroupChannelSelect.openDialog()
},
}
};
</script>