行政区划支持异常数据补充行政区划节点以及清理异常行政区划节点使通道可被挂载

master
lin 2025-03-14 14:53:47 +08:00
parent d5dc0f9afd
commit 4dce850aea
12 changed files with 200 additions and 22 deletions

View File

@ -46,6 +46,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git
# 功能特性 # 功能特性
- [X] 集成web界面 - [X] 集成web界面
- [X] 兼容性良好 - [X] 兼容性良好
- [X] 跨平台服务,一次编译多端部署, 可以同时用于x86和arm架构
- [X] 接入设备 - [X] 接入设备
- [X] 视频预览 - [X] 视频预览
- [X] 支持主码流子码流切换 - [X] 支持主码流子码流切换

View File

@ -161,13 +161,10 @@ public class CommonChannelController {
} }
@Operation(summary = "清除存在行政区划但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "清除存在行政区划但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "param", description = "当前页", required = true) @Parameter(name = "param", description = "清理参数, all为true清理所有异常数据。 否则按照传入的设备Id清理", required = true)
@GetMapping("/civilCode/unusual/clear") @PostMapping("/civilCode/unusual/clear")
public void queryListByCivilCodeForUnusual(ChannelToRegionParam param){ public void clearChannelCivilCode(@RequestBody ChannelToRegionParam param){
if (ObjectUtils.isEmpty(query)){ channelService.clearChannelCivilCode(param.getAll(), param.getChannelIds());
query = null;
}
return channelService.queryListByCivilCodeForUnusual(page, count, query, online, channelType);
} }
@Operation(summary = "获取关联业务分组通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "获取关联业务分组通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))

View File

@ -124,4 +124,20 @@ public class RegionController {
public void sync(){ public void sync(){
regionService.syncFromChannel(); regionService.syncFromChannel();
} }
@Operation(summary = "根据行政区划编号从文件中查询层级和描述")
@ResponseBody
@GetMapping("/description")
public String getDescription(String civilCode){
return regionService.getDescription(civilCode);
}
@Operation(summary = "根据行政区划编号从文件中查询层级并添加")
@ResponseBody
@GetMapping("/addByCivilCode")
public void addByCivilCode(String civilCode){
regionService.addByCivilCode(civilCode);
}
} }

View File

@ -307,6 +307,14 @@ public interface CommonGBChannelMapper {
" </script>"}) " </script>"})
int removeCivilCodeByChannels(List<CommonGBChannel> channelList); int removeCivilCodeByChannels(List<CommonGBChannel> channelList);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_civil_code = null, civil_code = null" +
" WHERE id in "+
" <foreach collection='channelIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
" </script>"})
int removeCivilCodeByChannelIds(List<Integer> channelIdList);
@SelectProvider(type = ChannelProvider.class, method = "queryByCivilCode") @SelectProvider(type = ChannelProvider.class, method = "queryByCivilCode")
List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode); List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode);
@ -548,4 +556,7 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryListByCivilCodeForUnusual") @SelectProvider(type = ChannelProvider.class, method = "queryListByCivilCodeForUnusual")
List<CommonGBChannel> queryListByCivilCodeForUnusual(@Param("query") String query, @Param("online") Boolean online, @Param("dataType")Integer dataType); List<CommonGBChannel> queryListByCivilCodeForUnusual(@Param("query") String query, @Param("online") Boolean online, @Param("dataType")Integer dataType);
@SelectProvider(type = ChannelProvider.class, method = "queryAllForUnusual")
List<Integer> queryAllForUnusual();
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.common.CivilCodePo;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
@ -179,4 +180,12 @@ public interface RegionMapper {
" </script>") " </script>")
Set<Region> queryNotShareRegionForPlatformByRegionList(Set<Region> allRegion, @Param("platformId") Integer platformId); Set<Region> queryNotShareRegionForPlatformByRegionList(Set<Region> allRegion, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT device_id " +
" from wvp_common_region" +
" where device_id in " +
" <foreach collection='civilCodePoList' item='item' open='(' separator=',' close=')' > #{item.code}</foreach>" +
" </script>")
Set<String> queryInCivilCodePoList(List<CivilCodePo> civilCodePoList);
} }

