Selaa lähdekoodia

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

mengxiangge 6 vuotta sitten
vanhempi
commit
b450be5aad
38 muutettua tiedostoa jossa 319 lisäystä ja 275 poistoa
  1. 1 0
      MBI/SAGA.GplotDrawData/DBView/VerticalPipeGraphView.cs
  2. 0 49
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  3. 1 1
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj.user
  4. 21 17
      MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs
  5. 1 1
      MBI/SAGA.GplotDrawData/WinDrawSpace.xaml.cs
  6. 1 61
      MBI/SAGA.GplotManage/Command.cs
  7. 23 17
      MBI/SAGA.GplotManage/GplotCommand.cs
  8. 9 1
      MBI/SAGA.GplotManage/RelationManager/ElectricalRelationUploader.cs
  9. 5 28
      MBI/SAGA.GplotManage/RelationManager/RelationDataManager.cs
  10. 15 4
      MBI/SAGA.GplotManage/RelationManager/RelationUploader.cs
  11. 3 15
      MBI/SAGA.GplotManage/RelationManager/SpaceRelationUploader.cs
  12. 2 0
      MBI/SAGA.GplotManage/RelationManager/SystemRelationUploader.cs
  13. 2 2
      MBI/SAGA.GplotManage/RelationManager/WinComputeRelations.xaml
  14. 1 0
      MBI/SAGA.GplotManage/RelationManager/WinComputeRelations.xaml.cs
  15. 11 3
      MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs
  16. 1 1
      MBI/SAGA.GplotManage/UploadRelated/ChillWaterLoop.cs
  17. 1 1
      MBI/SAGA.GplotManage/UploadRelated/CoolingWaterLoop.cs
  18. 5 17
      MBI/SAGA.GplotManage/UploadRelated/ElementSpNeighborhood.cs
  19. 1 1
      MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphRelationItem.cs
  20. 0 3
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  21. 5 4
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/FloorSpaceItems.cs
  22. 2 1
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerContext.cs
  23. 7 20
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerDataUtil.cs
  24. 12 2
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs
  25. 3 2
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerManager.cs
  26. 14 5
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  27. 6 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/EquipmentNode.cs
  28. 1 6
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  29. 4 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  30. 138 0
      MBI/SAGA.MBI/Common/PhaseUtil.cs
  31. 2 0
      MBI/SAGA.MBI/Extend/ElementExtend.cs
  32. 3 0
      MBI/SAGA.MBI/Interaction/MBIModelInfoManager.cs
  33. 3 5
      MBI/SAGA.MBI/RevitExport/ExportData.cs
  34. 1 0
      MBI/SAGA.MBI/SAGA.MBI.csproj
  35. 5 5
      MBI/SAGA.MBI/WinView/Space/SpaceManager.cs
  36. 1 1
      MBI/SAGA.Models/LogicNode.cs
  37. 7 0
      MBI/SAGA.Models/SgElement.cs
  38. 1 1
      MBI/SAGA.Models/SgSpace.cs

+ 1 - 0
MBI/SAGA.GplotDrawData/DBView/VerticalPipeGraphView.cs

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Media;
 using System.Windows.Media.Media3D;
