소스 검색

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

mengxiangge 6 년 전
부모
커밋
c43da78767
53개의 변경된 파일1482개의 추가작업 그리고 123개의 파일을 삭제
  1. BIN
      MBI/MBIResource/Config/物理世界关系定义列表-2019-1.xlsx
  2. 9 9
      MBI/Menu/SAGABIM.xml
  3. 59 0
      MBI/SAGA.GplotDrawData/DBView/FloorSystemGraphView.cs
  4. 31 0
      MBI/SAGA.GplotDrawData/DBView/VerticalSYstemGraphView.cs
  5. 13 8
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  6. 45 0
      MBI/SAGA.GplotDrawData/View/WinSystem.xaml
  7. 136 0
      MBI/SAGA.GplotDrawData/View/WinSystem.xaml.cs
  8. 10 16
      MBI/SAGA.GplotDrawData/WinDrawEndPoint-Web.xaml.cs
  9. 1 1
      MBI/SAGA.GplotDrawData/WinMachineRoomView-Web.xaml.cs
  10. 1 1
      MBI/SAGA.GplotDrawData/WinMachineRoomView.xaml.cs
  11. 173 0
      MBI/SAGA.GplotManage/Command.cs
  12. 1 3
      MBI/SAGA.GplotManage/Command/ColdGplot/ColdRoomSystemView.cs
  13. 1 6
      MBI/SAGA.GplotManage/Command/RoomShowHandler.cs
  14. 11 6
      MBI/SAGA.GplotManage/GplotCommand.cs
  15. 1 4
      MBI/SAGA.GplotManage/GplotManage/GplotView/GplotView.cs
  16. 1 0
      MBI/SAGA.GplotManage/SAGA.GplotManage.csproj
  17. 1 3
      MBI/SAGA.GplotRelationComputerManage/ColdRoom/ColdRoomManager.cs
  18. 21 0
      MBI/SAGA.GplotRelationComputerManage/Common/ComputerFileSetting.cs
  19. 51 0
      MBI/SAGA.GplotRelationComputerManage/Draw/DocumentNode.cs
  20. 99 0
      MBI/SAGA.GplotRelationComputerManage/Draw/DrawDocumentUtil.cs
  21. 26 0
      MBI/SAGA.GplotRelationComputerManage/Draw/DrawLine.cs
  22. 33 0
      MBI/SAGA.GplotRelationComputerManage/Draw/DrawText.cs
  23. 36 0
      MBI/SAGA.GplotRelationComputerManage/Draw/DrawVertex.cs
  24. 26 0
      MBI/SAGA.GplotRelationComputerManage/Draw/GplotNode.cs
  25. 15 0
      MBI/SAGA.GplotRelationComputerManage/Draw/IDraw.cs
  26. 43 0
      MBI/SAGA.GplotRelationComputerManage/Draw/PointExtension.cs
  27. 1 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/RelationItem.cs
  28. 3 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/SystemItem.cs
  29. 5 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs
  30. 9 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeShell.cs
  31. 17 5
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  32. 1 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemCalcUtil.cs
  33. 171 17
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  34. 23 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/VerticalResult.cs
  35. 10 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/BinaryRelationItem.cs
  36. 14 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/EquipmentNode.cs
  37. 34 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/NodeExtendData.cs
  38. 1 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/SetRelationItem.cs
  39. 125 32
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  40. 30 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawData.cs
  41. 4 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawRecord.cs
  42. 5 2
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRecord.cs
  43. 5 2
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRelationRecord.cs
  44. 22 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomDrawRecord.cs
  45. 22 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomRelationRecord.cs
  46. 30 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawData.cs
  47. 35 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawRecord.cs
  48. 30 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalRelationRecord.cs
  49. 24 4
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerContext.cs
  50. 1 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  51. 1 1
      MBI/SAGA.MBI/RevitModelHandle/ParameterDefinitionFactory.cs
  52. 5 0
      MBI/SAGA.Models/ChangesRelationship.cs
  53. 10 0
      MBI/SAGA.RevitUtils/MEP/TNode.cs

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


+ 9 - 9
MBI/Menu/SAGABIM.xml

@@ -411,11 +411,11 @@
   </Panel>
   <Panel PanelName="基于物理世界的拓扑计算" GroupFlag="True" GroupImage="" RevitVer="R15,R16,R17" ButtonStyles="Large">
     <Button ButtonStyles="Large">
-      <ButtonName>SAGA.GplotRelationComputerManage.DistributionRelationshipCommand</ButtonName>
+      <ButtonName>SAGA.GplotManage.DistributionRelationshipCommand</ButtonName>
       <ButtonText>配电柜拓扑关系</ButtonText>
       <ImageName>9、位置信标建模</ImageName>
-      <DllName>..\OutputDll\SAGA.GplotRelationComputerManage.dll</DllName>
-      <ClassName>SAGA.GplotRelationComputerManage.DistributionRelationshipCommand</ClassName>
+      <DllName>..\OutputDll\SAGA.GplotManage.exe</DllName>
+      <ClassName>SAGA.GplotManage.DistributionRelationshipCommand</ClassName>
       <ToolTip>配电柜与配电柜拓扑关系</ToolTip>
       <LongDescription>配电柜与配电柜拓扑关系</LongDescription>
       <ToolTipImage></ToolTipImage>
@@ -423,11 +423,11 @@
       <Modules>SJJC</Modules>
     </Button>
     <Button ButtonStyles="Large">
-      <ButtonName>SAGA.GplotRelationComputerManage.DistributionEqRelationshipCommand</ButtonName>
+      <ButtonName>SAGA.GplotManage.DistributionEqRelationshipCommand</ButtonName>
       <ButtonText>配电柜与设备</ButtonText>
       <ImageName>9、位置信标建模</ImageName>
-      <DllName>..\OutputDll\SAGA.GplotRelationComputerManage.dll</DllName>
-      <ClassName>SAGA.GplotRelationComputerManage.DistributionEqRelationshipCommand</ClassName>
+      <DllName>..\OutputDll\SAGA.GplotManage.exe</DllName>
+      <ClassName>SAGA.GplotManage.DistributionEqRelationshipCommand</ClassName>
       <ToolTip>配电柜与设备拓扑关系</ToolTip>
       <LongDescription>配电柜与设备拓扑关系</LongDescription>
       <ToolTipImage></ToolTipImage>
@@ -436,11 +436,11 @@
     </Button>
 
     <Button ButtonStyles="Large">
-      <ButtonName>SAGA.GplotRelationComputerManage.BelongEqRelationshipCommand</ButtonName>
+      <ButtonName>SAGA.GplotManage.BelongEqRelationshipCommand</ButtonName>
       <ButtonText>对象受控关系</ButtonText>
       <ImageName>9、位置信标建模</ImageName>
-      <DllName>..\OutputDll\SAGA.GplotRelationComputerManage.dll</DllName>
-      <ClassName>SAGA.GplotRelationComputerManage.BelongEqRelationshipCommand</ClassName>
+      <DllName>..\OutputDll\SAGA.GplotManage.exe</DllName>
+      <ClassName>SAGA.GplotManage.BelongEqRelationshipCommand</ClassName>
       <ToolTip>对象受控关系</ToolTip>
       <LongDescription>对象受控关系</LongDescription>
       <ToolTipImage></ToolTipImage>

+ 59 - 0
MBI/SAGA.GplotDrawData/DBView/FloorSystemGraphView.cs

@@ -0,0 +1,59 @@
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models.Graphs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace SAGA.GplotDrawData
+{
+    public class FloorSystemGraphView : GraphDBView<FloorDrawData>
+    {
+        public override GraphDB AppendDb(FloorDrawData t, GraphDB db)
+        {
+            var floorId = t.FloorId??string.Empty;
+            var records = t.DrawRecords;
+            foreach (var floorDrawRecord in records)
+            {
+                var drawItems = floorDrawRecord.DrawIems;
+                #region 点信息处理
+                foreach (var pt in drawItems.Points)
+                {
+                    GVertex node = new GVertex();
+                    node.Location = pt.Point.ConvertINToMM().ConvertToPoint3D();
+                    node.ElementColor = Colors.Red;
+                    node.Name = pt.Name;
+                    node.Radius = 5;
+                    db.Elements.Add(node);
+                }
+
+                #endregion
+
+                #region 边信息处理
+                foreach (var line in drawItems.Curves)
+                {
+                    GPath path = new GPath();
+                    path.Data = line.Points.Select(p => p.ConvertINToMM().ConvertToPoint3D()).ToList();
+                    path.ElementColor = Colors.Red;
+                    db.Elements.Add(path);
+                }
+                #endregion
+            }      
+            #region 底图获取
+            var floorName = floorId;
+            try
+            {
+                var jsObject = BaseMapManager.GetFloorInfo(floorName);
+                db.RefJObjects.Add(jsObject);
+            }
+            catch (Exception ex)
+            {
+
+            }
+            #endregion
+            return db;
+        }
+    }
+}