View File

@ -431,4 +431,13 @@ public class ChannelProvider {
} }
return sqlBuild.toString(); return sqlBuild.toString();
} }
public String queryAllForUnusual(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)" +
" where coalesce(wdc.gb_civil_code, wdc.civil_code) is not null and temp.device_id is null ");
sqlBuild.append(" AND wdc.channel_type = 0 ");
return sqlBuild.toString();
}
} }

View File

@ -91,4 +91,6 @@ public interface IGbChannelService {
void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> callback); void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> callback);
PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count, String query, Boolean online, Integer channelType); PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count, String query, Boolean online, Integer channelType);
void clearChannelCivilCode(Boolean all, List<Integer> channelIds);
} }

View File

@ -36,4 +36,8 @@ public interface IRegionService {
boolean batchAdd(List<Region> regionList); boolean batchAdd(List<Region> regionList);
List<Region> getPath(String deviceId); List<Region> getPath(String deviceId);
String getDescription(String civilCode);
void addByCivilCode(String civilCode);
} }

View File

@ -762,4 +762,16 @@ public class GbChannelServiceImpl implements IGbChannelService {
List<CommonGBChannel> all = commonGBChannelMapper.queryListByCivilCodeForUnusual(query, online, channelType); List<CommonGBChannel> all = commonGBChannelMapper.queryListByCivilCodeForUnusual(query, online, channelType);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@Override
public void clearChannelCivilCode(Boolean all, List<Integer> channelIds) {
List<Integer> channelIdsForClear;
if (all != null && all) {
channelIdsForClear = commonGBChannelMapper.queryAllForUnusual();
}else {
channelIdsForClear = channelIds;
}
commonGBChannelMapper.removeCivilCodeByChannelIds(channelIdsForClear);
}
} }

View File

@ -262,4 +262,66 @@ public class RegionServiceImpl implements IRegionService {
regionList.addAll(allParent); regionList.addAll(allParent);
return regionList; return regionList;
} }
@Override
public String getDescription(String civilCode) {
CivilCodePo civilCodePo = CivilCodeUtil.INSTANCE.getCivilCodePo(civilCode);
Assert.notNull(civilCodePo, String.format("节点%s未查询到", civilCode));
StringBuilder sb = new StringBuilder();
sb.append(civilCodePo.getName());
List<CivilCodePo> civilCodePoList = CivilCodeUtil.INSTANCE.getAllParentCode(civilCode);
if (civilCodePoList.isEmpty()) {
return sb.toString();
}
for (int i = 0; i < civilCodePoList.size(); i++) {
CivilCodePo item = civilCodePoList.get(i);
sb.insert(0, item.getName());
if (i != civilCodePoList.size() - 1) {
sb.insert(0, "/");
}
}
return sb.toString();
}
@Override
@Transactional
public void addByCivilCode(String civilCode) {
CivilCodePo civilCodePo = CivilCodeUtil.INSTANCE.getCivilCodePo(civilCode);
// 查询是否已经存在此节点
Assert.notNull(civilCodePo, String.format("节点%s未查询到", civilCode));
List<CivilCodePo> civilCodePoList = CivilCodeUtil.INSTANCE.getAllParentCode(civilCode);
civilCodePoList.add(civilCodePo);
Set<String> civilCodeSet = regionMapper.queryInCivilCodePoList(civilCodePoList);
if (!civilCodeSet.isEmpty()) {
civilCodePoList.removeIf(item -> civilCodeSet.contains(item.getCode()));
}
if (civilCodePoList.isEmpty()) {
return;
}
int parentId = -1;
for (int i = civilCodePoList.size() - 1; i > -1; i--) {
CivilCodePo codePo = civilCodePoList.get(i);
Region region = new Region();
region.setDeviceId(codePo.getCode());
region.setParentDeviceId(codePo.getParentCode());
region.setName(civilCodePo.getName());
region.setCreateTime(DateUtil.getNow());
region.setUpdateTime(DateUtil.getNow());
if (parentId == -1 && codePo.getParentCode() != null) {
Region parentRegion = regionMapper.queryByDeviceId(codePo.getParentCode());
if (parentRegion == null){
log.error(String.format("行政区划%sy已存在但查询错误", codePo.getParentCode()));
throw new ControllerException(ErrorCode.ERROR100.getCode(), String.format("行政区划%sy已存在但查询错误", codePo.getParentCode()));
}
region.setParentId(parentRegion.getId());
}else {
region.setParentId(parentId);
}
regionMapper.add(region);
parentId = region.getId();
}
}
} }

