完善行政区划管理

pull/1642/head
648540858 2024-07-31 15:07:54 +08:00
parent 3ce973d2ee
commit 7ee3cdb801
11 changed files with 268 additions and 127 deletions

View File

@ -10,6 +10,12 @@ import lombok.Data;
@Schema(description = "区域树")
public class RegionTree {
/**
* Id
*/
@Schema(description = "数据库Id")
private int dbId;
/**
*
*/

View File

@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceType;
import com.genersoft.iot.vmp.gb28181.bean.IndustryCodeType;
import com.genersoft.iot.vmp.gb28181.bean.NetworkIdentificationType;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionBYGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionParam;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
@ -111,7 +112,22 @@ public class CommonChannelController {
@Operation(summary = "通道删除行政区划", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/region/delete")
public void deleteChannelToRegion(@RequestBody ChannelToRegionParam param){
Assert.isTrue(param.getChannelIds().isEmpty() && ObjectUtils.isEmpty(param.getCivilCode()),"参数异常");
Assert.isTrue(!param.getChannelIds().isEmpty() || !ObjectUtils.isEmpty(param.getCivilCode()),"参数异常");
channelService.deleteChannelToRegion(param.getCivilCode(), param.getChannelIds());
}
@Operation(summary = "通道设置行政区划-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/region/device/add")
public void addChannelToRegionBYGbDevice(@RequestBody ChannelToRegionBYGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
Assert.hasLength(param.getCivilCode(),"未添加行政区划");
channelService.addChannelToRegionBYGbDevice(param.getCivilCode(), param.getDeviceIds());
}
@Operation(summary = "通道删除行政区划-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/region/device/delete")
public void deleteChannelToRegionBYGbDevice(@RequestBody ChannelToRegionBYGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
channelService.deleteChannelToRegionBYGbDevice(param.getDeviceIds());
}
}

View File

@ -0,0 +1,11 @@
package com.genersoft.iot.vmp.gb28181.controller.bean;
import lombok.Data;
import java.util.List;
@Data
public class ChannelToRegionBYGbDeviceParam {
private List<Integer> deviceIds;
private String civilCode;
}

View File

@ -313,6 +313,7 @@ public interface CommonGBChannelMapper {
" select " +
" coalesce(gb_device_id, device_id) as id," +
" coalesce(gb_name, name) as label, " +
" id as db_id, " +
" 1 as type, " +
" true as is_leaf " +
" from wvp_device_channel " +
@ -341,4 +342,18 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryByIdsOrCivilCode")
List<CommonGBChannel> queryByIdsOrCivilCode(@Param("civilCode") String civilCode, @Param("ids") List<Integer> ids);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_civil_code = null" +
" WHERE id in "+
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
" </script>"})
int removeCivilCodeByChannels(List<CommonGBChannel> channelList);
@SelectProvider(type = ChannelProvider.class, method = "queryByCivilCode")
List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode);
@SelectProvider(type = ChannelProvider.class, method = "queryByGbDeviceIds")
List<CommonGBChannel> queryByGbDeviceIds(List<Integer> deviceIds);
}

View File

@ -70,6 +70,7 @@ public interface RegionMapper {
" device_id as id," +
" name as label, " +
" parent_device_id," +
" id as db_id," +
" 0 as type," +
" false as is_leaf" +
" from wvp_common_region " +

View File

@ -132,6 +132,24 @@ public class ChannelProvider {
return sqlBuild.toString() ;
}
public String queryByGbDeviceIds(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(getBaseSelectSql());
sqlBuild.append("where device_db_id in ( ");
Collection<Integer> ids = (Collection<Integer>)params.get("deviceIds");
boolean first = true;
for (Integer id : ids) {
if (!first) {
sqlBuild.append(",");
}
sqlBuild.append(id);
first = false;
}
sqlBuild.append(" )");
return sqlBuild.toString() ;
}
public String queryByIdsOrCivilCode(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(getBaseSelectSql());
@ -157,4 +175,11 @@ public class ChannelProvider {
}
return sqlBuild.toString() ;
}
public String queryByCivilCode(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(getBaseSelectSql());
sqlBuild.append("where gb_civil_code = #{civilCode} ");
return sqlBuild.toString() ;
}
}

View File

@ -49,4 +49,12 @@ public interface IGbChannelService {
void addChannelToRegion(String civilCode, List<Integer> channelIds);
void deleteChannelToRegion(String civilCode, List<Integer> channelIds);
void deleteChannelToRegionByCivilCode(String civilCode);
void deleteChannelToRegionByChannelIds(List<Integer> channelIds);
void addChannelToRegionBYGbDevice(String civilCode, List<Integer> deviceIds);
void deleteChannelToRegionBYGbDevice(List<Integer> deviceIds);
}