+ 31 - 0
MBI/SAGA.GplotDrawData/DBView/VerticalSYstemGraphView.cs

@@ -0,0 +1,31 @@
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models.Graphs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotDrawData
+{
+    /// <summary>
+    /// 解析立管数据
+    /// </summary>
+    public class VerticalSystemGraphView : GraphDBView<VerticalDrawData>
+    {
+        public override GraphDB AppendDb(VerticalDrawData t, GraphDB db)
+        {
+            var levaleData = t.LevelDatas;
+            db.Elements.AddRange(levaleData);
+            var records = t.DrawRecords ?? new List<VerticalDrawRecord>();
+            var groupRecords = records.GroupBy(r => r.GroupId);
+            foreach (var item in groupRecords)
+            {
+                VGroupPipe groupPipe = new VGroupPipe(item.Select(c=>c.RefPipe).ToList());
+                db.Elements.Add(groupPipe);
+            }
+         
+            return db;
+        }
+    }
+}

+ 13 - 8
MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj

@@ -69,22 +69,19 @@
     <Compile Include="Common\WebGplotSettings.cs" />
     <Compile Include="DBView\BaseMapManager.cs" />
     <Compile Include="DBView\EquipmentGraphView.cs" />
+    <Compile Include="DBView\FloorSystemGraphView.cs" />
     <Compile Include="DBView\IGraphDBView.cs" />
     <Compile Include="DBView\PipeEndGraphView.cs" />
     <Compile Include="DBView\RoomGraphView.cs" />
     <Compile Include="DBView\SpaceGraphView.cs" />
     <Compile Include="DBView\VerticalPipeGraphView.cs" />
+    <Compile Include="DBView\VerticalSystemGraphView.cs" />
     <Compile Include="DBView\ViewExtension.cs" />
     <Compile Include="DBView\VirticalSpaceGraphView.cs" />
-    <Compile Include="Draw\DocumentNode.cs" />
-    <Compile Include="Draw\DrawDocumentUtil.cs" />
     <Compile Include="DrawElementEdges.cs" />
-    <Compile Include="Draw\DrawLine.cs" />
-    <Compile Include="Draw\DrawText.cs" />
-    <Compile Include="Draw\DrawVertex.cs" />
-    <Compile Include="Draw\GplotNode.cs" />
-    <Compile Include="Draw\IDraw.cs" />
-    <Compile Include="Draw\PointExtension.cs" />
+    <Compile Include="View\WinSystem.xaml.cs">
+      <DependentUpon>WinSystem.xaml</DependentUpon>
+    </Compile>
     <Compile Include="WinControlRelation-Web.xaml.cs">
       <DependentUpon>WinControlRelation-Web.xaml</DependentUpon>
     </Compile>
@@ -124,6 +121,10 @@
     <Compile Include="WinMachineRoomView.xaml.cs">
       <DependentUpon>WinMachineRoomView.xaml</DependentUpon>
     </Compile>
+    <Page Include="View\WinSystem.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="WinControlRelation-Web.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -224,6 +225,10 @@
       <Project>{07b73c98-dcb0-4782-81fa-f50a30b563ab}</Project>
       <Name>SAGA.DotNetUtils</Name>
     </ProjectReference>
+    <ProjectReference Include="..\SAGA.GplotRelationComputerManage\SAGA.GplotRelationComputerManage.csproj">
+      <Project>{f77b7e95-15f0-4b67-947e-318b608fc27f}</Project>
+      <Name>SAGA.GplotRelationComputerManage</Name>
+    </ProjectReference>
     <ProjectReference Include="..\SAGA.MBI\SAGA.MBI.csproj">
       <Project>{F6216892-A198-4991-820A-4A2F2637103E}</Project>
       <Name>SAGA.MBI</Name>

+ 45 - 0
MBI/SAGA.GplotDrawData/View/WinSystem.xaml

@@ -0,0 +1,45 @@
+<windows:WinBase x:Class="SAGA.GplotDrawData.View.WinSystem"
+     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:SAGA.GplotDrawData"
+    xmlns:local1="clr-namespace:CEFSharpWPF;assembly=CEFSharpWPF"
+    xmlns:windows="clr-namespace:SAGA.RevitUtils.Windows;assembly=SAGA.RevitUtils"
+    mc:Ignorable="d"
+         Title="管道关系查看" Height="800" Width="1000" Name="win" WindowState="Maximized" >
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="Auto"/>
+            <ColumnDefinition Width="*"/>
+
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"/>
+            <RowDefinition Height="20"/>
+        </Grid.RowDefinitions>
+        <local1:UcGplotShow Grid.Row="0" Grid.Column="1" x:Name="ucShowElement"></local1:UcGplotShow>
+
+        <TreeView Name="rootNode" Width="150" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" SelectedItemChanged="RootNode_OnSelectedItemChanged" 
+                     >
+            <TreeView.ItemContainerStyle>
+                <Style TargetType="{x:Type TreeViewItem}">
+                    <Setter Property="IsExpanded" Value="True" />
+                </Style>
+            </TreeView.ItemContainerStyle>
+            <TreeView.ItemTemplate>
+                <HierarchicalDataTemplate ItemsSource="{Binding Path=Childrens}">
+                    <TextBlock  Name="Block" Text="{Binding EName}" HorizontalAlignment="Stretch"></TextBlock>
+                    <HierarchicalDataTemplate.Triggers>
+                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem},Path=IsSelected}" Value="True">
+                            <Setter TargetName="Block" Property="Background"  Value="DodgerBlue"></Setter>
+                            <Setter TargetName="Block" Property="Foreground"  Value="White"></Setter>
+                        </DataTrigger>
+                    </HierarchicalDataTemplate.Triggers>
+                </HierarchicalDataTemplate>
+
+            </TreeView.ItemTemplate>
+        </TreeView>
+    </Grid>
+</windows:WinBase>
+

+ 136 - 0
MBI/SAGA.GplotDrawData/View/WinSystem.xaml.cs

@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using CEFSharpWPF;
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models;
+using SAGA.RevitUtils.Windows;
+
+namespace SAGA.GplotDrawData.View
+{
+    /// <summary>
+    /// WinSystem.xaml 的交互逻辑
+    /// </summary>
+    public partial class WinSystem : WinBase
+    {
+        #region 构造函数相关
+        private WinSystem()
+        {
+            InitializeComponent();
+           // this.Loaded +=OnLoaded;
+        }
+        public WinSystem(GplotShowType showType) : this()
+        {
+            this.ShowType = showType;
+        }
+        #endregion
+        /// <summary>
+        /// 展示拓扑类型
+        /// </summary>
+        public GplotShowType ShowType { get; private set; }
+        public Action ComputerAction;
+        public Action LoadData;
+
+        protected override void OnLoaded(object sender, RoutedEventArgs e)
+        {
+            if (ShowType == GplotShowType.VerticalPlan)
+            {
+                InitVerticalData();
+            }
+            else
+            {
+                InitFloorData();
+            }
+            RootNode_OnSelectedItemChanged(null, null);
+        }
+
+        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
+        {
+            if (!(rootNode.SelectedItem is DataNode dn))
+                return;
+            if (ShowType == GplotShowType.VerticalPlan)
+            {
+                Draw(dn.GetData<VerticalDrawData>());
+            }
+            else
+            {               
+                Draw(dn.GetData<FloorDrawData>());
+            }
+        }
+        #region 平面数据处理
+
+        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<DataNode> treeDataSource = new List<DataNode>();
+            foreach (var groupSystem in groupSystems)
+            {
+                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);
+            }
+            this.rootNode.ItemsSource = treeDataSource;
+              
+        }
+
+        /// <summary>
+        /// 画楼层平面
+        /// </summary>
+        /// <param name="fd"></param>
+        private void Draw(FloorDrawData fd)
+        {
+            if (fd == null) return;
+            FloorSystemGraphView view = new FloorSystemGraphView();
+            var db = view.CreateDb(fd);
+            ConstData.ResponseData = db.CreateJObjectGroup();
+            ucShowElement.Show(WebGplotSettings.GplotUrl);
+        }
+        #endregion
+
+        #region 立面数据处理
+        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)
+            {
+                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>
+        /// 画立管数据
+        /// </summary>
+        private void Draw(VerticalDrawData data)
+        {
+            VerticalSystemGraphView view = new VerticalSystemGraphView();
+            var db = view.CreateDb(data);
+            ConstData.ResponseData = db.CreateJObjectGroup();
+            ucShowElement.Show(WebGplotSettings.VPipeUrl);
+        }
+
+
+        #endregion
+    }
+}

+ 10 - 16
MBI/SAGA.GplotDrawData/WinDrawEndPoint-Web.xaml.cs

