浏览代码

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

mengxiangge 6 年之前
父节点
当前提交
adcf480072
共有 49 个文件被更改,包括 1450 次插入219 次删除
  1. 二进制
      MBI/MBIResource/Config/物理世界关系定义列表-2019-1.xlsx
  2. 64 0
      MBI/SAGA.DotNetUtils/Extend/IEnumerableExtensions.cs
  3. 1 0
      MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj
  4. 42 0
      MBI/SAGA.GplotDrawData/DBView/MachineRoomGraphView.cs
  5. 1 0
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  6. 2 2
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml
  7. 45 28
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs
  8. 70 27
      MBI/SAGA.GplotDrawData/View/WinSystem.xaml.cs
  9. 4 1
      MBI/SAGA.GplotManage/Command/ColdGplot/ColdRoomSystemParse.cs
  10. 68 27
      MBI/SAGA.GplotManage/GplotCommand.cs
  11. 2 2
      MBI/SAGA.GplotManage/GplotManage/GplotCompute/GplotComputeData.cs
  12. 1 0
      MBI/SAGA.GplotManage/SAGA.GplotManage.csproj
  13. 146 0
      MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs
  14. 11 0
      MBI/SAGA.GplotRelationComputerManage/Common/ComputerFileSetting.cs
  15. 26 0
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/Common/DataNodeUtil.cs
  16. 1 0
      MBI/SAGA.GplotRelationComputerManage/Common/DataServerUtil.cs
  17. 50 0
      MBI/SAGA.GplotRelationComputerManage/Common/FloorUtil.cs
  18. 75 0
      MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs
  19. 35 0
      MBI/SAGA.GplotRelationComputerManage/Data/MBIFloorInfo.cs
  20. 25 6
      MBI/SAGA.GplotRelationComputerManage/DataServer/DataServer.cs
  21. 1 1
      MBI/SAGA.GplotRelationComputerManage/DataServer/TimeVersionFile.cs
  22. 2 1
      MBI/SAGA.GplotRelationComputerManage/ReadSpaceCommand.cs
  23. 1 1
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/RelationItem.cs
  24. 2 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/SystemItem.cs
  25. 22 1
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs
  26. 6 2
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs
  27. 1 0
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParseSetting.cs
  28. 7 1
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  29. 63 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/RelationTypeUtil.cs
  30. 55 7
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  31. 15 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/BinaryRelationItem.cs
  32. 6 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/EquipmentNode.cs
  33. 239 73
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  34. 191 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/RelationComputerData.cs
  35. 37 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/RelationDataCheck.cs
  36. 5 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawData.cs
  37. 2 5
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRecord.cs
  38. 4 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRelationRecord.cs
  39. 13 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomDrawRecord.cs
  40. 13 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomRelationRecord.cs
  41. 25 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/ServerData.cs
  42. 1 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawData.cs
  43. 1 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalRelationRecord.cs
  44. 28 23
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerContext.cs
  45. 35 4
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  46. 1 1
      MBI/SAGA.MBI/Interaction/MBIModelInfoManager.cs
  47. 3 0
      MBI/SAGA.MBI/RevitModelHandle/RevitParameterUpdate.cs
  48. 1 0
      MBI/SAGA.Revit.sln.DotSettings.user
  49. 1 0
      MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

二进制
MBI/MBIResource/Config/物理世界关系定义列表-2019-1.xlsx


+ 64 - 0
MBI/SAGA.DotNetUtils/Extend/IEnumerableExtensions.cs

@@ -0,0 +1,64 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IEnumerableExtensions
+ * 作者:xulisong
+ * 创建时间: 2019/1/25 11:15:03
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Extend
+{
+    public static class IEnumerableExtensions
+    {
+        /*
+         * 没有什么是string办不了的
+         */
+        #region 分组扩展
+        /// <summary>
+        /// 给指定数据源分组
+        /// </summary>
+        /// <typeparam name="IN"></typeparam>
+        /// <typeparam name="TREE"></typeparam>
+        /// <param name="inputSource"></param>
+        /// <param name="treeAdd"></param>
+        /// <param name="groupConditions"></param>
+        /// <returns></returns>
+        public static List<TREE> GroupTree<IN, TREE>(this IEnumerable<IN> inputSource, Action<TREE, List<TREE>> treeAdd, List<GroupCondition<IN, TREE>> groupConditions)
+        {
+            List<TREE> reuslt = new List<TREE>();
+            var firstCondition = groupConditions.FirstOrDefault();
+            if (firstCondition == null)
+                return reuslt;
+            var groups = inputSource.GroupBy(firstCondition.GroupKeySelect);
+            foreach (var groupItem in groups)
+            {
+                var tree = firstCondition.GroupSelect(groupItem);
+                reuslt.Add(tree);
+                if (!firstCondition.GroupContinue(groupItem))
+                {
+                    continue;
+                }
+                var childNodes = groupItem.ToList().GroupTree(treeAdd, groupConditions.GetRange(1, groupConditions.Count-1));
+                treeAdd(tree, childNodes);
+            }
+            return reuslt;
+        }
+        #endregion
+    }
+    /// <summary>
+    /// 分组约束类
+    /// </summary>
+    /// <typeparam name="IN"></typeparam>
+    /// <typeparam name="TREE"></typeparam>
+    public class GroupCondition<IN, TREE>
+    {
+        public Func<IN, string> GroupKeySelect { get; set; }
+        public Func<IGrouping<string, IN>, bool> GroupContinue { get; set; }
+        public Func<IGrouping<string, IN>, TREE> GroupSelect { get; set; }
+    }
+}

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

@@ -267,6 +267,7 @@
     <Compile Include="Extend\DoubleExt.cs" />
     <Compile Include="Extend\EnumExtends.cs" />
     <Compile Include="Extend\FilePathExt.cs" />
+    <Compile Include="Extend\IEnumerableExtensions.cs" />
     <Compile Include="Extend\JObjectExt.cs" />
     <Compile Include="Extend\ObjectExtend.cs" />
     <Compile Include="FileOperate\FileStreamOperate.cs" />

+ 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" />

+ 2 - 2
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml

@@ -29,8 +29,8 @@
                 </Style>
             </TreeView.ItemContainerStyle>
             <TreeView.ItemTemplate>
-                <HierarchicalDataTemplate ItemsSource="{Binding Path=Nodes}">
-                    <TextBlock Name="Block" Text="{Binding Name}"></TextBlock>
+                <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
+                    <TextBlock Name="Block" Text="{Binding EName}"></TextBlock>
 
                     <HierarchicalDataTemplate.Triggers>
                         <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem},Path=IsSelected}" Value="True">

+ 45 - 28
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,49 +21,64 @@ 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;
-         
+            InitTreeNode();
         }
-        private void SetSelectedItem(DocumentNode node)
+        #region 事件相关
+        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
         {
-            node.IsSelected = true;
-            node.IsExpanded = true;
-            var parent = node.Parent;
-            while (parent != null)
+            if (TreeRootNode.SelectedItem is DataNode ln)
             {
-                parent.IsExpanded = true;
-                parent = parent.Parent;
+                Draw(ln.GetData<MachineRoomDrawRecord>());
             }
-
-            RootNode_OnSelectedItemChanged(null, null);
         }
-
-        #region 事件相关
-        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
+        #endregion
+        #region 数据相关处理
+        /// <summary>
+        /// 获取平面绘图数据
+        /// </summary>
+        /// <returns></returns>
+        private List<List<MachineRoomDrawRecord>> GetMachineRoomDrawData()
         {
-            if (TreeRootNode.SelectedItem is DocumentNode ln)
+            List<List<MachineRoomDrawRecord>> datas = new List<List<MachineRoomDrawRecord>>();
+            List<string> relationTypes = RelationTypeManager.GetSystemRelationTypeNames();
+            foreach (string relationType in relationTypes)
             {
-                Draw(ln);
+                LoadMachineRoomDrawData loadData = new LoadMachineRoomDrawData(relationType);
+                loadData.LoadData();
+                datas.Add(loadData.MachineRoomDrawRecords);
             }
+            return datas;
         }
