fix: 新增更新分组时校验节点编码唯一性

pull/1772/head
guo 2025-02-19 09:19:14 +08:00
parent 36004d471c
commit e8c65bed62
1 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.service.IGroupService; import com.genersoft.iot.vmp.gb28181.service.IGroupService;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -47,6 +48,13 @@ public class GroupServiceImpl implements IGroupService {
GbCode gbCode = GbCode.decode(group.getDeviceId()); GbCode gbCode = GbCode.decode(group.getDeviceId());
Assert.notNull(gbCode, "设备编号不满足国标定义"); Assert.notNull(gbCode, "设备编号不满足国标定义");
// 查询数据库中已经存在的.
List<Group> groupListInDb = groupManager.queryInGroupListByDeviceId(Lists.newArrayList(group));
if (!ObjectUtils.isEmpty(groupListInDb)){
throw new ControllerException(ErrorCode.ERROR100.getCode(), String.format("该节点编号 %s 已存在", group.getDeviceId()));
}
if ("215".equals(gbCode.getTypeCode())){ if ("215".equals(gbCode.getTypeCode())){
// 添加业务分组 // 添加业务分组
addBusinessGroup(group); addBusinessGroup(group);
@ -100,6 +108,12 @@ public class GroupServiceImpl implements IGroupService {
Group groupInDb = groupManager.queryOne(group.getId()); Group groupInDb = groupManager.queryOne(group.getId());
Assert.notNull(groupInDb, "分组不存在"); Assert.notNull(groupInDb, "分组不存在");
// 查询数据库中已经存在的.
List<Group> groupListInDb = groupManager.queryInGroupListByDeviceId(Lists.newArrayList(group));
if (!ObjectUtils.isEmpty(groupListInDb) && groupListInDb.get(0).getId() != group.getId()){
throw new ControllerException(ErrorCode.ERROR100.getCode(), String.format("该该节点编号 %s 已存在", group.getDeviceId()));
}
group.setName(group.getName()); group.setName(group.getName());
group.setUpdateTime(DateUtil.getNow()); group.setUpdateTime(DateUtil.getNow());
groupManager.update(group); groupManager.update(group);