@@ -23,23 +23,24 @@ namespace SAGA.GplotDrawData
     /// </summary>
     public partial class WinDrawEndPoint_Web : WinBase
     {
+        #region 构造函数相关
         private WinDrawEndPoint_Web()
         {
             InitializeComponent();
             this.Loaded += WinDrawWaterNode_Loaded;
         }
-        private GplotShowType m_ShowType;
         public WinDrawEndPoint_Web(GplotShowType showType) : this()
         {
-            this.m_ShowType = showType;
-        }
-        private List<FloorData> m_Data;
+            this.ShowType = showType;
+        } 
+        #endregion
+        public GplotShowType ShowType { get; private set; }
         public Action ComputerAction;
         public Action LoadData;
         private void WinDrawWaterNode_Loaded(object sender, RoutedEventArgs e)
         {
             //平面供水
-            if (m_ShowType == GplotShowType.Default)
+            if (ShowType == GplotShowType.Default)
             {
                 var datas = DrawDataServer.GetData<AcWater>()?.FloorDatas.ToList();
                 if (datas != null)
@@ -52,19 +53,13 @@ namespace SAGA.GplotDrawData
                             child.SetData(floorData);
                             d.Childrens.Add(child);
                         }
-
                         return d;
                     });
-            } //平面回水
-            else if (m_ShowType == GplotShowType.ViewPlan)
-            {
-                m_Data = DrawDataServer.GetData<AcWater>()?.FloorDatas.Where(t => t.DataType == "回水").ToList();
-            }  //立面水管
-            else if (m_ShowType == GplotShowType.VerticalPlan)
+            } 
+            else if (ShowType == GplotShowType.VerticalPlan)
             {
                 #region 计算立管逻辑                           
                 this.LoadData?.Invoke();
-                //Draw();
                 InitVerticalPipeData();
                 #endregion
                 return;
@@ -76,7 +71,7 @@ namespace SAGA.GplotDrawData
         {
             if (rootNode.SelectedItem is DataNode dn)
             {
-                if (m_ShowType == GplotShowType.VerticalPlan)
+                if (ShowType == GplotShowType.VerticalPlan)
                 {
                     Draw(dn);
                 }
@@ -127,8 +122,7 @@ namespace SAGA.GplotDrawData
         /// </summary>
         private void Draw(DataNode node)
         {
-            //rootNode.Visibility = Visibility.Collapsed;
-            var datas = VerticalPipeData;// DrawDataServer.GetData<VerticalPipeData>();
+            var datas = VerticalPipeData;
             VerticalPipeGraphView view = new VerticalPipeGraphView();
             view.PipeSystem = node.EName;
             var db = view.CreateDb(datas);

+ 1 - 1
MBI/SAGA.GplotDrawData/WinMachineRoomView-Web.xaml.cs

@@ -1,5 +1,5 @@
 using CEFSharpWPF;
-using SAGA.GplotDrawData.Draw;
+using SAGA.GplotRelationComputerManage.Draw;
 using SAGA.Models;
 using SAGA.RevitUtils.Windows;
 using System;

+ 1 - 1
MBI/SAGA.GplotDrawData/WinMachineRoomView.xaml.cs

@@ -15,7 +15,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Shapes;
 using DrawData;
 using SAGA.DotNetUtils.Logger;
-using SAGA.GplotDrawData.Draw;
+using SAGA.GplotRelationComputerManage.Draw;
 using SAGA.Models;
 using SAGA.Models.GplotElement;
 using SAGA.RevitUtils.Windows;

+ 173 - 0
MBI/SAGA.GplotManage/Command.cs

@@ -0,0 +1,173 @@
+using DrawData;
+using System;
+using System.Linq;
+using Autodesk.Revit.Attributes;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.UI;
+using SAGA.GplotDrawData;
+using SAGA.GplotRelationComputerManage.PumpEnd;
+using SAGA.RevitUtils;
+using SAGA.RevitUtils.Extends;
+using MainWindow = SAGA.GplotDrawData.MainWindow;
+using SAGA.GplotRelationComputerManage;
+
+namespace SAGA.GplotManage
+{
+    /// <summary>
+    /// 供水管 回水管拓扑图
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class SupplyHydronicTopoGraph : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            base.Execute(commandData, ref message, elements);
+            using (Transaction trans = new Transaction(ExternalDataWrapper.Current.Doc, "读取风管系统"))
+            {
+                trans.Start();
+                try
+                {
+                    DuctTerminalBll.DrawPipePlane();
+
+                    trans.Commit();
+                }
+                catch (Exception e)
+                {
+                    trans.RollBack();
+                    MessageShow.Show(e);
+                }
+            }
+            return Result.Succeeded;
+        }
+    }
+
+    /// <summary>
+    /// 配电关系图--配电柜与配电柜
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class DistributionRelationshipCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            #region 核心
+            try
+            {
+                DistributionRelationshipHandler handler = new DistributionRelationshipHandler();
+                var re = handler.GetViewData(new PowerComputerContext());
+                if (re[0].Childrens.Any())
+                {
+                    WinEquipmentRelation_Web window =
+                        new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
+                    window.Title = "配电拓扑图:配电柜--配电柜";
+                    window.Show();
+                }
+
+            }
+            catch (Exception ex)
+            {
+
+                MessageShow.Show(ex);
+            } 
+            #endregion
+            return Result.Succeeded;
+        }
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+      
+    }
+
+
+
+    /// <summary>
+    /// 配电关系图--配电柜与配电设备
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class DistributionEqRelationshipCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            #region 核心处理
+            EquipPowerRelationshipHandler handler = new EquipPowerRelationshipHandler();
+            var re = handler.GetViewData(new PowerComputerContext());
+            if (re[0].Childrens.Any())
+            {
+                WinEquipmentRelation_Web window =
+                    new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
+                window.Title = "配电拓扑图:配电柜--末端";
+                window.Show();
+            } 
+            #endregion
+            return Result.Succeeded;
+        }    
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
+
+
+    /// <summary>
+    /// 对象受控关系
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class BelongEqRelationshipCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+
+            #region 核心处理
+            ObjectControlRelationshipHandler handler = new ObjectControlRelationshipHandler();
+            var re = handler.GetViewData(new PowerComputerContext());
+            if (re[0].Childrens.Any())
+            {
+                WinControlRelation_Web window =
+                    new WinControlRelation_Web(re[0].Childrens, re[1].Childrens);
+                window.Title = "对象受控关系图";
+                window.Show();
+            } 
+            #endregion
+
+            return Result.Succeeded;
+        }
+
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
+
+    /// <summary>
+    /// 空间关系查看
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class SpaceViewCommand : ExternalCommand
+    {
+        public SpaceViewCommand()
+        {
+            IsShowNoDocument = true;
+        }
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            try
+            {
+
+                var win = new WinDrawSpace();
+                win.ShowDialog();
+            }
+            catch (Exception e)
+            {
+
+                MessageShow.Show(e);
+            }
+
+            return Result.Succeeded;
+        }
+    }
+}

+ 1 - 3
MBI/SAGA.GplotManage/Command/ColdGplot/ColdRoomSystemView.cs

@@ -1,6 +1,4 @@
-using SAGA.GplotDrawData;
-using SAGA.GplotDrawData.Draw;
-using SAGA.GplotRelationComputerManage;
+
 using SAGA.GplotRelationComputerManage.ColdRoom;
 using SAGA.Models;
 using SAGA.RevitUtils;

+ 1 - 6
MBI/SAGA.GplotManage/Command/RoomShowHandler.cs

@@ -1,13 +1,8 @@
 using SAGA.GplotDrawData;
-using SAGA.GplotDrawData.Draw;
 using SAGA.GplotRelationComputerManage.ColdRoom;
+using SAGA.GplotRelationComputerManage.Draw;
 using SAGA.Models;
