Explorar o código

xls:系统计算中,建筑信息分类

xulisong %!s(int64=6) %!d(string=hai) anos
pai
achega
20a1706353

+ 42 - 0
MBI/SAGA.GplotDrawData/DBView/MachineRoomGraphView.cs

@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MachineRoomView
+ * 作者:xulisong
+ * 创建时间: 2019/1/25 10:40:50
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models.GplotElement;
+using SAGA.Models.Graphs;
+
+namespace SAGA.GplotDrawData
+{
+    public class MachineRoomGraphView : GraphDBView<MachineRoomDrawRecord>
+    {
+        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[0].ConvertToPoint3D());
+                gline.ElementColor = Colors.Red;
+                db.Elements.Add(gline);
+            }
+
+            return db;
+        }
+    }
+}

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

@@ -71,6 +71,7 @@
     <Compile Include="DBView\EquipmentGraphView.cs" />
     <Compile Include="DBView\FloorSystemGraphView.cs" />
     <Compile Include="DBView\IGraphDBView.cs" />
+    <Compile Include="DBView\MachineRoomGraphView.cs" />
     <Compile Include="DBView\PipeEndGraphView.cs" />
     <Compile Include="DBView\RoomGraphView.cs" />
     <Compile Include="DBView\SpaceGraphView.cs" />

+ 16 - 22
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs

@@ -1,9 +1,11 @@
 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;
@@ -19,31 +21,11 @@ namespace SAGA.GplotDrawData.View
         {
             InitializeComponent();
         }
-      
-        public Func<List<DocumentNode>> LoadData;
-        private ObservableCollection<DocumentNode> DocumentNodes { get; set; }
         protected override void OnLoaded(object sender, RoutedEventArgs e)
         {
             base.OnLoaded(sender, e);
-
-            DocumentNodes = new ObservableCollection<DocumentNode>(this.LoadData?.Invoke() ?? new List<DocumentNode>());
-            this.TreeRootNode.ItemsSource = DocumentNodes;
-         
-        }
-        private void SetSelectedItem(DocumentNode node)
-        {
-            node.IsSelected = true;
-            node.IsExpanded = true;
-            var parent = node.Parent;
-            while (parent != null)
-            {
-                parent.IsExpanded = true;
-                parent = parent.Parent;
-            }
-
-            RootNode_OnSelectedItemChanged(null, null);
+            InitTreeNode();
         }
-
         #region 事件相关
         private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
         {
@@ -53,6 +35,17 @@ namespace SAGA.GplotDrawData.View
             }
         }
         #endregion
+        #region 数据相关处理
+
+        private void InitTreeNode()
+        {
+            var drawData = DataServerUtil.Current.LoadData<VerticalDrawData>(ComputerFileSetting.MachineRoomDraw);
+            List<GplotDocument> nodes = new List<GplotDocument>();
+            
+           // nodes.GroupBy()
+            //增加建筑级别的分级处理
+            // this.TreeRootNode.ItemsSource = DocumentNodes;
+        }
         private void Draw(DocumentNode docNode)
         {
             if (docNode?.LinkDocument == null)
@@ -62,6 +55,7 @@ namespace SAGA.GplotDrawData.View
             var db = view.CreateDb(document);
             ConstData.ResponseData = db.CreateJObjectGroup();
             ucShowElement.Show(WebGplotSettings.GplotUrl);
-        }
+        } 
+        #endregion
     }
 }

+ 2 - 2
MBI/SAGA.GplotManage/GplotManage/GplotCompute/GplotComputeData.cs

@@ -115,11 +115,11 @@ namespace SAGA.GplotManage
         {
             if (Node1?.Id == id)
             {
-                return Node2.Id;
+                return Node2?.Id;
             }
             if (Node2?.Id == id)
             {
-                return Node1.Id;
+                return Node1?.Id;
             }
             return null;
         }

+ 50 - 0
MBI/SAGA.GplotRelationComputerManage/Common/FloorUtil.cs

@@ -0,0 +1,50 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FloorUtil
+ * 作者:xulisong
+ * 创建时间: 2019/1/25 17:41:51
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{  
+    /// <summary>
+    /// 楼层信息相关
+    /// </summary>
+    public static class FloorUtil
+    {
+        private static Dictionary<string, MBIFloorInfo> m_Floors ;
+
+        public static Dictionary<string, MBIFloorInfo> Floors
+        {
+            get
+            {
+                if (m_Floors == null)
+                {
+                    var floorItems = MBIInfoUtil.GetFloors();
+                    m_Floors = floorItems.ToDictionary(c => c.FloorId);
+                }
+                return m_Floors;
+            }
+        }
+        public static void InitData()
+        {
+            m_Floors = null;
+        }
+        /// <summary>
+        /// 获取楼层信息
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public static MBIFloorInfo GetFloorInfo(string floorId)
+        {
+            m_Floors.TryGetValue(floorId, out MBIFloorInfo info);
+            return info;
+        }
+    }
+}

+ 28 - 0
MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs

@@ -8,7 +8,10 @@ using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
+using SAGA.MBI.Common;
 using SAGA.MBI.DataArrange;
+using SAGA.MBI.JsonConvert;
+using SAGA.MBI.Model;
 
 namespace SAGA.GplotRelationComputerManage
 {
@@ -91,5 +94,30 @@ namespace SAGA.GplotRelationComputerManage
         {
             return levelName.Replace(AppSetting.ViewSuffix, "");
         }
+        /// <summary>
+        /// 获取当前项目下的楼层信息
+        /// </summary>
+        /// <returns></returns>
+        public static List<MBIFloorInfo> GetFloors()
+        {
+            List<MBIFloorInfo> result = new List<MBIFloorInfo>();
+            MProject project = MBIControl.ProjectCur;
+            var projectId = project.Id;
+            List<MBuilding> buildings = ModeFileConvert.GetProjectBuildings(projectId);
+            foreach (var mBuilding in buildings)
+            {
+                List<MFloor> floors = ModeFileConvert.GetBuildingFloors(mBuilding.Id);
+                foreach (MFloor floor in floors)
+                {
+                    MBIFloorInfo info = new MBIFloorInfo();
+                    info.BuildingId = mBuilding.Id;
+                    info.BuildingName = mBuilding.LocalName;
+                    info.FloorId = floor.Id;
+                    info.FloorName = floor.LocalName;
+                    result.Add(info);
+                }
+            }
+            return result;
+        }
     }
 }

+ 35 - 0
MBI/SAGA.GplotRelationComputerManage/Data/MBIFloorInfo.cs

@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MBIFloorInfocs
+ * 作者:xulisong
+ * 创建时间: 2019/1/25 17:26:02
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    public class MBIFloorInfo
+    {
+        /// <summary>
+        /// 楼层Id
+        /// </summary>
+        public string FloorId { get; set; }
+        /// <summary>
+        /// 楼层名称
+        /// </summary>
+        public string FloorName { get; set; }
+        /// <summary>
+        /// 建筑Id
+        /// </summary>
+        public string BuildingId { get; set; }
+        /// <summary>
+        /// 建筑名称
+        /// </summary>
+        public string BuildingName { get; set; }
+    }
+}

+ 2 - 1
MBI/SAGA.GplotRelationComputerManage/ReadSpaceCommand.cs

