浏览代码

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

mengxiangge 6 年之前
父节点
当前提交
931c8b2c1c

+ 5 - 5
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemGraphUtil.cs

@@ -32,7 +32,7 @@ namespace SAGA.GplotRelationComputerManage
         {          
             SystemGraph graph = new SystemGraph();
             Queue<JoinElement> joinElements = new Queue<JoinElement>();           
-            joinElements.Enqueue(CreateJoinElement(startElement, ignoredConnector, new List<int>()));
+            joinElements.Enqueue(CreateJoinElement(startElement, ignoredConnector, new HashSet<int>()));
             while (joinElements.Any())
             {
                 var current = joinElements.Peek();
@@ -62,7 +62,7 @@ namespace SAGA.GplotRelationComputerManage
                 var existJoinElement = joinElements.FirstOrDefault(j => j.Element.Id == end.Id);
                 if (existJoinElement == null)
                 {
-                    existJoinElement = CreateJoinElement(end, ignoredConnector, new List<int>(){ });
+                    existJoinElement = CreateJoinElement(end, ignoredConnector, new HashSet<int>());
                     joinElements.Enqueue(existJoinElement);
                 }
                 existJoinElement.UsedRefIds.Add(pathElements[pathElements.Count - 2].Id.IntegerValue);
@@ -73,14 +73,14 @@ namespace SAGA.GplotRelationComputerManage
             return graph;
         }
         #region 辅助类构建
-        public static JoinElement CreateJoinElement(Element element, Predicate<Connector> ignoredConnector, List<int> usedIds)
+        public static JoinElement CreateJoinElement(Element element, Predicate<Connector> ignoredConnector, HashSet<int> usedIds)
         {
             var joinItems = GetJoinItems(element, ignoredConnector, usedIds);
             JoinElement joinElement = new JoinElement(element, joinItems);
             return joinElement;
         }
 
-        public static List<JoinItem> GetJoinItems(Element element, Predicate<Connector> ignoredConnector, List<int> usedIds)
+        public static List<JoinItem> GetJoinItems(Element element, Predicate<Connector> ignoredConnector, HashSet<int> usedIds)
         {
             List<JoinItem> joinItems = new List<JoinItem>();
             var connectors = element.GetAllConnectors();
@@ -92,7 +92,7 @@ namespace SAGA.GplotRelationComputerManage
                 {
                     foreach (Connector refConnector in connector.AllRefs)
                     {
-                        if (refConnector.IsLogical() || refConnector.Owner.Id == element.Id || usedIds.Any(id => refConnector.Owner.Id.IntegerValue == id))
+                        if (refConnector.IsLogical() || refConnector.Owner.Id == element.Id || usedIds.Contains(refConnector.Owner.Id.IntegerValue))
                             continue;
                         if (ignoredConnector(refConnector))
                             continue;

+ 26 - 31
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -35,41 +35,47 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         /// <param name="startElement"></param>
         /// <param name="startConnector"></param>
-        /// <param name="predicateEnd"></param>
+        /// <param name="predicateEnd">遍历节点满足条件,则不再往下遍历,但使用当前对象</param>
         /// <returns></returns>
         public static ElementTreeNode CreateTreeNode(Element startElement, Connector startConnector,
             Predicate<Element> predicateEnd)
         {
+            HashSet<int> handled = new HashSet<int>();
             ElementTreeNode node = new ElementTreeNode();
             node.Current = startElement;
-            List<ElementTreeNode> reference = new List<ElementTreeNode>();
-            reference.Add(node);
-            for (int i = 0; i < reference.Count; i++)
+            Queue<ElementTreeNode> queue = new Queue<ElementTreeNode>();
+            queue.Enqueue(node);
+            handled.Add(startElement.Id.IntegerValue);
+            bool isStart = true;
+            while (queue.Count != 0)
             {
-                var baseNode = reference[i];
+                var baseNode = queue.Dequeue();
                 List<Connector> connectors;
-                if (i == 0 && startConnector != null)
+                if (isStart && startConnector != null)
                 {
-                    connectors = new List<Connector> { startConnector };
+                    connectors = new List<Connector> { startConnector };                   
                 }
                 else
                 {
                     connectors = baseNode.Current.GetAllConnectors().ToList();
                 }
+                if (isStart)
+                {
+                    isStart = false;
+                }               
                 foreach (var connector in connectors)
                 {
                     if (connector.Searchable())
                     {
-                        var refConnectors = connector.GetReferenceConnectors()
-                            .Where(c => ConnectorType.Physical.HasFlag(c.ConnectorType)).ToList();
+                        var refConnectors = connector.GetPhysicalConnectors();
                         foreach (var refConnector in refConnectors)
                         {
                             var refElement = refConnector.Owner;
-                            if (reference.Reverse<ElementTreeNode>().Any(e => e.Current.Id.IntegerValue == refElement.Id.IntegerValue))
+                            if (handled.Contains(refElement.Id.IntegerValue))
                             {
                                 continue;
                             }
-
+                            handled.Add(refElement.Id.IntegerValue);
                             ElementTreeNode refNode = new ElementTreeNode();
                             refNode.Current = refElement;
                             refNode.StartLocation = refConnector.Origin;
@@ -78,14 +84,11 @@ namespace SAGA.GplotRelationComputerManage
                             {
                                 continue;
                             }
-                            //if (reference.All(e => e.Current.Id.IntegerValue != refElement.Id.IntegerValue))
-                            //{
-                                reference.Add(refNode);
-                            //}
+                            queue.Enqueue(refNode);
                         }
                     }
                 }
-            }
+            }        
             return node;
         }
         #endregion
@@ -97,9 +100,9 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="domain"></param>
         /// <param name="endConditon">遍历中断条件,遇到指定条件的管道则停止遍历</param>
         /// <returns>树形节点中包好的Id信息</returns>
-        public static List<int> BuildSystemNode(ElementTreeNode etn, Domain domain, Func<MEPCurve, bool> endConditon)
+        public static HashSet<int> BuildSystemNode(ElementTreeNode etn, Domain domain, Func<MEPCurve, bool> endConditon)
         {
-            List<int> useIds = new List<int>();
+            HashSet<int> useIds = new HashSet<int>();
             etn.GetAllNodes().ForEach(n =>
             {
                 if (!n.IsLeaf&&n.Current != null)
@@ -114,7 +117,7 @@ namespace SAGA.GplotRelationComputerManage
             }        
             return useIds;
         }
-        private static void BuildSystemNode(ElementTreeNode etn, Domain domain, List<int> useIds, Func<MEPCurve, bool> endConditon)
+        private static void BuildSystemNode(ElementTreeNode etn, Domain domain, HashSet<int> useIds, Func<MEPCurve, bool> endConditon)
         {
             var useElement = etn.Current;
             #region 预判退出
@@ -122,28 +125,21 @@ namespace SAGA.GplotRelationComputerManage
             {
                 return;
             }
-            if (useIds.Any(id => id == useElement.Id.IntegerValue))
+            if (useIds.Contains(useElement.Id.IntegerValue))
             {
                 return;
             }
             #endregion
-
             useIds.Add(useElement.Id.IntegerValue);
             var connectors = useElement.GetConnectors(domain);
             foreach (var baseConnector in connectors)
             {
                 if (!baseConnector.Searchable())
                     continue;
-                var refConnectors = baseConnector.GetReferenceConnectors()
-                    .Where(c => ConnectorType.Physical.HasFlag(c.ConnectorType)).ToList();
+                var refConnectors = baseConnector.GetPhysicalConnectors();
                 foreach (var refConnector in refConnectors)
                 {
-                    var refElement = refConnector.Owner;
-                    //逻辑变更,如果存在,不继续遍历。但要完成本次操作;移动到最后
-                    //if (useIds.Any(id => id == refElement.Id.IntegerValue))
-                    //{
-                    //    continue;
-                    //}
+                    var refElement = refConnector.Owner;                  
                     //初始化当前节点,未必一定加入集合,为了下面代码书写方便,先进性初始化
                     ElementTreeNode currentNode = new ElementTreeNode()
                     {
@@ -153,7 +149,6 @@ namespace SAGA.GplotRelationComputerManage
                     if (refElement is MEPCurve mepCurve)
                     {
                         //优先判定系统,再进行立管相关逻辑的处理;如果系统不兼容则直接退出遍历
-                        //var systemName=mepCurve.GetSystemTypeName();
                         if (endConditon != null && endConditon(mepCurve))
                         {
                             continue;
@@ -178,7 +173,7 @@ namespace SAGA.GplotRelationComputerManage
                         }
                     }
                     //useIds的控制:跳出时,直接加入UseIds。继续遍历的,在遍历函数中加入               
-                    if (useIds.Any(id => id == refElement.Id.IntegerValue))
+                    if (useIds.Contains(refElement.Id.IntegerValue))
                     {
                         continue;
                     }

+ 5 - 5
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -243,7 +243,7 @@ namespace SAGA.GplotRelationComputerManage
              * 3、要不要显示端头管所在空间的位置
              */
             var startNodes = GetStartNodes();
-            List<int> useIds = new List<int>();
+            HashSet<int> useIds = new HashSet<int>();
             List<MEPCurve> verticalMepCurves = new List<MEPCurve>();
             for (int i = 0; i < startNodes.Count; i++)
             {
@@ -265,7 +265,7 @@ namespace SAGA.GplotRelationComputerManage
                     (m => !startNode.Flag.Equals(m.GetSystemTypeName())));
                 startNode.Instance.PipeSystemTypeName = startNode.Flag;
                 BuildElementNodeData(context, startNode.Instance);
-                useIds.AddRange(tempIds);
+                useIds.UnionWith(tempIds);
                 startNode.Handled = true;
 
                 //可以清空Leaves的子节点
@@ -304,7 +304,7 @@ namespace SAGA.GplotRelationComputerManage
             for (int i = 0; i < singleInstances.Count; i++)
             {
                 var useInstance = singleInstances[i];
-                if (useIds.Any(id => id == useInstance.Id.IntegerValue) || useEquipments.Any(id => id == useInstance.Id.ToString()))
+                if (useIds.Contains(useInstance.Id.IntegerValue) || useEquipments.Any(id => id == useInstance.Id.ToString()))
                 {
                     continue;
                 }
@@ -344,7 +344,7 @@ namespace SAGA.GplotRelationComputerManage
                             (m => !systemTypeName.Equals(m.GetSystemTypeName())));
                         newStartNode.PipeSystemTypeName = systemTypeName;
                         BuildElementNodeData(context, newStartNode);
-                        useIds.AddRange(tempIds);
+                        useIds.UnionWith(tempIds);
 
                         #region 生成绘图,计算数据
 
@@ -352,7 +352,7 @@ namespace SAGA.GplotRelationComputerManage
                         var drawRecord = BuildFloorDrawRecord(relationSetting, newStartNode);
                         drawRecord.SystemName = systemTypeName;
                         drawRecords.Add(drawRecord);
-
+                       
                         var relationRecord = BuildFloorRelationRecord(relationSetting, newStartNode, context);
                         relationRecords.Add(relationRecord);
 

+ 1 - 1
MBI/SAGA.MBI/RequestData/LoginRequest.cs

@@ -89,7 +89,7 @@ namespace SAGA.MBI.RequestData
             ManageInfo mode = new ManageInfo();
             JObject jObject = JObject.Parse(json);
             mode.Phone_Num = (string)jObject["person"]["phone"];
-            mode.Person_Id = (string)jObject["person"]["personId"];
+            mode.Person_Id = (string)jObject["person"]["phone"];
             return mode;
         }
 

+ 10 - 0
MBI/SAGA.RevitUtils/MEP/ConnectorExtend.cs

@@ -254,6 +254,16 @@ namespace SAGA.RevitUtils.MEP
             }
             return list;
         }
+        /// <summary>
+        /// 获取与指定connector相连接的物理连接点为
+        /// </summary>
+        /// <param name="connector"></param>
+        /// <returns></returns>
+        public static List<Connector> GetPhysicalConnectors(this Connector connector)
+        {
+            var originConnectors = connector.GetReferenceConnectors();
+            return originConnectors.Where(c => ConnectorType.Physical.HasFlag(c.ConnectorType)).ToList();
+        }
     }
 }