临时提交
parent
dddcff8fdb
commit
5216e9723c
|
@ -505,4 +505,14 @@ public interface CommonGBChannelMapper {
|
|||
|
||||
)
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
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.RegionTree;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
@ -115,4 +114,13 @@ public interface RegionMapper {
|
|||
" </script>")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -78,4 +78,5 @@ public interface IGbChannelService {
|
|||
|
||||
CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId);
|
||||
|
||||
void updateCivilCode(String oldCivilCode, String newCivilCode);
|
||||
}
|
||||
|
|
|
@ -648,4 +648,25 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
public CommonGBChannel queryOneWithPlatform(Integer platformId, String 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
|
|||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
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.RegionTree;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
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.IRegionService;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
|
@ -41,6 +44,9 @@ public class RegionServiceImpl implements IRegionService {
|
|||
@Autowired
|
||||
private IGbChannelService gbChannelService;
|
||||
|
||||
@Autowired
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
@Override
|
||||
public void add(Region region) {
|
||||
Assert.hasLength(region.getName(), "名称必须存在");
|
||||
|
@ -98,7 +104,26 @@ public class RegionServiceImpl implements IRegionService {
|
|||
@Override
|
||||
@Transactional
|
||||
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
|
||||
|
|
|
@ -157,7 +157,7 @@ export default {
|
|||
}
|
||||
},
|
||||
{
|
||||
label: "重命名",
|
||||
label: "编辑节点",
|
||||
icon: "el-icon-edit",
|
||||
disabled: node.level === 1,
|
||||
onClick: () => {
|
||||
|
@ -321,15 +321,19 @@ export default {
|
|||
this.$refs.regionCode.openDialog(form => {
|
||||
node.loaded = false
|
||||
node.expand();
|
||||
}, node.data.deviceId, node.data.id);
|
||||
}, {
|
||||
deviceId: "",
|
||||
name: "",
|
||||
parentId: node.data.id,
|
||||
parentDeviceId: node.data.deviceId,
|
||||
});
|
||||
},
|
||||
editCatalog: function (data, node){
|
||||
// 打开添加弹窗
|
||||
this.$refs.regionCode.openDialog(form => {
|
||||
node.loaded = false
|
||||
node.expand();
|
||||
}, node.data.deviceId, node.data.id);
|
||||
|
||||
}, node.data);
|
||||
},
|
||||
nodeClickHandler: function (data, node, tree) {
|
||||
console.log(data)
|
||||
|
|
|
@ -129,12 +129,11 @@ export default {
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
openDialog: function (endCallBck, parentDeviceId, parentId, code, lockContent) {
|
||||
openDialog: function (endCallBck, region, code, lockContent) {
|
||||
this.showVideoDialog = true
|
||||
this.activeKey= '0';
|
||||
this.regionList = []
|
||||
this.form.parentDeviceId = parentDeviceId
|
||||
this.form.parentId = parentId
|
||||
this.form = region
|
||||
this.allVal = [
|
||||
{
|
||||
id: [1, 2],
|
||||
|
@ -165,29 +164,41 @@ export default {
|
|||
lock: false,
|
||||
}
|
||||
]
|
||||
if (parentDeviceId) {
|
||||
if (parentDeviceId.length >= 2) {
|
||||
this.allVal[0].val = parentDeviceId.substring(0, 2)
|
||||
if (this.form.deviceId) {
|
||||
if (this.form.deviceId.length >= 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"
|
||||
}
|
||||
if (parentDeviceId.length >= 4) {
|
||||
this.allVal[1].val = parentDeviceId.substring(2, 4)
|
||||
if (this.form.deviceId.length >= 6) {
|
||||
this.allVal[2].val = this.form.deviceId.substring(4, 6)
|
||||
this.activeKey = "2"
|
||||
}
|
||||
if (parentDeviceId.length >= 6) {
|
||||
this.allVal[2].val = parentDeviceId.substring(4, 6)
|
||||
if (this.form.deviceId.length === 8) {
|
||||
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.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;
|
||||
},
|
||||
getRegionList: function() {
|
||||
|
@ -263,9 +274,10 @@ export default {
|
|||
|
||||
},
|
||||
handleOk: function() {
|
||||
if (this.form.id) {
|
||||
this.$axios({
|
||||
method: 'post',
|
||||
url: "/api/region/add/",
|
||||
url: "/api/region/update",
|
||||
data: this.form
|
||||
}).then((res) => {
|
||||
if (res.data.code === 0) {
|
||||
|
@ -279,6 +291,25 @@ export default {
|
|||
}).catch((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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue