fix: 新增更新分组时校验节点编码唯一性
parent
36004d471c
commit
e8c65bed62
|
@ -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.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -47,6 +48,13 @@ public class GroupServiceImpl implements IGroupService {
|
|||
|
||||
GbCode gbCode = GbCode.decode(group.getDeviceId());
|
||||
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())){
|
||||
// 添加业务分组
|
||||
addBusinessGroup(group);
|
||||
|
@ -100,6 +108,12 @@ public class GroupServiceImpl implements IGroupService {
|
|||
Group groupInDb = groupManager.queryOne(group.getId());
|
||||
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.setUpdateTime(DateUtil.getNow());
|
||||
groupManager.update(group);
|
||||
|
|
Loading…
Reference in New Issue