临时提交

pull/1642/head
648540858 2024-08-24 21:54:59 +08:00
parent dddcff8fdb
commit 5216e9723c
7 changed files with 139 additions and 39 deletions

View File

@ -505,4 +505,14 @@ public interface CommonGBChannelMapper {
) )
List<CommonGBChannel> queryShareChannelByParentId(@Param("parentId") String parentId, @Param("platformId") Integer platformId); List<CommonGBChannel> queryShareChannelByParentId(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_civil_code = #{civilCode}" +
" WHERE id in "+
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
" </script>"})
int updateCivilCodeByChannelList(@Param("civilCode") String civilCode, List<CommonGBChannel> channelList);
} }

View File

@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
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;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -115,4 +114,13 @@ public interface RegionMapper {
" </script>") " </script>")
void updateParentId(List<Region> regionListForAdd); void updateParentId(List<Region> regionListForAdd);
@Update(" <script>" +
" update wvp_common_region" +
" set parent_device_id = #{parentDeviceId}" +
" where parent_id = #{parentId} " +
" </script>")
void updateChild(@Param("parentId") int parentId, @Param("parentDeviceId") String parentDeviceId);
@Select("SELECT * from wvp_common_region WHERE device_id = #{deviceId} ")
Region queryByDeviceId(@Param("deviceId") String deviceId);
} }

View File

@ -78,4 +78,5 @@ public interface IGbChannelService {
CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId); CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId);
void updateCivilCode(String oldCivilCode, String newCivilCode);
} }

View File

@ -648,4 +648,25 @@ public class GbChannelServiceImpl implements IGbChannelService {
public CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId) { public CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId) {
return platformChannelMapper.queryOneWithPlatform(platformId, channelDeviceId); return platformChannelMapper.queryOneWithPlatform(platformId, channelDeviceId);
} }
@Override
public void updateCivilCode(String oldCivilCode, String newCivilCode) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByCivilCode(oldCivilCode);
if (channelList.isEmpty()) {
return;
}
int result = commonGBChannelMapper.updateCivilCodeByChannelList(newCivilCode, channelList);
if (result > 0) {
for (CommonGBChannel channel : channelList) {
channel.setGbCivilCode(newCivilCode);
}
// 发送catalog
try {
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
} catch (Exception e) {
log.warn("[多个通道业务分组] 发送失败,数量:{}", channelList.size(), e);
}
}
}
} }

View File