+using SAGA.GplotRelationComputerManage;
 
 namespace SAGA.GplotDrawData
 { 

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

@@ -98,42 +98,21 @@
     <Compile Include="WinControlRelation-Web.xaml.cs">
       <DependentUpon>WinControlRelation-Web.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WinControlRelation.xaml.cs">
-      <DependentUpon>WinControlRelation.xaml</DependentUpon>
-    </Compile>
     <Compile Include="UcShowElement.xaml.cs">
       <DependentUpon>UcShowElement.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WinDrawData.xaml.cs">
-      <DependentUpon>WinDrawData.xaml</DependentUpon>
-    </Compile>
     <Compile Include="WinDrawEndPoint-Web.xaml.cs">
       <DependentUpon>WinDrawEndPoint-Web.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WinDrawEndPoint.xaml.cs">
-      <DependentUpon>WinDrawEndPoint.xaml</DependentUpon>
-    </Compile>
-    <Compile Include="WinDrawPipePoint.xaml.cs">
-      <DependentUpon>WinDrawPipePoint.xaml</DependentUpon>
-    </Compile>
     <Compile Include="WinDrawSpace-Web.xaml.cs">
       <DependentUpon>WinDrawSpace-Web.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WinDrawSpace.xaml.cs">
-      <DependentUpon>WinDrawSpace.xaml</DependentUpon>
-    </Compile>
-    <Compile Include="WinDrawWaterNode.xaml.cs">
-      <DependentUpon>WinDrawWaterNode.xaml</DependentUpon>
-    </Compile>
     <Compile Include="WinEquipmentRelation-Web.xaml.cs">
       <DependentUpon>WinEquipmentRelation-Web.xaml</DependentUpon>
     </Compile>
     <Compile Include="WinMachineRoomView-Web.xaml.cs">
       <DependentUpon>WinMachineRoomView-Web.xaml</DependentUpon>
     </Compile>
-    <Compile Include="WinMachineRoomView.xaml.cs">
-      <DependentUpon>WinMachineRoomView.xaml</DependentUpon>
-    </Compile>
     <Page Include="View\WinMachineRoom.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -146,10 +125,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WinControlRelation.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -166,34 +141,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WinDrawData.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
     <Page Include="WinDrawEndPoint-Web.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WinDrawEndPoint.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
-    <Page Include="WinDrawPipePoint.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="WinDrawSpace-Web.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WinDrawSpace.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
-    <Page Include="WinDrawWaterNode.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="WinEquipmentRelation-Web.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -202,10 +157,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="WinMachineRoomView.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs">

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

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <ProjectView>ShowAllFiles</ProjectView>
+    <ProjectView>ProjectFiles</ProjectView>
   </PropertyGroup>
 </Project>

+ 21 - 17
MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs

@@ -16,8 +16,10 @@ using System.Windows.Shapes;
 using CEFSharpWPF;
 using DrawData;
 using SAGA.DotNetUtils.Logger;
+using SAGA.GplotRelationComputerManage;
 using SAGA.MBI.Common;
 using SAGA.Models;
+using SAGA.RevitUtils;
 
 namespace SAGA.GplotDrawData
 {
@@ -43,18 +45,22 @@ namespace SAGA.GplotDrawData
 
         private void WinDrawWaterNode_Loaded(object sender, RoutedEventArgs e)
         {
-            if (m_showType == GplotShowType.VerticalPlan)
+            try
             {
-                //this.rootNode.Visibility = Visibility.Collapsed;
-                //grid.ColumnDefinitions[0].Width = new GridLength(0);
-                //DrawVSpaces();
-                InitVerticalSpaces();
-
+                if (m_showType == GplotShowType.VerticalPlan)
+                {
+                    InitVerticalSpaces();
+                }
+                else
+                {
+                    var node = GetSpaceData();
+                    this.rootNode.ItemsSource = new List<DataNode>() { node };
+                }
             }
-            else
+            catch (Exception ex)
             {
-                var node = GetSpaceData();
-                this.rootNode.ItemsSource = new List<DataNode>() { node };
+
+                DotNetUtils.Others.MessageShowBase.Show(ex);
             }
         }
         #region 立面空间处理
@@ -64,7 +70,7 @@ namespace SAGA.GplotDrawData
         private SpaceData VerticalSpaces { get; set; }
         public void InitVerticalSpaces()
         {
-            var spaceDatas = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
+            var spaceDatas = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);// DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
             this.VerticalSpaces = spaceDatas;
             InitVSpaceTree();
         }
@@ -75,8 +81,7 @@ namespace SAGA.GplotDrawData
         {
             if (node == null)
                 return;
-            //rootNode.Visibility = Visibility.Collapsed;
-            var spaceDatas = VerticalSpaces;// DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
+            var spaceDatas = VerticalSpaces;
             VirticalSpaceGraphView view = new VirticalSpaceGraphView();
             view.SpaceType = node.Sno;
             var db = view.CreateDb(spaceDatas);
@@ -116,7 +121,6 @@ namespace SAGA.GplotDrawData
         {
             SpaceGraphView view = new SpaceGraphView();
             var db = view.CreateDb(fd);
-            //db.SaveToFile(@"c:\space.json");
             ConstData.ResponseData = db.CreateJObjectGroup();
             ucShowElement.Show(WebGplotSettings.GplotUrl);    
         }
@@ -124,11 +128,11 @@ namespace SAGA.GplotDrawData
 
         private DataNode GetSpaceData()
         {
-            var aData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.All);
-            var tData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
+            var aData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Adjacent);
+            var tData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);
 
-            var vData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Ventilation);
-            var rData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Radiation);
+            var vData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Ventilation);
+            var rData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Radiation);
             DataNode root = new DataNode("空间关系");
             DataNode a = new DataNode("空间临接关系")
             {

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

@@ -249,7 +249,7 @@ namespace DrawData
 
         private DataNode GetSpaceData()
         {
-            var aData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.All);
+            var aData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Adjacent);
             var tData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
 
             var vData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Ventilation);

+ 1 - 61
MBI/SAGA.GplotManage/Command.cs

@@ -5,10 +5,8 @@ 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;
 using SAGA.GplotRelationComputerManage.SystemChecks;
 using SAGA.GplotManage.SystemChecks;
@@ -17,34 +15,7 @@ using SAGA.MBI.Common;
 
 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>
     /// 配电关系图--配电柜与配电柜
@@ -145,37 +116,6 @@ namespace SAGA.GplotManage
             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;
-        }
-    }
-
-
     /// <summary>
     /// 系统检查
     /// </summary>

+ 23 - 17
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -5,9 +5,9 @@ using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.UI;
 using Newtonsoft.Json;
+using SAGA.GplotDrawData;
 using SAGA.GplotDrawData.View;
 using SAGA.GplotManage.RelationManager;
-using SAGA.GplotManage.UploadRelated;
 using SAGA.GplotRelationComputerManage;
 using SAGA.Models;
 using SAGA.RevitUtils.Extends;
@@ -22,9 +22,12 @@ namespace SAGA.GplotManage
     public class SpaceComputerGraph : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {        
-            var space = GplotFactory.Create(GraphTypeEnum.ElementSpNeighborhood);
-            space.Show(GplotShowType.ViewPlan);           
+        {
+            //var space = GplotFactory.Create(GraphTypeEnum.ElementSpNeighborhood);
+            //space.Show(GplotShowType.ViewPlan);   
+            SpaceComputerHandler.ComputerAllRelations();
+            var win = new WinDrawSpace_Web(GplotShowType.ViewPlan);// 
+            win.Show();
             return Result.Succeeded;
         }
 
@@ -42,8 +45,11 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            var space = GplotFactory.Create(GraphTypeEnum.ElementSpNeighborhood);
-            space.Show(GplotShowType.VerticalPlan);
+            //var space = GplotFactory.Create(GraphTypeEnum.ElementSpNeighborhood);
+            //space.Show(GplotShowType.VerticalPlan);
+            SpaceComputerHandler.ComputerAllRelations();
+            var win = new WinDrawSpace_Web(GplotShowType.VerticalPlan);
+            win.Show();
             return Result.Succeeded;
         }
 