@@ -106,7 +106,8 @@ namespace SAGA.GplotRelationComputerManage
                 if (File.Exists(fileInfo))
                 {
                     //var uiApp = ExternalDataWrapper.Current.UiApp.Application;
-                   // var doc = uiApp.OpenDocumentFile(fileInfo);
+                    //var doc = uiApp.OpenDocumentFile(fileInfo);
+                    Trace.Write(fileInfo);
                     FloorSpaceItems floorItems = context.GetFloorItems(fileInfo);
                     floorItems.Parse(context);
                     //if(floorItems.Document.Application.Creat)

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

@@ -84,6 +84,7 @@
     <Compile Include="Common\AppSetting.cs" />
     <Compile Include="Common\ComputerFileSetting.cs" />
     <Compile Include="Common\DataServerUtil.cs" />
+    <Compile Include="Common\FloorUtil.cs" />
     <Compile Include="Common\MBIInfoUtil.cs" />
     <Compile Include="Common\PointConverter.cs" />
     <Compile Include="ComputerPipes.cs" />
@@ -97,6 +98,7 @@
     <Compile Include="DataServer\FileKeyAttribute.cs" />
     <Compile Include="DataServer\IVersionFile.cs" />
     <Compile Include="DataServer\TimeVersionFile.cs" />
+    <Compile Include="Data\MBIFloorInfo.cs" />
     <Compile Include="Draw\DocumentNode.cs" />
     <Compile Include="Draw\DrawDocumentUtil.cs" />
     <Compile Include="Draw\DrawLine.cs" />

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

@@ -13,6 +13,7 @@ using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
 using Autodesk.Revit.DB.Plumbing;
 using SAGA.Models;
+using SAGA.Models.GplotElement;
 using SAGA.Models.Graphs;
 using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
@@ -404,7 +405,7 @@ namespace SAGA.GplotRelationComputerManage
             #region 确定返回之后进行后初始化处理
             if (outNode != null)
             {
-                outNode.RevitId = element.Id.IntegerValue;
+                outNode.RevitId = element.Id.IntegerValue.ToString();
                 outNode.BimId = element.GetBimId();
             } 
             #endregion
@@ -496,6 +497,47 @@ namespace SAGA.GplotRelationComputerManage
 
         }
         #endregion
+
+        #region 创建机房绘图数据
+        /// <summary>
+        /// 创建机房绘图数据
+        /// </summary>
+        /// <param name="document"></param>
+        /// <returns></returns>
+        public static SystemDrawItems CreateRoomDrawing(GplotDocument document)
+        {
+            List<SystemCurveItem> curveItems = new List<SystemCurveItem>();
+            List<SystemPointItem> pointItems = new List<SystemPointItem>();
+            foreach (var element in document.Elements)
+            {
+                if (element is TVertex vertex)
+                {                 
+                    SystemPointItem point = new SystemPointItem();
+                    point.Point = vertex.Location;
+                    point.Name = vertex.Name;
+                    point.IsVirtual = vertex.VertexType != Models.GplotElement.VertexType.Solid;
+                    pointItems.Add(point);
+                    continue;
+                }
+                if (element is TLine line)
+                {
+                    SystemCurveItem curveItem = new SystemCurveItem();
+                    curveItem.Points.Add(line.StartPoint);
+                    curveItem.Points.Add(line.EndPoint);
+                    continue;
+                }
+                if (element is TText text)
+                {
+
+                    continue;
+                }
+            }
+            SystemDrawItems drawItems = new SystemDrawItems();
+            drawItems.Curves = curveItems;
+            drawItems.Points = pointItems;
+            return drawItems;
+        }
+        #endregion
     }
 
     /// <summary>

+ 6 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/BinaryRelationItem.cs

@@ -28,6 +28,10 @@ namespace SAGA.GplotRelationComputerManage
         public EquipmentNode To { get; set; }
 
         /// <summary>
+        /// 关联类型
+        /// </summary>
+        public string RelationType { get; set; }
+        /// <summary>
         /// 反转关系
         /// </summary>
         public void Reverse()
@@ -36,5 +40,7 @@ namespace SAGA.GplotRelationComputerManage
             To = From;
             From = temp;
         }
+
+       
     }
 }

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/EquipmentNode.cs

@@ -30,7 +30,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <summary>
         /// revit模型中Id
         /// </summary>
-        public int RevitId { get; set; }
+        public string RevitId { get; set; }
         /// <summary>
         /// 设备分类
         /// </summary>

+ 151 - 39
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -7,11 +7,15 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.RegularExpressions;
+using System.Windows.Media;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
 using Autodesk.Revit.DB.Plumbing;
 using SAGA.DotNetUtils.Data;