-        #endregion
-        private void Draw(DocumentNode docNode)
+        /// <summary>
+        /// 初始化树形结构显示
+        /// </summary>
+        private void InitTreeNode()
         {
-            if (docNode?.LinkDocument == null)
+            List<List<MachineRoomDrawRecord>> drawDatas = GetMachineRoomDrawData();
+            List<DataNode> treeDataSource = new List<DataNode>();
+            foreach (var drawData in drawDatas)
+            {
+                foreach (var drawRecord in drawData)
+                {
+                    var recordNode= new DataNode(drawRecord.RelationName);
+                    recordNode.SetData(drawRecord);
+                    treeDataSource.Add(recordNode);
+                }
+            }
+           this.TreeRootNode.ItemsSource = treeDataSource;
+        }
+        private void Draw(MachineRoomDrawRecord record)
+        {
+            if (record == null)
                 return;
-            GplotDocument document = docNode.LinkDocument;
-            RoomGraphView view = new RoomGraphView();
-            var db = view.CreateDb(document);
+            MachineRoomGraphView view = new MachineRoomGraphView();
+            var db = view.CreateDb(record);
             ConstData.ResponseData = db.CreateJObjectGroup();
             ucShowElement.Show(WebGplotSettings.GplotUrl);
-        }
+        } 
+        #endregion
     }
 }

+ 70 - 27
MBI/SAGA.GplotDrawData/View/WinSystem.xaml.cs

@@ -59,30 +59,52 @@ namespace SAGA.GplotDrawData.View
             }
         }
         #region 平面数据处理
-
+        /// <summary>
+        /// 获取平面绘图数据
+        /// </summary>
+        /// <returns></returns>
+        private List<List<FloorDrawRecord>> GetFloorDrawData()
+        {
+            List<List<FloorDrawRecord>> datas = new List<List<FloorDrawRecord>>();
+            List<string> relationTypes = RelationTypeManager.GetSystemRelationTypeNames();
+            foreach (string relationType in relationTypes)
+            {
+                LoadFloorDrawData loadData = new LoadFloorDrawData(relationType);
+                loadData.LoadData();
+                datas.Add(loadData.FloorDrawRecords);
+            }
+            return datas;
+        }
+        /// <summary>
+        /// 初始化平面数据
+        /// </summary>
         private void InitFloorData()
         {
-            var records = DataServerUtil.Current.LoadData<List<FloorDrawRecord>>(ComputerFileSetting.FloorDraw);
-            if (records == null || !records.Any())
-                return;
-            var groupSystems = records.GroupBy(r => r.SystemName);
+            List<List<FloorDrawRecord>> recordDatas=GetFloorDrawData();
             List<DataNode> treeDataSource = new List<DataNode>();
-            foreach (var groupSystem in groupSystems)
+            foreach (var records in recordDatas)
             {
-                var system = new DataNode(groupSystem.Key);
-                var groupFloors = groupSystem.GroupBy(g => g.FloorName);
-                foreach (var groupFloor in groupFloors)
+                if (records == null || !records.Any())
+                    continue;
+                var groupSystems = records.GroupBy(r => r.SystemName);              
+                foreach (var groupSystem in groupSystems)
                 {
-                    var floor = new DataNode(groupFloor.Key);
-                    system.Childrens.Add(floor);
-                    var currentRecords = groupFloor.ToList();
-                    FloorDrawData floorData = new FloorDrawData() {FloorId = currentRecords.FirstOrDefault()?.FloorId};
-                    floorData.DrawRecords = currentRecords;
-                    floor.SetData(floorData);
-                }
+                    var system = new DataNode(groupSystem.Key);
+                    var groupFloors = groupSystem.GroupBy(g => g.FloorName);
+                    foreach (var groupFloor in groupFloors)
+                    {
+                        var floor = new DataNode(groupFloor.Key);
+                        system.Childrens.Add(floor);
+                        var currentRecords = groupFloor.ToList();
+                        FloorDrawData floorData = new FloorDrawData() { FloorId = currentRecords.FirstOrDefault()?.FloorId };
+                        floorData.DrawRecords = currentRecords;
+                        floor.SetData(floorData);
+                    }
 
-                treeDataSource.Add(system);
+                    treeDataSource.Add(system);
+                }
             }
+         
             this.rootNode.ItemsSource = treeDataSource;
               
         }
@@ -102,21 +124,42 @@ namespace SAGA.GplotDrawData.View
         #endregion
 
         #region 立面数据处理
+        /// <summary>
+        /// 获取立面展示数据
+        /// </summary>
+        /// <returns></returns>
+        private List<VerticalDrawData> GetVerticalDrawData()
+        {
+            List<VerticalDrawData> datas = new List<VerticalDrawData>();
+            List<string> relationTypes = RelationTypeManager.GetSystemRelationTypeNames();
+            foreach (string relationType in relationTypes)
+            {
+                LoadVerticalDrawData loadData = new LoadVerticalDrawData(relationType);
+                loadData.LoadData();
+                datas.Add(loadData.VerticalDrawData);
+            }
+            return datas;
+        }
         private void InitVerticalData()
         {
             List<DataNode> dataNode = new List<DataNode>();
-            var drawData = DataServerUtil.Current.LoadData<VerticalDrawData>(ComputerFileSetting.VerticalDraw);
-            var groups = (drawData.DrawRecords ?? new List<VerticalDrawRecord>()).GroupBy(c => c.SystemName);
-            foreach (var group in groups)
+            List<VerticalDrawData> drawDatas = GetVerticalDrawData();
+            foreach (var drawData in drawDatas)
             {
-                if (string.IsNullOrEmpty(group.Key))
+                if (drawData == null)
                     continue;
-                var node = new DataNode() {EName = group.Key};
-                var currentDrawData = new VerticalDrawData(){LevelDatas=drawData.LevelDatas};
-                currentDrawData.DrawRecords = group.ToList();
-                node.SetData(currentDrawData);
-                dataNode.Add(node);
-            }
+                var groups = (drawData.DrawRecords ?? new List<VerticalDrawRecord>()).GroupBy(c => c.SystemName);
+                foreach (var group in groups)
+                {
+                    if (string.IsNullOrEmpty(group.Key))
+                        continue;
+                    var node = new DataNode() { EName = group.Key };
+                    var currentDrawData = new VerticalDrawData() { LevelDatas = drawData.LevelDatas };
+                    currentDrawData.DrawRecords = group.ToList();
+                    node.SetData(currentDrawData);
+                    dataNode.Add(node);
+                }
+            }          
             this.rootNode.ItemsSource = dataNode;
         }
         /// <summary>

+ 4 - 1
MBI/SAGA.GplotManage/Command/ColdGplot/ColdRoomSystemParse.cs

@@ -21,7 +21,10 @@ namespace SAGA.GplotManage
             base.Parse();
             GplotOptions options = new GplotOptions();
             options.BaseOnDefinition(Definition);
-            SystemParse parse = new SystemParse(new SystemParseSetting(options));
+            var relationType= RelationTypeManager.GetRelationTypeItem(Definition.Name.Split('-')[0]);
+            if (relationType == null)
+                return new GplotParseData();
+            SystemParse parse = new SystemParse(new SystemParseSetting(new RelationTypeShell(relationType)));
             StartElementsManager startManager = new StartElementsManager(options);
             //可能出现多个document;每一个document是一个测试节点
             var fileInfos = RevitModelPath.GetAllRevitFiles();

+ 68 - 27
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -1,14 +1,17 @@
 using System.Collections.Generic;
+using System.IO;
 using System.Threading;
 using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.UI;
+using Newtonsoft.Json;
 using SAGA.GplotDrawData;
 using SAGA.GplotDrawData.View;
 using SAGA.GplotManage.UploadRelated;
 using SAGA.GplotRelationComputerManage;
 using SAGA.MBI.Common;
 using SAGA.Models;
+using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 
 namespace SAGA.GplotManage
@@ -61,8 +64,13 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            space.Show(GplotShowType.Default);
+            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            SystemComputerHandler handler1 = new SystemComputerHandler();
+            handler1.ComputerWidthCache(useRelations);
+            WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
+            floorWin.Show();
+            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
+            //space.Show(GplotShowType.Default);
             return Result.Succeeded;
         }
 
@@ -81,8 +89,13 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            space.Show(GplotShowType.ViewPlan);
+            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            SystemComputerHandler handler1 = new SystemComputerHandler();
+            handler1.ComputerWidthCache(useRelations);
+            WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
+            floorWin.Show();
+            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
+            //space.Show(GplotShowType.ViewPlan);
             return Result.Succeeded;
         }
 
@@ -101,8 +114,13 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
-            space.Show(GplotShowType.VerticalPlan);
+            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            SystemComputerHandler handler1 = new SystemComputerHandler();
+            handler1.ComputerWidthCache(useRelations);
+            WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);
+            verticalWin.Show();
+            //var space = GplotFactory.Create(GraphTypeEnum.ChillWaterLoop);
+            //space.Show(GplotShowType.VerticalPlan);
             return Result.Succeeded;
 
         }
@@ -123,22 +141,49 @@ namespace SAGA.GplotManage
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             //var graph = new ChillWaterLoop();
-            List<Gplot> gplots = new List<Gplot>();
-            gplots.Add(new ElementSpNeighborhood());
-            gplots.Add(new TrafficNetwork());
-            gplots.Add(new ConvectionNetwork());
-            gplots.Add(new RadiationNetwork());
-            foreach (var gplot in gplots)
-            {
-                var graph =gplot;//new ElementSpNeighborhood();
-                graph.Relationship = graph.ComputerEffectRelationShip;
-                graph.Upload();
+            //List<Gplot> gplots = new List<Gplot>();
+            //gplots.Add(new ElementSpNeighborhood());
+            //gplots.Add(new TrafficNetwork());
+            //gplots.Add(new ConvectionNetwork());
+            //gplots.Add(new RadiationNetwork());
+            //foreach (var gplot in gplots)
+            //{
+            //    var graph =gplot;//new ElementSpNeighborhood();
+            //    graph.Relationship = graph.ComputerEffectRelationShip;
+            //    graph.Upload();
 
-            }
-           
+            //}
+            var relationDatas = RelationDataUtil.BuildRelations("ChillWaterLoop");
+              Criteria Criterias= new Criteria
+              {
+                  criterias = relationDatas
+              };
+            var relation= ConvertJsonString(Criterias);
+            MessageShow.Infomation(relation);
             return Result.Succeeded;
         }
+        private string ConvertJsonString(object object1)
+        {
+            //格式化json字符串
+            JsonSerializer serializer = new JsonSerializer();
 
+            if (object1 != null)
+            {
+                StringWriter textWriter = new StringWriter();
+                JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
+                {
+                    Formatting = Formatting.Indented,
+                    Indentation = 4,
+                    IndentChar = ' '
+                };
+                serializer.Serialize(jsonWriter, object1);
+                return textWriter.ToString();
+            }
+            else
+            {
+                return "";
+            }
+        }
         public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
             return true;
@@ -153,16 +198,12 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            var relationType = RelationTypeManager.GetRelationTypeItem("ChillWaterLoop");
-            //return Result.Succeeded;
+            //var relationType = RelationTypeManager.GetRelationTypeItem("ChillWaterLoop");
+            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
             SystemComputerHandler handler1 = new SystemComputerHandler();
-            SystemComputerContext context = new SystemComputerContext();
-            context.Relations.Add("ChillWaterLoop");
-            handler1.GetParseData(context);
-            WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
-            floorWin.Show();
-            WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);
-            verticalWin.Show();
+            handler1.ComputerWidthCache(useRelations);
+            WinMachineRoom room = new WinMachineRoom();
+            room.Show();
             return Result.Succeeded;
             RoomShowHandler handler = new RoomShowHandler("ChillWaterLoop");
             handler.Show();

+ 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;
         }

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

@@ -120,6 +120,7 @@
     <Compile Include="GplotManage\GplotView\GplotView.cs" />
     <Compile Include="Command\GplotUtil.cs" />
     <Compile Include="GraphTypeEnum.cs" />
+    <Compile Include="SystemRelation\RelationDataUtil.cs" />
     <Compile Include="UploadRelated\AirNetwork.cs" />
     <Compile Include="UploadRelated\ControlRelation.cs" />
     <Compile Include="UploadRelated\ConvectionNetwork.cs" />

+ 146 - 0
MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs

@@ -0,0 +1,146 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.GplotRelationComputerManage;
+
+namespace SAGA.GplotManage
+{
+    /// <summary>
+    /// 关系数据处理
+    /// </summary>
+    public class RelationDataUtil
+    {
+        /// <summary>
+        /// 上传关系数据
+        /// </summary>
+        /// <param name="relationData"></param>
+        /// <returns></returns>
+        public static List<ReleateData> BuildRelations(LoadRelationData relationData)
+        {
+            #region 说明
+            /*
+             * 数据关联项:
+             * 机房设备---特殊阀门
+             * 特殊阀门---立管
+             * 立管--立管
+             * 立管---平面设备;由此=》机房设备---平面设备
+             */
+            #endregion
+            List<ReleateData> result = new List<ReleateData>();
+            List<BinaryRelationItem> roomRelations = new List<BinaryRelationItem>();
+            List<BinaryRelationItem> floorRelations = new List<BinaryRelationItem>();
+            #region 机房关系数据
+            var machineRoomData = relationData.MachineRoomRelationRecords;
+            foreach (var machineRelation in machineRoomData)
+            {
+                foreach (var item in machineRelation.RelationItems)
+                {
+                    if (item.IsEquipmentLink())
+                    {
+                        result.Add(CreateRelationData(item));
+                    }
+                    else
+                    {
+                        roomRelations.Add(item);
+                    }
+                }
+            }
+            #endregion
+            #region 平面关系数据
+            foreach (var floorRelation in relationData.FloorRelationRecords)
+            {
+                foreach (var item in floorRelation.RelationItems)
+                {
+                    if (item.IsEquipmentLink())
+                    {
+                        result.Add(CreateRelationData(item));
+                    }
+                    else
+                    {
+                        roomRelations.Add(item);
+                    }
+                }
+            }
+            #endregion
+
+            var verticalSets = relationData.VerticalRelationRecords;
+
+            #region 机房和平面关联
+            /*
+             * 前提不是全设备
+             */
+            foreach (var roomRelation in roomRelations)
+            {
+                EquipmentNode equipmentNode, linkNode;
+                if(!roomRelation.From.IsRealEquipment&&!roomRelation.To.IsRealEquipment)
+                {
+                    continue;
+                }
+                if(roomRelation.From.IsRealEquipment)
+                {
+                    equipmentNode = roomRelation.From;
+                    linkNode = roomRelation.To;
+                }
+                else
+                {
+                    equipmentNode = roomRelation.To;
+                    linkNode = roomRelation.From;
+                }
+                List<string> useLinks = new List<string>();
+                var useSet = verticalSets.FirstOrDefault(s => s.RelationItems.Any(item => item == linkNode.BimId));
+                if(useSet==null)
+                {
+                    useLinks.Add(linkNode.BimId);
+                }
+                else
+                {
+                    useLinks.AddRange(useSet.RelationItems);
+                }
+                foreach (var useLink in useLinks)
+                {
+                   var floorRelation= floorRelations.FirstOrDefault(c => c.From.BimId == useLink || c.To.BimId == useLink);
+                    BinaryRelationItem newRelationItem = new BinaryRelationItem();
+                    newRelationItem.From = equipmentNode;
+                    newRelationItem.To = floorRelation.From.BimId != useLink ? floorRelation.From : floorRelation.To;
+                    newRelationItem.RelationType = floorRelation.RelationType;
+
+                    //加入关系数据
+                    result.Add(CreateRelationData(newRelationItem));
+                }
+
+            }
+            #endregion
+            return result;
+        }
+        /// <summary>
+        /// 创建上传关系数据
+        /// </summary>
+        /// <param name="relationType"></param>
+        /// <returns></returns>
+        public static List<ReleateData> BuildRelations(string  relationType)
+        {
+            LoadRelationData data = new LoadRelationData(relationType);
+            data.LoadData();
+            return BuildRelations(data);
+        }
+
+        #region 私有方法
+        /// <summary>
+        /// 创建上传关系数据
+        /// </summary>
+        /// <param name="relationItem"></param>
+        /// <returns></returns>
+        private static ReleateData CreateRelationData(BinaryRelationItem relationItem)
+        {
+            ReleateData relation = new ReleateData();
+            relation.from_id = relationItem.From.MbiId;
+            relation.to_id = relationItem.To.MbiId;
+            relation.rel_type = relationItem.RelationType;
+            return relation;
+        }
+        #endregion
+    }
+}

+ 11 - 0
MBI/SAGA.GplotRelationComputerManage/Common/ComputerFileSetting.cs

@@ -17,5 +17,16 @@ namespace SAGA.GplotRelationComputerManage
         public const string VerticalRelation = "VerticalRelation";
         public const string MachineRoomDraw = "MechineRoomDraw";
         public const string MachineRoomRelation = "MechineRoomRelation";
+
+        /// <summary>
+        /// 获取通用的文件名称
+        /// </summary>
+        /// <param name="relationType">关系类型</param>
+        /// <param name="commonKey">通用键值</param>
+        /// <returns></returns>
+        public static string GetRealKey(string relationType,string commonKey)
+        {
+            return string.Format("{0}_{1}", relationType, commonKey);
+        }
     }
 }

+ 26 - 0
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/Common/DataNodeUtil.cs

@@ -10,6 +10,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using SAGA.DotNetUtils.Extend;
 using SAGA.Models;
 
 namespace SAGA.GplotRelationComputerManage
@@ -65,5 +66,30 @@ namespace SAGA.GplotRelationComputerManage
             }
             #endregion
         }
+
+        /// <summary>
+        /// 将数据源分组处理
+        /// </summary>
+        /// <typeparam name="IN"></typeparam>
+        /// <param name="source"></param>
+        /// <param name="selects"></param>
+        /// <returns></returns>
+        public static List<DataNode> CreateTree<IN>(List<IN> source, List<Func<IN, string>> selects)
+        {
+            List<GroupCondition<IN, DataNode>> conditions = new List<GroupCondition<IN, DataNode>>();
+            foreach (var selectItem in selects)
+            {
+                GroupCondition<IN, DataNode> condition = new GroupCondition<IN, DataNode>();
+                condition.GroupContinue = (g) => true;
+                condition.GroupSelect = (g) => {
+                    var tempNode=new DataNode { EName = g.Key };
+                    tempNode.SetData(g.ToList());
+                    return tempNode;
+                };
+                condition.GroupKeySelect = selectItem;
+                conditions.Add(condition);
+            }
+            return source.GroupTree<IN, DataNode>((p, children) => { p.Childrens.AddRange(children); }, conditions);
+        }
     }
 }

+ 1 - 0
MBI/SAGA.GplotRelationComputerManage/Common/DataServerUtil.cs

@@ -30,5 +30,6 @@ namespace SAGA.GplotRelationComputerManage
 
             }
         }
+
     }
 }

+ 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;
+        }
+    }
+}

+ 75 - 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
 {
@@ -83,6 +86,53 @@ namespace SAGA.GplotRelationComputerManage
         }
 
         /// <summary>
+        /// 获取设备的分类
+        /// </summary>
+        /// <param name="element"></param>
+        /// <returns></returns>
+        public static bool TryGetEquipmentCategory(Element element,out string category)
+        {
+            category = null;
+            if (!(element is FamilyInstance))
+            {
+                return false;
+            }
+            List<BuiltInCategory> categories = new List<BuiltInCategory>();
+            categories.Add(BuiltInCategory.OST_PipeFitting);
+            categories.Add(BuiltInCategory.OST_DuctFitting);
+            if (categories.Any(c => element.Category.Id.IntegerValue == (int)c))
+            {
+                return false;
+            }
+            string familyName = element.GetFamily()?.Name ?? string.Empty;
+            var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
+            if (match.Success)
+            {
+                category = match.Groups[1].ToString();
+            }
+            return match.Success;
+        }
+        /// <summary>
+        /// 获取设备的设备分类
+        /// </summary>
+        /// <param name="element"></param>
+        /// <returns></returns>
+        public static string GetEquipmentCategory(Element element)
+        {
+            string category = null;
+            if (!(element is FamilyInstance fi))
+            {
+                return category;
+            }
+            string familyName = fi.GetFamily()?.Name;
+            var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
+            if (match.Success)
+            {
+                category = match.Groups[1].ToString();
+            }
+            return category;
+        }
+        /// <summary>
         /// 通过标高名称获取楼层名称
         /// </summary>
         /// <param name="levelName"></param>
@@ -91,5 +141,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; }
+    }
+}

+ 25 - 6
MBI/SAGA.GplotRelationComputerManage/DataServer/DataServer.cs

@@ -17,10 +17,10 @@ namespace SAGA.GplotRelationComputerManage
         public DataServer(Func<string, IVersionFile> versionFileBuilder)
         {
             m_BuilderVersionFile = versionFileBuilder;
-        }      
+        }
         public virtual IVersionFile CreateVersionFile(string fileName)
         {
-           return m_BuilderVersionFile?.Invoke(fileName);
+            return m_BuilderVersionFile?.Invoke(fileName);
         }
         #region 功能相关类
         /// <summary>
@@ -112,10 +112,29 @@ namespace SAGA.GplotRelationComputerManage
         }
         public bool IsExpired<T>(DateTime dateTime)
         {
-            var fileName = DataServer.GetFileKey<T>();
-            return IsExpired(fileName, dateTime);
+            var fileKey = DataServer.GetFileKey<T>();
+            return IsExpired(fileKey, dateTime);
 
-        } 
+        }
+        /// <summary>
+        /// 获取当前文件信息
+        /// </summary>
+        /// <param name="fileKey"></param>
+        /// <returns></returns>
+        public IVersionFile GetFile(string fileKey)
+        {
+            return CreateVersionFile(fileKey);
+        }
+        /// <summary>
+        /// 获取当前文件信息
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <returns></returns>
+        public IVersionFile GetFile<T>()
+        {
+            var fileKey = DataServer.GetFileKey<T>();
+            return GetFile(fileKey);
+        }
         #endregion
         /// <summary>
         /// 获取文件类型key值
@@ -125,7 +144,7 @@ namespace SAGA.GplotRelationComputerManage
         public static string GetFileKey<T>()
         {
             var type = typeof(T);
-            FileKeyAttribute fileKey = null;        
+            FileKeyAttribute fileKey = null;
             fileKey = type.GetCustomAttribute<FileKeyAttribute>();
             if (type.IsGenericType && fileKey == null)
             {

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

@@ -110,7 +110,7 @@ namespace SAGA.GplotRelationComputerManage
         public string ReadVersion()
         {
             string filePath = GetFilePath();
-            if (filePath != null)
+            if (string.IsNullOrWhiteSpace(filePath))
                 return ReadFileVersion(Path.GetFileName(filePath));
             return string.Empty;
         }

+ 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)

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/RelationType/Data/RelationItem.cs

@@ -17,7 +17,7 @@ namespace SAGA.GplotRelationComputerManage
             Objects = new List<ObjectItem>();
             Systems = new List<SystemItem>();
             ObjectRelations = new List<BinaryItem<ObjectItem>>();
-            this.SystemType = SystemType.Pipe;
+            this.SystemType = SystemType.Unknown;
         }
         #region 属性相关维护
         /// <summary>

+ 2 - 0
MBI/SAGA.GplotRelationComputerManage/RelationType/Data/SystemItem.cs

@@ -44,6 +44,8 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public bool IsMatch(string inputSystemName)
         {
+            if (string.IsNullOrWhiteSpace(inputSystemName))
+                return false;
             return inputSystemName.Contains(Name);
         }
     }

+ 22 - 1
MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs

@@ -63,7 +63,12 @@ namespace SAGA.GplotRelationComputerManage
                 ParseSystems(relationItem, strSystem);
                 #endregion
 
-                if (firstItem.SystemType == "1")
+
+                if (firstItem.SystemType == "0")
+                {
+                    relationItem.SystemType = SystemType.Pipe;
+                }
+                else if (firstItem.SystemType == "1")
                 {
                     relationItem.SystemType = SystemType.Duct;
                 }
@@ -208,5 +213,21 @@ namespace SAGA.GplotRelationComputerManage
         {
             return Items.FirstOrDefault(c => c.Type == relationType);
         }
+        /// <summary>
+        /// 获取全部系统的关系类型
+        /// </summary>
+        /// <returns></returns>
+        public static List<RelationItem> GetSystemRelationTypes()
+        {
+            return Items.Where(r => r.SystemType!=SystemType.Unknown).ToList();
+        }
+        /// <summary>
+        /// 获取全部系统的关系类型
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> GetSystemRelationTypeNames()
+        {
+            return GetSystemRelationTypes().Select(r => r.Type).ToList() ;
+        }
     }
 }

+ 6 - 2
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs

@@ -405,8 +405,12 @@ namespace SAGA.GplotRelationComputerManage
                 originEdge.SystemName = (refElements.FirstOrDefault(e => e is MEPCurve) as MEPCurve)?.GetSystemTypeName();
                 //根据系统类型和特殊设备确定旁通和补水;未完,待续
                 var systemItem = Setting.RelationTypeShell.GetFirstMatchSystem(originEdge.SystemName);
-                originEdge.EdgeCategory = systemItem.ContainEdgeTypes.FirstOrDefault();// Setting.GplotOptions.GetCategory(originEdge.SystemName);
-                originEdge.FlowType = systemItem.FlowType == FlowType.In ? 2 : 1;
+                if (systemItem != null)
+                {
+                    originEdge.EdgeCategory = systemItem.ContainEdgeTypes.FirstOrDefault();// Setting.GplotOptions.GetCategory(originEdge.SystemName);
+                    originEdge.FlowType = systemItem.FlowType == FlowType.In ? 2 : 1;
+                }
+            
             }
             #endregion
             #region 方向处理

+ 1 - 0
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParseSetting.cs

@@ -20,6 +20,7 @@ namespace SAGA.GplotRelationComputerManage
         public SystemParseSetting(GplotOptions options)
         {
             //GplotOptions = options;
+            //var relationType = RelationTypeManager.GetRelationTypeItem(options.);
         }
         public SystemParseSetting(RelationTypeShell relationShell)
         {

+ 7 - 1
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" />
@@ -106,7 +108,7 @@
     <Compile Include="Draw\IDraw.cs" />
     <Compile Include="Draw\PointExtension.cs" />
     <Compile Include="LvSpace.cs" />
-    <Compile Include="PowerDistribution\Common\DataNodeUtil.cs" />
+    <Compile Include="Common\DataNodeUtil.cs" />
     <Compile Include="PowerDistribution\Common\PowerComputerContext.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\DistributionRelationshipHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\EquipPowerRelationshipHandler.cs" />
@@ -135,6 +137,7 @@
     <Compile Include="SpaceRelation\SpaceComputerHandler.cs" />
     <Compile Include="SpaceRelation\SpaceComputerManager.cs" />
     <Compile Include="SystemRelation\Common\PointItemType.cs" />
+    <Compile Include="SystemRelation\Common\RelationTypeUtil.cs" />
     <Compile Include="SystemRelation\Common\SystemCalcUtil.cs" />
     <Compile Include="SystemRelation\Common\SystemParseManager.cs" />
     <Compile Include="SystemRelation\Common\VerticalResult.cs" />
@@ -146,9 +149,12 @@
     <Compile Include="SystemRelation\Data\SystemDrawItems.cs" />
     <Compile Include="SystemRelation\Data\SystemPointItem.cs" />
     <Compile Include="SystemRelation\FloorSystemItem.cs" />
+    <Compile Include="SystemRelation\RelationComputerData.cs" />
+    <Compile Include="SystemRelation\RelationDataCheck.cs" />
     <Compile Include="SystemRelation\ServerData\FloorDrawData.cs" />
     <Compile Include="SystemRelation\ServerData\MachineRoomDrawRecord.cs" />
     <Compile Include="SystemRelation\ServerData\MachineRoomRelationRecord.cs" />
+    <Compile Include="SystemRelation\ServerData\ServerData.cs" />
     <Compile Include="SystemRelation\ServerData\VerticalDrawData.cs" />
     <Compile Include="SystemRelation\ServerData\VerticalDrawRecord.cs" />
     <Compile Include="SystemRelation\ServerData\FloorDrawRecord.cs" />

+ 63 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/RelationTypeUtil.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 图类型相关计算方法
+    /// </summary>
+    public class RelationTypeUtil
+    {
+        /// <summary>
+        /// 获取需要重新计算的图类型
+        /// </summary>
+        /// <param name="relationTypes"></param>
+        /// <returns></returns>
+        public static List<string> NeedResetRelationTypes(List<string> relationTypes)
+        {
+            List<string> result = new List<string>();
+            foreach (string relationType in relationTypes)
+            {
+                RelationDataCheck check = new RelationDataCheck(relationType);
+                if(check.IsMissData())
+                {
+                    result.Add(relationType);
+                    continue;
+                }
+                //获取日志变更时间
+                DateTime dateTime = GetLastWriteTime();
+                if(check.IsExpired(dateTime))
+                {
+                    //测试不验证事件
+                   // result.Add(relationType);
+                    continue;
+                }
+            }
+
+            return result;
+        }
+     
+        /// <summary>
+        /// 获取最近的修改时间
+        /// </summary>
+        /// <returns></returns>
+        public static DateTime GetLastWriteTime()
+        {
+            DateTime dateTime = new DateTime(0);
+            var files = RevitModelPath.GetAllRevitFiles();
+            foreach (var file in files)
+            {
+                var tempTime = File.GetLastWriteTime(file);
+                if (tempTime > dateTime)
+                {
+                    dateTime = tempTime;
+                }
+            }       
+            return dateTime;
+        }
+    }
+}

+ 55 - 7
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;
@@ -62,6 +63,11 @@ namespace SAGA.GplotRelationComputerManage
                         foreach (var refConnector in refConnectors)
                         {
                             var refElement = refConnector.Owner;
+                            if (reference.Reverse<ElementTreeNode>().Any(e => e.Current.Id.IntegerValue == refElement.Id.IntegerValue))
+                            {
+                                continue;
+                            }
+
                             ElementTreeNode refNode = new ElementTreeNode();
                             refNode.Current = refElement;
                             refNode.StartLocation = refConnector.Origin;
@@ -70,10 +76,10 @@ namespace SAGA.GplotRelationComputerManage
                             {
                                 continue;
                             }
-                            if (reference.All(e => e.Current.Id.IntegerValue != refElement.Id.IntegerValue))
-                            {
+                            //if (reference.All(e => e.Current.Id.IntegerValue != refElement.Id.IntegerValue))
+                            //{
                                 reference.Add(refNode);
-                            }
+                            //}
                         }
                     }
                 }
@@ -390,9 +396,11 @@ namespace SAGA.GplotRelationComputerManage
             }
             else if (element is FamilyInstance)
             {
-                if (MBIInfoUtil.IsEquipment(element))
+                string tempCategory;
+                if (MBIInfoUtil.TryGetEquipmentCategory(element,out tempCategory))
                 {
-                    node.Category = PointItemType.Equipment.ToString();
+                    node.Category = tempCategory;
+                    node.IsRealEquipment = true;
                 }
                 else if (SystemCalcUtil.IsStart(element))
                 {
@@ -404,7 +412,7 @@ namespace SAGA.GplotRelationComputerManage
             #region 确定返回之后进行后初始化处理
             if (outNode != null)
             {
-                outNode.RevitId = element.Id.IntegerValue;
+                outNode.RevitId = element.Id.ToString();
                 outNode.BimId = element.GetBimId();
             } 
             #endregion
@@ -496,6 +504,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>
@@ -505,7 +554,6 @@ namespace SAGA.GplotRelationComputerManage
     {
         /// <summary>
         ///  立管左右错开小于2Cm
-        /// 
         /// </summary>
         /// <param name="x"></param>
         /// <param name="y"></param>

+ 15 - 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,16 @@ namespace SAGA.GplotRelationComputerManage
             To = From;
             From = temp;
         }
+
+        /// <summary>
+        /// 是否是设备连接
+        /// </summary>
+        /// <returns></returns>
+        public bool IsEquipmentLink()
+        {
+            return From.IsRealEquipment && To.IsRealEquipment;
+        }
+
+       
     }
 }

+ 6 - 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>
@@ -49,5 +49,10 @@ namespace SAGA.GplotRelationComputerManage
             node.Category = this.Category;
             return node;
         }
+        /// <summary>
+        /// 是否是真实设备
+        /// </summary>
+        public bool IsRealEquipment { get; set; }
+        
     }
 }

+ 239 - 73
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -7,11 +7,16 @@
 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.DotNetUtils.Extend;