@@ -146,18 +152,18 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<Gplot> gplots = new List<Gplot>();
-            gplots.Add(new ElementSpNeighborhood());
-            gplots.Add(new TrafficNetwork());
-            gplots.Add(new ConvectionNetwork());
-            gplots.Add(new RadiationNetwork());
-            foreach (var gplot in gplots)
-            {
-                var graph = gplot;
-                graph.Relationship = graph.ComputerEffectRelationShip;
-                graph.Upload();
+            //List<Gplot> gplots = new List<Gplot>();
+            //gplots.Add(new ElementSpNeighborhood());
+            //gplots.Add(new TrafficNetwork());
+            //gplots.Add(new ConvectionNetwork());
+            //gplots.Add(new RadiationNetwork());
+            //foreach (var gplot in gplots)
+            //{
+            //    var graph = gplot;
+            //    graph.Relationship = graph.ComputerEffectRelationShip;
+            //    graph.Upload();
 
-            }
+            //}
             WinComputeRelations win = new WinComputeRelations();
             win.ShowDialog();
             return Result.Succeeded;

+ 9 - 1
MBI/SAGA.GplotManage/RelationManager/ElectricalRelationUploader.cs

@@ -47,9 +47,17 @@ namespace SAGA.GplotManage
             {
                 foreach (var child in dn.Childrens)
                 {
+                    //后续遍历,先遍历子节点
+                    items.AddRange(CreateGraph(child));
+                    
                     GraphRelationItem item = new GraphRelationItem();
+                 
                     item.FromId = dn.EId;
                     item.ToId = child.EId;
+                    if (string.IsNullOrWhiteSpace(item.FromId) || string.IsNullOrWhiteSpace(item.ToId))
+                    {
+                        continue;
+                    }
                     item.RelType = "1";
                     //item.GraphId = string.Empty;
                     if (!string.IsNullOrWhiteSpace(child.InLineNo1) && child.InLineNo1 == dn.Sno)
@@ -61,7 +69,7 @@ namespace SAGA.GplotManage
                         item.RelType = "2";
                     }
                     items.Add(item);
-                    items.AddRange(CreateGraph(child));
+                    
                 }
             }
             return items;

+ 5 - 28
MBI/SAGA.GplotManage/RelationManager/RelationDataManager.cs

@@ -28,7 +28,7 @@ namespace SAGA.GplotManage
             var sytemRelationTypes = RelationTypeManager.GetSystemRelationTypes();
             foreach (RelationItem relation in sytemRelationTypes)
             {
-                uploaders.Add(new SpaceRelationUploader(relation.Type, relation.Name));
+                uploaders.Add(new SystemRelationUploader(relation.Type, relation.Name));
             }
             return uploaders;
         }
@@ -81,30 +81,14 @@ namespace SAGA.GplotManage
         #endregion
         public void InitRelationData(List<RelationUploader> uploaders)
         {
-            ComputerRelations(uploaders, false);
-            if (uploaders.Any(s=>s is SpaceRelationUploader))
-            {
-                SpaceData = SpaceComputerDataUtil.LoadData();
-            }
-           
+            ComputerRelations(uploaders, true);
         }
-        /// <summary>
-        /// 获取空间计算数据
-        /// </summary>
-        private object SpaceData { get; set; }
         public void CommitRelations(List<RelationUploader> uploaders)
         {
             InitRelationData(uploaders);
             foreach (RelationUploader uploader in uploaders)
             {
-                if(uploader is SpaceRelationUploader)
-                {
-                    uploader.Upload(SpaceData);
-                }
-                else
-                {
-                    uploader.Upload();
-                }
+                 uploader.Upload();
             }
         }
         /// <summary>
@@ -113,17 +97,10 @@ namespace SAGA.GplotManage
         /// <param name="uploaders"></param>
         public void CommitRelationsByReComputer(List<RelationUploader> uploaders)
         {
-            ComputerRelations(uploaders, true);
+            ComputerRelations(uploaders, false);
             foreach (RelationUploader uploader in uploaders)
             {
-                if (uploader is SpaceRelationUploader)
-                {
-                    uploader.Upload(SpaceData);
-                }
-                else
-                {
-                    uploader.Upload();
-                }
+                   uploader.Upload();
             }
         }
     }

+ 15 - 4
MBI/SAGA.GplotManage/RelationManager/RelationUploader.cs

