Browse Source

xls:计算相关

xulisong 6 years ago
parent
commit
b40296e193
21 changed files with 478 additions and 96 deletions
  1. 1 9
      MBI/CEFSharpWPF/ModifyResponseFilter.cs
  2. 15 3
      MBI/SAGA.DotNetUtils/Data/EdgesArray/EAEdge.cs
  3. 9 4
      MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArrayGraph.cs
  4. 58 0
      MBI/SAGA.DotNetUtils/Data/SingleFactory.cs
  5. 1 0
      MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj
  6. 5 1
      MBI/SAGA.GplotDrawData/Common/WebGplotSettings.cs
  7. 19 15
      MBI/SAGA.GplotDrawData/DBView/MachineRoomGraphView.cs
  8. 4 5
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs
  9. 5 1
      MBI/SAGA.GplotRelationComputerManage/DataServer/DataServer.cs
  10. 35 0
      MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphInstance.cs
  11. 28 0
      MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphRelationItem.cs
  12. 175 0
      MBI/SAGA.GplotRelationComputerManage/RelationBll/RelationBll.cs
  13. 55 34
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphParse.cs
  14. 20 1
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphSetting.cs
  15. 5 4
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemGraphUtil.cs
  16. 3 0
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  17. 1 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  18. 2 2
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  19. 4 4
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  20. 9 3
      MBI/SAGA.Models/Graphs/GElementConverter.cs
  21. 24 10
      MBI/SAGA.RevitUtils/MEP/MepJoinUtil.cs

+ 1 - 9
MBI/CEFSharpWPF/ModifyResponseFilter.cs

@@ -6,25 +6,17 @@
  *  -------------------------------------------------------------------------*/
 
 using System;
-using System.Collections.Generic;
 using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading;