+using SAGA.GplotRelationComputerManage.ColdRoom;
 using SAGA.Models;
+using SAGA.Models.GplotElement;
+using SAGA.Models.Graphs;
 using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.MEP;
@@ -21,6 +25,7 @@ namespace SAGA.GplotRelationComputerManage
     public class FloorSystemItem
     {
         #region 构造函数
+
         /// <summary>
         /// 初始化解析类
         /// </summary>
@@ -30,17 +35,23 @@ namespace SAGA.GplotRelationComputerManage
             Document = doc;
             InitData();
         }
+
         #endregion
+
         #region 属性相关
+
         /// <summary>
         /// 关联模型信息
         /// </summary>
         public Document Document { get; private set; }
+
         /// <summary>
         /// 使用关联标高
         /// </summary>
         public Level UseLevel { get; private set; }
+
         private bool m_IsInited;
+
         /// <summary>
         /// 初始化数据
         /// </summary>
@@ -51,13 +62,16 @@ namespace SAGA.GplotRelationComputerManage
             UseLevel = Document.GetUseView()?.GenLevel;
             m_IsInited = true;
         }
+
         #endregion
 
         #region 开始节点获取
+
         /// <summary>
         /// 缓存信息
         /// </summary>
         private List<StringFlag<ElementTreeNode>> m_StartNodes;
+
         /// <summary>
         /// 按系统获取开始节点
         /// </summary>
@@ -67,11 +81,14 @@ namespace SAGA.GplotRelationComputerManage
             if (m_StartNodes != null)
             {
                 //返回没有处理过的节点信息
-                return m_StartNodes.Where(s=>!s.Handled).ToList();
+                return m_StartNodes.Where(s => !s.Handled).ToList();
             }
+
             List<StringFlag<ElementTreeNode>> startNodes = new List<StringFlag<ElementTreeNode>>();
             var doc = Document;
+
             #region 立管处理
+
             /*
              * 暂时认定,一个立管之关联一个系统
              */
@@ -94,7 +111,8 @@ namespace SAGA.GplotRelationComputerManage
             var specialValves = doc.FilterElements(filter).Where(f => SystemCalcUtil.IsStart(f));
             foreach (var familyInstance in specialValves)
             {
-                var connector = familyInstance.GetAllConnectors().FirstOrDefault(c => Regex.IsMatch(c.Description, AppSetting.EndFlag));
+                var connector = familyInstance.GetAllConnectors()
+                    .FirstOrDefault(c => Regex.IsMatch(c.Description, AppSetting.EndFlag));
                 if (connector == null)
                     continue;
                 var node = SystemParseManager.CreateTreeNode(familyInstance, connector, e => e is MEPCurve);
@@ -104,18 +122,22 @@ namespace SAGA.GplotRelationComputerManage
                 var systemTypeName = useMepCurve.GetSystemTypeName();
                 startNodes.Add(new StringFlag<ElementTreeNode>(systemTypeName, node));
             }
+
             #endregion
 
 
             return m_StartNodes = startNodes;
         }
+
         #endregion
 
         #region 设备节点获取
+
         /// <summary>
         /// 模型中包含的设备
         /// </summary>
         public Dictionary<string, List<FamilyInstance>> RevitEquipments { get; private set; }
+
         /// <summary>
         /// 通过设备类型获取相关设备
         /// </summary>
@@ -132,21 +154,25 @@ namespace SAGA.GplotRelationComputerManage
                     var familyName = familyInstance.GetFamily().Name;
                     if (string.IsNullOrEmpty(familyName))
                         continue;
-                   var match=Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
+                    var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
                     if (match.Success)
                     {
                         original.Add(new StringFlag<FamilyInstance>(match.Groups[1].ToString(), familyInstance));
-                    }               
+                    }
                 }
-                RevitEquipments= original.GroupBy(f => f.Flag).ToDictionary(g=>g.Key,g=>g.ToList().Select(f=>f.Instance).ToList());
+
+                RevitEquipments = original.GroupBy(f => f.Flag)
+                    .ToDictionary(g => g.Key, g => g.ToList().Select(f => f.Instance).ToList());
             }
 
             RevitEquipments.TryGetValue(category, out List<FamilyInstance> result);
