From e8c65bed6207168103268eda71325ecfb641f205 Mon Sep 17 00:00:00 2001 From: guo <260206558@qq.com> Date: Wed, 19 Feb 2025 09:19:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=88=86=E7=BB=84=E6=97=B6=E6=A0=A1=E9=AA=8C=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=94=AF=E4=B8=80=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/service/impl/GroupServiceImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java index b0316c18..bc8e9f10 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java @@ -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 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 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);