-using SAGA.RevitUtils;
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace SAGA.GplotManage
 {

+ 11 - 6
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -4,6 +4,7 @@ using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.UI;
 using SAGA.GplotDrawData;
+using SAGA.GplotDrawData.View;
 using SAGA.GplotManage.UploadRelated;
 using SAGA.GplotRelationComputerManage;
 using SAGA.MBI.Common;
@@ -152,13 +153,17 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            //var relationType = RelationTypeManager.GetRelationTypeItem("ChillWaterLoop");
-            //return Result.Succeeded;
-            //SystemComputerHandler handler1 = new SystemComputerHandler();
-            //SystemComputerContext context = new SystemComputerContext();
-            //context.Relations.Add("ChillWaterLoop");
-            //handler1.GetParseData(context);
+            var relationType = RelationTypeManager.GetRelationTypeItem("ChillWaterLoop");
             //return Result.Succeeded;
+            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();
+            return Result.Succeeded;
             RoomShowHandler handler = new RoomShowHandler("ChillWaterLoop");
             handler.Show();
             ;

+ 1 - 4
MBI/SAGA.GplotManage/GplotManage/GplotView/GplotView.cs

@@ -1,7 +1,4 @@
-using SAGA.GplotDrawData;
-using SAGA.GplotDrawData.Draw;
-using SAGA.GplotRelationComputerManage;
-using SAGA.GplotRelationComputerManage.ColdRoom;
+
 using SAGA.Models;
 using SAGA.Models.Graphs;
 using System;

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

@@ -90,6 +90,7 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="CheckAndKeepGplotLaster.cs" />
+    <Compile Include="Command.cs" />
     <Compile Include="Command\ColdGplot\ColdRoomSystemCompute.cs" />
     <Compile Include="Command\ColdGplot\ColdRoomSystemParse.cs" />
     <Compile Include="Command\ColdGplot\ColdRoomSystemView.cs" />

+ 1 - 3
MBI/SAGA.GplotRelationComputerManage/ColdRoom/ColdRoomManager.cs

@@ -5,9 +5,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
-using DrawData;
-using SAGA.GplotDrawData;
-using SAGA.GplotDrawData.Draw;
+using SAGA.GplotRelationComputerManage.Draw;
 using SAGA.Models;
 using SAGA.RevitUtils;
 using GriphicVertexType = SAGA.Models.GplotElement.VertexType;

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

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+  //
+    /// </summary>
+    public class ComputerFileSetting
+    {
+        public const string FloorDraw = "FloorDraw";
+        public const string FloorRelation = "FloorRelation";
+        public const string VerticalDraw = "VerticalDraw";
+        public const string VerticalRelation = "VerticalRelation";
+        public const string MachineRoomDraw = "MechineRoomDraw";
+        public const string MachineRoomRelation = "MechineRoomRelation";
+    }
+}

+ 51 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/DocumentNode.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.Models;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class DocumentNode:TNode<DocumentNode>,INotifyPropertyChanged
+    {
+        /// <summary>
+        /// 关联的文件
+        /// </summary>
+        public GplotDocument LinkDocument { get; set; }
+
+        private bool m_IsExpanded;
+
+        public bool IsExpanded
+        {
+            get { return this.m_IsExpanded; }
+            set
+            {
+                this.m_IsExpanded = value;
+                RaisePropertyChanged(nameof(IsExpanded));
+            }
+        }
+        private bool m_IsSelected;
+        /// <summary>
+        /// 是否选中
+        /// </summary>
+        public bool IsSelected
+        {
+            get { return this.m_IsSelected; }
+            set
+            {
+                this.m_IsSelected = value;
+                RaisePropertyChanged(nameof(IsSelected));
+            }
+        }
+        #region 实现通知接口
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        public void RaisePropertyChanged(string propertyName)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        } 
+        #endregion
+    }
+}

+ 99 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/DrawDocumentUtil.cs

@@ -0,0 +1,99 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using SAGA.Models;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class DrawDocumentUtil
+    {
+        private static Dictionary<Type,object> m_Draws=new Dictionary<Type, object>();
+        private static Dictionary<Type, Tuple<object, MethodInfo>> m_Methods = new Dictionary<Type, Tuple<object, MethodInfo>>();
+        static DrawDocumentUtil()
+        {
+            InitDraw();
+            CoordiateMatrix = new Matrix(1, 0, 0, 1, 0, 0);
+        }
+        private static void InitDraw()
+        {
+            m_Draws.Add(typeof(TText), new DrawText());
+            m_Draws.Add(typeof(TVertex), new DrawVertex());
+            m_Draws.Add(typeof(TLine), new DrawLine());
+        }
+        public static IDraw<T> DrawFactory<T>() where T:TElement
+        {
+            if (m_Draws.TryGetValue(typeof(T), out object  draw))
+            {
+                return (IDraw<T>) draw;
+            }
+            return null;
+        }
+        public static bool DrawProxy(Type type,TElement element, Canvas canvas)
+        {
+            Tuple<object, MethodInfo> tupleValue = null;
+            if (!m_Methods.TryGetValue(type, out tupleValue))
+            {
+                object value = null;
+                if (m_Draws.TryGetValue(type, out value))
+                {
+                    if (value != null)
+                    {
+                        var drawMethod = value.GetType().GetMethod("Draw");
+                        m_Methods.Add(type, tupleValue = new Tuple<object, MethodInfo>(value, drawMethod));
+                    }
+                }
+            }
+            if (tupleValue != null && tupleValue.Item2 != null)
+            {
+                tupleValue.Item2.Invoke(tupleValue.Item1, new object[] { element ,canvas });
+                return true;
+            }
+
+            return false;
+        }
+        public static void Draw(GplotDocument document, Canvas canvas)
+        {
+
+            var elements = document.Elements;
+            foreach (var element in elements)
+            {
+                try
+                {
+                    DrawProxy(element.GetType(), element, canvas);
+                }
+                catch (Exception ex)
+                {
+                }
+            }
+        }
+        /// <summary>
+        /// 坐标设定
+        /// </summary>
+        public static Matrix CoordiateMatrix
+        {
+            get;set;
+        }
+
+        public static Matrix CreateMatrix(FrameworkElement view, Rect rect)
+        {
+            var reg = rect;
+            var center = new Point(reg.Location.X + reg.Width / 2, reg.Location.Y + reg.Height / 2);
+            var zoom1 = view.ActualWidth / (float)reg.Width;
+            var zoom2 = view.ActualHeight / (float)reg.Height;
+            var zoom = Math.Min(zoom1, zoom2);
+            //映射到屏幕中心
+            var tempMatrix =  new Matrix(1, 0f, 0f, -1, view.ActualWidth / (float)2, view.ActualHeight / (float)2);
+            //移动到视口中心
+            tempMatrix.Prepend(new Matrix(zoom, 0f, 0f, zoom, -center.X * zoom, -center.Y * zoom));
+            return tempMatrix;
+        }
+    }  
+}

+ 26 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/DrawLine.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using SAGA.Models;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class DrawLine : IDraw<TLine>
+    {
+        public void Draw(TLine element, Canvas canvas)
+        {
+            var start = DrawDocumentUtil.CoordiateMatrix.Transform(element.StartPoint);
+            var end = DrawDocumentUtil.CoordiateMatrix.Transform(element.EndPoint);
+            var line = new SgLine(start, end);
+            if (line != null)
+            {
+                canvas.Children.Add(line);
+            }
+
+        }
+    }
+}

+ 33 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/DrawText.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class DrawText : IDraw<TText>
+    {
+        public void Draw(TText element, Canvas canvas)
+        {
+            TextBlock tb = new TextBlock()
+            {
+                Width = element.Width,
+                Height = element.Height,
+                TextAlignment = TextAlignment.Center,
+                Text = element.Text,
+                Foreground = Brushes.Red,
+                RenderTransform = new MatrixTransform(new Matrix(1, 0, 0, -1, 0, 0))
+            };
+            var end = DrawDocumentUtil.CoordiateMatrix.Transform( element.Center);
+           
+            Canvas.SetTop(tb, end.Y + 15 + tb.Height/2);
+            Canvas.SetLeft(tb, end.X - tb.Width / 2.0d);
+            canvas.Children.Add(tb);
+        }
+    }
+}

+ 36 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/DrawVertex.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Media;
+using SAGA.Models;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class DrawVertex : IDraw<TVertex>
+    {
+        public void Draw(TVertex element, Canvas canvas)
+        {
+            Vertex vertex = null;
+            var location = DrawDocumentUtil.CoordiateMatrix.Transform(element.Location);
+            if (element.VertexType == VertexType.Hellow)
+            {
+                vertex=Vertex.GetHollow(location);
+                vertex.Fill = Brushes.Gray;
+                Canvas.SetZIndex(vertex, 100);
+            }
+            else
+            {
+                vertex = new Vertex(location);
+            }
+
+            if (vertex != null)
+            {
+                canvas.Children.Add(vertex);
+            }
+        }
+    }
+}

+ 26 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/GplotNode.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public class GplotNode
+    {
+        /// <summary>
+        /// 节点位置
+        /// </summary>
+        public Point Location { get; set; }
+        /// <summary>
+        /// 节点类型
+        /// </summary>
+        public VertexType NodeType { get; set; }
+        /// <summary>
+        /// 节点描述
+        /// </summary>
+        public string Description { get; set; }
+    }
+}

+ 15 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/IDraw.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using SAGA.Models.GplotElement;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public interface IDraw<T> where T :TElement
+    {
+        void Draw(T element, Canvas canvas);
+    }
+}

+ 43 - 0
MBI/SAGA.GplotRelationComputerManage/Draw/PointExtension.cs