+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 +26,7 @@ namespace SAGA.GplotRelationComputerManage
     public class FloorSystemItem
     {
         #region 构造函数
+
         /// <summary>
         /// 初始化解析类
         /// </summary>
@@ -30,17 +36,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 +63,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 +82,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 +112,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 +123,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 +155,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>
@@ -162,7 +189,7 @@ namespace SAGA.GplotRelationComputerManage
                 var shell = context.RelationShells.GetItem(relation);
                 if (shell.IsPipeSystem())
                 {
-                    ParsePipe(context, shell);
+                    ParsePipe(context, shell,Domain.DomainPiping);
                 }
                 else
                 {
@@ -172,12 +199,16 @@ namespace SAGA.GplotRelationComputerManage
         }
 
         #region 水系统解析
-        public void ParsePipe(SystemComputerContext context,RelationTypeShell relationSetting)
+
+        public void ParsePipe(SystemComputerContext context, RelationTypeShell relationSetting, Domain currentDomain)
         {
-            Domain useDomain = Domain.DomainPiping;
+            Domain useDomain = currentDomain;//Domain.DomainPiping;
+            var relationType = relationSetting.RelationItem.Type;
             List<FloorDrawRecord> drawRecords = new List<FloorDrawRecord>();
             List<FloorRelationRecord> relationRecords = new List<FloorRelationRecord>();
+            List<Element> roomStartElements = new List<Element>();
             #region 计算拓扑树形结构 
+
             /*
              * 1、遍历开始点的限制:特殊阀门,指定标注的Connector;立管,已连接连接件;空间,相交风管元素;
              * 2、根据拓扑图关联的对象信息,找到系统关联的设备生成节点。如果没有遍历到要独立生成
@@ -192,17 +223,22 @@ 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;
                 }
-
+                //加入立管
                 if (startNode.Instance.Current is MEPCurve mepCurve)
                 {
                     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 +246,9 @@ namespace SAGA.GplotRelationComputerManage
                 startNode.Handled = true;
 
                 //可以清空Leaves的子节点
+
                 #region 整理原始数据
+
                 //判断是否有设备节点,不进行数据处理
                 var useNode = startNode.Instance;
                 //var firstEquipment = useNode.FirstOrDefault(t => MBIInfoUtil.IsEquipment(t.Current));
@@ -223,22 +261,31 @@ namespace SAGA.GplotRelationComputerManage
                     drawRecord.SystemName = startNode.Flag;
                     drawRecords.Add(drawRecord);
 
-                    var relationRecord = BuildFloorRelationRecord(relationSetting, useNode);
+                    var relationRecord = BuildFloorRelationRecord(relationSetting, useNode,context);
                     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,66 +293,89 @@ 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)
-                        continue;
-                    var systemTypeName = useMepCurve.GetSystemTypeName();
-                    if (!relationSetting.IsMatchSystem(systemTypeName))
+                    //查找需要遍历的路径信息
+                    var leaves = startNode.GetLeaves();
+                    //使用过的系统不再进行遍历
+                    List<string> useSystems = new List<string>();
+                    foreach (var leaf in leaves)
                     {
-                        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;
-                    drawRecords.Add(drawRecord);
-
-                    var relationRecord = BuildFloorRelationRecord(relationSetting, startNode);
-                    relationRecords.Add(relationRecord);
-                    #endregion
+                        var useMepCurve = leaf?.Current as MEPCurve;
+                        if (useMepCurve == null)
+                            continue;
+                        var systemTypeName = useMepCurve.GetSystemTypeName();
+                        if (!relationSetting.IsMatchSystem(systemTypeName))
+                        {
+                            continue;
+                        }
 
-                }
+                        if (useSystems.Any(s => s == systemTypeName))
+                        {
+                            continue;
+                        }
+                        useSystems.Add(systemTypeName);
+                        //创建制定的startNode;[一个分支,一个分支去处理]
+                        ElementTreeNode newStartNode = new ElementTreeNode() {Current = useInstance};
+                        var tempIds = SystemParseManager.BuildSystemNode(newStartNode, useDomain,
+                            (m => !systemTypeName.Equals(m.GetSystemTypeName())));
+                        newStartNode.PipeSystemTypeName = systemTypeName;
+                        BuildElementNodeData(context, newStartNode);
+                        useIds.AddRange(tempIds);
 
+                        #region 生成绘图,计算数据
 
+                        //解析数据,找管道定系统,管道找不到,系统名为"关联类型-未知"
+                        var drawRecord = BuildFloorDrawRecord(relationSetting, newStartNode);
+                        drawRecord.SystemName = systemTypeName;
+                        drawRecords.Add(drawRecord);
 
+                        var relationRecord = BuildFloorRelationRecord(relationSetting, newStartNode, context);
+                        relationRecords.Add(relationRecord);
 
+                        #endregion
+                    }
+                }
             }
+
             #endregion
+
             //增加立管数据
-            ComputerVerticalPipes(UseLevel, verticalMepCurves, context);
-            context.FloorDrawRecords.AddRange(drawRecords);
-            context.FloorRelationRecords.AddRange(relationRecords);
+            ComputerVerticalPipes(UseLevel, verticalMepCurves, context, relationSetting);
+            context[relationType].FloorDrawRecords.AddRange(drawRecords);
+            context[relationType].FloorRelationRecords.AddRange(relationRecords);
         }
+
         #endregion
 
         #region 风系统解析
+
         public void ParseDuct(SystemComputerContext context, RelationTypeShell relationSetting)
-        { } 
+        {
+            ParsePipe(context, relationSetting, Domain.DomainHvac);
+        }
+
         #endregion
+
         #endregion
 
         #region 解析立管
+
         /*
          * 1、解析立管需要考虑,竖直风管,水管,空间的情况;
          *2、将各层数据汇总,才能统一计算立管的相关关系数据
          */
-        private void ComputerVerticalPipes(Level refLevel, List<MEPCurve> mepCurves, SystemComputerContext context)
+        private void ComputerVerticalPipes(Level refLevel, List<MEPCurve> mepCurves, SystemComputerContext context, RelationTypeShell relationSetting)
         {
             var result = new List<VerticalPipe>();
             var spaces = Document.GetElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>();
             var level = refLevel;
+            var relationType = relationSetting.RelationItem.Type;
             var currentLevelName = MBIInfoUtil.GetFloorNameByLevel(level.Name);
             foreach (var pipe in mepCurves)
             {
                 if (pipe == null)
-                    continue;             
+                    continue;
                 var vp = new VerticalPipe
                 {
                     Id = pipe.Id.IntegerValue.ToString(),
@@ -315,24 +385,30 @@ 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(),
                 Name = MBIInfoUtil.GetFloorNameByLevel(refLevel.Name)
             };
-            context.VerticalPipes.AddRange(result);
-            context.Levels.Add(levelData);
+            context[relationType].VerticalPipes.AddRange(result);
+            context[relationType].Levels.Add(levelData);
         }
+
         #endregion
 
 
@@ -342,25 +418,49 @@ 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)
+
+        private FloorRelationRecord BuildFloorRelationRecord(RelationTypeShell relationShell, ElementTreeNode node, SystemComputerContext context)
         {
             var floorRelation = new FloorRelationRecord();
             floorRelation.SetFloorLevel(UseLevel);
             floorRelation.RelationType = relationShell.RelationItem.Type;
-            floorRelation.RelationItems = SystemParseManager.CreateRelation(node)??new List<BinaryRelationItem>();
+            var records= SystemParseManager.CreateRelation(node) ?? new List<BinaryRelationItem>();
+            floorRelation.RelationItems = records;
+            var mathSystem=relationShell.GetFirstMatchSystem(node.PipeSystemTypeName);
+            var edgeType = mathSystem.ContainEdgeTypes.FirstOrDefault();
+            if(string.IsNullOrWhiteSpace(edgeType))
+            {
+                edgeType = "1";
+            }
+
+            //增加关联对象名称
+            records.ForEach(e => {
+                var nodes = new List<EquipmentNode>() { e.From, e.To };
+                nodes.ForEach(n => n.MbiId = context.EquipmentItems.GetItem(n.BimId)?.Id);
+                e.RelationType = edgeType;
+                if(mathSystem!=null&&mathSystem.FlowType==FlowType.Out)
+                {
+                    //根据流向反转关系
+                    e.Reverse();
+                }
+
+            });
             return floorRelation;
         }
+
         #endregion
 
         #region 初始化名称,分类
+
         /// <summary>
         /// 初始化节点扩展数据
         /// </summary>
@@ -373,16 +473,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 +494,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 +519,93 @@ 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>();
+            var relationType = relationSetting.RelationItem.Type;
+            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[relationType].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 = ConverEquipmentNode(item.EquipmentItem1, context);
+                node.To = ConverEquipmentNode(item.EquipmentItem2, context); 
+                node.RelationType = item.LinkType;
+                relationRecord.RelationItems.Add(node);
+
+
+                var newIds = new List<string>() {item.EquipmentItem1.Id, item.EquipmentItem2.Id};
+                useEquipments.AddRange(newIds);
+
+
+            }
+            context[relationType].MachineRoomRelationRecords.Add(relationRecord);
+            #endregion
+
+            return useEquipments;
+
+        }
+
+        private EquipmentNode ConverEquipmentNode(EquipmentItem item, SystemComputerContext context)
+        {
+            EquipmentNode result = new EquipmentNode();
+            result.RevitId = item.Id;
+            result.BimId = CreateBimId(result.RevitId);
+            result.MbiId = context.EquipmentItems.GetItem(result.BimId)?.Id ?? string.Empty;
+            return result;
+        }
+        #endregion 解析机房数据
+        /// <summary>
+        /// 根据revitId获取bimId
+        /// </summary>
+        /// <param name="revitId"></param>
+        /// <returns></returns>
+        private string CreateBimId(string revitId)
+        {
+            return string.Format($"{Document.PathName.GetFileName()}:{revitId}");
         }