@@ -15,7 +15,7 @@ namespace SAGA.GplotManage
         public RelationUploader(string relationType,string relationDisplay)
         {
             RelationType = relationType;
-            RelationDisplay = RelationDisplay;
+            RelationDisplay = relationDisplay;
         }
         /*
          *可以将计算写在upload中,就像把计算卸载Show中 
@@ -56,15 +56,26 @@ namespace SAGA.GplotManage
         {
             string graphId = RelationRequest.GetCurrentGraphId(RelationType);
             if (graphId == null) return;
+            if (realtionItems != null)
+            {
+                realtionItems.ForEach(r => r.GraphId = graphId);
+            }
+            #region 删除拓扑关系
             var deleteObject = new JObject();
-            deleteObject.Add("graph_id", graphId);
-            RelationRequest.DeleteRelation(deleteObject);
+            var deleteArray = new JArray();
+            var deleteCondition = new JObject();
+            deleteCondition.Add("graph_id", graphId);
+            deleteArray.Add(deleteCondition);
+            deleteObject.Add("criterias", deleteArray);
+            
+            RelationRequest.DeleteRelation(deleteObject); 
+            #endregion
             if (realtionItems!=null&&realtionItems.Any())
             {
                 var jarry = JArray.FromObject(realtionItems);
                 JObject jobject = new JObject();
                 jobject.Add("criterias", jarry);
-                RelationRequest.AddRelation(jobject);
+                var result=RelationRequest.AddRelation(jobject);
             }
 
         }

+ 3 - 15
MBI/SAGA.GplotManage/RelationManager/SpaceRelationUploader.cs

@@ -28,7 +28,7 @@ namespace SAGA.GplotManage
             List<GraphRelationItem> items = new List<GraphRelationItem>();
             SpaceData spaces = loadData as SpaceData;
             if (spaces == null) return items ;
-            spaces = GetSpaceData(spaces, GetRelatedEnum());
+            spaces = SpaceComputerDataUtil.GetSpaceDataByType(spaces, GetRelatedEnum());
             foreach (var floorSpaceData in spaces.FloorDatas)
             {
                 foreach (var space in floorSpaceData.EndPoints)
@@ -38,12 +38,12 @@ namespace SAGA.GplotManage
                     foreach (var adjacentSpace in relationSpaces)
                     {
                         GraphRelationItem item = new GraphRelationItem();
-                        item.FromId = space.Id;
+                        item.FromId = space.PlatformId;
                         if (string.IsNullOrWhiteSpace(item.FromId))
                         {
                             continue;
                         }
-                        item.ToId = adjacentSpace.Space.Id;
+                        item.ToId = adjacentSpace.Space.PlatformId;
                         if(string.IsNullOrWhiteSpace(item.ToId))
                         {
                             continue;
@@ -80,18 +80,6 @@ namespace SAGA.GplotManage
             }
             return SpaceRelatedEnum.Adjacent; 
             #endregion
-        }
-        public  SpaceData GetSpaceData(SpaceData spaces,SpaceRelatedEnum spaceRelated)
-        {
-            foreach (var fd in spaces.FloorDatas)
-            {
-                foreach (var space in fd.EndPoints)
-                {
-                    space.AdjacentSpaces = space.AdjacentSpaces.Where(s=>s.RelatedEnum.HasFlag(spaceRelated)).ToList();
-                    space.UpElements = space.UpElements.Where(s => s.RelatedEnum.HasFlag(spaceRelated)).ToList();
-                }
-            }
-            return spaces;
         }    
         #endregion
     }

+ 2 - 0
MBI/SAGA.GplotManage/RelationManager/SystemRelationUploader.cs

@@ -17,6 +17,7 @@ namespace SAGA.GplotManage
         protected override object GetDefaultUploadData()
         {
             LoadRelationData data = new LoadRelationData(RelationType);
+            data.LoadData();
             return data;
         }
 
@@ -44,6 +45,7 @@ namespace SAGA.GplotManage
                     continue;
                 }
                 item.RelType = originItem.rel_type;
+                items.Add(item);
             }
             return items;
         }

+ 2 - 2
MBI/SAGA.GplotManage/RelationManager/WinComputeRelations.xaml

@@ -29,11 +29,11 @@
                                     <Border Width="150">
                                         <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}"  HorizontalAlignment="Stretch">
                                             <CheckBox.Content>
-                                                <TextBlock TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Uploader.Display}"></TextBlock>
+                                                <TextBlock TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Text="{Binding Uploader.RelationDisplay}"></TextBlock>
                                             </CheckBox.Content>
                                         </CheckBox>
                                         <Border.ToolTip>
-                                            <TextBlock TextWrapping="Wrap" Text="{Binding Uploader.Display}"></TextBlock>
+                                            <TextBlock TextWrapping="Wrap" Text="{Binding Uploader.RelationDisplay}"></TextBlock>
                                         </Border.ToolTip>
                                     </Border>
                                 </ControlTemplate>

+ 1 - 0
MBI/SAGA.GplotManage/RelationManager/WinComputeRelations.xaml.cs

@@ -106,6 +106,7 @@ namespace SAGA.GplotManage.RelationManager
                 RelationDataManager.ComputerRelations(relationUploaders, !IsReCompute);
             }
             #endregion
+            MessageBox.Show("操作完成");
         }
 
         private void Close_Click(object sender, RoutedEventArgs e)

+ 11 - 3
MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs

@@ -91,7 +91,15 @@ namespace SAGA.GplotManage
             #endregion
             var roomItems = machineRoomData.SelectMany(c => c.RelationItems).ToList();
             var sourceGraph = CreateGraph(verticalNodes, roomItems);
-            //连接类型,以机房端类型为基准
+            //连接类型,以机房端类型为基准;
+            #region 描述
+            /*
+             * 处理数据结构两种:
+             * 源----》特殊阀门(断开点)---》端
+             * 源----》特殊阀门(断开点)---》立管----》端
+             * 根据立管数据,在机房里找到机房设备数据,在平面找到平面数据
+             */
+            #endregion
             #region 机房和平面关联
             foreach (var verticalNode in verticalNodes)
             {
@@ -189,7 +197,7 @@ namespace SAGA.GplotManage
                 {
                     if (replaceStart != null && replaceEnd != null)
                         break;
-                    var currentVertical = verticalNodes[i];
+                    var currentVertical = verticalNodes[j];
                     if (currentVertical.Instance.RelationItems.Contains(startId))
                     {
                         replaceStart = currentVertical.Flag;                                        
@@ -201,7 +209,7 @@ namespace SAGA.GplotManage
                     graph.AddVertex(new SimpleVertex<object>(currentVertical.Instance) { Id = currentVertical.Flag });
                 }
                 replaceStart = replaceStart ?? startId;
-                replaceEnd = replaceEnd ?? startId;
+                replaceEnd = replaceEnd ?? endId;
                 if (!string.IsNullOrWhiteSpace(replaceStart) && !string.IsNullOrWhiteSpace(replaceEnd))
                 {
                     SimpleEdge<object> edge = new SimpleEdge<object>(replaceStart, replaceEnd);

+ 1 - 1
MBI/SAGA.GplotManage/UploadRelated/ChillWaterLoop.cs

@@ -28,7 +28,7 @@ namespace SAGA.GplotManage.UploadRelated
 
         public override void Computer()
         {
-            ComputerPipes.Computer();
+            //ComputerPipes.Computer();
         }
         [CheckAndKeepGplotLaster]
         public override void Show(GplotShowType showType = GplotShowType.Default)

+ 1 - 1
MBI/SAGA.GplotManage/UploadRelated/CoolingWaterLoop.cs

@@ -121,7 +121,7 @@ namespace SAGA.GplotManage.UploadRelated {
 
         public override void Computer()
         {
-            ComputerPipes.Computer();
+            //ComputerPipes.Computer();
         }
         [CheckAndKeepGplotLaster]
         public override void Show(GplotShowType showType = GplotShowType.Default)

+ 5 - 17
MBI/SAGA.GplotManage/UploadRelated/ElementSpNeighborhood.cs

@@ -30,10 +30,7 @@ namespace SAGA.GplotManage.UploadRelated
         }
         [CheckAndKeepGplotLaster]
         public override void Show(GplotShowType showType)
-        {
-            
-            if (true||showType == GplotShowType.ViewPlan)
-            {
+        {                   
                 var win = new WinDrawSpace_Web(showType);// 
                 win.ComputerAction += () => ExecuteCmd.ExecuteCommand(() =>
                 {
@@ -41,22 +38,13 @@ namespace SAGA.GplotManage.UploadRelated
                     return Result.Succeeded;
                 });
                 win.Show();
-            }
-            else
-            {
-                var win = new WinDrawSpace(showType);
-                win.ComputerAction += () => ExecuteCmd.ExecuteCommand(() =>
-                {
-                    Computer();
-                    return Result.Succeeded;
-                });
-                win.Show();
-            }
+        
+            
         }
         [CheckAndKeepGplotLaster]
         protected override void DealUploadData()
         {
-            var spaces = DrawDataServer.GetSpaceData(SpaceRelatedEnum.All);
+            var spaces = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Adjacent);
             foreach (var spacesFloorData in spaces.FloorDatas)
             {
                 foreach (var space in spacesFloorData.EndPoints)
@@ -75,7 +63,7 @@ namespace SAGA.GplotManage.UploadRelated
         {
             switch (sre)
             {
-                case SpaceRelatedEnum.All:
+                case SpaceRelatedEnum.Adjacent:
                     return SpaceRelationType.Throught;//虚拟墙
                 case SpaceRelatedEnum.Radiation | SpaceRelatedEnum.Ventilation:
                     return SpaceRelationType.Window;//窗

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/RelationBll/GraphRelationItem.cs

@@ -15,7 +15,7 @@ namespace SAGA.GplotRelationComputerManage
         public string ToId { get; set; }
         [JsonProperty("graph_id")]
         public string GraphId { get; set; }
-
+        [JsonIgnore]
         public bool IsValid
         {
             get

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

@@ -107,7 +107,6 @@
     <Compile Include="Common\MBIInfoUtil.cs" />
     <Compile Include="Common\PointConverter.cs" />
     <Compile Include="Common\StorageEnum.cs" />
-    <Compile Include="ComputerPipes.cs" />
     <Compile Include="ComputerVerticalPipe.cs" />
     <Compile Include="ComputerWalls\ComputerWallsData.cs" />
     <Compile Include="ComputerWalls\LogicWall.cs" />
@@ -134,8 +133,6 @@
     <Compile Include="PowerDistribution\ComputerHandler\EquipPowerRelationshipHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\IElectricalRelationHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\ObjectControlRelationshipHandler.cs" />
-    <Compile Include="PumpEnd\DrawEnd.cs" />
-    <Compile Include="PumpEnd\DuctTerminalBll.cs" />
     <Compile Include="ReadSpaceCommand.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RelationBll\GraphInstance.cs" />

+ 5 - 4
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/FloorSpaceItems.cs

@@ -14,6 +14,7 @@ using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
 using FWindSoft.Data;
 using SAGA.DotNetUtils.Extend;
+using SAGA.MBI.Common;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Model;
 using SAGA.Models;
@@ -105,7 +106,7 @@ namespace SAGA.GplotRelationComputerManage
                         return "-1";
                     return host.Id.IntegerValue.ToString();
                 }).ToDictionary(g => g.Key, g => g.ToList());
-                Spaces = doc.GetElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().Where(s=>s.Area>0.001).ToList();
+                Spaces = doc.GetUseSpaces();
                 ComputerSpaceItems = Spaces.Select(s => new ComputerSpaceItem(s)).ToList();            
                 m_IsInited = true;
             }          
@@ -162,10 +163,10 @@ namespace SAGA.GplotRelationComputerManage
             };
             m_SaveSpaces.Values.ToList().ForEach(s => floorData.EndPoints.Add(s));
             //获取标高名称,并按高度排序
-            List<string> levelNames = levels.OrderBy(t => t.Elevation).Where(t => Regex.IsMatch(t.Name, "[F|B]")).Select(t => t.Name.Replace("-saga", "")).ToList();
-            DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>() { floorData }, levelNames);
+            //List<string> levelNames = levels.OrderBy(t => t.Elevation).Where(t => Regex.IsMatch(t.Name, "[F|B]")).Select(t => t.Name.Replace("-saga", "")).ToList();
+            //DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>() { floorData }, levelNames);
             context.SpaceComputeData.FloorDatas.Add(floorData);
-            context.SpaceComputeData.Levels.Add(new LevelData(){Name=levelName,Elevation= elevation });
+            context.SpaceComputeData.Levels.Add(new LevelData(){Name= floorData.LevelName, Elevation= elevation });
 
             #endregion
         }

+ 2 - 1
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerContext.cs

@@ -79,6 +79,7 @@ namespace SAGA.GplotRelationComputerManage
                 var display = roomItem.LocalName;
                 useSpace.Name = string.IsNullOrEmpty(display) ? space.Name : display;
                 useSpace.RoomFuncType = roomItem.RoomFuncType;
+                useSpace.PlatformId = roomItem.Id;
             }
             return useSpace;
         }
