Переглянути джерело

xls:调试解析数据相关

xulisong 6 роки тому
батько
коміт
7a09ac9097
20 змінених файлів з 494 додано та 122 видалено
  1. BIN
      MBI/MBIResource/Config/物理世界关系定义列表-2019-1.xlsx
  2. 41 64
      MBI/SAGA.GplotDrawData/DBView/FloorSystemGraphView.cs
  3. 1 1
      MBI/SAGA.GplotDrawData/DBView/VerticalSYstemGraphView.cs
  4. 7 0
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  5. 45 0
      MBI/SAGA.GplotDrawData/View/WinSystem.xaml
  6. 136 0
      MBI/SAGA.GplotDrawData/View/WinSystem.xaml.cs
  7. 10 16
      MBI/SAGA.GplotDrawData/WinDrawEndPoint-Web.xaml.cs
  8. 11 6
      MBI/SAGA.GplotManage/GplotCommand.cs
  9. 1 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/RelationItem.cs
  10. 3 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/Data/SystemItem.cs
  11. 5 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs
  12. 9 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeShell.cs
  13. 2 0
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  14. 18 5
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  15. 34 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/NodeExtendData.cs
  16. 122 29
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  17. 30 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorDrawData.cs
  18. 4 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/FloorRecord.cs
  19. 5 0
      MBI/SAGA.Models/ChangesRelationship.cs
  20. 10 0
      MBI/SAGA.RevitUtils/MEP/TNode.cs

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


+ 41 - 64
MBI/SAGA.GplotDrawData/DBView/FloorSystemGraphView.cs

@@ -5,77 +5,54 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
 
-namespace SAGA.GplotDrawData.DBView
+namespace SAGA.GplotDrawData
 {
-    public class FloorSystemGraphView : GraphDBView<List<FloorDrawRecord>>
+    public class FloorSystemGraphView : GraphDBView<FloorDrawData>
     {
-        public override GraphDB AppendDb(List<FloorDrawRecord> t, GraphDB db)
+        public override GraphDB AppendDb(FloorDrawData t, GraphDB db)
         {
-            //var baseRecord = t.FirstOrDefault();
-            //if(baseRecord!=null)
-            //{
-              
-            //    #region 起点信息
-            //    if (fd.MEPCurveData != null)
-            //    {
-            //        try
-            //        {
-            //            foreach (var startData in fd.MEPCurveData)
-            //            {
-            //                if (startData.Current == null)
-            //                    continue;
-            //                GVertex node = new GVertex();
-            //                var planPoint = new Point(startData.Current.DownPoint3D.X, startData.Current.DownPoint3D.Y);
-            //                if (planPoint.X == 0 && planPoint.Y == 0)
-            //                {
-            //                    continue;
-            //                }
+            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);
+                }
 
-            //                var useLocation = planPoint.ConvertINToMM().ConvertToPoint3D();
-            //                node.Location = new System.Windows.Media.Media3D.Point3D(useLocation.X, useLocation.Y, 0);
-            //                node.ElementColor = Colors.Red;
-            //                node.Name = "start";
-            //                node.Radius = 4;
-            //                db.Elements.Add(node);
-            //            }
-            //        }
-            //        catch (Exception)
-            //        {
+                #endregion
 
-            //        }
-            //    }
-            //    #endregion
-            //    foreach (var pt in endPoints)
-            //    {
-            //        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);
-            //    }
-            //    foreach (var line in lines)
-            //    {
-            //        GPath path = new GPath();
-            //        path.Data = line.Select(p => p.ConvertINToMM().ConvertToPoint3D()).ToList();
-            //        path.ElementColor = Colors.Red;
-            //        db.Elements.Add(path);
-            //    }
-            //}
-           
-            //#region 底图获取
-            //var floorName = fd.Id.Split('-')[1];
-            //try
-            //{
-            //    var jsObject = BaseMapManager.GetFloorInfo(floorName);
-            //    db.RefJObjects.Add(jsObject);
-            //}
-            //catch (Exception ex)
-            //{
+                #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
+            }
+            #endregion
             return db;
         }
     }

+ 1 - 1
MBI/SAGA.GplotDrawData/DBView/VerticalSYstemGraphView.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace SAGA.GplotDrawData.DBView
+namespace SAGA.GplotDrawData
 {
     /// <summary>
     /// 解析立管数据

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

@@ -79,6 +79,9 @@
     <Compile Include="DBView\ViewExtension.cs" />
     <Compile Include="DBView\VirticalSpaceGraphView.cs" />
     <Compile Include="DrawElementEdges.cs" />
+    <Compile Include="View\WinSystem.xaml.cs">
+      <DependentUpon>WinSystem.xaml</DependentUpon>
+    </Compile>
     <Compile Include="WinControlRelation-Web.xaml.cs">
       <DependentUpon>WinControlRelation-Web.xaml</DependentUpon>
     </Compile>
@@ -118,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>

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

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

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

@@ -140,11 +140,13 @@
     <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" />

+ 18 - 5
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -131,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()
                     {
@@ -170,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);
 
                 }
@@ -228,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
@@ -272,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))
@@ -279,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
@@ -440,7 +453,7 @@ namespace SAGA.GplotRelationComputerManage
                 //按坐标分组
                 foreach (var groupPosition in groupSystem.GroupBy(p=>p.DownPoint3D, comparer))
                 {
-                    var currentGroupdId = groupId + 1;
+                    var currentGroupdId = ++groupId ;
                     SetRelationItem set = new SetRelationItem();
                     #region 处理绘图数据
                     foreach (var groupFloor in groupPosition.GroupBy(p => p.LevelName))

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

+ 122 - 29
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,33 +234,52 @@ 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
-
+            //增加立管数据
+            ComputerVerticalPipes(UseLevel, verticalMepCurves, context);
             context.FloorDrawRecords.AddRange(drawRecords);
             context.FloorRelationRecords.AddRange(relationRecords);
         }
@@ -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;             
@@ -328,5 +359,67 @@ namespace SAGA.GplotRelationComputerManage
             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/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
 { 
@@ -23,6 +24,7 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     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 - 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;
+        }
     }
 }