@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SAGA.GplotRelationComputerManage.Draw
+{
+    public static class PointExtension
+    {
+        //public static Point UnitVector(this Point point)
+        //{
+        //    double sqr = Math.Sqrt(point.X * point.X + point.Y * point.Y);
+        //    if (sqr == 0)
+        //        return point;
+        //    return new Point(point.X / sqr, point.Y / sqr);
+        //}
+
+        //public static Point Offset(this Point point,  direction)
+        //{
+        //    Vector
+        //    return Point.Add(point, direction);
+        //}
+        public static Point AddX(this Point point, double x)
+        {
+            return new Point(point.X + x, point.Y);
+        }
+        public static Point AddY(this Point point, double y)
+        {
+            return new Point(point.X, point.Y + y);
+        }
+        public static Point Add(this Point point, Point point1)
+        {
+            return new Point(point.X + point.X, point.Y + point1.Y);
+        }
+        public static Point Mult(this Point point, Point point1)
+        {
+            return new Point(point.X - point1.X, point.Y - point1.Y);
+        }
+
+    }
+}

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

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

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

@@ -22,6 +22,7 @@ namespace SAGA.GplotRelationComputerManage
         public SystemItem()
         {
             ContainEdgeTypes = new List<string>();
+
         }
         /// <summary>
         /// 系统名称
@@ -61,6 +62,8 @@ namespace SAGA.GplotRelationComputerManage
 
     public enum SystemType
     {
+        [Description("未知")]
+        Unknown,
         [Description("管道系统")]
         Pipe,
         [Description("风管系统")]

+ 5 - 0
MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs

@@ -63,6 +63,11 @@ namespace SAGA.GplotRelationComputerManage
                 ParseSystems(relationItem, strSystem);
                 #endregion
 
+                if (firstItem.SystemType == "1")
+                {
+                    relationItem.SystemType = SystemType.Duct;
+                }
+
                 items.Add(relationItem);
             }
 

+ 9 - 0
MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeShell.cs

@@ -33,6 +33,15 @@ namespace SAGA.GplotRelationComputerManage
             return RelationItem.Systems.Any(c => c.IsMatch(systemName));
         }
         /// <summary>
+        /// 获取第一个匹配写系统元素
+        /// </summary>
+        /// <param name="systemName"></param>
+        /// <returns></returns>
+        public SystemItem GetFirstMatchSystem(string systemName)
+        {
+            return RelationItem.Systems.FirstOrDefault(c => c.IsMatch(systemName));
+        }
+        /// <summary>
         /// 对象是否匹配
         /// </summary>
         /// <param name="equipmentCategory"></param>

+ 17 - 5
MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj

@@ -81,8 +81,8 @@
     <Compile Include="ColdRoom\ElementsVertexExtension.cs" />
     <Compile Include="ColdRoom\EquipmentItem.cs" />
     <Compile Include="ColdRoom\VectorExtension.cs" />
-    <Compile Include="Command.cs" />
     <Compile Include="Common\AppSetting.cs" />
+    <Compile Include="Common\ComputerFileSetting.cs" />
     <Compile Include="Common\DataServerUtil.cs" />
     <Compile Include="Common\MBIInfoUtil.cs" />
     <Compile Include="Common\PointConverter.cs" />
@@ -97,6 +97,14 @@
     <Compile Include="DataServer\FileKeyAttribute.cs" />
     <Compile Include="DataServer\IVersionFile.cs" />
     <Compile Include="DataServer\TimeVersionFile.cs" />
+    <Compile Include="Draw\DocumentNode.cs" />
+    <Compile Include="Draw\DrawDocumentUtil.cs" />
+    <Compile Include="Draw\DrawLine.cs" />
+    <Compile Include="Draw\DrawText.cs" />
+    <Compile Include="Draw\DrawVertex.cs" />
+    <Compile Include="Draw\GplotNode.cs" />
+    <Compile Include="Draw\IDraw.cs" />
+    <Compile Include="Draw\PointExtension.cs" />
     <Compile Include="LvSpace.cs" />
     <Compile Include="PowerDistribution\Common\DataNodeUtil.cs" />
     <Compile Include="PowerDistribution\Common\PowerComputerContext.cs" />
@@ -129,24 +137,28 @@
     <Compile Include="SystemRelation\Common\PointItemType.cs" />
     <Compile Include="SystemRelation\Common\SystemCalcUtil.cs" />
     <Compile Include="SystemRelation\Common\SystemParseManager.cs" />
+    <Compile Include="SystemRelation\Common\VerticalResult.cs" />
     <Compile Include="SystemRelation\Data\BinaryRelationItem.cs" />
     <Compile Include="SystemRelation\Data\EquipmentNode.cs" />
+    <Compile Include="SystemRelation\Data\NodeExtendData.cs" />
     <Compile Include="SystemRelation\Data\SetRelationItem.cs" />
     <Compile Include="SystemRelation\Data\SystemCurveItem.cs" />
     <Compile Include="SystemRelation\Data\SystemDrawItems.cs" />
     <Compile Include="SystemRelation\Data\SystemPointItem.cs" />
     <Compile Include="SystemRelation\FloorSystemItem.cs" />
+    <Compile Include="SystemRelation\ServerData\FloorDrawData.cs" />
+    <Compile Include="SystemRelation\ServerData\MachineRoomDrawRecord.cs" />
+    <Compile Include="SystemRelation\ServerData\MachineRoomRelationRecord.cs" />
+    <Compile Include="SystemRelation\ServerData\VerticalDrawData.cs" />
+    <Compile Include="SystemRelation\ServerData\VerticalDrawRecord.cs" />
     <Compile Include="SystemRelation\ServerData\FloorDrawRecord.cs" />
     <Compile Include="SystemRelation\ServerData\FloorRecord.cs" />
     <Compile Include="SystemRelation\ServerData\FloorRelationRecord.cs" />
+    <Compile Include="SystemRelation\ServerData\VerticalRelationRecord.cs" />
     <Compile Include="SystemRelation\SystemComputerContext.cs" />
     <Compile Include="SystemRelation\SystemComputerHandler.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\SAGA.GplotDrawData\SAGA.GplotDrawData.csproj">
-      <Project>{e7a7daac-f310-46cb-bd9b-1d5ab9e01923}</Project>
-      <Name>SAGA.GplotDrawData</Name>
-    </ProjectReference>
     <ProjectReference Include="..\SAGA.DotNetUtils\SAGA.DotNetUtils.csproj">
       <Project>{07b73c98-dcb0-4782-81fa-f50a30b563ab}</Project>
       <Name>SAGA.DotNetUtils</Name>

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemCalcUtil.cs

@@ -39,7 +39,7 @@ namespace SAGA.GplotRelationComputerManage
                var name = element.GetFamily().Name;
                return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
            }
-           return element.GetParameterString(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS) == AppSetting.StartFlag;
+           return (element.GetParameterString(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS)??string.Empty).StartsWith(AppSetting.StartFlag);
         }
 
         /// <summary>

+ 171 - 17
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -8,9 +8,12 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Windows.Media.Media3D;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
 using Autodesk.Revit.DB.Plumbing;
+using SAGA.Models;
+using SAGA.Models.Graphs;
 using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.MEP;
@@ -128,10 +131,11 @@ namespace SAGA.GplotRelationComputerManage
                 foreach (var refConnector in refConnectors)
                 {
                     var refElement = refConnector.Owner;
-                    if (useIds.Any(id => id == refElement.Id.IntegerValue))
-                    {
-                        continue;
-                    }
+                    //逻辑变更,如果存在,不继续遍历。但要完成本次操作;移动到最后
+                    //if (useIds.Any(id => id == refElement.Id.IntegerValue))
+                    //{
+                    //    continue;
+                    //}
                     //初始化当前节点,未必一定加入集合,为了下面代码书写方便,先进性初始化
                     ElementTreeNode currentNode = new ElementTreeNode()
                     {
@@ -167,6 +171,10 @@ namespace SAGA.GplotRelationComputerManage
                     }
                     //useIds的控制:跳出时,直接加入UseIds。继续遍历的,在遍历函数中加入
                     etn.AddChild(currentNode);
+                    if (useIds.Any(id => id == refElement.Id.IntegerValue))
+                    {
+                        continue;
+                    }
                     BuildSystemNode(currentNode, domain, useIds, endConditon);
 
                 }
@@ -225,6 +233,7 @@ namespace SAGA.GplotRelationComputerManage
                         point.RefId = mepCurve.Id.IntegerValue;
                         point.IsVirtual = true;
                         point.EquipmentType = PointItemType.StandPipe.ToString();
+                        point.Name = AppSetting.StartFlag;
                         pointItems.Add(point);
                     } 
                     #endregion
@@ -269,6 +278,12 @@ namespace SAGA.GplotRelationComputerManage
                     {
                         point.Name = string.Empty;
                         point.EquipmentType = PointItemType.Equipment.ToString();
+                        var equipExtend = currentNode.GetTag<NodeExtendData>();
+                        if (equipExtend != null)
+                        {
+                            point.Name = equipExtend.Name;
+                            point.EquipmentType = equipExtend.Category;
+                        }
                         pointItems.Add(point);
                     }
                     else if (SystemCalcUtil.IsStart(fiEq))