@@ -144,7 +145,7 @@ namespace SAGA.GplotRelationComputerManage
             spaceData.LevelNames = levelNames;
             SpaceComputerDataUtil.SaveData(spaceData);
             //暂时放开,全部更新完了要删除
-            DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>(spaceData.FloorDatas) , spaceData.LevelNames);
+            //DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>(spaceData.FloorDatas) , spaceData.LevelNames);
         }
     }
 }

+ 7 - 20
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerDataUtil.cs

@@ -71,30 +71,17 @@ namespace SAGA.GplotRelationComputerManage
         public static SpaceData GetSpaceDataByType(SpaceData sourceSpaceData, SpaceRelatedEnum spaceRelated)
         {
             //每次读取都是新的数据源
-            SpaceData dn = sourceSpaceData;
-            if (dn == null) return default(SpaceData);
-
-            bool Predicate(AdjacentSpace se)
-            {
-                if (se is AdjacentSpace space)
-                {
-                    return (space.RelatedEnum & spaceRelated) != 0;
-                }
-                return false;
-            }
-            foreach (var fd in dn.FloorDatas)
+            SpaceData spaces = sourceSpaceData;
+            if (spaces == null) return null;
+            foreach (var fd in spaces.FloorDatas)
             {
-                foreach (var sgElement in fd.EndPoints)
+                foreach (var space in fd.EndPoints)
                 {
-                    if (sgElement is SgSpace space)
-                    {
-                        space.AdjacentSpaces = space.AdjacentSpaces.Where(Predicate).ToList();
-                        //垂直空间也处理
-                        space.UpElements = space.UpElements.Where(Predicate).ToList();
-                    }
+                    space.AdjacentSpaces = space.AdjacentSpaces.Where(s => s.RelatedEnum.HasFlag(spaceRelated)).ToList();
+                    space.UpElements = space.UpElements.Where(s => s.RelatedEnum.HasFlag(spaceRelated)).ToList();
                 }
             }
-            return dn;
+            return spaces;         
         } 
         #endregion
     }