@ -2,10 +2,13 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.CivilCodePo; import com.genersoft.iot.vmp.common.CivilCodePo;
import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.exception.ControllerException;
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;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper; import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.service.IRegionService; import com.genersoft.iot.vmp.gb28181.service.IRegionService;
import com.genersoft.iot.vmp.utils.CivilCodeUtil; import com.genersoft.iot.vmp.utils.CivilCodeUtil;
@ -41,6 +44,9 @@ public class RegionServiceImpl implements IRegionService {
@Autowired @Autowired
private IGbChannelService gbChannelService; private IGbChannelService gbChannelService;
@Autowired
private EventPublisher eventPublisher;
@Override @Override
public void add(Region region) { public void add(Region region) {
Assert.hasLength(region.getName(), "名称必须存在"); Assert.hasLength(region.getName(), "名称必须存在");
@ -98,7 +104,26 @@ public class RegionServiceImpl implements IRegionService {
@Override @Override
@Transactional @Transactional
public void update(Region region) { public void update(Region region) {
Assert.notNull(region.getDeviceId(), "编号不可为NULL");
Assert.notNull(region.getName(), "名称不可为NULL");
Region regionInDb = regionMapper.queryOne(region.getId());
Assert.notNull(regionInDb, "待更新行政区划在数据库中不存在");
if (!regionInDb.getDeviceId().equals(region.getDeviceId())) {
Region regionNewInDb = regionMapper.queryByDeviceId(region.getDeviceId());
Assert.isNull(regionNewInDb, "此行政区划已存在");
// 编号发生变化,把分配了这个行政区划的通道全部更新,并发送数据
gbChannelService.updateCivilCode(regionInDb.getDeviceId(), region.getDeviceId());
// 子节点信息更新
regionMapper.updateChild(region.getId(), region.getDeviceId());
}
regionMapper.update(region);
// 发送变化通知
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, CommonGBChannel.build(region), CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[行政区划变化] 发送失败,{}", region.getDeviceId(), e);
}
} }
@Override @Override

View File

@ -157,7 +157,7 @@ export default {
} }
}, },
{ {
label: "重命名", label: "编辑节点",
icon: "el-icon-edit", icon: "el-icon-edit",
disabled: node.level === 1, disabled: node.level === 1,
onClick: () => { onClick: () => {
@ -321,15 +321,19 @@ export default {
this.$refs.regionCode.openDialog(form => { this.$refs.regionCode.openDialog(form => {
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, node.data.deviceId, node.data.id); }, {
deviceId: "",
name: "",
parentId: node.data.id,
parentDeviceId: node.data.deviceId,
});
}, },
editCatalog: function (data, node){ editCatalog: function (data, node){
// //
this.$refs.regionCode.openDialog(form => { this.$refs.regionCode.openDialog(form => {
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, node.data.deviceId, node.data.id); }, node.data);
}, },
nodeClickHandler: function (data, node, tree) { nodeClickHandler: function (data, node, tree) {
console.log(data) console.log(data)

View File

@ -129,12 +129,11 @@ export default {
}; };
}, },
methods: { methods: {
openDialog: function (endCallBck, parentDeviceId, parentId, code, lockContent) { openDialog: function (endCallBck, region, code, lockContent) {
this.showVideoDialog = true this.showVideoDialog = true
this.activeKey= '0'; this.activeKey= '0';
this.regionList = [] this.regionList = []
this.form.parentDeviceId = parentDeviceId this.form = region
this.form.parentId = parentId
this.allVal = [ this.allVal = [
{ {
id: [1, 2], id: [1, 2],
@ -165,29 +164,41 @@ export default {
lock: false, lock: false,
} }
] ]
if (parentDeviceId) { if (this.form.deviceId) {
if (parentDeviceId.length >= 2) { if (this.form.deviceId.length >= 2) {
this.allVal[0].val = parentDeviceId.substring(0, 2) this.allVal[0].val = this.form.deviceId.substring(0, 2)
this.activeKey = "0"
}
if (this.form.deviceId.length >= 4) {
this.allVal[1].val = this.form.deviceId.substring(2, 4)
this.activeKey = "1" this.activeKey = "1"
} }
if (parentDeviceId.length >= 4) { if (this.form.deviceId.length >= 6) {
this.allVal[1].val = parentDeviceId.substring(2, 4) this.allVal[2].val = this.form.deviceId.substring(4, 6)
this.activeKey = "2" this.activeKey = "2"
} }
if (parentDeviceId.length >= 6) { if (this.form.deviceId.length === 8) {
this.allVal[2].val = parentDeviceId.substring(4, 6) this.allVal[3].val = this.form.deviceId.substring(6, 8)
this.activeKey = "3"
}
}else {
if (this.form.parentDeviceId) {
if (this.form.parentDeviceId.length >= 2) {
this.allVal[0].val = this.form.parentDeviceId.substring(0, 2)
this.activeKey = "1"
}
if (this.form.parentDeviceId.length >= 4) {
this.allVal[1].val = this.form.parentDeviceId.substring(2, 4)
this.activeKey = "2"
}
if (this.form.parentDeviceId.length >= 6) {
this.allVal[2].val = this.form.parentDeviceId.substring(4, 6)
this.activeKey = "3" this.activeKey = "3"
} }
} }
this.getRegionList() }
// if (typeof code != 'undefined' && code.length === 8) {
// this.allVal[0].val = code.substring(0, 2)
// this.allVal[1].val = code.substring(2, 4)
// this.allVal[2].val = code.substring(4, 6)
// this.allVal[3].val = code.substring(6, 8)
// }
console.log(this.allVal) this.getRegionList()
this.endCallBck = endCallBck; this.endCallBck = endCallBck;
}, },
getRegionList: function() { getRegionList: function() {
@ -263,9 +274,10 @@ export default {
}, },
handleOk: function() { handleOk: function() {
if (this.form.id) {
this.$axios({ this.$axios({
method: 'post', method: 'post',
url: "/api/region/add/", url: "/api/region/update",
data: this.form data: this.form
}).then((res) => { }).then((res) => {
if (res.data.code === 0) { if (res.data.code === 0) {
@ -279,6 +291,25 @@ export default {
}).catch((error) => { }).catch((error) => {
this.$message.error(error); this.$message.error(error);
}); });
}else {
this.$axios({
method: 'post',
url: "/api/region/add",
data: this.form
}).then((res) => {
if (res.data.code === 0) {
if (typeof this.endCallBck == "function") {
this.endCallBck(this.form)
}
this.showVideoDialog = false
} else {
this.$message.error(res.data.msg);
}
}).catch((error) => {
this.$message.error(error);
});
}
} }
}, },