临时提交

This commit is contained in:
648540858
2024-08-24 21:54:59 +08:00
parent dddcff8fdb
commit 5216e9723c
7 changed files with 139 additions and 39 deletions

View File

@@ -78,4 +78,5 @@ public interface IGbChannelService {
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) {
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.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