行政区划支持异常数据补充行政区划节点以及清理异常行政区划节点使通道可被挂载
parent
d5dc0f9afd
commit
4dce850aea
|
@ -46,6 +46,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git
|
|||
# 功能特性
|
||||
- [X] 集成web界面
|
||||
- [X] 兼容性良好
|
||||
- [X] 跨平台服务,一次编译多端部署, 可以同时用于x86和arm架构
|
||||
- [X] 接入设备
|
||||
- [X] 视频预览
|
||||
- [X] 支持主码流子码流切换
|
||||
|
|
|
@ -161,13 +161,10 @@ public class CommonChannelController {
|
|||
}
|
||||
|
||||
@Operation(summary = "清除存在行政区划但无法挂载的通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "param", description = "当前页", required = true)
|
||||
@GetMapping("/civilCode/unusual/clear")
|
||||
public void queryListByCivilCodeForUnusual(ChannelToRegionParam param){
|
||||
if (ObjectUtils.isEmpty(query)){
|
||||
query = null;
|
||||
}
|
||||
return channelService.queryListByCivilCodeForUnusual(page, count, query, online, channelType);
|
||||
@Parameter(name = "param", description = "清理参数, all为true清理所有异常数据。 否则按照传入的设备Id清理", required = true)
|
||||
@PostMapping("/civilCode/unusual/clear")
|
||||
public void clearChannelCivilCode(@RequestBody ChannelToRegionParam param){
|
||||
channelService.clearChannelCivilCode(param.getAll(), param.getChannelIds());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取关联业务分组通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
|
|
|
@ -124,4 +124,20 @@ public class RegionController {
|
|||
public void sync(){
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -307,6 +307,14 @@ public interface CommonGBChannelMapper {
|
|||
" </script>"})
|
||||
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")
|
||||
List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode);
|
||||
|
||||
|
@ -548,4 +556,7 @@ 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();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
|
@ -179,4 +180,12 @@ public interface RegionMapper {
|
|||
" </script>")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -431,4 +431,13 @@ public class ChannelProvider {
|
|||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,6 @@ public interface IGbChannelService {
|
|||
void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> callback);
|
||||
|
||||
PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count, String query, Boolean online, Integer channelType);
|
||||
|
||||
void clearChannelCivilCode(Boolean all, List<Integer> channelIds);
|
||||
}
|
||||
|
|
|
@ -36,4 +36,8 @@ public interface IRegionService {
|
|||
boolean batchAdd(List<Region> regionList);
|
||||
|
||||
List<Region> getPath(String deviceId);
|
||||
|
||||
String getDescription(String civilCode);
|
||||
|
||||
void addByCivilCode(String civilCode);
|
||||
}
|
||||
|
|
|
@ -762,4 +762,16 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
List<CommonGBChannel> all = commonGBChannelMapper.queryListByCivilCodeForUnusual(query, online, channelType);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,4 +262,66 @@ public class RegionServiceImpl implements IRegionService {
|
|||
regionList.addAll(allParent);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<el-button size="mini" type="primary" :loading="getChannelListLoading" :disabled="multipleSelection.length ===0"
|
||||
@click="clearUnusualRegion()">清除</el-button>
|
||||
<el-button size="mini" :loading="getChannelListLoading"
|
||||
@click="clearUnusualRegion()">全部清除</el-button>
|
||||
@click="clearUnusualRegion(true)">全部清除</el-button>
|
||||
<el-button size="mini" :loading="getChannelListLoading"
|
||||
@click="getChannelList()">刷新</el-button>
|
||||
|
||||
|
@ -75,6 +75,7 @@
|
|||
size="medium"
|
||||
type="text"
|
||||
icon="el-icon-plus"
|
||||
:loading="scope.row.addRegionLoading"
|
||||
@click="addRegion(scope.row)"
|
||||
>
|
||||
添加
|
||||
|
@ -154,6 +155,9 @@ export default {
|
|||
}).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)=> {
|
||||
|
@ -170,27 +174,26 @@ export default {
|
|||
close: function () {
|
||||
this.showDialog = false;
|
||||
},
|
||||
clearUnusualRegion: function () {
|
||||
if (this.multipleSelection.length === 0) {
|
||||
return;
|
||||
}
|
||||
let channels = []
|
||||
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/region/add`,
|
||||
url: `/api/common/channel/civilCode/unusual/clear`,
|
||||
data: {
|
||||
civilCode: regionDeviceId,
|
||||
all: all,
|
||||
channelIds: channels
|
||||
}
|
||||
}).then((res) => {
|
||||
if (res.data.code === 0) {
|
||||
this.$message.success({
|
||||
showClose: true,
|
||||
message: "保存成功"
|
||||
message: "清除成功"
|
||||
})
|
||||
this.getChannelList()
|
||||
} else {
|
||||
|
@ -199,18 +202,71 @@ export default {
|
|||
message: res.data.msg
|
||||
})
|
||||
}
|
||||
this.loading = false
|
||||
}).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;
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ export default {
|
|||
getProgressRun: false,
|
||||
timer: null,
|
||||
downloadFile: null,
|
||||
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
Loading…
Reference in New Issue