-        #endregion
     }
 }

+ 191 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/RelationComputerData.cs

@@ -0,0 +1,191 @@
+using SAGA.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /*
+     * 为了控制属性的安全想,想计算数据分为保存数据,和加载数据
+     */
+    /// <summary>
+    /// 关系计算数据
+    /// </summary>
+    public class RelationComputerData
+    {
+
+        public RelationComputerData(string relationType)
+        {
+            this.RelationType = relationType;
+        }
+
+        /// <summary>
+        /// 关系类型
+        /// </summary>
+        public string RelationType { get; protected set; }
+
+
+
+        /// <summary>
+        /// 获取当前关系类型的通用键值
+        /// </summary>
+        /// <param name="commonKey"></param>
+        /// <returns></returns>
+        public string RealKey(string commonKey)
+        {
+            return ComputerFileSetting.GetRealKey(RelationType, commonKey);
+        }
+
+    }
+
+    /// <summary>
+    /// 保存的计算数据类型
+    /// </summary>
+    public class SaveComputerData : RelationComputerData
+    {
+        public SaveComputerData(string relationType) : base(relationType)
+        {
+            Init();
+        }
+        /// <summary>
+        /// 初始化集合字段
+        /// </summary>
+        private void Init()
+        {
+            VerticalPipes = new List<VerticalPipe>();
+            Levels = new List<LevelData>();
+            FloorDrawRecords = new List<FloorDrawRecord>();
+            FloorRelationRecords = new List<FloorRelationRecord>();
+            MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
+            MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
+        }
+        #region 存储数据
+        public List<VerticalPipe> VerticalPipes { get; private set; }
+        public List<LevelData> Levels { get; private set; }
+
+        public List<FloorDrawRecord> FloorDrawRecords { get; protected set; }
+        public List<FloorRelationRecord> FloorRelationRecords { get; protected set; }
+        public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; protected set; }
+        public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; protected set; }
+        #endregion
+
+        /// <summary>
+        /// 保存立面数据
+        /// </summary>
+        public void SaveData()
+        {
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.FloorDraw), FloorDrawRecords);
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.FloorRelation), FloorRelationRecords);
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.MachineRoomDraw), MachineRoomDrawRecords);
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.MachineRoomRelation), MachineRoomRelationRecords);
+            var result = SystemParseManager.ComputerVerticalData(VerticalPipes, Levels);
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.VerticalDraw), result.DrawData);
+            DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.VerticalRelation), result.RelationData);
+        }
+    }
+
+    /// <summary>
+    /// 加载的关系数据
+    /// </summary>
+    public class LoadRelationData : RelationComputerData
+    {
+        public LoadRelationData(string relationType) : base(relationType)
+        {
+            FloorRelationRecords = new List<FloorRelationRecord>();
+            VerticalRelationRecords = new List<VerticalRelationRecord>();
+            MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
+        }
+        #region 存储数据
+
+        public List<FloorRelationRecord> FloorRelationRecords { get; protected set; }
+        public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; protected set; }
+        public List<VerticalRelationRecord> VerticalRelationRecords { get; private set; }
+        #endregion
+        #region 数据的保存加载
+        /// <summary>
+        /// 加载计算数据
+        /// </summary>
+        public void LoadData()
+        {
+            FloorRelationRecords = DataServerUtil.Current.LoadData<List<FloorRelationRecord>>(RealKey(ComputerFileSetting.FloorRelation))??new List<FloorRelationRecord>();
+            MachineRoomRelationRecords = DataServerUtil.Current.LoadData<List<MachineRoomRelationRecord>>(RealKey(ComputerFileSetting.MachineRoomRelation))??new List<MachineRoomRelationRecord>();
+            VerticalRelationRecords = DataServerUtil.Current.LoadData<List<VerticalRelationRecord>>(RealKey(ComputerFileSetting.VerticalRelation))??new List<VerticalRelationRecord>();
+        }
+
+        #endregion
+    }
+
+    /// <summary>
+    /// 加载平面展示数据
+    /// </summary>
+    public class LoadFloorDrawData : RelationComputerData
+    {
+        public LoadFloorDrawData(string relationType) : base(relationType)
+        {
+            FloorDrawRecords = new List<FloorDrawRecord>();
+        }
+        #region 存储数据
+
+        public List<FloorDrawRecord> FloorDrawRecords { get; protected set; }
+
+        #endregion
+        #region 数据的保存加载
+        /// <summary>
+        /// 加载计算数据
+        /// </summary>
+        public void LoadData()
+        {
+            FloorDrawRecords = DataServerUtil.Current.LoadData<List<FloorDrawRecord>>(RealKey(ComputerFileSetting.FloorDraw))??new List<FloorDrawRecord>();
+        }
+
+        #endregion
+    }
+
+    /// <summary>
+    /// 加载机房展示数据
+    /// </summary>
+    public class LoadMachineRoomDrawData : RelationComputerData
+    {
+        public LoadMachineRoomDrawData(string relationType) : base(relationType)
+        {
+            MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
+        }
+
+        public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; protected set; }
+        #region 数据的保存加载
+        /// <summary>
+        /// 加载计算数据
+        /// </summary>
+        public void LoadData()
+        {
+            MachineRoomDrawRecords = DataServerUtil.Current.LoadData<List<MachineRoomDrawRecord>>(RealKey(ComputerFileSetting.MachineRoomDraw))??new List<MachineRoomDrawRecord>();
+        }
+        #endregion
+    }
+
+    /// <summary>
+    /// 加载立面展示
+    /// </summary>
+    public class LoadVerticalDrawData : RelationComputerData
+    {
+        public LoadVerticalDrawData(string relationType) : base(relationType)
+        {
+            VerticalDrawData = new VerticalDrawData();
+        }
+        #region 存储数据
+
+        public VerticalDrawData VerticalDrawData { get; protected set; }
+        #endregion
+        /// <summary>
+        /// 加载计算数据
+        /// </summary>
+        public void LoadData()
+        {
+
+            VerticalDrawData = DataServerUtil.Current.LoadData<VerticalDrawData>(RealKey(ComputerFileSetting.VerticalDraw))??new VerticalDrawData();
+
+        }
+    }
+}

+ 37 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/RelationDataCheck.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 关系数据检查[借用基类的数据和方法:在语义上应该没有关联关系]
+    /// </summary>
+    public class RelationDataCheck:RelationComputerData
+    {
+
+        public RelationDataCheck(string relationType):base(relationType)
+        {
+          
+        }
+        /// <summary>
+        /// 判定数据是否过期
+        /// </summary>
+        /// <param name="dateTime"></param>
+        /// <returns></returns>
+        public bool IsExpired(DateTime dateTime)
+        {
+           return DataServerUtil.Current.IsExpired(RealKey(ComputerFileSetting.FloorDraw), dateTime);
+        }
+        /// <summary>
+        /// 判断计算数据是否缺失
+        /// </summary>
+        /// <returns></returns>
+        public bool IsMissData()
+        {
+            return !DataServerUtil.Current.GetFile(RealKey(ComputerFileSetting.FloorDraw)).Exists();
+        }
+    }
+}

+ 5 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawData.cs

@@ -16,8 +16,12 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 平面数据结构
     /// </summary>
