This commit is contained in:
Xuwznln
2026-03-04 19:18:09 +08:00
parent e0fae94c10
commit b993c1f590

View File

@@ -840,14 +840,27 @@ class ResourceTreeSet(object):
f"从远端同步了 {added_count} 个物料子树" f"从远端同步了 {added_count} 个物料子树"
) )
else: else:
# 情况2: 二级物料(不是 device # 二级物料已存在,比较三级子节点是否缺失
if remote_child_name not in local_children_map: local_material = local_children_map[remote_child_name]
# 引入整个子树 local_material_children_map = {child.res_content.name: child for child in
remote_child.res_content.parent = local_device.res_content local_material.children}
local_device.children.append(remote_child) added_count = 0
logger.info(f"Device '{remote_root_id}': 从远端同步物料子树 '{remote_child_name}'") for remote_sub in remote_child.children:
else: remote_sub_name = remote_sub.res_content.name
logger.info(f"物料 '{remote_root_id}/{remote_child_name}' 已存在,跳过") if remote_sub_name not in local_material_children_map:
remote_sub.res_content.parent = local_material.res_content
local_material.children.append(remote_sub)
added_count += 1
else:
logger.info(
f"物料 '{remote_root_id}/{remote_child_name}/{remote_sub_name}' "
f"已存在,跳过"
)
if added_count > 0:
logger.info(
f"物料 '{remote_root_id}/{remote_child_name}': "
f"从远端同步了 {added_count} 个子物料"
)
else: else:
# 情况1: 一级节点是物料(不是 device # 情况1: 一级节点是物料(不是 device
# 检查是否已存在 # 检查是否已存在