-using System.Threading.Tasks;
 using CefSharp;
 using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
 using Newtonsoft.Json.Linq;
 
 namespace CEFSharpWPF
 {
     public class ModifyResponseFilter : IResponseFilter
     {
-        private MemoryStream memoryStream;
-
-
         public void Dispose()
         {
 
@@ -87,7 +79,7 @@ namespace CEFSharpWPF
 
         public bool InitFilter()
         {
-            memoryStream = new MemoryStream();
+         //memoryStream = new MemoryStream();
             return true;
         }
     }

+ 15 - 3
MBI/SAGA.DotNetUtils/Data/EdgesArray/EAEdge.cs

@@ -74,6 +74,18 @@ namespace SAGA.DotNetUtils.Data
         }
         #endregion
 
+        public void UpdateStartVertex(string vertexId)
+        {
+            if (string.IsNullOrWhiteSpace(vertexId))
+                throw new ArgumentNullException(nameof(vertexId));
+            this.m_StartVertex = vertexId;
+        }
+        public void UpdateEndVertex(string vertexId)
+        {
+            if (string.IsNullOrWhiteSpace(vertexId))
+                throw new ArgumentNullException(nameof(vertexId));
+            this.m_EndVertex = vertexId;
+        }
         #region 边提供方法
         /// <summary>
         /// 判断是否包含指定id的点(-1 表示不包含;0,开始点,1,结束点)
@@ -105,9 +117,9 @@ namespace SAGA.DotNetUtils.Data
         /// </summary>
         public virtual void Reverse()
         {
-            var tempId = StartVertex;
-            StartVertex = EndVertex;
-            EndVertex = tempId;
+            var tempId = m_StartVertex;
+            m_StartVertex = m_EndVertex;
+            m_EndVertex = tempId;
         }
         #endregion
 

+ 9 - 4
MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArrayGraph.cs

@@ -135,16 +135,21 @@ namespace SAGA.DotNetUtils.Data
         /// <returns></returns>
         public virtual bool RemoveVertex(string vertexId)
         {
+            return RemoveVertex(vertexId, false);
+        }
+
+        public virtual bool RemoveVertex(string vertexId,bool deleteRefEdge)
+        {
             var realRemove = this.m_Vertexes.Remove(vertexId);
-            if (realRemove)
+            if (realRemove&&deleteRefEdge)
             {
                 //移除节点需要移除相应的边
                 #region 移除相关联的边
-                var edges = this.Edges.Where(e => e.ContainVertex(vertexId) > -1);
+                var edges = this.Edges.Where(e => e.ContainVertex(vertexId) > -1).ToList();
                 foreach (var edge in edges)
                 {
                     this.m_Edges.Remove(edge.Id);
-                } 
+                }
                 #endregion
 
             }
@@ -420,7 +425,7 @@ namespace SAGA.DotNetUtils.Data
         /// <returns></returns>
         public static List<E> GeFirstStateEdges(IEnumerable<E> inputEdges)
         {
-            var edges = inputEdges.Where(e => e.Parent.Children.Count == 0).ToList();
+            var edges = inputEdges.Where(e => e.Children.Count == 0).ToList();
             return edges;
         }
         /// <summary>

+ 58 - 0
MBI/SAGA.DotNetUtils/Data/SingleFactory.cs

@@ -0,0 +1,58 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SingleFactory
+ * 作者:xulisong
+ * 创建时间: 2019/2/18 16:36:52
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Data
+{
+    public class SingleFactory<T> where T:class
+    {
+        private static Hashtable m_ObjCache = new Hashtable();
+        private static object m_SyncRoot = new Object();
+
+        /// <summary>
+        /// 单例实例类
+        /// </summary>
+        public static T Instance
+        {
+            get
+            {
+                string cacheKey = typeof(T).FullName;
+                T instance = (T)m_ObjCache[cacheKey];
+                if (instance == null)
+                {
+                    lock (m_SyncRoot)
+                    {
+                        if (instance == null)
+                        {
+                            Assembly assObj = Assembly.Load(typeof(T).Assembly.GetName().Name);
+                            object obj = assObj.CreateInstance(cacheKey);
+                            instance = obj as T;
+                            m_ObjCache.Add(cacheKey, instance);
+                        }
+                    }
+                }
+                return instance
+;
+            }
+        }
+        /// <summary>
+        /// 清除集合信息
+        /// </summary>
+        public static void Clear()
+        {
+            string cacheKey = typeof(T).FullName;
+            m_ObjCache.Remove(cacheKey);
+        }
+    }
+}

+ 1 - 0
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -286,6 +286,7 @@
     <Compile Include="Data\InitAttribute.cs" />
     <Compile Include="Data\InitObejct.cs" />
     <Compile Include="Data\NumberGenerater.cs" />
+    <Compile Include="Data\SingleFactory.cs" />
     <Compile Include="Data\SingleInstance.cs" />
     <Compile Include="DB\SQLiteHelper.cs" />
     <Compile Include="DB\TableNameAttribute.cs" />

+ 5 - 1
MBI/SAGA.GplotDrawData/Common/WebGplotSettings.cs

@@ -15,7 +15,7 @@ namespace SAGA.GplotDrawData
             MindMapUrl =MBIConst.GplotViewHost+"mindMap";
             VPipeUrl=MBIConst.GplotViewHost+"conduitGraphy";
             VSpaceUrl = MBIConst.GplotViewHost+"spaceGraphy";
-            
+            MachineRoomUrl = MBIConst.GplotViewHost + "coldside";
         }
         /// <summary>
         /// 拓扑图地址
@@ -33,5 +33,9 @@ namespace SAGA.GplotDrawData
         /// 立面空间地址
         /// </summary>
         public static readonly string VSpaceUrl;
+        /// <summary>
+        /// 机房地址
+        /// </summary>
+        public static readonly string MachineRoomUrl;
     }
 }

+ 19 - 15
MBI/SAGA.GplotDrawData/DBView/MachineRoomGraphView.cs

@@ -21,22 +21,26 @@ namespace SAGA.GplotDrawData
     {
         public override GraphDB AppendDb(MachineRoomDrawRecord t, GraphDB db)
         {
-            var drawItem = t.DrawIems;
-            foreach (var point in drawItem.Points)
-            {
-                GVertex gv = new GVertex() { Location = point.Point.ConvertToPoint3D(), IsSolid =!point.IsVirtual};
-                gv.ElementColor = Colors.Red;
-                gv.Name = point.Name;
-                db.Elements.Add(gv);
-            }
-            foreach (var curve in drawItem.Curves)
-            {
-                GLine gline = new GLine(curve.Points[0].ConvertToPoint3D(), curve.Points[1].ConvertToPoint3D());
-                gline.ElementColor = Colors.Red;
-                db.Elements.Add(gline);
-            }
-
+            #region 老方法
+            //var drawItem = t.DrawIems;
+            //foreach (var point in drawItem.Points)
+            //{
+            //    GVertex gv = new GVertex() { Location = point.Point.ConvertToPoint3D(), IsSolid = !point.IsVirtual };
+            //    gv.ElementColor = Colors.Red;
+            //    gv.Name = point.Name;
+            //    db.Elements.Add(gv);
+            //}
+            //foreach (var curve in drawItem.Curves)
+            //{
+            //    GLine gline = new GLine(curve.Points[0].ConvertToPoint3D(), curve.Points[1].ConvertToPoint3D());
+            //    gline.ElementColor = Colors.Red;
+            //    db.Elements.Add(gline);
+            //} 
+            #endregion
+            db.Elements.AddRange(t.NodePaths);
             return db;
         }
     }
