Fix resource tree update

This commit is contained in:
Xuwznln
2025-10-14 01:53:04 +08:00
parent ca027bf0eb
commit 4e434eeb97

View File

@@ -932,12 +932,19 @@ class HostNode(BaseROS2DeviceNode):
from unilabos.app.web.client import http_client from unilabos.app.web.client import http_client
uuid_to_trees = collections.defaultdict(list)
for root_node in resource_tree_set.root_nodes:
uuid_to_trees[root_node.res_content.uuid].append(root_node)
for uuid, trees in uuid_to_trees.items():
new_tree_set = ResourceTreeSet(trees)
resource_start_time = time.time() resource_start_time = time.time()
uuid_mapping = http_client.resource_tree_update(resource_tree_set, "", False) uuid_mapping = http_client.resource_tree_add(new_tree_set, uuid, False)
success = bool(uuid_mapping) success = bool(uuid_mapping)
resource_end_time = time.time() resource_end_time = time.time()
self.lab_logger().info( self.lab_logger().info(
f"[Host Node-Resource] 物料更新上传 {round(resource_end_time - resource_start_time, 5) * 1000} ms" f"[Host Node-Resource] 挂载 {uuid} 物料更新上传 {round(resource_end_time - resource_start_time, 5) * 1000} ms"
) )
if uuid_mapping: if uuid_mapping:
self.lab_logger().info(f"[Host Node-Resource] UUID映射: {len(uuid_mapping)} 个节点") self.lab_logger().info(f"[Host Node-Resource] UUID映射: {len(uuid_mapping)} 个节点")