临时提交
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user