+
+  
 }

+ 4 - 5
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs

@@ -1,12 +1,10 @@
 using System;
 using System.Collections.Generic;
-using System.Collections.ObjectModel;
 using System.Linq;
 using System.Windows;
 
 using CEFSharpWPF;
 using SAGA.GplotRelationComputerManage;
-using SAGA.GplotRelationComputerManage.Draw;
 using SAGA.Models;
 using SAGA.RevitUtils.Windows;
 
@@ -63,7 +61,7 @@ namespace SAGA.GplotDrawData.View
             {
                 foreach (var drawRecord in drawData)
                 {
-                    if (drawRecord.DrawIems.IsEmpty)
+                    if (!drawRecord.NodePaths.Any())
                         continue;
                     var relationNode = treeDataSource.FirstOrDefault(d => d.EName == drawRecord.RelationName);
                     if (relationNode == null)
@@ -85,8 +83,9 @@ namespace SAGA.GplotDrawData.View
             MachineRoomGraphView view = new MachineRoomGraphView();
             var db = view.CreateDb(record);
             ConstData.ResponseData = db.CreateJObjectGroup();
-            ucShowElement.Show(WebGplotSettings.GplotUrl);
-        } 
+            //ucShowElement.Show(WebGplotSettings.GplotUrl);
+            ucShowElement.Show(WebGplotSettings.MachineRoomUrl);
+        }
         #endregion
     }
 }

+ 5 - 1
MBI/SAGA.GplotRelationComputerManage/DataServer/DataServer.cs

@@ -6,6 +6,7 @@ using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 using Newtonsoft.Json;
+using SAGA.Models.Graphs;
 
 namespace SAGA.GplotRelationComputerManage
 {
@@ -80,7 +81,10 @@ namespace SAGA.GplotRelationComputerManage
             var content = file.ReadFileContent();
             if (!string.IsNullOrWhiteSpace(content))
             {
-                return JsonConvert.DeserializeObject<T>(content);
+                JsonSerializerSettings jsetting = new JsonSerializerSettings();
+                //jsetting.Converters.Add(new Point3DConverter());
+                jsetting.Converters.Add(GElementConverter.CreateConverter());
+                return JsonConvert.DeserializeObject<T>(content, jsetting);
             }
             return default(T);
         }

+ 35 - 0
MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphInstance.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 图实例
+    /// </summary>
+    public class GraphInstance
+    {
+        /// <summary>
+        /// 图实例Id
+        /// </summary>
+        public string Id { get; set; }
+        /// <summary>
+        /// 图实例开始时间
+        /// </summary>
+        public string BeginTime { get; set; }
+        /// <summary>
+        /// 图实例结束时间
+        /// </summary>
+        public string UpdateTime { get; set; }
+        /// <summary>
+        /// 图实例类型
+        /// </summary>
+        public string Type { get; set; }
+        public bool IsValid
+        {
+            get { return !string.IsNullOrWhiteSpace(Id); }
+        }
+    }
+}

+ 28 - 0
MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphRelationItem.cs

@@ -0,0 +1,28 @@
+using Newtonsoft.Json;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 图关系类型
+    /// </summary>
+    public class GraphRelationItem
+    {
+        [JsonProperty("rel_type")]
+        public string RelType { get; set; }
+        [JsonProperty("from_id")]
+        public string FromId { get; set; }
+        [JsonProperty("to_id")]
+        public string ToId { get; set; }
+        [JsonProperty("graph_id")]
+        public string GraphId { get; set; }
+
+        public bool IsValid
+        {
+            get
+            {
+                return !string.IsNullOrWhiteSpace(GraphId)&&!string.IsNullOrWhiteSpace(FromId) && !string.IsNullOrWhiteSpace(ToId);
+            }
+        }
+     
+    }
+}