+ 12 - 2
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs

@@ -54,11 +54,21 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         public void ComputerWidthCache()
         {
-            bool hasCache = SpaceComputerDataUtil.IsReCompute();
-            if (!hasCache)
+            bool isReCoumpute = SpaceComputerDataUtil.IsReCompute();
+            if (isReCoumpute)
             {
                 Computer();
             }
         }
+
+        /// <summary>
+        /// 计算空间空间关系
+        /// </summary>
+        public static void ComputerAllRelations()
+        {
+            SpaceComputerHandler handler1 = new SpaceComputerHandler();
+            handler1.ComputerWidthCache();
+        }
+
     }
 }

+ 3 - 2
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerManager.cs

@@ -22,7 +22,7 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     public class SpaceComputerManager
     {
-        private readonly static List<string> m_UpSpaceFunTypes = new List<string>() {"140"};// new List<string>() { "140","150","1A0","1B0" };
+        private readonly static List<string> m_UpSpaceFunTypes =  new List<string>() { "140","150","1A0","1B0" };//new List<string>() {"140"};//
      /// <summary>
      /// 获取计算上下关系的空间类型
      /// </summary>
@@ -53,10 +53,11 @@ namespace SAGA.GplotRelationComputerManage
                 return result;         
             if (type.HasFlag(AdjanceElementType.Wall))
             {
+                result = result | SpaceRelatedEnum.Adjacent;
             }
             if (type.HasFlag(AdjanceElementType.VirtualWall))
             {
-                result = result | SpaceRelatedEnum.All;
+                result = result | SpaceRelatedEnum.Adjacent | SpaceRelatedEnum.Crossing | SpaceRelatedEnum.Ventilation | SpaceRelatedEnum.Radiation;
             }
             if (type.HasFlag(AdjanceElementType.Door))
             {

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

@@ -177,12 +177,12 @@ namespace SAGA.GplotRelationComputerManage
                             continue;
                         }
                     }
-                    //useIds的控制:跳出时,直接加入UseIds。继续遍历的,在遍历函数中加入
-                    etn.AddChild(currentNode);
+                    //useIds的控制:跳出时,直接加入UseIds。继续遍历的,在遍历函数中加入               
                     if (useIds.Any(id => id == refElement.Id.IntegerValue))
                     {
                         continue;
                     }
+                    etn.AddChild(currentNode);
                     BuildSystemNode(currentNode, domain, useIds, endConditon);
 
                 }
@@ -364,9 +364,18 @@ namespace SAGA.GplotRelationComputerManage
                 var currentNode = loopNodes[i];
                 if (TryGetNode(currentNode.Current, out EquipmentNode outNode))
                 {
-                    foreach (var currentNodeNode in currentNode.Nodes)
+                    foreach (var childNode in currentNode.Nodes)
                     {
-                        outNode.AddChildren(ConvertEquipmentNodes(currentNodeNode));
+                        var relationNodes = ConvertEquipmentNodes(childNode);
+                        foreach (var equipmentNode in relationNodes)
+                        {
+                            if (outNode.RevitId == equipmentNode.RevitId)
+                            {
+                                continue;
+                            }
+                            outNode.AddChild(equipmentNode);
+                        }
+                        
                     }                  
                     nodes.Add(outNode);
                 }