-    public class FloorDrawData
+    public class FloorDrawData: ServerData
     {
+        public FloorDrawData()
+        {
+            DrawRecords = new List<FloorDrawRecord>();
+        }
         /// <summary>
         /// 楼层信息
         /// </summary>

+ 2 - 5
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRecord.cs

@@ -22,7 +22,7 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 楼层信息记录
     /// </summary>
-    public class FloorRecord
+    public class FloorRecord: ServerData
     {
         public string FloorId { get; set; }
         public string FloorName { get; set; }
@@ -31,10 +31,7 @@ namespace SAGA.GplotRelationComputerManage
         /// 楼层高度
         /// </summary>
         public double FloorLevelElevation { get; set; }
-        /// <summary>
-        /// 关联类型
-        /// </summary>
-        public string RelationType { get; set; }
+     
 
         /// <summary>
         /// 设置楼层信息

+ 4 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRelationRecord.cs

@@ -18,6 +18,10 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
    public  class FloorRelationRecord: FloorRecord
     {
+        public FloorRelationRecord()
+        {
+            RelationItems = new List<BinaryRelationItem>();
+        }
         /// <summary>
         /// 关联数据
         /// </summary>

+ 13 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomDrawRecord.cs

@@ -16,7 +16,19 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 机房绘图数据
     /// </summary>
-    public class MachineRoomDrawRecord
+    public class MachineRoomDrawRecord : ServerData
     {
+        public MachineRoomDrawRecord()
+        {
+            DrawIems = new SystemDrawItems();
+        }
+        /// <summary>
+        /// 关系名称
+        /// </summary>
+        public string RelationName { get; set; }
+        /// <summary>
+        /// 绘图数据
+        /// </summary>
+        public SystemDrawItems DrawIems { get; set; }
     }
 }

+ 13 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomRelationRecord.cs

@@ -16,7 +16,19 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 机房关系数据
     /// </summary>
-    public class MachineRoomRelationRecord
+    public class MachineRoomRelationRecord : ServerData
     {
+        public MachineRoomRelationRecord()
+        {
+            RelationItems = new List<BinaryRelationItem>();
+        }
+        /// <summary>
+        /// 关系名称
+        /// </summary>
+        public string RelationName { get; set; }
+        /// <summary>
+        /// 关联数据
+        /// </summary>
+        public List<BinaryRelationItem> RelationItems { get; set; }
     }
 }

+ 25 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/ServerData.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{ 
+    public class ServerData
+    {
+        /// <summary>
+        /// 建筑Id
+        /// </summary>
+        public string BuildingId { get; set; }
+        /// <summary>
+        /// 建筑名称
+        /// </summary>
+        public string BuildingName { get; set; }
+
+        /// <summary>
+        /// 关联类型
+        /// </summary>
+        public string RelationType { get; set; }
+    }
+}

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawData.cs

@@ -11,7 +11,7 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 垂直立管相关信息
     /// </summary>
-    public class VerticalDrawData
+    public class VerticalDrawData : ServerData
     {
         public VerticalDrawData()
         {

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalRelationRecord.cs

@@ -16,7 +16,7 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 立面关系数据
     /// </summary>
-    public class VerticalRelationRecord
+    public class VerticalRelationRecord : ServerData
     {
         /// <summary>
         /// 系统名称

+ 28 - 23
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerContext.cs

@@ -23,13 +23,7 @@ namespace SAGA.GplotRelationComputerManage
             Rooms = SystemCalcUtil.CreateRoomItems();
             RelationShells = SystemCalcUtil.CreateRelationShellItems();
             EquipmentItems = SystemCalcUtil.CreateEquipmentItems();
-            VerticalPipes = new List<VerticalPipe>();
-            Levels = new List<LevelData>();
             Relations = new List<string>();
-            FloorDrawRecords = new List<FloorDrawRecord>();
-            FloorRelationRecords = new List<FloorRelationRecord>();
-            MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
-            MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
             #endregion
         }
         #region 计算缓存对象
@@ -77,16 +71,30 @@ namespace SAGA.GplotRelationComputerManage
         }
         #endregion
 
-        #region 计算结果存储类
-        /*
-         *计算数据存储在Context中,FloorSystemItem尽量只跟解析算法相关
-         */
-        public List<VerticalPipe> VerticalPipes { get; private set; }
-        public List<LevelData> Levels { get; private set; }
-        public List<FloorDrawRecord> FloorDrawRecords { get; private set; }
-        public List<FloorRelationRecord> FloorRelationRecords { get; private set; }
-        public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; private set; }
-        public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; private set; }
+        #region 计算结果存储类      
+        private Dictionary<string, SaveComputerData> m_DicComputerData = new Dictionary<string, SaveComputerData>();
+        /// <summary>
+        /// 获取指定类型的保存数据
+        /// </summary>
+        /// <param name="relationType"></param>
+        /// <returns></returns>
+        public SaveComputerData this[string relationType]
+        {
+            get
+            {
+                if (string.IsNullOrWhiteSpace(relationType))
+                    throw new ArgumentNullException(nameof(relationType));
+                if (m_DicComputerData.TryGetValue(relationType, out SaveComputerData tempData))
+                {
+                    return tempData;
+                }
+                else
+                {
+                    m_DicComputerData[relationType] = tempData = new SaveComputerData(relationType);
+                    return tempData;
+                }
+            }
+        }
         #endregion
 
         #region 需要计算的系统相关
@@ -107,13 +115,10 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         public void SaveComputerData()
         {
-            DataServerUtil.Current.SaveData(ComputerFileSetting.FloorDraw, FloorDrawRecords);
-            DataServerUtil.Current.SaveData(ComputerFileSetting.FloorRelation, FloorRelationRecords);
-            DataServerUtil.Current.SaveData(ComputerFileSetting.MachineRoomDraw, MachineRoomDrawRecords);
-            DataServerUtil.Current.SaveData(ComputerFileSetting.MachineRoomRelation, MachineRoomRelationRecords);
-            var result = SystemParseManager.ComputerVerticalData(VerticalPipes, Levels);
-            DataServerUtil.Current.SaveData(ComputerFileSetting.VerticalDraw, result.DrawData);
-            DataServerUtil.Current.SaveData(ComputerFileSetting.VerticalRelation, result.RelationData);
+            foreach (var item in m_DicComputerData)
+            {
+                item.Value.SaveData();
+            }
         }
         #endregion
     }

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

@@ -17,22 +17,53 @@ namespace SAGA.GplotRelationComputerManage
 {
    public  class SystemComputerHandler
     {
-        public List<object> GetParseData(SystemComputerContext context)
+        /// <summary>
+        /// 根据上下文计算系统数据
+        /// </summary>
+        /// <param name="context"></param>
+        public void Computer(SystemComputerContext context)
         {
-            List<object> items = new List<object>();
             var fileInfos = RevitModelPath.GetAllRevitFiles();
             foreach (var fileInfo in fileInfos)
             {
                 if (File.Exists(fileInfo))
                 {
+                    if (!fileInfo.Contains("Fl420105000189c43312dce811e8a5530301735c51a0.rvt"))
+                    {
+                        continue;
+                    }
                     FloorSystemItem floorItems = context.FloorItems.GetItem(fileInfo);
                     floorItems.Parse(context);
                     floorItems.Document.CloseDocSimple();
                 }
             }
             context.SaveComputerData();
-            //最后统保存缓存数据
-            return items;
+        }
+        
+        /// <summary>
+        /// 根据输入系统类型计算系统数据
+        /// </summary>
+        /// <param name="relationTypes"></param>
+        public void Computer(List<string> relationTypes)
+        {
+            SystemComputerContext context = new SystemComputerContext();
+            context.Relations.AddRange(relationTypes);
+            Computer(context);
+        }
+        /// <summary>
+        /// 计算没有被缓存或者缓存过期的数据
+        /// </summary>
+        /// <param name="relationTypes"></param>
+        public void ComputerWidthCache(List<string> relationTypes)
+        {
+            if (relationTypes == null || !relationTypes.Any())
+                return;
+            var useRelationTypes = RelationTypeUtil.NeedResetRelationTypes(relationTypes);
+            if(!useRelationTypes.Any())
+            {
+                return;
+            }
+            Computer(useRelationTypes);
         }
     }
 }

+ 1 - 1
MBI/SAGA.MBI/Interaction/MBIModelInfoManager.cs

@@ -32,7 +32,7 @@ namespace SAGA.MBI.Interaction
                     break;
                 }
                 if (element is FamilyInstance)
-                {
+                {                  
                     RevitParameterUpdate.UpdateElementByMbi(element, MBIBuiltInParameter.EquipLocalName, mbiItem.LocalName);
                     RevitParameterUpdate.UpdateElementByMbi(element, MBIBuiltInParameter.EquipLocalID, mbiItem.LocalId);                 
                     break;

+ 3 - 0
MBI/SAGA.MBI/RevitModelHandle/RevitParameterUpdate.cs

@@ -149,6 +149,9 @@ namespace SAGA.MBI
         }
         public static void UpdateElementByMbi(Element element, string mbiParameterName, string value, bool checkValueEmpty)
         {
+            //设备信息同步关闭
+            if (element is FamilyInstance)
+                return;
             if (checkValueEmpty && string.IsNullOrWhiteSpace(value))
                 return;
             ParameterDefinitionFactory.GetParameterDefinition(mbiParameterName)

+ 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>

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

@@ -310,5 +310,6 @@
       <Name>SAGA.RevitUtility</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>