+ 175 - 0
MBI/SAGA.GplotRelationComputerManage/RelationBll/RelationBll.cs

@@ -0,0 +1,175 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SAGA.DotNetUtils.Http;
+using SAGA.MBI.Common;
+using SAGA.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    public class RelationBll
+    {
+        #region 地址相关
+        /// <summary>
+        /// 获取基础地址
+        /// </summary>
+        /// <returns></returns>
+        public string GetBaseUrl()
+        {
+            return $"{ MBIConst.DataPlatformLocalHost}data - platform - 3 / relation / ";
+        }
+        /// <summary>
+        /// 获取密码相关地址字符串
+        /// </summary>
+        /// <returns></returns>
+        private string GetPasswordQuerry()
+        {
+            return $"projectId={MBIControl.ProjectCur.Id}&secret={MBIControl.ProjectCur.Password}";
+        }
+        #endregion
+
+        /// <summary>
+        /// 创建图实例
+        /// </summary>
+        /// <param name="graphType">图类型</param>
+        /// <param name="beginTime">实例启用时间</param>
+        /// <returns></returns>
+        public string AddGraphInstance(string graphType, string beginTime)
+        {
+            var baseUrl = GetBaseUrl();
+            var password = GetPasswordQuerry();
+            string url = $"{baseUrl}graph_instance/create?{password}";
+            JObject jObject = new JObject();
+            jObject.Add("graph_type", graphType);
+            var periods = new JArray();
+            var timeObject = new JObject();
+            timeObject.Add("begin_time", beginTime);
+            timeObject.Add("end_time", "29000101000000");
+            jObject.Add("periods", periods);
+            //string postData = $"{{\"graph_type\":\"{graphType}\",\"periods\":[{{\"begin_time\":\"{begin_time}\",\"end_time\":\"29000101000000\"}}]}}";
+            RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
+
+            return restClient.GetRequest().GetValue("graph_id");
+        }
+
+        /// <summary>
+        /// 根据图类型获取图实例id
+        /// </summary>
+        /// <param name="graphType"></param>
+        /// <returns></returns>
+        public GraphInstance QueryGraphInstance(string graphType)
+        {
+            var baseUrl = GetBaseUrl();
+            var password = GetPasswordQuerry();
+            string url = $"{baseUrl}graph_instance/query?{password}";
+            JObject jObject = new JObject();
+            JObject criteria = new JObject();
+            jObject.Add("criteria", criteria);
+            criteria.Add("jObjectValue", graphType);
+            //string postData = $"{{\"graph_type\":\"{graphType}\"}}";
+            //postData = $"{{\"criteria\":{{\"graph_type\":\"{graphType}\"}}}}";
+            RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
+            GraphInstance instance = new GraphInstance();
+            var result = restClient.GetRequest();
+            return instance;
+        }
+
+        /// <summary>
+        /// 修改实例(如果当前时间点与最新的节点有重复,
+        /// 修改之前的图实例时间,然后创建新的,20171123)
+        /// </summary>
+        /// <param name="graphId">图类型</param>
+        /// <param name="statrDateTime"></param>
+        /// <param name="endDateTime"></param>
+        /// <returns></returns>
+        public  string UpdateGraphInstance(string graphId, string biginTime, string endTime)
+        {
+            var baseUrl = GetBaseUrl();
+            var password = GetPasswordQuerry();
+            string url = $"{baseUrl}graph_instance/update?{password}";
+            JObject jObject = new JObject();
+            JObject criteria = new JObject();
+            jObject.Add("criteria", criteria);
+            criteria.Add("graph_id", graphId);
+
+            JObject set = new JObject();
+            jObject.Add("set", set);
+            var periods = new JArray();
+            set.Add("periods", periods);
+            var timeObject = new JObject();
+            timeObject.Add("begin_time", biginTime);
+            timeObject.Add("end_time", "endTime");
+          
+            //string postData = $"{{\"criteria\":{{\"graph_id\":\"{graphId}\"}},\"set\":{{\"periods\":[{{\"begin_time\":\"{statrDateTime}\",\"end_time\":\"{endDateTime}\"}}]}}}}";
+            RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
+
+            return restClient.GetRequest().GetValue("graph_id");
+        }
+
+        /// <summary>
+        /// 获取图实例ID
+        /// </summary>
+        /// <returns></returns>
+        public string GetGraphId(string graphyType)
+        {
+            var instance = QueryGraphInstance(graphyType);
+            var nowTime = DateTime.Now;
+          
+            if (instance.IsValid)
+            {
+                //将图类型的终止时间改成当前时间
+                UpdateGraphInstance(instance.Id, instance.BeginTime, nowTime.ToString("yyyyMMddHHmmss"));
+            }               
+            //创建新的图类型
+            var newGraphId = AddGraphInstance(graphyType, nowTime.ToString("yyyyMMddHHmmss"));
+            return newGraphId;
+        }
+        /// <summary>
+        /// 创建关系数据
+        /// </summary>
+        /// <param name="criteria">关系数据</param>
+        /// <returns></returns>
+        public  bool CreateRelations(List<GraphRelationItem> items)
+        {
+            var baseUrl = GetBaseUrl();
+            var password = GetPasswordQuerry();
+            string url = $"{baseUrl}create?{password}";
+            var useItems = new List<GraphRelationItem>();
+            foreach (var item in items)
+            {
+                if(item.IsValid)
+                {
+                    useItems.Add(item);
+                }
+            }
+            if(useItems.Count==0)
+            {
+                return true;
+            }
+            JObject jobject = new JObject();
+            jobject.Add("criterias", JArray.FromObject(useItems));
+            RestClient restClient1 = new RestClient(url, HttpVerb.POST, JsonConvert.SerializeObject(jobject).ToString());
+            var result =restClient1.GetRequest().IsSuccess();
+            return result;      
+        }
+
+        /// <summary>
+        /// 创建关系数据
+        /// </summary>
+        /// <param name="graphType"></param>
+        /// <param name="items"></param>
+        /// <returns></returns>
+        public bool CreateRelations(string graphType, List<GraphRelationItem> items)
+        {
+            var newGraphId = GetGraphId(graphType);
+            if (string.IsNullOrWhiteSpace(newGraphId))
+                return false;
+            items.ForEach(item => item.GraphId = newGraphId);
+            return CreateRelations(items);
+        }
+    }
+}