View File

@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Collection;
@ -352,8 +353,55 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
@Transactional
public void deleteChannelToRegion(String civilCode, List<Integer> channelIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByIdsOrCivilCode(civilCode, channelIds);
if (!ObjectUtils.isEmpty(civilCode)) {
deleteChannelToRegionByCivilCode(civilCode);
}
if (!ObjectUtils.isEmpty(channelIds)) {
deleteChannelToRegionByChannelIds(channelIds);
}
}
@Override
public void deleteChannelToRegionByCivilCode(String civilCode) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByCivilCode(civilCode);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList);
// TODO 发送通知
// if (result > 0) {
// try {
// // 发送catalog
// eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
// }catch (Exception e) {
// log.warn("[多个通道添加行政区划] 发送失败,数量:{}", channelList.size(), e);
// }
// }
}
@Override
public void deleteChannelToRegionByChannelIds(List<Integer> channelIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByIds(channelIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList);
// TODO 发送通知
// if (result > 0) {
// try {
// // 发送catalog
// eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
// }catch (Exception e) {
// log.warn("[多个通道添加行政区划] 发送失败,数量:{}", channelList.size(), e);
// }
// }
}
@Override
public void addChannelToRegionBYGbDevice(String civilCode, List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
@ -368,4 +416,13 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
}
}
@Override
public void deleteChannelToRegionBYGbDevice(List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList);
}
}

View File

