Ver código fonte

Merge branch 'master' of http://dev.dp.sagacloud.cn:8886/r/Revit/SAGA.MBI

mengxiangge 6 anos atrás
pai
commit
f026d4672f

+ 16 - 3
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs

@@ -54,15 +54,28 @@ namespace SAGA.GplotRelationComputerManage
             var originNodes = items.Select(i => context.ItemConvert(i)).ToList();
             #region 构建树形结构
             var tdls = originNodes.Where(t => t.Type ==MBIBuiltInCategory.TDLS).ToList();
-            var eqs = originNodes.Where(t => t.Type != MBIBuiltInCategory.TDLS).ToList();
+           // var eqs = originNodes.Where(t => t.Type != MBIBuiltInCategory.TDLS).ToList();
+            var eqs = originNodes.Where(t =>true).ToList();
             foreach (var dn in tdls)
             {
                  DataNodeUtil.BuildNode(dn, eqs);
             }
             #endregion
-            var allDataNodes = originNodes.Where(t => t.Childrens.Count == 0 || t.Childrens.Any(n => n.Type != MBIBuiltInCategory.TDLS))
+
+            List<DataNode> useNodes = new List<DataNode>();
+            List<DataNode> ignoreNodes = new List<DataNode>();
+            foreach (var originNode in originNodes)
+            {
+                if(originNode.Type==MBIBuiltInCategory.TDLS&&originNode.Childrens.Any()&&originNode.Childrens.All(c=>c.Type==MBIBuiltInCategory.TDLS))
+                {
+                    ignoreNodes.Add(originNode);
+                    continue;
+                }
+                useNodes.Add(originNode);
+            }
+            var allDataNodes = useNodes.Where(t => t.Childrens.Count == 0 || t.Childrens.Any(n => n.Type != MBIBuiltInCategory.TDLS))
               .ToList();
-            var incomingCabinet = allDataNodes.Where(t => t.Childrens.Count != 0 && t.Parent == null).ToList();
+            var incomingCabinet = allDataNodes.Where(t => t.Childrens.Count != 0 &&(t.Parent == null||ignoreNodes.Contains(t.Parent))).ToList();
             var orphanNodes = allDataNodes.Where(t => t.Childrens.Count == 0 && t.Parent == null).ToList();
             DrawDataServer.SaveAsFile<DataNode>(new DataNode("root") { Childrens = incomingCabinet }, "EquipPower");