+ 55 - 34
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphParse.cs

@@ -46,6 +46,7 @@ namespace SAGA.GplotRelationComputerManage
             while (newStartElements.Any())
             {
                 var baseElement = newStartElements[0];
+                newStartElements.Remove(baseElement);
                 var graph = CreateGplotGraph(baseElement);
                 var containElements = graph.GetRefElements();
                 newStartElements = newStartElements.Except(containElements, new ElementEqualComparer()).ToList();
@@ -76,7 +77,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public SystemGraph GetOriginGraph(Element element)
         {
-            return SystemGraphUtil.CreateGraph(element, Setting.IgnoredConnector, Setting.BreakElement);
+            return SystemGraphUtil.CreateGraph(element, Setting.IgnoredConnector, Setting.IgnoredElement,Setting.BreakElement);
         }
         #endregion
 
@@ -112,7 +113,7 @@ namespace SAGA.GplotRelationComputerManage
             foreach (var systemVertex in useVertexes)
             {
                 var data = systemVertex.Data;
-                if (data.Any())
+                if (!data.Any())
                 {
                     continue;
                 }
@@ -220,7 +221,7 @@ namespace SAGA.GplotRelationComputerManage
             for (int i = 0; i < useEdges.Count; i++)
             {
                 var baseEdge = useEdges[i];
-                if (map.GetHandled(baseEdge))
+                if (map.GetHandled(baseEdge.Id))
                     continue;
                 var startVertex = graph.GetBootStartVertex(baseEdge);
                 var endVertex = graph.GetBootEndVertex(baseEdge);
@@ -260,11 +261,11 @@ namespace SAGA.GplotRelationComputerManage
                         var flag = systemEdge.ContainVertex(vertexId);
                         if (flag == 0)
                         {
-                            systemEdge.StartVertex = newVertex.Id;
+                            systemEdge.UpdateStartVertex(newVertex.Id);
                         }
                         else if (flag == 1)
                         {
-                            systemEdge.EndVertex = newVertex.Id;
+                            systemEdge.UpdateEndVertex(newVertex.Id);
                         }
                     }
                 }
@@ -286,7 +287,7 @@ namespace SAGA.GplotRelationComputerManage
             DirectedEdge(graph);
             graph.IsDirection = true;
             //串并联处理
-            EdgesArrayGraphUtil.GplotAnalyse(graph);
+            //EdgesArrayGraphUtil.GplotAnalyse(graph);
         }
         /// <summary>
         /// 确定流向
