修改代码
This commit is contained in:
parent
c08855a3b5
commit
054460beaf
|
|
@ -247,22 +247,13 @@ public class ThingsBoardDomainImpl implements IThingsBoardDomain {
|
|||
try {
|
||||
DeviceId gatewayId = new DeviceId(UUID.fromString(gatewayDeviceId));
|
||||
|
||||
// 构建查询参数:从网关出发查询子设备
|
||||
// direction = FROM 表示从 rootId 出发的关系(网关 -> 子设备)
|
||||
RelationsSearchParameters parameters = new RelationsSearchParameters(
|
||||
gatewayId, // rootId: 网关设备ID
|
||||
EntitySearchDirection.FROM, // direction: 从网关出发
|
||||
1, // maxLevel: 查询深度为1(直接子设备)
|
||||
RelationTypeGroup.COMMON, // relationTypeGroup: COMMON
|
||||
false // fetchLastLevelOnly: false
|
||||
// 调用 findInfoByFrom 查询从网关出发的关系信息
|
||||
// 对应前端 API: GET /api/relations/info?fromId=xxx&fromType=DEVICE&relationTypeGroup=COMMON
|
||||
List<EntityRelationInfo> relationInfos = client.findInfoByFrom(
|
||||
gatewayId,
|
||||
RelationTypeGroup.COMMON
|
||||
);
|
||||
|
||||
EntityRelationsQuery query = new EntityRelationsQuery();
|
||||
query.setParameters(parameters);
|
||||
|
||||
// 调用 findInfoByQuery 查询关系信息
|
||||
List<EntityRelationInfo> relationInfos = client.findInfoByQuery(query);
|
||||
|
||||
if (relationInfos == null || relationInfos.isEmpty()) {
|
||||
log.debug("网关 {} 没有子设备", gatewayDeviceId);
|
||||
return childDeviceIds;
|
||||
|
|
|
|||
Loading…
Reference in New Issue