-            return result??new List<FamilyInstance>();
+            return result ?? new List<FamilyInstance>();
         }
+
         #endregion
 
         #region 数据解析方法
+
         /// <summary>
         /// 解析当前楼层系统数据
         /// </summary>
@@ -172,12 +198,15 @@ namespace SAGA.GplotRelationComputerManage
         }
 
         #region 水系统解析
-        public void ParsePipe(SystemComputerContext context,RelationTypeShell relationSetting)
+
+        public void ParsePipe(SystemComputerContext context, RelationTypeShell relationSetting)
         {
             Domain useDomain = Domain.DomainPiping;
             List<FloorDrawRecord> drawRecords = new List<FloorDrawRecord>();
             List<FloorRelationRecord> relationRecords = new List<FloorRelationRecord>();
+            List<Element> roomStartElements = new List<Element>();
             #region 计算拓扑树形结构 
+
             /*
              * 1、遍历开始点的限制:特殊阀门,指定标注的Connector;立管,已连接连接件;空间,相交风管元素;
              * 2、根据拓扑图关联的对象信息,找到系统关联的设备生成节点。如果没有遍历到要独立生成
@@ -192,7 +221,10 @@ namespace SAGA.GplotRelationComputerManage
                 var useRelation = relationSetting.GetFirstMatchSystem(startNode.Flag);
                 if (useRelation == null)
                     continue;
-               
+                if (startNode.Instance.Current is FamilyInstance)
+                {
+                    roomStartElements.Add(startNode.Instance.Current);
+                }
                 if (useIds.Any(id => id == startNode.Instance.Current.Id.IntegerValue))
                 {
                     continue;
@@ -202,7 +234,8 @@ namespace SAGA.GplotRelationComputerManage
                 {
                     verticalMepCurves.Add(mepCurve);
                 }
-                var tempIds=SystemParseManager.BuildSystemNode(startNode.Instance, useDomain,
+
+                var tempIds = SystemParseManager.BuildSystemNode(startNode.Instance, useDomain,
                     (m => !startNode.Flag.Equals(m.GetSystemTypeName())));
                 startNode.Instance.PipeSystemTypeName = startNode.Flag;
                 BuildElementNodeData(context, startNode.Instance);
@@ -210,7 +243,9 @@ namespace SAGA.GplotRelationComputerManage
                 startNode.Handled = true;
 
                 //可以清空Leaves的子节点
+
                 #region 整理原始数据
+
                 //判断是否有设备节点,不进行数据处理
                 var useNode = startNode.Instance;
                 //var firstEquipment = useNode.FirstOrDefault(t => MBIInfoUtil.IsEquipment(t.Current));
@@ -225,20 +260,29 @@ namespace SAGA.GplotRelationComputerManage
 
                     var relationRecord = BuildFloorRelationRecord(relationSetting, useNode);
                     relationRecords.Add(relationRecord);
-                }             
+                }
+
                 #endregion
             }
-            
+
+
+            #region 解析机房数据
+
+            var useEquipments = ParseMachineRoomData(context, relationSetting, roomStartElements);
+            useEquipments=useEquipments.Distinct().ToList();
+            #endregion
+
             //获取没有使用过的对象节点
             List<FamilyInstance> singleInstances =
                 relationSetting.RelationItem.Objects.SelectMany(o => GetEquipments(o.Type)).ToList();
             for (int i = 0; i < singleInstances.Count; i++)
             {
-                var useInstance = singleInstances[i];       
-                if (useIds.Any(id => id == useInstance.Id.IntegerValue))
+                var useInstance = singleInstances[i];
+                if (useIds.Any(id => id == useInstance.Id.IntegerValue)|| useEquipments.Any(id=>id==useInstance.Id.ToString()))
                 {
                     continue;
                 }
+
                 var connectors = useInstance.GetAllConnectors();
                 foreach (var connector in connectors)
                 {
@@ -246,6 +290,7 @@ namespace SAGA.GplotRelationComputerManage
                     {
                         continue;
                     }
+
                     var startNode = SystemParseManager.CreateTreeNode(useInstance, connector, e => e is MEPCurve);
                     var useMepCurve = startNode.GetLeaves().FirstOrDefault()?.Current as MEPCurve;
                     if (useMepCurve == null)
@@ -255,13 +300,16 @@ namespace SAGA.GplotRelationComputerManage
                     {
                         continue;
                     }
+
                     //var startNode = new ElementTreeNode() { Current = useInstance };
                     var tempIds = SystemParseManager.BuildSystemNode(startNode, useDomain,
                         (m => !systemTypeName.Equals(m.GetSystemTypeName())));
                     startNode.PipeSystemTypeName = systemTypeName;
                     BuildElementNodeData(context, startNode);
                     useIds.AddRange(tempIds);
+
                     #region 生成绘图,计算数据
+
                     //解析数据,找管道定系统,管道找不到,系统名为"关联类型-未知"
                     var drawRecord = BuildFloorDrawRecord(relationSetting, startNode);
                     drawRecord.SystemName = systemTypeName;
@@ -269,6 +317,7 @@ namespace SAGA.GplotRelationComputerManage
 
                     var relationRecord = BuildFloorRelationRecord(relationSetting, startNode);
                     relationRecords.Add(relationRecord);
+
                     #endregion
 
                 }
@@ -277,21 +326,29 @@ namespace SAGA.GplotRelationComputerManage
 
 
             }
+
             #endregion
+
             //增加立管数据
             ComputerVerticalPipes(UseLevel, verticalMepCurves, context);
             context.FloorDrawRecords.AddRange(drawRecords);
             context.FloorRelationRecords.AddRange(relationRecords);
         }
+
         #endregion
 
         #region 风系统解析
+
         public void ParseDuct(SystemComputerContext context, RelationTypeShell relationSetting)
-        { } 
+        {
+        }
+
         #endregion
+
         #endregion
 
         #region 解析立管
+
         /*
          * 1、解析立管需要考虑,竖直风管,水管,空间的情况;
          *2、将各层数据汇总,才能统一计算立管的相关关系数据
@@ -305,7 +362,7 @@ namespace SAGA.GplotRelationComputerManage
             foreach (var pipe in mepCurves)
             {
                 if (pipe == null)
-                    continue;             
+                    continue;
                 var vp = new VerticalPipe
                 {
                     Id = pipe.Id.IntegerValue.ToString(),
@@ -315,16 +372,21 @@ namespace SAGA.GplotRelationComputerManage
                     DownPoint3D = PointConverter.XYZToPoint3D(pipe.GetVerticalBottomPoint()),
                     PipeSytemType = pipe.GetSystemTypeName()
                 };
+
                 #region  获取立管关联空间
+
                 var locationCurve = pipe.GetLocationCurve();
                 var midPoint = (locationCurve.StartPoint() + locationCurve.EndPoint()) / 2;
-                Space refSpace = spaces.FirstOrDefault(s => s.IsPointInSpace(midPoint));//关联
+                Space refSpace = spaces.FirstOrDefault(s => s.IsPointInSpace(midPoint)); //关联
                 var display = context.GetSpaceDisplay(refSpace, out string tip);
                 vp.Display = $"{display}:{pipe.Id.IntegerValue.ToString()}";
-                vp.DisplayTip = tip ?? string.Empty; 
+                vp.DisplayTip = tip ?? string.Empty;
+
                 #endregion
+
                 result.Add(vp);
             }
+
             LevelData levelData = new LevelData()
             {
                 Id = refLevel.Id.ToString(),
@@ -333,6 +395,7 @@ namespace SAGA.GplotRelationComputerManage
             context.VerticalPipes.AddRange(result);
             context.Levels.Add(levelData);
         }
+
         #endregion
 
 
@@ -342,25 +405,29 @@ namespace SAGA.GplotRelationComputerManage
         {
             return relationShell.RelationItem?.Name + "---未知";
         }
-        private FloorDrawRecord BuildFloorDrawRecord(RelationTypeShell relationShell,ElementTreeNode node)
+
+        private FloorDrawRecord BuildFloorDrawRecord(RelationTypeShell relationShell, ElementTreeNode node)
         {
             var floorDraw = new FloorDrawRecord();
             floorDraw.SetFloorLevel(UseLevel);
             floorDraw.RelationType = relationShell.RelationItem.Type;
-            floorDraw.DrawIems = SystemParseManager.CreateDrawing(node)??new SystemDrawItems();
+            floorDraw.DrawIems = SystemParseManager.CreateDrawing(node) ?? new SystemDrawItems();
             return floorDraw;
         }
+
         private FloorRelationRecord BuildFloorRelationRecord(RelationTypeShell relationShell, ElementTreeNode node)
         {
             var floorRelation = new FloorRelationRecord();
             floorRelation.SetFloorLevel(UseLevel);
             floorRelation.RelationType = relationShell.RelationItem.Type;
-            floorRelation.RelationItems = SystemParseManager.CreateRelation(node)??new List<BinaryRelationItem>();
+            floorRelation.RelationItems = SystemParseManager.CreateRelation(node) ?? new List<BinaryRelationItem>();
             return floorRelation;
         }
+
         #endregion
 
         #region 初始化名称,分类
+
         /// <summary>
         /// 初始化节点扩展数据
         /// </summary>
@@ -373,16 +440,20 @@ namespace SAGA.GplotRelationComputerManage
             while (nodeQueue.Any())
             {
                 #region 控制验证
+
                 var currentNode = nodeQueue.Dequeue();
                 if (currentNode == null)
                     continue;
                 var element = currentNode.Current;
                 if (element == null)
                     continue;
+
                 #endregion
+
                 if (element is FamilyInstance fiEq)
-                {                      
+                {
                     #region 判断是否是设备
+
                     if (MBIInfoUtil.IsEquipment(fiEq))
                     {
                         var equipItem = context.EquipmentItems.GetItem(fiEq.GetBimId());
@@ -390,15 +461,17 @@ namespace SAGA.GplotRelationComputerManage
                         if (equipItem != null)
                         {
                             data.Name = equipItem.GetDisplay();
-                            data.Category = equipItem.Category;                          
+                            data.Category = equipItem.Category;
                         }
                         else
                         {
                             data.Name = fiEq.GetFamily()?.Name;
                         }
+
                         data.SystemType = node.PipeSystemTypeName;
                         currentNode.Tag = data;
-                    }               
+                    }
+
                     #endregion
                 }
                 else if (element is Space revitSpace)
@@ -413,33 +486,72 @@ namespace SAGA.GplotRelationComputerManage
                     {
                         data.Name = revitSpace.Name;
                     }
+
                     data.SystemType = node.PipeSystemTypeName;
                     currentNode.Tag = data;
                 }
+
                 currentNode.Nodes.ForEach(e => nodeQueue.Enqueue(e));
             }
 
         }
+
         #endregion
 
         #region 解析机房数据
-        private void ParseMachineRoomData()
+        /// <summary>
+        /// 解析机房数据
+        /// </summary>
+        /// <param name="context"></param>
+        /// <param name="relationSetting"></param>
+        /// <param name="startElements"></param>
+        private List<string> ParseMachineRoomData(SystemComputerContext context, RelationTypeShell relationSetting,
+            List<Element> startElements)
         {
-            //GplotOptions options = new GplotOptions();
-            //options.BaseOnDefinition(Definition);
-            //SystemParse parse = new SystemParse(new SystemParseSetting(options));
-            //StartElementsManager startManager = new StartElementsManager(options);
-            ////所有项目中所有文档
-            //List<Element> startElements = new List<Element>();
-            //startElements.AddRange(startManager.GetStartElements(Document));
-            //var arrays = parse.Execute(startElements);
-            ////arrays.ForEach(a => parse.LoadEquipmentItem(a));
-            ////去除不包含真实设备的拓扑
-            //arrays.RemoveAll(c => c.GetAvailableVertexes(null).All(v => !v.IsRealEquipment()));
-
-            ////GplotParseData data = new GplotParseData();
-            //data.OriginalData = arrays;
+            /*
+             *1、解析过程中尽量少处理和后续相关的数据
+             * 2、设备整理,带缓存的设备信息读取
+             */
+            List<string> useEquipments = new List<string>();
+            SystemParse parse = new SystemParse(new SystemParseSetting(relationSetting));
+            List<Element> useStartElements = new List<Element>(startElements);
+            var arrays = parse.Execute(useStartElements);
+            arrays.RemoveAll(c => c.GetAvailableVertexes(null).All(v => !v.IsRealEquipment()));
+            
+            #region 生成图形数据
+            ColdRoomManager manager = new ColdRoomManager();
+            var doc = manager.CreateDocument(new List<ElementEdgesArray>(arrays));
+            var drawData = SystemParseManager.CreateRoomDrawing(doc);
+            MachineRoomDrawRecord record = new MachineRoomDrawRecord();
+            record.RelationName = relationSetting.RelationItem.Name;
+            record.DrawIems = drawData;
+            context.MachineRoomDrawRecords.Add(record);
+            #endregion
+
+            #region 生成关系数据
+            var relations = manager.CreateRelation(arrays);         
+            MachineRoomRelationRecord relationRecord = new MachineRoomRelationRecord();
+            relationRecord.RelationName = relationSetting.RelationItem.Name;
+            foreach (var item in relations)
+            {
+                var node = new BinaryRelationItem();
+                node.From = new EquipmentNode() { RevitId = item.EquipmentItem1.Id };
+                node.To = new EquipmentNode() { RevitId = item.EquipmentItem2.Id };
+                node.RelationType = item.LinkType;
+                relationRecord.RelationItems.Add(node);
+
+
+                var newIds = new List<string>() {item.EquipmentItem1.Id, item.EquipmentItem2.Id};
+                useEquipments.AddRange(newIds);
+
+
+            }
+            context.MachineRoomRelationRecords.Add(relationRecord);
+            #endregion
+
+            return useEquipments;
+
         }