@@ -345,44 +346,64 @@ namespace SAGA.GplotRelationComputerManage
             #region 确定开始点
             List<string> edgeIds = new List<string>();
             List<string> vertexIds = new List<string>();
-            Queue<SystemVertex> queueVertexes = new Queue<SystemVertex>();
-            vertexes.ForEach(v => queueVertexes.Enqueue(v));
-            bool isDeepSearch = false;
-            bool isStart = true;
-            while (queueVertexes.Any())
+            foreach (var systemVertex in vertexes)
             {
-                var currentVertex = queueVertexes.Dequeue();
-                if (!isDeepSearch)
+                if (vertexIds.Contains(systemVertex.Id))
                 {
-                    isStart = (currentVertex.GetEquipment()?.Name ?? string.Empty).Contains("入口");
-                    isDeepSearch = vertexes.LastOrDefault().Id == currentVertex.Id;
+                    continue;
+                }
+                bool isStart = true;
+             
+                var currentVertexName = systemVertex.GetEquipment().Name;
+                if (string.IsNullOrWhiteSpace(currentVertexName))
+                {
+                    continue;
                 }
 
-                vertexIds.Add(currentVertex.Id);
-                var edges = graph.GetInEdges(currentVertex.Id);               
-                foreach (var systemEdge in edges)
+                if (currentVertexName.Contains("入口"))
                 {
-                    if (edgeIds.Contains(systemEdge.Id))
-                    {
-                        continue;
-                    }
-                    edgeIds.Add(systemEdge.Id);
-                    if ((isStart && systemEdge.ContainVertex(currentVertex.Id) == 1)||(!isStart&& systemEdge.ContainVertex(currentVertex.Id) == 0))
-                    {
-                        systemEdge.Reverse();
-                    }
+                    isStart = true;
+                }
+                else if(currentVertexName.Contains("出口"))
+                {
+                    isStart = false;
+                }
+                else
+                {
+                    continue;
+                }
 
-                    var otherId = systemEdge.GetAnotherVertex(currentVertex.Id);
-                    if (!vertexIds.Contains(otherId))
+                Queue<SystemVertex> queueVertexes = new Queue<SystemVertex>();
+                queueVertexes.Enqueue(systemVertex);
+                while (queueVertexes.Any())
+                {
+                    var currentVertex = queueVertexes.Dequeue();                  
+                    vertexIds.Add(currentVertex.Id);
+                    var edges = graph.GetInEdges(currentVertex.Id);
+                    foreach (var systemEdge in edges)
                     {
-                        var nextVertex = graph.FindVertex(otherId);
-                        if (nextVertex != null)
+                        if (edgeIds.Contains(systemEdge.Id))
                         {
-                            queueVertexes.Enqueue(nextVertex);
-                        }                      
+                            continue;
+                        }
+                        edgeIds.Add(systemEdge.Id);
+                        if ((isStart && systemEdge.ContainVertex(currentVertex.Id) == 1) || (!isStart && systemEdge.ContainVertex(currentVertex.Id) == 0))
+                        {
+                            systemEdge.Reverse();
+                        }
+
+                        var otherId = systemEdge.GetAnotherVertex(currentVertex.Id);
+                        if (!vertexIds.Contains(otherId))
+                        {
+                            var nextVertex = graph.FindVertex(otherId);
+                            if (nextVertex != null)
+                            {
+                                queueVertexes.Enqueue(nextVertex);
+                            }
+                        }
                     }
                 }
-            }
+            }    
             #endregion
         }
         #endregion

+ 20 - 1
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphSetting.cs

@@ -73,7 +73,7 @@ namespace SAGA.GplotRelationComputerManage
                 }
                 if (SystemCalcUtil.IsStartValve(owner))
                 {
-                    result = Regex.IsMatch(connector.Description, AppSetting.SourceFlag);
+                    result = !Regex.IsMatch(connector.Description, AppSetting.SourceFlag);
                     break;
                 }
                 #endregion
@@ -91,7 +91,26 @@ namespace SAGA.GplotRelationComputerManage
             return result;
         }
         #endregion
+        /// <summary>
+        /// 忽略元素信息
+        /// </summary>
+        /// <param name="element"></param>
+        /// <returns></returns>
+        public bool IgnoredElement(Element element)
+        {
+            bool result = false;
+            do
+            {
+                if (element is MEPCurve mepCurve)
+                {
+                    string typeName = mepCurve.GetSystemTypeName();
+                    result = !RelationTypeShell.IsMatchSystem(typeName);
+                    break;
+                }
+            } while (false);
 
+            return result;
+        }
         #region 元素断开点
         /// <summary>
         /// 节点断开条件

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

