diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java index 66aace072..31f046264 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import java.util.List; @@ -70,6 +71,16 @@ public class GroupServiceImpl implements IGroupService { assert group.getCommonGroupDeviceId() != null; group.setCommonGroupCreateTime(DateUtil.getNow()); group.setCommonGroupUpdateTime(DateUtil.getNow()); + Gb28181CodeType channelIdType = SipUtils.getChannelIdType(group.getCommonGroupParentId()); + if (ObjectUtils.isEmpty(group.getCommonGroupParentId().trim()) || channelIdType.equals(Gb28181CodeType.BUSINESS_GROUP)) { + group.setCommonGroupParentId(null); + } + if (ObjectUtils.isEmpty(group.getCommonGroupTopId().trim())) { + Gb28181CodeType channelIdTypeForItem = SipUtils.getChannelIdType(group.getCommonGroupDeviceId()); + if (channelIdTypeForItem.equals(Gb28181CodeType.BUSINESS_GROUP)) { + group.setCommonGroupTopId(group.getCommonGroupDeviceId()); + } + } return groupMapper.add(group) > 0; } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java index c8d427815..75223c8ba 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GroupMapper.java @@ -27,20 +27,22 @@ public interface GroupMapper { " WHERE common_group_device_id = #{deviceId} ") Group queryByDeviceId(@Param("deviceId") String deviceId); - @Insert("INSERT INTO wvp_common_group (" + + @Insert(value = " ") int add(@Param("group") Group group); @Delete("delete from wvp_common_group where common_group_id = #{id}")