@@ -276,6 +291,7 @@ namespace SAGA.GplotRelationComputerManage
                         point.Name = string.Empty;
                         point.EquipmentType = PointItemType.StartValve.ToString(); ;
                         point.IsVirtual = true;
+                        point.Name=AppSetting.StartFlag;
                         pointItems.Add(point);
                     }
                     #endregion
@@ -300,15 +316,30 @@ namespace SAGA.GplotRelationComputerManage
         #endregion
 
         #region 创建关系数据相关
-        public static List<EquipmentNode> CreateRelation(ElementTreeNode etn)
+        public static List<BinaryRelationItem> CreateRelation(ElementTreeNode etn)
         {
+            List<BinaryRelationItem> result = new List<BinaryRelationItem>();
             #region 描述
             /*
-             * 1、将树形结构初步处理,修剪成存留设备之间的关系
+             * 1、将树形结构初步处理,修剪成存留设备之间的关系;
+             * 2、处理成二维关系
              */
             #endregion
-
-            return ConvertEquipmentNodes(etn);
+            var equipmentNodes= ConvertEquipmentNodes(etn);
+            var loopNodes = new List<EquipmentNode>(equipmentNodes);
+            for (int i = 0; i < loopNodes.Count; i++)
+            {
+                var currentNode = loopNodes[i];
+                foreach (var childNode in currentNode.Nodes)
+                {
+                    BinaryRelationItem relation = new BinaryRelationItem();
+                    relation.From = currentNode.CloneCurrentNode();
+                    relation.To = childNode.CloneCurrentNode();
+                    result.Add(relation);
+                    loopNodes.Add(childNode);
+                }
+            }
+            return result;
         }
 
         /// <summary>
@@ -319,14 +350,22 @@ namespace SAGA.GplotRelationComputerManage
         private static List<EquipmentNode> ConvertEquipmentNodes(ElementTreeNode etn)
         {
             List<EquipmentNode> nodes = new List<EquipmentNode>();
-            if (TryGetNode(etn.Current,out EquipmentNode outNode))
-            {
-                nodes.Add(outNode);
-                return nodes;
-            }
-            foreach (var elementTreeNode in etn.Nodes)
+            List<ElementTreeNode> loopNodes = new List<ElementTreeNode>(){ etn };
+            for (int i = 0; i < loopNodes.Count; i++)
             {
-                nodes.AddRange(ConvertEquipmentNodes(elementTreeNode));
+                var currentNode = loopNodes[i];
+                if (TryGetNode(currentNode.Current, out EquipmentNode outNode))
+                {
+                    foreach (var currentNodeNode in currentNode.Nodes)
+                    {
+                        outNode.AddChildren(ConvertEquipmentNodes(currentNodeNode));
+                    }                  
+                    nodes.Add(outNode);
+                }
+                else
+                {
+                    loopNodes.AddRange(currentNode.Nodes);
+                }
             }
             return nodes;
         }
@@ -340,8 +379,7 @@ namespace SAGA.GplotRelationComputerManage
         {
             bool flag = false;
             EquipmentNode node = new EquipmentNode();
-            node.RevitId = element.Id.IntegerValue;
-            node.BimId = element.GetBimId();
+        
             if (element is Space space)
             {
                 node.Category = PointItemType.Space.ToString();
@@ -363,8 +401,124 @@ namespace SAGA.GplotRelationComputerManage
             }
             flag = !string.IsNullOrEmpty(node.Category);
             outNode = flag ? node : null;
+            #region 确定返回之后进行后初始化处理
+            if (outNode != null)
+            {
+                outNode.RevitId = element.Id.IntegerValue;
+                outNode.BimId = element.GetBimId();
+            } 
+            #endregion
             return flag;
         }
         #endregion
+
+        #region 创建立面绘图和关系数据
+        /// <summary>
+        /// 计算立面数据
+        /// </summary>
+        public static VerticalResult ComputerVerticalData(List<VerticalPipe> pipeDatas, List<LevelData> levelDatas)
+        {
+
+            List<VerticalDrawRecord> drawRecords = new List<VerticalDrawRecord>();
+            List<VerticalRelationRecord> relationRecords = new List<VerticalRelationRecord>();
+            #region 标高绘图数据整理
+            List<VFloor> floors = new List<VFloor>();
+            for (int i = 0; i < levelDatas.Count; i++)
+            {
+                var tempFloor = new VFloor();
+                tempFloor.Name = levelDatas[i].Name;
+                if (tempFloor.Name == "F1")
+                {
+                    tempFloor.ValueDescription = "G";
+                }
+                tempFloor.Index = i;
+                tempFloor.FloorId = i.ToString();
+                tempFloor.LinkId = levelDatas[i].Id;
+                floors.Add(tempFloor);
+
+            }
+            #endregion
+
+            #region 立管或相当于立管的空间处理
+            /*
+             * 按系统分组,[一个空间会不会对应多个系统]
+             */
+            var comparer = new VpComparer();
+         
+            int groupId = 0;
+            //按系统分组
+            var goupSystems = pipeDatas.GroupBy(p => p.PipeSytemType);
+            foreach (var groupSystem in goupSystems)
+            {
+                //按坐标分组
+                foreach (var groupPosition in groupSystem.GroupBy(p=>p.DownPoint3D, comparer))
+                {
+                    var currentGroupdId = ++groupId ;
+                    SetRelationItem set = new SetRelationItem();
+                    #region 处理绘图数据
+                    foreach (var groupFloor in groupPosition.GroupBy(p => p.LevelName))
+                    {
+                        var verData = groupFloor.FirstOrDefault();
+                        string floorId = floors.FirstOrDefault(c => c.Name == groupFloor.Key)?.FloorId;
+                        #region 生成存储核心数据
+                        VPipe pipe = new VPipe();
+                        pipe.LinkId = verData.Id;
+                        pipe.Name = string.Join(",", groupFloor.Select(v => v.Display));//verData.Display;
+                        pipe.Tip = verData.DisplayTip;
+                        pipe.PipeSystemType = verData.PipeSytemType;
+                        pipe.FloorId = floorId;
+                        #endregion
+                        VerticalDrawRecord drawRecord = new VerticalDrawRecord();
+                        drawRecord.GroupId = currentGroupdId.ToString();
+                        drawRecord.RefPipe = pipe;
+                        drawRecord.SystemName = groupSystem.Key;
+                        drawRecords.Add(drawRecord);
+                        set.AddRange(groupFloor.Select(v => string.Format("{0}:{1}", floorId, v.Id)));
+                    }
+                    #endregion
+
+                    #region 处理关系数据
+
+                    VerticalRelationRecord relationRecord = new VerticalRelationRecord();
+                    relationRecord.SystemName = groupSystem.Key;
+                    relationRecord.RelationItems = set;
+                    relationRecords.Add(relationRecord);
+                    #endregion
+                }
+            }
+
+            #endregion
+
+            VerticalResult result = new VerticalResult();
+            result.DrawData = new VerticalDrawData() { LevelDatas = floors, DrawRecords = drawRecords };
+            result.RelationData = relationRecords;
+            return result;
+
+        }
+        #endregion
+    }
+
+    /// <summary>
+    /// 点位置比较相关
+    /// </summary>
+    public class VpComparer : IEqualityComparer<Point3D>
+    {
+        /// <summary>
+        ///  立管左右错开小于2Cm
+        /// 
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <returns></returns>
+        public bool Equals(Point3D x, Point3D y)
+        {//数据为英寸
+            var diff = 2 * 10d / 304.8;
+            return Math.Abs(x.X - y.X) <= diff && Math.Abs(x.Y - y.Y) <= diff;
+        }
+
+        public int GetHashCode(Point3D obj)
+        {
+            return 0;
+        }
     }
 }

+ 23 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/VerticalResult.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 立面计算结果信息
+    /// </summary>
+    public class VerticalResult
+    {
+        /// <summary>
+        /// 绘图数据
+        /// </summary>
+        public VerticalDrawData DrawData { get; set; }
+        /// <summary>
+        /// 关系数据
+        /// </summary>
+        public List<VerticalRelationRecord> RelationData { get; set; }
+    }
+}

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

@@ -26,5 +26,15 @@ namespace SAGA.GplotRelationComputerManage
         /// 结束节点
         /// </summary>
         public EquipmentNode To { get; set; }
+
+        /// <summary>
+        /// 反转关系
+        /// </summary>
+        public void Reverse()
+        {
+            var temp = To;
+            To = From;
+            From = temp;
+        }
     }
 }

+ 14 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/EquipmentNode.cs