@@ -25,9 +25,10 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         /// <param name="startElement"></param>
         /// <param name="ignoredConnector">忽略的Connector</param>
+        /// <param name="ignoredElement">忽略的Connector</param>
         /// <param name="breakCondition">当connector数量不满足,却又想识别成节点的元素控制</param>
         /// <returns></returns>
-        public static SystemGraph CreateGraph(Element startElement,Predicate<Connector> ignoredConnector, Predicate<Element> breakCondition)
+        public static SystemGraph CreateGraph(Element startElement,Predicate<Connector> ignoredConnector, Predicate<Element> ignoredElement,Predicate<Element> breakCondition)
         {          
             SystemGraph graph = new SystemGraph();
             Queue<JoinElement> joinElements = new Queue<JoinElement>();           
@@ -41,7 +42,7 @@ namespace SAGA.GplotRelationComputerManage
                     joinElements.Dequeue();
                     continue;
                 }
-                var pathElements = joinItem.BaseElement.GetPathElements(joinItem.BaseConnector, breakCondition);
+                var pathElements = joinItem.BaseElement.GetPathElements(joinItem.BaseConnector, ignoredElement, breakCondition);
                 if (pathElements.Count < 2)
                 {
                     continue;
@@ -52,7 +53,7 @@ namespace SAGA.GplotRelationComputerManage
                 var end = pathElements[pathElements.Count - 1];
                 var startVertex = graph.AddVertex(new SystemData(start));
                 var endVertex = graph.AddVertex(new SystemData(end));
-                var edge = graph.AddEdge(new SystemEdge(new SystemData(pathElements.GetRange(1, pathElements.Count - 2))));
+                var edge = new SystemEdge(new SystemData(pathElements.GetRange(1, pathElements.Count - 2)));
                 edge.StartVertex = startVertex.Id;
                 edge.EndVertex = endVertex.Id;
                 edge = graph.AddEdge(edge);
@@ -61,7 +62,7 @@ namespace SAGA.GplotRelationComputerManage
                 var existJoinElement = joinElements.FirstOrDefault(j => j.Element.Id == end.Id);
                 if (existJoinElement == null)
                 {
-                    existJoinElement = CreateJoinElement(startElement, ignoredConnector, new List<int>(){ });
+                    existJoinElement = CreateJoinElement(end, ignoredConnector, new List<int>(){ });
                     joinElements.Enqueue(existJoinElement);
                 }
                 existJoinElement.UsedRefIds.Add(pathElements[pathElements.Count - 2].Id.IntegerValue);

+ 3 - 0
MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj

@@ -129,6 +129,9 @@
     <Compile Include="PumpEnd\DuctTerminalBll.cs" />
     <Compile Include="ReadSpaceCommand.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RelationBll\GraphInstance.cs" />
+    <Compile Include="RelationBll\GraphRelationItem.cs" />
+    <Compile Include="RelationBll\RelationBll.cs" />
     <Compile Include="RelationType\Data\EdgeItem.cs" />
     <Compile Include="RelationType\Data\ObjectItem.cs" />
     <Compile Include="RelationType\Data\RelationItem.cs" />

+ 1 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -562,6 +562,7 @@ namespace SAGA.GplotRelationComputerManage
                 foreach (var elementsEdge in edges)
                 {
                     GNodePath path = new GNodePath();
+                    //path.Id = elementsEdge.Id;
                     path.StartNodeId = elementsEdge.StartVertex;
                     path.EndNodeId = elementsEdge.EndVertex;
                     nodeGraph.Paths.Add(path);

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

@@ -659,7 +659,7 @@ namespace SAGA.GplotRelationComputerManage
                         var spaceIem = context.Rooms.GetItem(equipmentItem.BimId);
                         if (spaceIem != null)
                         {
-                            equipmentItem.Name = spaceIem.Name;
+                            equipmentItem.Name = spaceIem.GetDisplay();
                         }
                     }
                     else if (equipmentItem.ElementType == ElementType.Equipment)
@@ -667,7 +667,7 @@ namespace SAGA.GplotRelationComputerManage
                         var equipment = context.EquipmentItems.GetItem(equipmentItem.BimId);
                         if (equipment != null)
                         {
-                            equipmentItem.Name = equipment.Name;
+                            equipmentItem.Name = equipment.GetDisplay();
                         }
                     }
                 }