-        #endregion
+        #endregion 解析机房数据
     }
 }

+ 8 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomDrawRecord.cs

@@ -18,5 +18,13 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     public class MachineRoomDrawRecord
     {
+        /// <summary>
+        /// 关系名称
+        /// </summary>
+        public string RelationName { get; set; }
+        /// <summary>
+        /// 绘图数据
+        /// </summary>
+        public SystemDrawItems DrawIems { get; set; }
     }
 }

+ 8 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomRelationRecord.cs

@@ -18,5 +18,13 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     public class MachineRoomRelationRecord
     {
+        /// <summary>
+        /// 关系名称
+        /// </summary>
+        public string RelationName { get; set; }
+        /// <summary>
+        /// 关联数据
+        /// </summary>
+        public List<BinaryRelationItem> RelationItems { get; set; }
     }
 }

+ 1 - 0
MBI/SAGA.Revit.sln.DotSettings.user

@@ -4,4 +4,5 @@
   &lt;Assembly Path="D:\SVNCode\MBI\Dlls\Newtonsoft.Json.dll" /&gt;&#xD;
   &lt;Assembly Path="D:\SVNCode\MBI\Dlls\FirmLibDll\FWindSoft.Wpf.dll" /&gt;&#xD;
   &lt;Assembly Path="D:\MBI\Revit\SAGA.MBI\SAGA.MBI\MBI\Dlls\RevitRefDll\AdWindows.dll" /&gt;&#xD;
+  &lt;Assembly Path="D:\MBI\Revit\SAGA.MBI\SAGA.MBI\MBI\packages\log4net.2.0.8\lib\net45-full\log4net.dll" /&gt;&#xD;
 &lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>