@@ -35,5 +35,19 @@ namespace SAGA.GplotRelationComputerManage
         /// 设备分类
         /// </summary>
         public string Category { get; set; }
+
+        /// <summary>
+        /// 复制当前节点信息
+        /// </summary>
+        /// <returns></returns>
+        public EquipmentNode CloneCurrentNode()
+        {
+            EquipmentNode node = new EquipmentNode();
+            node.MbiId = this.MbiId;
+            node.BimId = this.BimId;
+            node.RevitId = this.RevitId;
+            node.Category = this.Category;
+            return node;
+        }
     }
 }

+ 34 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/NodeExtendData.cs

@@ -0,0 +1,34 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:NodeExtendData
+ * 作者:xulisong
+ * 创建时间: 2019/1/24 15:45:02
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// treeNode的扩展数据
+    /// </summary>
+    public class NodeExtendData
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 分类
+        /// </summary>
+        public string Category { get; set; }
+        /// <summary>
+        /// 关联系统类型
+        /// </summary>
+        public string SystemType { get; set; }
+    }
+}

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

@@ -16,7 +16,7 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 集合关系类,其中的元素两两进行相关
     /// </summary>
-    public class SetRelationItem :List<EquipmentNode>
+    public class SetRelationItem :List<string>
     {
         /*
          * 目前,将立管之间的关系整理成集合关系

+ 125 - 32
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -75,7 +75,7 @@ namespace SAGA.GplotRelationComputerManage
             /*
              * 暂时认定,一个立管之关联一个系统
              */
-            var verticalPipes = doc.GetElements<Pipe>().Where(p => SystemCalcUtil.IsStart(p) && p.IsVerticalPipe());
+            var verticalPipes = doc.GetElements<MEPCurve>().Where(p => SystemCalcUtil.IsStart(p) && p.IsVerticalPipe());
             foreach (var verticalPipe in verticalPipes)
             {
                 ElementTreeNode node = new ElementTreeNode();
@@ -153,6 +153,8 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="context"></param>
         public void Parse(SystemComputerContext context)
         {
+            if (UseLevel == null)
+                return;
             var doc = Document;
             var relations = context.Relations;
             foreach (var relation in relations)
@@ -172,6 +174,7 @@ namespace SAGA.GplotRelationComputerManage
         #region 水系统解析
         public void ParsePipe(SystemComputerContext context,RelationTypeShell relationSetting)
         {
+            Domain useDomain = Domain.DomainPiping;
             List<FloorDrawRecord> drawRecords = new List<FloorDrawRecord>();
             List<FloorRelationRecord> relationRecords = new List<FloorRelationRecord>();
             #region 计算拓扑树形结构 
@@ -182,19 +185,27 @@ namespace SAGA.GplotRelationComputerManage
              */
             var startNodes = GetStartNodes();
             List<int> useIds = new List<int>();
+            List<MEPCurve> verticalMepCurves = new List<MEPCurve>();
             for (int i = 0; i < startNodes.Count; i++)
             {
                 var startNode = startNodes[i];
-                if (!relationSetting.IsMatchSystem(startNode.Flag))
-                {
+                var useRelation = relationSetting.GetFirstMatchSystem(startNode.Flag);
+                if (useRelation == null)
                     continue;
-                }
+               
                 if (useIds.Any(id => id == startNode.Instance.Current.Id.IntegerValue))
                 {
                     continue;
                 }
-                var tempIds=SystemParseManager.BuildSystemNode(startNode.Instance, Domain.DomainPiping,
-                    (m => !relationSetting.IsMatchSystem(m.GetSystemTypeName())));
+
+                if (startNode.Instance.Current is MEPCurve mepCurve)
+                {
+                    verticalMepCurves.Add(mepCurve);
+                }
+                var tempIds=SystemParseManager.BuildSystemNode(startNode.Instance, useDomain,
+                    (m => !startNode.Flag.Equals(m.GetSystemTypeName())));
+                startNode.Instance.PipeSystemTypeName = startNode.Flag;
+                BuildElementNodeData(context, startNode.Instance);
                 useIds.AddRange(tempIds);
                 startNode.Handled = true;
 
@@ -202,9 +213,10 @@ namespace SAGA.GplotRelationComputerManage
                 #region 整理原始数据
                 //判断是否有设备节点,不进行数据处理
                 var useNode = startNode.Instance;
-                var firstEquipment = useNode.FirstOrDefault(t => MBIInfoUtil.IsEquipment(t.Current));
+                //var firstEquipment = useNode.FirstOrDefault(t => MBIInfoUtil.IsEquipment(t.Current));
                 //要不要以这个为判定条件,图形可以画出,关系肯定是没有的
-                if (firstEquipment != null)
+                //if (firstEquipment != null)
+                if (useNode.Nodes.Any())
                 {
                     //存在设备则保存信息
                     var drawRecord = BuildFloorDrawRecord(relationSetting, useNode);
@@ -222,35 +234,54 @@ namespace SAGA.GplotRelationComputerManage
                 relationSetting.RelationItem.Objects.SelectMany(o => GetEquipments(o.Type)).ToList();
             for (int i = 0; i < singleInstances.Count; i++)
             {
-                var useInstance = singleInstances[i];
+                var useInstance = singleInstances[i];       
                 if (useIds.Any(id => id == useInstance.Id.IntegerValue))
                 {
                     continue;
                 }
-                var startNode = new ElementTreeNode() {Current = useInstance};
-                var tempIds = SystemParseManager.BuildSystemNode(startNode, Domain.DomainPiping,
-                    (m => !relationSetting.IsMatchSystem(m.GetSystemTypeName())));
-                useIds.AddRange(tempIds);
-                #region 生成绘图,计算数据
-                //解析数据,找管道定系统,管道找不到,系统名为"关联类型-未知"
-                var firstMepCurve = startNode.FirstOrDefault(t => t.Current is MEPCurve);
-                if (firstMepCurve == null)
-                    continue;
-                var useSystemName = (firstMepCurve.Current as MEPCurve)?.GetSystemTypeName() ?? GetUnknownSystemName(relationSetting);
-                //存在设备则保存信息
-                var drawRecord = BuildFloorDrawRecord(relationSetting, startNode);
-                drawRecord.SystemName = useSystemName;
-                drawRecords.Add(drawRecord);
+                var connectors = useInstance.GetAllConnectors();
+                foreach (var connector in connectors)
+                {
+                    if (connector.Domain != useDomain)
+                    {
+                        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))
+                    {
+                        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 relationRecord = BuildFloorRelationRecord(relationSetting, startNode);
-                relationRecords.Add(relationRecord); 
-                #endregion
 
             }
             #endregion
-
-            context.DrawRecords.AddRange(drawRecords);
-            context.RelationRecords.AddRange(relationRecords);
+            //增加立管数据
+            ComputerVerticalPipes(UseLevel, verticalMepCurves, context);
+            context.FloorDrawRecords.AddRange(drawRecords);
+            context.FloorRelationRecords.AddRange(relationRecords);
         }
         #endregion
 
@@ -265,13 +296,13 @@ namespace SAGA.GplotRelationComputerManage
          * 1、解析立管需要考虑,竖直风管,水管,空间的情况;
          *2、将各层数据汇总,才能统一计算立管的相关关系数据
          */
-        private void ComputerVerticalPipes(Level refLevel, List<Pipe> pipes, SystemComputerContext context)
+        private void ComputerVerticalPipes(Level refLevel, List<MEPCurve> mepCurves, SystemComputerContext context)
         {
             var result = new List<VerticalPipe>();
             var spaces = Document.GetElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>();
             var level = refLevel;
             var currentLevelName = MBIInfoUtil.GetFloorNameByLevel(level.Name);
-            foreach (var pipe in pipes)
+            foreach (var pipe in mepCurves)
             {
                 if (pipe == null)
                     continue;             
@@ -324,9 +355,71 @@ namespace SAGA.GplotRelationComputerManage
             var floorRelation = new FloorRelationRecord();
             floorRelation.SetFloorLevel(UseLevel);
             floorRelation.RelationType = relationShell.RelationItem.Type;
-            floorRelation.EquipmentItems = SystemParseManager.CreateRelation(node)??new List<EquipmentNode>();
+            floorRelation.RelationItems = SystemParseManager.CreateRelation(node)??new List<BinaryRelationItem>();
             return floorRelation;
         }
         #endregion
+
+        #region 初始化名称,分类
+        /// <summary>
+        /// 初始化节点扩展数据
+        /// </summary>
+        /// <param name="context"></param>
+        /// <param name="node"></param>
+        private void BuildElementNodeData(SystemComputerContext context, ElementTreeNode node)
+        {
+            Queue<ElementTreeNode> nodeQueue = new Queue<ElementTreeNode>();
+            nodeQueue.Enqueue(node);
+            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());
+                        NodeExtendData data = new NodeExtendData();
+                        if (equipItem != null)
+                        {
+                            data.Name = equipItem.GetDisplay();
+                            data.Category = equipItem.Category;                          
+                        }
+                        else
+                        {
+                            data.Name = fiEq.GetFamily()?.Name;
+                        }
+                        data.SystemType = node.PipeSystemTypeName;
+                        currentNode.Tag = data;
+                    }               
+                    #endregion
+                }
+                else if (element is Space revitSpace)
+                {
+                    var space = context.Rooms.GetItem(element.GetBimId());
+                    NodeExtendData data = new NodeExtendData();
+                    if (space != null)
+                    {
+                        data.Name = space.GetDisplay();
+                    }
+                    else
+                    {
+                        data.Name = revitSpace.Name;
+                    }
+                    data.SystemType = node.PipeSystemTypeName;
+                    currentNode.Tag = data;
+                }
+                currentNode.Nodes.ForEach(e => nodeQueue.Enqueue(e));
+            }
+
+        }
+        #endregion
     }
 }

+ 30 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawData.cs

@@ -0,0 +1,30 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FloorDrawData
+ * 作者:xulisong
+ * 创建时间: 2019/1/24 10:59:14
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 平面数据结构
+    /// </summary>
+    public class FloorDrawData
+    {
+        /// <summary>
+        /// 楼层信息
+        /// </summary>
+        public string FloorId { get; set; }
+        /// <summary>
+        /// 绘图数据信息
+        /// </summary>
+        public List<FloorDrawRecord> DrawRecords { get; set; }
+    }
+}