+ 4 - 4
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs

@@ -31,10 +31,10 @@ namespace SAGA.GplotRelationComputerManage
             {
                 if (File.Exists(fileInfo))
                 {
-                    if (testFiles.All(f => !fileInfo.Contains(f)))
-                    {
-                        continue;
-                    }
+                    //if (testFiles.All(f => !fileInfo.Contains(f)))
+                    //{
+                    //    continue;
+                    //}
                     FloorSystemItem floorItems = context.FloorItems.GetItem(fileInfo);
                     floorItems.Parse(context);
                     floorItems.Document.CloseDocSimple();

+ 9 - 3
MBI/SAGA.Models/Graphs/GElementConverter.cs

@@ -11,6 +11,10 @@ namespace SAGA.Models.Graphs
 {
     public class GElementConverter : JsonConverter
     {
+        public static JsonConverter CreateConverter()
+        {
+            return new GElementConverter();
+        }
         #region 初始化类型使用字典
         public static Dictionary<string, Type> Types { get; private set; }
         static GElementConverter()
@@ -48,8 +52,9 @@ namespace SAGA.Models.Graphs
             serializer.Serialize(writer, value);
         }
         public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
-        {
-            JObject jObject = (JObject)serializer.Deserialize(reader, typeof(JObject));
+        {        
+            //JObject jObject = (JObject)serializer.Deserialize(reader, typeof(JObject));
+            var jObject = JsonSerializer.Create().Deserialize<JObject>(reader);
             //jObject.CreateReader()//下面直接直接使用reader会出问题,
             try
             {
@@ -83,7 +88,8 @@ namespace SAGA.Models.Graphs
 
         public override bool CanConvert(Type objectType)
         {
-            return objectType == typeof(GElement);
+            return false;
+            return typeof(GElement).IsAssignableFrom(objectType);
         }
 
      

+ 24 - 10
MBI/SAGA.RevitUtils/MEP/MepJoinUtil.cs

@@ -141,30 +141,44 @@ namespace SAGA.RevitUtils.MEP
             /*
              * 获取元素以指定Connector开始的Path,单点相连情况,不分叉
              */
-            List<Element> elements = new List<Element>();
-            List<Element> useElements = new List<Element>(){startElement};
+            return GetPathElements(startElement, startConnector, null, breakCondition);      
+        }
+        /// <summary>
+        /// 获取单线Path
+        /// </summary>
+        /// <param name="startElement">起始元素</param>
+        /// <param name="startConnector">指定元素上一点</param>
+        /// <param name="ignoredElement">忽略点位</param>
+        /// <param name="breakCondition">断开约束条件</param>
+        /// <returns></returns>
+        public static List<Element> GetPathElements(this Element startElement, Connector startConnector,Predicate<Element> ignoredElement, Predicate<Element> breakCondition)
+        {
+            List<Element> useElements = new List<Element>() { startElement };
             Connector useConnector = startConnector;
             while (useConnector != null)
             {
                 var joinElements = useConnector.GetJoinElements();
-                if (joinElements.Count==0||joinElements.Count > 1)
+                if (joinElements.Count !=1)
                 {
                     break;
                 }
                 var nextElement = joinElements[0];
-                //如果原始集合中存在,如环路情况。则收尾元素相等;【理论上是只可能和第一个元素相等】
-                if (startElement.Id == nextElement.Id)
+                if (ignoredElement != null&& ignoredElement(nextElement))
                 {
-                    useElements.Add(nextElement);
                     break;
                 }
                 useElements.Add(nextElement);
+                //如果原始集合中存在,如环路情况。则收尾元素相等;【理论上是只可能和第一个元素相等】
+                if (startElement.Id == nextElement.Id)
+                {        
+                    break;
+                }
                 if (breakCondition != null && breakCondition(nextElement))
-                {                
+                {
                     break;
                 }
-                var connectors=nextElement.GetAllConnectors();
-                if (connectors.Count !=2)
+                var connectors = nextElement.GetAllConnectors();            
+                if (connectors.Count != 2)
                 {
                     break;
                 }
@@ -180,7 +194,7 @@ namespace SAGA.RevitUtils.MEP
                     }
                 }
             }
-            return elements;
+            return useElements;
         }
     }
 }