View File

@ -33,7 +33,7 @@
<el-button size="mini" type="primary" :loading="getChannelListLoading" :disabled="multipleSelection.length ===0" <el-button size="mini" type="primary" :loading="getChannelListLoading" :disabled="multipleSelection.length ===0"
@click="clearUnusualRegion()">清除</el-button> @click="clearUnusualRegion()">清除</el-button>
<el-button size="mini" :loading="getChannelListLoading" <el-button size="mini" :loading="getChannelListLoading"
@click="clearUnusualRegion()">全部清除</el-button> @click="clearUnusualRegion(true)">全部清除</el-button>
<el-button size="mini" :loading="getChannelListLoading" <el-button size="mini" :loading="getChannelListLoading"
@click="getChannelList()">刷新</el-button> @click="getChannelList()">刷新</el-button>
@ -75,6 +75,7 @@
size="medium" size="medium"
type="text" type="text"
icon="el-icon-plus" icon="el-icon-plus"
:loading="scope.row.addRegionLoading"
@click="addRegion(scope.row)" @click="addRegion(scope.row)"
> >
添加 添加
@ -154,6 +155,9 @@ export default {
}).then( (res)=> { }).then( (res)=> {
if (res.data.code === 0) { if (res.data.code === 0) {
this.total = res.data.data.total; 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; this.channelList = res.data.data.list;
} }
}).catch( (error)=> { }).catch( (error)=> {
@ -170,27 +174,26 @@ export default {
close: function () { close: function () {
this.showDialog = false; this.showDialog = false;
}, },
clearUnusualRegion: function () { clearUnusualRegion: function (all) {
if (this.multipleSelection.length === 0) { let channels = null
return; if (all || this.multipleSelection.length > 0 ) {
channels = []
for (let i = 0; i < this.multipleSelection.length; i++) {
channels.push(this.multipleSelection[i].gbId)
}
} }
let channels = []
for (let i = 0; i < this.multipleSelection.length; i++) {
channels.push(this.multipleSelection[i].gbId)
}
this.$axios({ this.$axios({
method: 'post', method: 'post',
url: `/api/common/channel/region/add`, url: `/api/common/channel/civilCode/unusual/clear`,
data: { data: {
civilCode: regionDeviceId, all: all,
channelIds: channels channelIds: channels
} }
}).then((res) => { }).then((res) => {
if (res.data.code === 0) { if (res.data.code === 0) {
this.$message.success({ this.$message.success({
showClose: true, showClose: true,
message: "保存成功" message: "清除成功"
}) })
this.getChannelList() this.getChannelList()
} else { } else {
@ -199,18 +202,71 @@ export default {
message: res.data.msg message: res.data.msg
}) })
} }
this.loading = false
}).catch((error) => { }).catch((error) => {
this.$message.error({ this.$message.error({
showClose: true, showClose: true,
message: error message: error
}) })
}).finally(()=>{
this.loading = false this.loading = false
}); })
}, },
addRegion: function (row) { 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;
})
}, },
} }

View File

@ -40,7 +40,6 @@ export default {
getProgressRun: false, getProgressRun: false,
timer: null, timer: null,
downloadFile: null, downloadFile: null,
}; };
}, },
methods: { methods: {