+ 4 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawRecord.cs

@@ -13,7 +13,10 @@ using System.Threading.Tasks;
 
 namespace SAGA.GplotRelationComputerManage
 {
-    public class FloorDrawRecord : FloorFlag
+    /// <summary>
+    /// 平面绘图数据
+    /// </summary>
+    public class FloorDrawRecord : FloorRecord
     {
         /// <summary>
         /// 系统名称信息

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

@@ -12,6 +12,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using SAGA.DotNetUtils.Extend;
 
 namespace SAGA.GplotRelationComputerManage
 { 
@@ -21,8 +22,9 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 楼层信息记录
     /// </summary>
-    public class FloorFlag
+    public class FloorRecord
     {
+        public string FloorId { get; set; }
         public string FloorName { get; set; }
         public string FloorIndex { get; set; }
         /// <summary>
@@ -42,8 +44,9 @@ namespace SAGA.GplotRelationComputerManage
         {
             if (level == null)
                 return;
-            FloorName = MBIInfoUtil.GetFloorNameByLevel(level.Name);
+            FloorName = MBIInfoUtil.GetFloorNameByLevel(level.Name)??string.Empty;
             FloorLevelElevation = level.ProjectElevation.FromApi();
+            FloorId = level.Document.PathName.GetFileName(); 
         }
     }
 }

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

@@ -13,11 +13,14 @@ using System.Threading.Tasks;
 
 namespace SAGA.GplotRelationComputerManage
 {
-   public  class FloorRelationRecord: FloorFlag
+    /// <summary>
+    /// 平面关系数据
+    /// </summary>
+   public  class FloorRelationRecord: FloorRecord
     {
         /// <summary>
         /// 关联数据
         /// </summary>
-        public List<EquipmentNode> EquipmentItems { get; set; }
+        public List<BinaryRelationItem> RelationItems { get; set; }
     }
 }

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

@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MachineRoomDrawRecord
+ * 作者:xulisong
+ * 创建时间: 2019/1/23 15:54:20
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 机房绘图数据
+    /// </summary>
+    public class MachineRoomDrawRecord
+    {
+    }
+}

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

@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MachineRoomRelationRecord
+ * 作者:xulisong
+ * 创建时间: 2019/1/23 15:55:00
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 机房关系数据
+    /// </summary>
+    public class MachineRoomRelationRecord
+    {
+    }
+}

+ 30 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawData.cs

@@ -0,0 +1,30 @@
+using SAGA.Models;
+using SAGA.Models.Graphs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 垂直立管相关信息
+    /// </summary>
+    public class VerticalDrawData
+    {
+        public VerticalDrawData()
+        {
+            LevelDatas = new List<VFloor>();
+            DrawRecords = new List<VerticalDrawRecord>();
+        }
+        /// <summary>
+        /// 标高数据
+        /// </summary>
+       public List<VFloor> LevelDatas { get; set; }
+        /// <summary>
+        /// 绘图相关数据
+        /// </summary>
+       public List<VerticalDrawRecord> DrawRecords { get; set; }
+    }
+}

+ 35 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalDrawRecord.cs

@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:DerticalDrawRecord
+ * 作者:xulisong
+ * 创建时间: 2019/1/23 15:50:53
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.Models.Graphs;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 立面绘图数据
+    /// </summary>
+    public class VerticalDrawRecord:FloorRecord
+    {
+        /// <summary>
+        /// 系统名称信息
+        /// </summary>
+        public string SystemName { get; set; }
+        /// <summary>
+        /// 竖向分组Id
+        /// </summary>
+        public string GroupId { get; set; }
+        /// <summary>
+        /// 关联管道信息
+        /// </summary>
+        public VPipe RefPipe{ get; set; }
+    }
+}

+ 30 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalRelationRecord.cs

@@ -0,0 +1,30 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:VerticalRelationRecord
+ * 作者:xulisong
+ * 创建时间: 2019/1/23 15:51:47
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 立面关系数据
+    /// </summary>
+    public class VerticalRelationRecord
+    {
+        /// <summary>
+        /// 系统名称
+        /// </summary>
+        public string SystemName { get; set; }
+        /// <summary>
+        /// 关联数据信息
+        /// </summary>
+        public SetRelationItem RelationItems { get; set; }
+    }
+}

+ 24 - 4
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerContext.cs

@@ -26,8 +26,10 @@ namespace SAGA.GplotRelationComputerManage
             VerticalPipes = new List<VerticalPipe>();
             Levels = new List<LevelData>();
             Relations = new List<string>();
-            DrawRecords = new List<FloorDrawRecord>();
-            RelationRecords = new List<FloorRelationRecord>();
+            FloorDrawRecords = new List<FloorDrawRecord>();
+            FloorRelationRecords = new List<FloorRelationRecord>();
+            MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
+            MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
             #endregion
         }
         #region 计算缓存对象
@@ -81,8 +83,10 @@ namespace SAGA.GplotRelationComputerManage
          */
         public List<VerticalPipe> VerticalPipes { get; private set; }
         public List<LevelData> Levels { get; private set; }
-        public List<FloorDrawRecord> DrawRecords { get; private set; }
-        public List<FloorRelationRecord> RelationRecords { 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; }
         #endregion
 
         #region 需要计算的系统相关
@@ -96,5 +100,21 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         public List<string> Relations { get;private set; }
         #endregion
+
+        #region 保存计算结果
+        /// <summary>
+        /// 保存立面数据
+        /// </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);
+        }
+        #endregion
     }
 }

+ 1 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs

@@ -30,6 +30,7 @@ namespace SAGA.GplotRelationComputerManage
                     floorItems.Document.CloseDocSimple();
                 }
             }
+            context.SaveComputerData();
             //最后统保存缓存数据
             return items;
         }

+ 1 - 1
MBI/SAGA.MBI/RevitModelHandle/ParameterDefinitionFactory.cs

@@ -22,7 +22,7 @@ namespace SAGA.MBI.RevitModelHandle
 
         static ParameterDefinitionFactory()
         {
-            m_InnerMap[MBIBuiltInParameter.EquipLocalID] = new ParameterDefinition("设备本地编");
+            m_InnerMap[MBIBuiltInParameter.EquipLocalID] = new ParameterDefinition("设备本地编");
             m_InnerMap[MBIBuiltInParameter.EquipLocalName] = new ParameterDefinition("设备本地名称");
             m_InnerMap[MBIBuiltInParameter.RoomLocalName] = new ParameterDefinition(BuiltInParameter.ROOM_NAME){CanUpdate=
                 (e, value) =>

+ 5 - 0
MBI/SAGA.Models/ChangesRelationship.cs

@@ -85,5 +85,10 @@ namespace SAGA.Models
         /// </summary>
         [CellIndex(10)]
         public string Systems { get; set; }
+        /// <summary>
+        /// 关联的是水系统还是风系统【0,水;1,风】
+        /// </summary>
+        [CellIndex(11)]
+        public string SystemType { get; set; }
     }
 }

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

@@ -299,6 +299,16 @@ namespace SAGA.RevitUtils.MEP
             return null;
         }
         #endregion
+
+        /// <summary>
+        /// 获取具体类型的tag值
+        /// </summary>
+        /// <typeparam name="V"></typeparam>
+        /// <returns></returns>
+        public V GetTag<V>()
+        {
+            return (V)Tag;
+        }
     }
 }