@ -4,7 +4,7 @@
<div class="page-title">行政区划</div>
<div class="page-header-btn">
<div style="display: inline;">
<el-input @input="search" style="margin-right: 1rem; width: 12rem;" size="mini" placeholder="关键字"
<el-input @input="search" style="visibility:hidden; margin-right: 1rem; width: 12rem;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
<el-checkbox v-model="showCode"></el-checkbox>
@ -13,11 +13,12 @@
</div>
<div>
<vue-easy-tree
class="flow-tree"
ref="veTree"
node-key="id"
height="72vh"
height="78vh"
lazy
style="height: 78vh; padding: 2rem"
style="padding: 2rem 0 2rem 0.5rem"
:load="loadNode"
:data="treeData"
:default-expanded-keys="['']"
@ -30,91 +31,42 @@
</span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
<span style=" padding-left: 1px" v-if="node.data.id !=='' && showCode">{{ node.label }}-{{ node.data.id }}</span>
<span style=" padding-left: 1px" v-if="node.data.id ==='' || !showCode">{{ node.label }}</span>
<span style=" padding-left: 1px" v-if="node.data.id !=='' && showCode" :title="node.data.id">{{ node.label }}{{ node.data.id }}</span>
<span style=" padding-left: 1px" v-if="node.data.id ==='' || !showCode" :title="node.data.id">{{ node.label }}</span>
</span>
</vue-easy-tree>
</div>
<regionCode ref="regionCode"></regionCode>
<gbDeviceSelect ref="gbDeviceSelect"></gbDeviceSelect>
</div>
</template>
<script>
import VueEasyTree from "@wchbrad/vue-easy-tree";
import regionCode from './../dialog/regionCode'
let treeData = []
import gbDeviceSelect from './../dialog/GbDeviceSelect'
export default {
name: 'DeviceTree',
components: {
VueEasyTree, regionCode
VueEasyTree, regionCode, gbDeviceSelect
},
data() {
return {
showCode: false,
searchSrt: "",
chooseId: "",
// props: {
// label: "name",
// },
treeData: [],
}
},
props: ['edit', 'clickEvent', 'chooseIdChange'],
props: ['edit', 'clickEvent', 'chooseIdChange', 'onChannelChange'],
created() {
// this.$axios({
// method: 'get',
// url: `/api/region/tree/list`,
// }).then((res)=> {
// if (res.data.code === 0) {
//
// for (let i = 0; i < res.data.data.length; i++) {
// let item = res.data.data[i]
// console.log(item)
// this.treeData.push({
// id: item.deviceId,
// label: item.name,
// children: [],
// isLeaf: false,
// })
// }
//
// }
//
// }).catch(function (error) {
// console.log(error);
// });
},
methods: {
onClick(evt, treeId, treeNode) {
},
onCheck(evt, treeId, treeNode) {
},
handleCreated(ztreeObj) {
},
search() {
},
handleNodeClick(data, node, element) {
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if (typeof (this.clickEvent) == "function") {
this.clickEvent(deviceNode.data.userData, data.userData, data.type === 2)
}
},
handleContextMenu(event, data, node, element) {
console.log("右键点击事件")
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if (typeof (this.contextMenuEvent) == "function") {
this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
}
},
loadNode: function (node, resolve) {
console.log(22222)
console.log(node)
if (node.level === 0) {
resolve([{
id: "",
@ -122,7 +74,7 @@ export default {
isLeaf: false,
type: 0
}]);
} else if (node.data.id.length < 8) {
} else if (node.data.id.length <= 8) {
this.$axios({
method: 'get',
url: `/api/region/tree/list`,
@ -142,56 +94,11 @@ export default {
resolve([]);
}
},
channelDataHandler: function (data, resolve) {
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
let item = data[i];
let type = 3;
if (item.id.length <= 10) {
type = 2;
} else {
if (item.id.length > 14) {
let channelType = item.id.substring(10, 13)
console.log("channelType: " + channelType)
if (channelType === '215' || channelType === '216') {
type = 2;
}
console.log(type)
if (item.basicData.ptzType === 1) { // 1-;2-;3-;4-
type = 4;
} else if (item.basicData.ptzType === 2) {
type = 5;
} else if (item.basicData.ptzType === 3 || item.basicData.ptzType === 4) {
type = 6;
}
} else {
if (item.basicData.subCount > 0 || item.basicData.parental === 1) {
type = 2;
}
}
}
let node = {
name: item.name || item.basicData.channelId,
isLeaf: type !== 2,
id: item.id,
deviceId: item.deviceId,
type: type,
online: item.basicData.status === 1,
hasGPS: item.basicData.longitude * item.basicData.latitude !== 0,
userData: item.basicData
}
nodeList.push(node);
}
resolve(nodeList)
} else {
resolve([])
}
},
reset: function () {
this.$forceUpdate();
},
contextmenuEventHandler: function (event, data, node, element) {
console.log(node.level)
if (node.data.type === 1) {
data.parentId = node.parent.data.id;
@ -202,14 +109,18 @@ export default {
icon: "el-icon-delete",
disabled: false,
onClick: () => {
console.log(data)
this.$axios({
method: "post",
url: `/api/common/channel/region/delete`,
data: {
channelIds: [data.id]
channelIds: [data.dbId]
}
}).then((res) => {
console.log("移除成功")
if (this.onChannelChange) {
this.onChannelChange()
}
node.parent.loaded = false
node.parent.expand();
}).catch(function (error) {
@ -324,21 +235,81 @@ export default {
node.parent.loaded = false
node.parent.expand();
}
})
.catch(function (error) {
}).catch(function (error) {
console.log(error);
});
});
},
addChannelFormDevice: function (id, node) {
this.$refs.gbDeviceSelect.openDialog((rows)=>{
let deviceIds = []
for (let i = 0; i < rows.length; i++) {
deviceIds.push(rows[i].id)
}
this.$axios({
method: 'post',
url: `/api/common/channel/region/device/add`,
data: {
civilCode: node.data.id,
deviceIds: deviceIds,
}
}).then((res)=> {
if (res.data.code === 0) {
this.$message.success("保存成功")
if (this.onChannelChange) {
this.onChannelChange()
}
node.loaded = false
node.expand();
}else {
this.$message.error(res.data.msg)
}
this.loading = false
}).catch((error)=> {
this.$message.error(error)
this.loading = false
});
})
},
removeChannelFormDevice: function (id, node) {
this.$refs.gbDeviceSelect.openDialog((rows)=>{
let deviceIds = []
for (let i = 0; i < rows.length; i++) {
deviceIds.push(rows[i].id)
}
this.$axios({
method: 'post',
url: `/api/common/channel/region/device/delete`,
data: {
deviceIds: deviceIds,
}
}).then((res)=> {
if (res.data.code === 0) {
this.$message.success("保存成功")
if (this.onChannelChange) {
this.onChannelChange()
}
node.loaded = false
node.expand();
}else {
this.$message.error(res.data.msg)
}
this.loading = false
}).catch((error)=> {
this.$message.error(error)
this.loading = false
});
})
},
refreshNode: function (node) {
node.loaded = false
node.expand();
},
refresh: function (id) {
// node
let node = this.$refs.veTree.getNode(id)
node.loaded = false
node.expand();
},
addRegion: function (id, node) {
console.log(node)
@ -382,4 +353,5 @@ export default {
.custom-tree-node .el-radio__label {
padding-left: 4px !important;
}
</style>

View File

@ -1,16 +1,16 @@
<template>
<div id="addUser" v-loading="getDeviceListLoading">
<el-dialog
title="选择设备"
width="40%"
title="添加国标设备通道到行政区划"
width="60%"
top="2rem"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
@close="close()"
>
<div class="page-header">
<div class="page-header-btn">
<div class="page-header" style="width: 100%">
<div class="page-header-btn" style="width: 100%; text-align: left">
搜索:
<el-input @input="getDeviceList" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
@ -21,8 +21,9 @@
<el-option label="在线" value="true"></el-option>
<el-option label="离线" value="false"></el-option>
</el-select>
<el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"
@click="getDeviceList()"></el-button>
<el-button size="mini" :loading="getDeviceListLoading"
@click="getDeviceList()">刷新</el-button>
<el-button type="primary" size="mini" style="float: right" @click="onSubmit"> </el-button>
</div>
</div>
<!--设备列表-->
@ -35,6 +36,14 @@
</el-table-column>
<el-table-column prop="manufacturer" label="厂家" min-width="120" >
</el-table-column>
<el-table-column label="地址" min-width="160" >
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if="scope.row.hostAddress" size="medium">{{ scope.row.hostAddress }}</el-tag>
<el-tag v-if="!scope.row.hostAddress" size="medium"></el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="状态" min-width="120">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
@ -45,12 +54,12 @@
</el-table-column>
</el-table>
<el-pagination
style="float: right"
style="text-align: right;"
@size-change="handleSizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50, 200, 1000, 50000]"
:page-sizes="[10, 25, 35, 50, 200, 1000, 50000]"
layout="total, sizes, prev, pager, next"
:total="total">
</el-pagination>
@ -74,9 +83,9 @@ export default {
videoComponentList: [],
updateLooper: 0, //
currentDeviceChannelsLenth: 0,
winHeight: window.innerHeight - 200,
winHeight: 580,
currentPage: 1,
count: 15,
count: 10,
total: 0,
getDeviceListLoading: false,
multipleSelection: [],
@ -127,7 +136,10 @@ export default {
this.showDialog = true;
},
onSubmit: function () {
if (this.listChangeCallback ) {
this.listChangeCallback(this.multipleSelection)
}
this.showDialog = false;
},
close: function () {
this.showDialog = false;

View File

@ -2,7 +2,7 @@
<div id="region" style="width: 100%">
<el-container v-loading="loading" >
<el-aside width="400px" >
<RegionTree ref="regionTree" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange"></RegionTree>
<RegionTree ref="regionTree" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange" :onChannelChange="getChannelList"></RegionTree>
</el-aside>
<el-main style="padding: 5px;">
<div class="page-header">
@ -30,11 +30,12 @@
<el-button size="mini" type="primary" @click="add()">
添加
</el-button>
<el-button icon="el-icon-refresh-right" circle size="mini" @click="getChannelList()"></el-button>
</div>
</div>
</div>
<el-table ref="channelListTable" :data="channelList" :height="winHeight" style="width: 100%"
header-row-class-name="table-header" @selection-change="handleSelectionChange">
header-row-class-name="table-header" @selection-change="handleSelectionChange" @row-dblclick="rowDblclick">
<el-table-column type="selection" width="55" :selectable="selectable">
</el-table-column>
<el-table-column prop="gbName" label="名称" min-width="180">
@ -43,6 +44,15 @@
</el-table-column>
<el-table-column prop="gbManufacturer" label="厂家" min-width="100">
</el-table-column>
<el-table-column label="类型" min-width="100">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.gbDeviceDbId"></el-tag>
<el-tag size="medium" v-if="scope.row.streamPushId"></el-tag>
<el-tag size="medium" v-if="scope.row.streamProxyId"></el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="状态" min-width="100">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
@ -54,7 +64,7 @@
<el-table-column label="添加状态" min-width="100">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.gbCivilCode">-{{scope.row.gbCivilCode}}</el-tag>
<el-tag size="medium" :title="scope.row.gbCivilCode" v-if="scope.row.gbCivilCode"></el-tag>
<el-tag size="medium" type="info" v-if="!scope.row.gbCivilCode"></el-tag>
</div>
</template>
@ -156,6 +166,11 @@ export default {
return true
}
},
rowDblclick: function (row, rowIndex) {
if (row.gbCivilCode) {
this.$refs.regionTree.refresh(row.gbCivilCode)
}
},
add: function (row) {
if (!this.regionId) {
this.$message.info("请选择左侧行政区划节点")
@ -181,6 +196,9 @@ export default {
}).then((res)=> {
if (res.data.code === 0) {
this.$message.success("保存成功")
this.getChannelList()
//
this.$refs.regionTree.refresh(this.regionId)
}else {
this.$message.error(res.data.msg)
}