@@ -618,11 +627,11 @@ namespace SAGA.GplotRelationComputerManage
             List<EquipmentRelation> relations = new List<EquipmentRelation>();
             foreach (var graph in graphs)
             {
+                //按有向图去查找关联信息
                 var sytemVertexes = graph.GetBootVertexs().Where(v => v.IsEquipment());
                 var currentRelation = new List<EquipmentRelation>();
                 foreach (SystemVertex vertex in sytemVertexes)
                 {
-
                     var paths = graph.GetPaths(vertex, v => v.IsEquipment());
                     foreach (var path in paths)
                     {

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

@@ -47,7 +47,12 @@ namespace SAGA.GplotRelationComputerManage
             //node.BimId = this.BimId;
             //node.RevitId = this.RevitId;
             //node.Category = this.Category;
-            return node= this.MemberwiseClone() as EquipmentNode;
+            node= this.MemberwiseClone() as EquipmentNode;
+            if (node != null)
+            {
+                node.Nodes = new List<EquipmentNode>();
+            }        
+            return node;
         }
         /// <summary>
         /// 是否是真实设备

+ 1 - 6
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -251,11 +251,6 @@ namespace SAGA.GplotRelationComputerManage
                 var useRelation = relationSetting.GetFirstMatchSystem(startNode.Flag);
                 if (useRelation == null)
                     continue;
-                //加入开始元素
-                //if (startNode.Instance.Current is FamilyInstance)
-                //{
-                //    roomStartElements.Add(startNode.Instance.Current);
-                //}
                 if (useIds.Any(id => id == startNode.Instance.Current.Id.IntegerValue))
                 {
                     continue;
@@ -343,7 +338,7 @@ namespace SAGA.GplotRelationComputerManage
                             continue;
                         }
                         useSystems.Add(systemTypeName);
-                        //创建定的startNode;[一个分支,一个分支去处理]
+                        //创建定的startNode;[一个分支,一个分支去处理]
                         ElementTreeNode newStartNode = new ElementTreeNode() {Current = useInstance};
                         var tempIds = SystemParseManager.BuildSystemNode(newStartNode, useDomain,
                             (m => !systemTypeName.Equals(m.GetSystemTypeName())));

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

@@ -50,6 +50,10 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="relationTypes"></param>
         public void Computer(List<string> relationTypes)
         {
+            if (relationTypes == null || !relationTypes.Any())
+            {
+                return;
+            }
             SystemComputerContext context = new SystemComputerContext();
             context.Relations.AddRange(relationTypes);
             Computer(context);

+ 138 - 0
MBI/SAGA.MBI/Common/PhaseUtil.cs

@@ -0,0 +1,138 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:PhaseUtil
+ * 作者:xulisong
+ * 创建时间: 2019/3/25 17:27:14
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+using SAGA.RevitUtils.Extends;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI.Common
+{
+    public static class PhaseUtil
+    {
+        public readonly static string UseablePhaseName = "阶段1";
+
+        /// <summary>
+        /// 获取系统使用的阶段Id
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <returns></returns>
+        public static ElementId GetUsePhaseId(this Document doc)
+        {
+            var phase = GetUsePhase(doc);
+            if (phase == null)
+            {
+                return ElementId.InvalidElementId;
+            }
+            return phase.Id;         
+        }
+        /// <summary>
+        /// 获取系统使用的阶段
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <returns></returns>
+        public static Phase GetUsePhase(this Document doc)
+        {
+            var elements = doc.GetElements<Phase>(BuiltInCategory.OST_Phases);
+            foreach (var element in elements)
+            {
+                var tempName = element.Name.Replace(" ", "").Trim();
+                if (UseablePhaseName == tempName)
+                {
+                    return element;
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 获取视图的阶段Id
+        /// </summary>
+        /// <param name="view"></param>
+        /// <returns></returns>
+        public static ElementId GetUsePhaseId(this View view)
+        {
+            var doc = view.Document;
+            //Parameter para = view.GetParameter(BuiltInParameter.VIEW_PHASE);
+            //ElementId phaseId = para.AsElementId();
+            return GetUsePhaseId(doc); ;
+        }
+        /// <summary>
+        /// 获取视图使用的阶段
+        /// </summary>
+        /// <param name="view"></param>
+        /// <returns></returns>
+        public static Phase GetUsePhase(this View view)
+        {
+            var doc = view.Document;
+            return doc.GetElement(GetUsePhaseId(view)) as Phase;
+        }
+
+        public static void ValidateUsePhase(Phase phase)
+        {
+            if (phase == null)
+            {
+                throw new Exception("操纵视图不存在,名称为“阶段1”的选项");
+            }
+        }
+
+        public static ElementId GetCurrentPhaseId(this Space space)
+        {
+            return space.GetParameterElementId(BuiltInParameter.ROOM_PHASE_ID)??ElementId.InvalidElementId;
+        }
+        /// <summary>
+        /// 获取系统指定阶段下的空间模型
+        /// </summary>
+        /// <param name="doc"></param>
+        /// <returns></returns>
+        public static List<Space> GetUseSpaces(this Document doc)
+        {
+            var useId = GetUsePhaseId(doc);
+            if (useId == null || useId == ElementId.InvalidElementId)
+            {
+                return new List<Space>();
+            }
+            var spaces = doc.GetElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>();
+            return spaces.Where(s => s.GetCurrentPhaseId() == useId&& s.Area > 0.001).ToList();
+        }
+        /// <summary>
+        /// 获取系统指定阶段下的空间模型
+        /// </summary>
+        /// <param name="collector"></param>
+        /// <returns></returns>
+        public static List<Space> GetUseSpaces(this FilteredElementCollector collector)
+        {
+            var sourceSpaces=collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().ToList();
+            if (!sourceSpaces.Any())
+            {
+                return sourceSpaces;
+            }
+            var doc = sourceSpaces[0].Document;
+            var useId = GetUsePhaseId(doc);
+            if (useId == null || useId == ElementId.InvalidElementId)
+            {
+                return new List<Space>();
+            }
+            return sourceSpaces.Where(s => s.GetCurrentPhaseId() == useId && s.Area > 0.001).ToList();
+        }
+        /// <summary>
+        /// 判断是否是阶段1的空间
+        /// </summary>
+        /// <param name="space"></param>
+        /// <returns></returns>
+        public static bool IsPhase1Space(this Space space)
+        {
+            var doc = space.Document;
+            var useId = GetUsePhaseId(doc);
+            return space.GetCurrentPhaseId() == useId;
+        }
+    }
+}

+ 2 - 0
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -83,6 +83,8 @@ namespace SAGA.MBI.Tools
             {
                 //空间比较特殊,周长为零就相当于删除
                 isspace = !ischeckzero || !(space.IsDeleteSpace());
+                //限制所用空间的阶段
+                //isspace = isspace && space.IsPhase1Space();
             }
 
             return isspace;

+ 3 - 0
MBI/SAGA.MBI/Interaction/MBIModelInfoManager.cs

@@ -12,6 +12,9 @@ using SAGA.MBI.RevitModelHandle;
 
 namespace SAGA.MBI.Interaction
 {
+    /*
+     * 同步暂时不取不限定操作数据,因为现阶段这部分只是使用信息,不产生新的信息
+     */
     /// <summary>
     /// MBI模型信息管理
     /// </summary>

+ 3 - 5
MBI/SAGA.MBI/RevitExport/ExportData.cs

@@ -1,10 +1,8 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using Autodesk.Revit.DB;
-using DevExpress.Data.Helpers;
+using SAGA.MBI.Common;
 using SAGA.RevitUtils.Extends;
 
 namespace SAGA.MBI.RevitExport
@@ -61,8 +59,8 @@ namespace SAGA.MBI.RevitExport
             data.All = new List<RevitElementWrapper>();
             data.Walls.AddRange(collector.Clone().FilterElements<Wall>().Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Wall }));
             data.VirtualWalls.AddRange(collector.Clone().FilterElements<CurveElement>(BuiltInCategory.OST_MEPSpaceSeparationLines).Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.VirtualWall }));
-            data.Spaces.AddRange(collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Space }));
-
+           // data.Spaces.AddRange(collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Space }));
+            data.Spaces.AddRange(collector.Clone().GetUseSpaces().Select(e => new RevitElementWrapper(e) { Category = MbiElementCategory.Space }));
             var familyInstances = collector.Clone().FilterElements<FamilyInstance>();
             foreach (FamilyInstance familyInstance in familyInstances)
             {

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

@@ -293,6 +293,7 @@
     <Compile Include="Common\CacheAspect.cs" />
     <Compile Include="Common\EquipmentCodeMap.cs" />
     <Compile Include="Common\MailLog.cs" />
+    <Compile Include="Common\PhaseUtil.cs" />
     <Compile Include="Common\WaitingView.cs" />
     <Compile Include="DataArrange\DalInfoCode.cs" />
     <Compile Include="Html5Command.cs" />

+ 5 - 5
MBI/SAGA.MBI/WinView/Space/SpaceManager.cs

@@ -127,10 +127,9 @@ namespace SAGA.MBI.WinView
             var view = doc.GetUseView();
             if (view != null)
             {
-                var level = view.GenLevel;
-                Parameter para = view.GetParameter(BuiltInParameter.VIEW_PHASE);
-                ElementId phaseId = para.AsElementId();
-                var phase = doc.GetElement(phaseId) as Phase;
+                var level = view.GenLevel;             
+                var phase = view.GetUsePhase();
+                PhaseUtil.ValidateUsePhase(phase);
                 #region 创建新的节点
                 List<XYZ> points = new List<XYZ>();
                 using (SubTransaction sub = new SubTransaction(doc))
@@ -333,7 +332,8 @@ namespace SAGA.MBI.WinView
                     }
                     //创建新的空间
                     var view = doc.GetUseView();
-                    Phase phase = view.GetParameterElement(BuiltInParameter.VIEW_PHASE) as Phase;
+                    Phase phase = view.GetUsePhase();
+                    PhaseUtil.ValidateUsePhase(phase);
                     foreach (var newSpaceLocation in newSpaceLocations)
                     {
                         var space = ExternalDataWrapper.Current.DocCreater.NewSpace(view.GenLevel, phase,newSpaceLocation);

+ 1 - 1
MBI/SAGA.Models/LogicNode.cs

@@ -256,7 +256,7 @@ namespace SAGA.Models {
         [JsonProperty]
         public string Name { get; set; }
         [JsonProperty]
-        public List<T> Nodes { get; private set; }
+        public List<T> Nodes { get; protected set; }
         [JsonIgnore]
         public T Parent { get; set; }
 

+ 7 - 0
MBI/SAGA.Models/SgElement.cs

@@ -33,5 +33,12 @@ namespace SAGA.Models {
             this.Id = id;
             this.Name = name;
         }
+
+        #region 数据平台Id
+        /// <summary>
+        /// 平台Id
+        /// </summary>
+        public string PlatformId { get; set; }
+        #endregion
     }
 }

+ 1 - 1
MBI/SAGA.Models/SgSpace.cs

@@ -68,7 +68,7 @@ namespace SAGA.Models
         /// <summary>
         /// 所有关系
         /// </summary>
-        All = 15
+       // All = 15
     }
 
 }