Bläddra i källkod

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

mengxiangge 6 år sedan
förälder
incheckning
36b8301a57
24 ändrade filer med 270 tillägg och 380 borttagningar
  1. 14 5
      MBI/SAGA.DotNetUtils/NPOI/WorkbookExtension.cs
  2. 4 5
      MBI/SAGA.GplotDrawData/DBView/VirticalSpaceGraphView.cs
  3. 0 1
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  4. 95 97
      MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs
  5. 1 35
      MBI/SAGA.GplotManage/GplotCommand.cs
  6. 15 0
      MBI/SAGA.GplotManage/RelationManager/RelationDataManager.cs
  7. 0 15
      MBI/SAGA.GplotManage/SAGA.GplotManage.csproj
  8. 8 17
      MBI/SAGA.GplotManage/TopologyApplication/SearchShaft/SearchShaftHandler.cs
  9. 34 4
      MBI/SAGA.GplotManage/TopologyApplicationCommand.cs
  10. 21 2
      MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs
  11. 0 87
      MBI/SAGA.GplotRelationComputerManage/ComputerVerticalPipe.cs
  12. 1 1
      MBI/SAGA.GplotRelationComputerManage/DataServer/DataServer.cs
  13. 2 12
      MBI/SAGA.GplotRelationComputerManage/RevitModelPath.cs
  14. 0 3
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  15. 12 4
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/FloorSpaceItems.cs
  16. 3 5
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerContext.cs
  17. 13 1
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs
  18. 3 36
      MBI/SAGA.MBI/Gplot/GplotFilesUpload.cs
  19. 25 46
      MBI/SAGA.Models/AcWater.cs
  20. 1 1
      MBI/SAGA.Models/DataNode.cs
  21. 0 2
      MBI/SAGA.Models/SAGA.Models.csproj
  22. 5 0
      MBI/SAGA.RevitUtils/Extends/CurveExtend.cs
  23. 6 1
      MBI/SAGA.RevitUtils/Extends/ElementExtend.cs
  24. 7 0
      MBI/SAGA.RevitUtils/Extends/LocationExtend.cs

+ 14 - 5
MBI/SAGA.DotNetUtils/NPOI/WorkbookExtension.cs

@@ -35,10 +35,10 @@ namespace SAGA.DotNetUtils.NPOI
                 {
                     book.Close();
                 }
-                var directory = Path.GetDirectoryName(filePath);
-                if (!Directory.Exists(directory))
+                var directory = Directory.GetParent(filePath);
+                if (!directory.Exists)
                 {
-                    Directory.CreateDirectory(directory);
+                    directory.Create();
                 }
                 using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write))
                 {
@@ -60,8 +60,17 @@ namespace SAGA.DotNetUtils.NPOI
         {
             return Save(book, filePath, true);
         }
-
-
+        /// <summary>
+        /// 获取sheet,存在返回,没有创建
+        /// </summary>
+        /// <param name="book"></param>
+        /// <param name="sheetName"></param>
+        /// <returns></returns>
+        public static ISheet GetSheet2(this IWorkbook book, string sheetName)
+        {
+           return book.GetSheet(sheetName) ?? book.CreateSheet("sheetName");
+        }
+      
         public static ICell SetCellValue(this ISheet sheet,int rowIndex, int columnIndex, object value)
         {
             #region 获取可用的Cell

+ 4 - 5
MBI/SAGA.GplotDrawData/DBView/VirticalSpaceGraphView.cs

@@ -9,18 +9,17 @@ using System.Windows.Media;
 
 namespace SAGA.GplotDrawData
 {
-    public class VirticalSpaceGraphView : GraphDBView<SpaceData>
+    public class VirticalSpaceGraphView : GraphDBView<BuildingItem>
     {
         /// <summary>
         /// 空间类型
         /// </summary>
         public string SpaceType { get; set; }
-        public override GraphDB AppendDb(SpaceData td, GraphDB db)
+        public override GraphDB AppendDb(BuildingItem build, GraphDB db)
         {
             if (SpaceType == null)
                 return db;
-
-            var levels = td.LevelNames;
+            var levels = build.Levels;
             List<VFloor> floors = new List<VFloor>();
             List<string> handledSpaces = new List<string>();//已经处理过的空间Id
             List<SpaceGroup> spaceGroups = new List<SpaceGroup>();
@@ -39,7 +38,7 @@ namespace SAGA.GplotDrawData
                 floors.Add(tempFloor); 
                 #endregion
 
-                var floorData= td.FloorDatas.FirstOrDefault(t => t.LevelName == levels[i]);
+                var floorData= build.FloorDataItems.FirstOrDefault(t => t.LevelName == levels[i]);
                 if (floorData == null)
                     continue;
                 var currentSpaces = floorData.EndPoints.Where(t =>!string.IsNullOrEmpty(t.RoomFuncType)&&MatchType(t.RoomFuncType)).ToList();

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

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

+ 95 - 97
MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs

@@ -1,25 +1,10 @@
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-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
 {
@@ -28,38 +13,31 @@ namespace SAGA.GplotDrawData
     /// </summary>
     public partial class WinDrawSpace_Web : Window
     {
+        public GplotShowType ShowType{ get; private set; }
         public WinDrawSpace_Web()
         {
             InitializeComponent();
-            Vertex.SetRadius(6, 6);
-        }
-
-        private GplotShowType m_showType;
+        } 
         public WinDrawSpace_Web(GplotShowType showType) : this()
         {
-
-            this.m_showType = showType;
+            this.ShowType = showType;
             this.Loaded += WinDrawWaterNode_Loaded;
         }
-        private bool IsRead = true;
-
         private void WinDrawWaterNode_Loaded(object sender, RoutedEventArgs e)
         {
             try
             {
-                if (m_showType == GplotShowType.VerticalPlan)
+                if (ShowType == GplotShowType.VerticalPlan)
                 {
                     InitVerticalSpaces();
                 }
                 else
                 {
-                    var node = GetSpaceData();
-                    this.rootNode.ItemsSource = new List<DataNode>() { node };
+                    InitHSpaceTree();                  
                 }
             }
             catch (Exception ex)
             {
-
                 DotNetUtils.Others.MessageShowBase.Show(ex);
             }
         }
@@ -67,12 +45,10 @@ namespace SAGA.GplotDrawData
         /// <summary>
         /// 立面空间相关数据源
         /// </summary>
-        private SpaceData VerticalSpaces { get; set; }
         public void InitVerticalSpaces()
         {
-            var spaceDatas = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);// DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
-            this.VerticalSpaces = spaceDatas;
-            InitVSpaceTree();
+            var spaceData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);
+            InitVSpaceTree(spaceData.FloorDatas);
         }
         /// <summary>
         /// 绘制立面空间
@@ -81,33 +57,54 @@ namespace SAGA.GplotDrawData
         {
             if (node == null)
                 return;
-            var spaceDatas = VerticalSpaces;
             VirticalSpaceGraphView view = new VirticalSpaceGraphView();
             view.SpaceType = node.Sno;
-            var db = view.CreateDb(spaceDatas);
+            var db = view.CreateDb(node.GetData<BuildingItem>());
             ConstData.ResponseData = db.CreateJObjectGroup();
             ucShowElement.Show(WebGplotSettings.VSpaceUrl);
         }
-        public void InitVSpaceTree()
+        public void InitVSpaceTree(List<FloorSpaceData> floorItems)
         {
-            List<DataNode> dataNode = new List<DataNode>();
-          
-            dataNode.Add(new DataNode() { EName = "楼梯间",Sno="140" });
-            dataNode.Add(new DataNode() { EName = "中庭", Sno = "150" });
-            dataNode.Add(new DataNode() { EName = "竖井", Sno = "1B0" });
-            dataNode.Add(new DataNode() { EName = "其他公共区域", Sno = "1A0" });
-            this.rootNode.ItemsSource = dataNode;
-        }  
+            List<DataNode> treeData = new List<DataNode>();
+            var buildGroup = floorItems.GroupBy(f => f.BuildingId);
+            foreach (var build in buildGroup)
+            {
+                var tempFloors = build.ToList();
+                var firstFloor = tempFloors.FirstOrDefault();
+                if (firstFloor == null)
+                {
+                    continue;
+                }
+                BuildingItem buildItem = new BuildingItem();
+                buildItem.Id = firstFloor.BuildingId;
+                buildItem.Name = firstFloor.BuildingName;
+                buildItem.FloorDataItems.AddRange(tempFloors);
+                var items = tempFloors.Select(f => f.LevelName).ToList();
+                //items.Reverse();
+                buildItem.Levels.AddRange(items);
+                var buildNode = new DataNode() {EName = firstFloor.BuildingName, Sno = firstFloor.BuildingId};
+                buildNode.Childrens.Add(new DataNode() { EName = "楼梯间", Sno = "140" });
+                buildNode.Childrens.Add(new DataNode() { EName = "中庭", Sno = "150" });
+                buildNode.Childrens.Add(new DataNode() { EName = "竖井", Sno = "1B0" });
+                buildNode.Childrens.Add(new DataNode() { EName = "其他公共区域", Sno = "1A0" });
+                buildNode.Childrens.ForEach(dn => dn.SetData(buildItem));
+                treeData.Add(buildNode);
+            }
+            this.rootNode.ItemsSource = treeData;
+        }       
         #endregion
 
         private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
         {
             if (rootNode.SelectedItem is DataNode ln)
             {
-                if (m_showType == GplotShowType.ViewPlan)
+                if (ln.Childrens.Count != 0)
+                {
+                    return;
+                }
+                if (ShowType == GplotShowType.ViewPlan)
                 {
-                    if (ln.GetData<FloorSpaceData>() is FloorSpaceData fd)
-                        Draw(fd);
+                     Draw(ln);
                 }
                 else
                 {
@@ -117,66 +114,67 @@ namespace SAGA.GplotDrawData
             }
         }
 
-        void Draw(FloorSpaceData fd)
+        #region 平面处理
+        private void Draw(DataNode dataNode)
         {
+            var fd = dataNode.GetData<FloorSpaceData>();
+            if (fd == null)
+            {
+                MessageBox.Show("楼层数据不存在");
+                return;
+            }
             SpaceGraphView view = new SpaceGraphView();
             var db = view.CreateDb(fd);
             ConstData.ResponseData = db.CreateJObjectGroup();
-            ucShowElement.Show(WebGplotSettings.GplotUrl);    
+            ucShowElement.Show(WebGplotSettings.GplotUrl);
         }
-
-
-        private DataNode GetSpaceData()
+        private void InitHSpaceTree()
         {
-            var aData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Adjacent);
-            var tData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);
-
-            var vData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Ventilation);
-            var rData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Radiation);
-            DataNode root = new DataNode("空间关系");
-            DataNode a = new DataNode("空间临接关系")
+            /*
+             * 层级结构:(建筑名称--空间关系)--四种关系--楼层
+             */
+            var buildNodes = new List<DataNode>();
+            Dictionary<SpaceRelatedEnum, string> seeds = new Dictionary<SpaceRelatedEnum, string>();
+            seeds[SpaceRelatedEnum.Adjacent] = "空间临接关系";
+            seeds[SpaceRelatedEnum.Crossing] = "建筑交通关系";
+            seeds[SpaceRelatedEnum.Ventilation] = "空气流通关系";
+            seeds[SpaceRelatedEnum.Radiation] = "光照辐射关系";
+            foreach (var seed in seeds)
             {
-                Childrens = aData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
+                var spaceDatas = SpaceComputerDataUtil.GetSpaceDataByType(seed.Key);
+                var floorItems = spaceDatas.FloorDatas;
+                var buildGroup = floorItems.GroupBy(f => f.BuildingId);
+                foreach (var build in buildGroup)
                 {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
+                    var buildFloors = build.ToList();
+                    var firstFloor = buildFloors.FirstOrDefault();
+                    if (firstFloor == null)
+                    {
+                        continue;
+                    }
 
-            DataNode t = new DataNode("建筑交通关系")
-            {
-                Childrens = tData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            DataNode v = new DataNode("空气流通关系")
-            {
-                Childrens = vData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            DataNode r = new DataNode("光照辐射关系")
-            {
-                Childrens = rData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            root.Childrens.AddRange(new List<DataNode>() { a, t, v, r });
-            return root;
-        }   
-        /// <summary>
-        /// 外部命令启动计算
-        /// </summary>
-        public Action ComputerAction;      
+                    #region 检测建筑节点
+                    var buildNode = buildNodes.FirstOrDefault(dn => dn.Sno == build.Key);
+                    if (buildNode == null)
+                    {
+                        buildNode = new DataNode() { EName = $"[{firstFloor.BuildingName}]--空间关系", Sno = firstFloor.BuildingId };
+                        buildNodes.Add(buildNode);
+                    }
+                    #endregion
+                    DataNode relationNode = new DataNode(seed.Value)
+                    {
+                        Childrens = buildFloors.Reverse<FloorSpaceData>().Select(f =>
+                        {
+                            var floorNode = new DataNode(f.Name);
+                            floorNode.SetData(f);
+                            return floorNode;
+                        }).ToList()
+                    };
+                    buildNode?.Childrens.Add(relationNode);
+                }
+            }
+            this.rootNode.ItemsSource = buildNodes;
+        }       
+        #endregion
     }
 }

+ 1 - 35
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -160,44 +160,10 @@ 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();
-
-            //}
             WinComputeRelations win = new WinComputeRelations();
             win.ShowDialog();
             return Result.Succeeded;
-        }
-        private string ConvertJsonString(object object1)
-        {
-            //格式化json字符串
-            JsonSerializer serializer = new JsonSerializer();
-
-            if (object1 != null)
-            {
-                StringWriter textWriter = new StringWriter();
-                JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
-                {
-                    Formatting = Formatting.Indented,
-                    Indentation = 4,
-                    IndentChar = ' '
-                };
-                serializer.Serialize(jsonWriter, object1);
-                return textWriter.ToString();
-            }
-            else
-            {
-                return "";
-            }
-        }
+        }    
         public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
             return true;

+ 15 - 0
MBI/SAGA.GplotManage/RelationManager/RelationDataManager.cs

@@ -32,6 +32,15 @@ namespace SAGA.GplotManage
             }
             return uploaders;
         }
+        /// <summary>
+        /// 获取所有使用uploader
+        /// </summary>
+        /// <returns></returns>
+        public static RelationUploader GetUploader(string graphType)
+        {
+            var items = GetAllUploaders();
+            return items.FirstOrDefault(up => up.RelationType == graphType);
+        }
         public static void ComputerRelations(List<RelationUploader> uploaders, bool useCache)
         {
             bool containSpace = false;
@@ -103,5 +112,11 @@ namespace SAGA.GplotManage
                    uploader.Upload();
             }
         }
+
+        public static void ComputerRelations(List<string> types, bool useCache)
+        {
+            var uploaders = types.Select(t => GetUploader(t));
+            ComputerRelations(uploaders.ToList(),useCache);
+        }     
     }
 }

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

@@ -99,7 +99,6 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
-    <Compile Include="CheckAndKeepGplotLaster.cs" />
     <Compile Include="Command.cs" />
     <Compile Include="Command\ColdGplot\ColdRoomSystemCompute.cs" />
     <Compile Include="Command\ColdGplot\ColdRoomSystemParse.cs" />
@@ -116,7 +115,6 @@
     <Compile Include="GplotManage\LocalDataUtil.cs" />
     <Compile Include="Command\MethodExtension.cs" />
     <Compile Include="GplotCommand.cs" />
-    <Compile Include="GplotFactory.cs" />
     <Compile Include="GplotManage\GplotClient.cs" />
     <Compile Include="GplotManage\GplotClientContext.cs" />
     <Compile Include="GplotManage\GplotCompute\GplotComputeData.cs" />
@@ -161,19 +159,6 @@
     <Compile Include="TopologyApplication\SpaceAirSupply\SpaceAirSupplyHandler.cs" />
     <Compile Include="TopologyApplication\SpaceAirSupply\SpaceAirSupplyResultItem.cs" />
     <Compile Include="TopologyApplication\TopologyApplicationUtil.cs" />
-    <Compile Include="UploadRelated\AirNetwork.cs" />
-    <Compile Include="UploadRelated\ControlRelation.cs" />
-    <Compile Include="UploadRelated\ConvectionNetwork.cs" />
-    <Compile Include="UploadRelated\EquipPower.cs" />
-    <Compile Include="UploadRelated\Gplot.cs" />
-    <Compile Include="UploadRelated\ChillWaterLoop.cs" />
-    <Compile Include="UploadRelated\CoolingWaterLoop.cs" />
-    <Compile Include="UploadRelated\LuDistribution.cs" />
-    <Compile Include="UploadRelated\NoGplot.cs" />
-    <Compile Include="UploadRelated\RadiationNetwork.cs" />
-    <Compile Include="UploadRelated\ElementSpNeighborhood.cs" />
-    <Compile Include="UploadRelated\TrafficNetwork.cs" />
-    <Compile Include="UploadRelated\WallGplot.cs" />
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 8 - 17
MBI/SAGA.GplotManage/TopologyApplication/SearchShaft/SearchShaftHandler.cs


+ 34 - 4
MBI/SAGA.GplotManage/TopologyApplicationCommand.cs

@@ -13,9 +13,11 @@ using System.Threading;
 using System.Threading.Tasks;
 using Autodesk.Revit.Attributes;
 using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
 using Autodesk.Revit.UI;
 using SAGA.DotNetUtils.Others;
 using SAGA.GplotManage.TopologyApplication;
+using SAGA.GplotRelationComputerManage;
 using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 
@@ -43,6 +45,7 @@ namespace SAGA.GplotManage
             return Result.Succeeded;
         }
     }
+
     /// <summary>
     /// 机组供电空间
     /// </summary>
@@ -54,16 +57,43 @@ namespace SAGA.GplotManage
         {
             return true;
         }
+
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             //MessageShow.Infomation(Thread.CurrentThread.ManagedThreadId.ToString());
-            if (!MessageShowBase.Confirm("确定执行所选命令"))
+            ComputerSpaceItem space1 =
+                new ComputerSpaceItem(ExternalDataWrapper.Current.Doc.GetElement(960127) as Space);
+            ComputerSpaceItem space2 =
+                new ComputerSpaceItem(ExternalDataWrapper.Current.Doc.GetElement(961500) as Space);
+            if (ClosedIntersect(space1.ZeroCurves, space2.ZeroCurves))
             {
-                return Result.Succeeded;
+
             }
-            SpaceAirSupplyHandler.ShellExecute();
-            MessageShow.Infomation("完成");
+
+            //if (!MessageShowBase.Confirm("确定执行所选命令"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            //SpaceAirSupplyHandler.ShellExecute();
+            //MessageShow.Infomation("完成");
             return Result.Succeeded;
         }
+
+        public bool ClosedIntersect(List<Curve> closed1, List<Curve> closed2)
+        {
+            //判断所有的线是否有相交
+            foreach (var curve1 in closed1)
+            {
+                if (curve1.IsIntersectPoly(closed2)) return true;
+            }
+
+            //判断是否包含
+            foreach (var curve in closed1)
+            {
+                if (curve.StartPoint().PointInPolygon(closed2)) return true;
+            }
+
+            return closed2.Any(curve => curve.StartPoint().PointInPolygon(closed1));
+        }
     }
 }

+ 21 - 2
MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs

@@ -12,6 +12,7 @@ using SAGA.MBI.Common;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.JsonConvert;
 using SAGA.MBI.Model;
+using SAGA.Models;
 
 namespace SAGA.GplotRelationComputerManage
 {
@@ -43,12 +44,12 @@ namespace SAGA.GplotRelationComputerManage
                 if (equip != null)
                 {
                     var jo = equip.CloundJObject;
-                    useName = jo.GetValueEx("EquipLocalName");
+                    useName = jo.GetValueEx(MBIBuiltInParameter.EquipLocalName);
                     if (!string.IsNullOrEmpty(useName))
                     {
                         break;
                     }
-                    useName = jo.GetValueEx("EquipName");
+                    useName = jo.GetValueEx(MBIBuiltInParameter.EquipName);
                     if (!string.IsNullOrEmpty(useName))
                     {
                         break;
@@ -183,5 +184,23 @@ namespace SAGA.GplotRelationComputerManage
             }
             return result;
         }
+
+        public static string GetBuildingName(string floorId)
+        {
+            return DalProjectTree.GetBuildingByFloor(floorId)?.LocalName;
+        }
+        public static string GetBuildingId(string floorId)
+        {
+            return DalProjectTree.GetBuildingIdByFloor(floorId);
+            
+        }
+        public static string GetProjectName(string floorId)
+        {
+            return null;
+        }
+        public static string GetProjectId(string floorId)
+        {
+            return null;
+        }
     }
 }

+ 0 - 87
MBI/SAGA.GplotRelationComputerManage/ComputerVerticalPipe.cs

@@ -84,91 +84,4 @@ namespace SAGA.GplotRelationComputerManage
         public List<VerticalPipe> VerticalPipes { get; private set; }
         public List<LevelData> Levels { get; private set; }
     }
-
-    public class ComputerVerticalPipe
-    {
-        public Document Document { get; private set; }
-        public ComputerVerticalPipe(Document document)
-        {
-            Document = document;
-        }
-        #region 修订函数
-        /// <summary>
-        /// 计算立管信息
-        /// </summary>
-        /// <param name="refLevel"></param>
-        /// <param name="pipes"></param>
-        /// <param name="context"></param>
-        public void ComputerVerticalPipes(Level refLevel, List<Pipe> pipes, PipeCalcContext context)
-        {
-            var result = new List<VerticalPipe>();
-            var spaces = Document.GetElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>();
-            foreach (var pipe in pipes)
-            {
-                if (pipe == null)
-                    continue;
-                var level = refLevel;
-                var vp = new VerticalPipe
-                {
-                    Id=pipe.Id.IntegerValue.ToString(),
-                    LevelName = level.Name.Replace("-saga", ""),
-                    LevelElevation = level.Elevation,
-                    UpPoint3D = Convert3DToWin(pipe.GetVerticalTopPoint()),
-                    DownPoint3D = Convert3DToWin(pipe.GetVerticalBottomPoint()),
-                    PipeSytemType = pipe.GetParameterString(BuiltInParameter.RBS_PIPING_SYSTEM_TYPE_PARAM)
-                };
-                //获取立管关联控件
-                var locationCurve = pipe.GetLocationCurve();
-                var midPoint = (locationCurve.StartPoint() + locationCurve.EndPoint()) / 2;
-                Space refSpace = spaces.FirstOrDefault(s => s.IsPointInSpace(midPoint));//关联
-                var display = context.GetSpaceDisplay(refSpace, out string tip);
-                vp.Display = $"{display}:{pipe.Id.IntegerValue.ToString()}";
-                vp.DisplayTip = tip ?? string.Empty;
-                result.Add(vp);
-            }
-            LevelData levelData = new LevelData()
-            {
-                Id = refLevel.Id.ToString(),
-                Name = refLevel.Name.Replace("-saga", ""),
-                Elevation = refLevel.Elevation
-            };
-            context.VerticalPipes.AddRange(result);
-            context.Levels.Add(levelData);
-        }
-
-        /// <summary>
-        /// 计算整体信息
-        /// </summary>
-        /// <param name="context"></param>
-        public static void Computer(PipeCalcContext context)
-        {
-            var verticalPipes = context.VerticalPipes;
-            if (verticalPipes == null)
-                return;
-            List<VerticalPipe> pipes = new List<VerticalPipe>(verticalPipes);
-            var levels = new List<LevelData>(context.Levels);
-            levels.Sort((l1, l2) => l1.Elevation.CompareTo(l2.Elevation));
-
-            var datas = new VerticalPipeData()
-            {
-                Datas = pipes,
-                Levels = levels
-            };
-            //保存数据到本地
-            DrawDataServer.SaveAsFile(datas);
-        }
-        #endregion
-
-
-
-        private static Point3D Convert3DToWin(XYZ xyz)
-        {
-            return new Point3D(xyz.X, xyz.Y, xyz.Z);
-        }
-
-        private static XYZ Convert3DToRevit(Point3D point)
-        {
-            return new XYZ(point.X, point.Y, point.Z);
-        }
-    }
 }

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

@@ -48,7 +48,7 @@ namespace SAGA.GplotRelationComputerManage
         public bool SaveData<T>(string fileName, T data)
         {
             IVersionFile file = CreateVersionFile(fileName);
-            var settings = new JsonSerializerSettings();
+            var settings = new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore };
             string dataStr = JsonConvert.SerializeObject(data, settings);
             ClearData(fileName);
             return file.WriteFileContent(dataStr);

+ 2 - 12
MBI/SAGA.GplotRelationComputerManage/RevitModelPath.cs

@@ -5,7 +5,6 @@ using System.Text;
 using System.Threading.Tasks;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Model;
-using SAGA.Models;
 
 namespace SAGA.GplotRelationComputerManage
 {
@@ -18,23 +17,14 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public static List<string> GetAllRevitFiles()
         {
-            var changeIds = DrawDataServer.GetData<List<string>>("ChangeFloorIds");
-            if (changeIds.Count > 0)
-            {
-                DrawDataServer.ClearData<List<string>>("ChangeFloorIds");
-                return changeIds;
-            }
             if (FilePaths.Count == 0)
-            {//TODO:有测试
+            {
                 List<string> files = new List<string>();
-                var projectFloors = DalModeFileManange.GetMissFileFloors(false);//.Where(t => t.Item.LocalName == "大师傅地方").ToList();
-
+                var projectFloors = DalModeFileManange.GetMissFileFloors(false);
                 projectFloors.ForEach((tni) => GetFilePaths(tni, files));
                 files.Reverse();
                 FilePaths = new List<string>(files);
-
             }
-
             return FilePaths;
         }
 

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

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

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

@@ -155,11 +155,15 @@ namespace SAGA.GplotRelationComputerManage
                 elevation = currLevel.Elevation;
                 levelName = currLevel.Name;
             }
+            var floorId = doc.PathName.GetFileName();
             FloorSpaceData floorData = new FloorSpaceData
             {
+                BuildingName= MBIInfoUtil.GetBuildingName(floorId),
+                BuildingId = MBIInfoUtil.GetBuildingId(floorId),
                 Name = saveName,
                 Id = id,
-                LevelName = levelName.Replace("-saga", "")
+                LevelName = levelName.Replace("-saga", ""),
+                LevelElevation= elevation,
             };
             m_SaveSpaces.Values.ToList().ForEach(s => floorData.EndPoints.Add(s));
             //获取标高名称,并按高度排序
@@ -523,11 +527,11 @@ namespace SAGA.GplotRelationComputerManage
                     }
                 }          
                 List<Curve> edgeCurves = new List<Curve>() {space1.SegEdge, space2.SegEdge};
-                if (doors.Any(d => edgeCurves.All(c => c.IsContain(c.GetProjectPt(d.GetLocationPoint())))))
+                if (doors.Any(d => d.GetLocationPoint()!=null&&edgeCurves.All(c => c.IsContain(c.GetProjectPt(d.GetLocationPoint())))))
                 {
                     result = result | AdjanceElementType.Door;
                 }
-                if (windows.Any(w => edgeCurves.All(c => c.IsContain(c.GetProjectPt(w.GetLocationPoint())))))
+                if (windows.Any(w => w.GetLocationPoint()!=null&& edgeCurves.All(c => c.IsContain(c.GetProjectPt(w.GetLocationPoint())))))
                 {
                     result = result | AdjanceElementType.Window;
                 }
@@ -566,11 +570,15 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public AdjanceElementType JudgeUpAdjancentSpace(ComputerSpaceItem aFSpace, ComputerSpaceItem bSpace)
         {
-            AdjanceElementType result = AdjanceElementType.None;
+            AdjanceElementType result = AdjanceElementType.None;         
             if (!aFSpace.Box.Intersects(bSpace.Box, 0))
             {
                 return result;
             }
+            if (aFSpace.BimId == "Fl42010500016dc07b43dcf111e8a553e7c23f5c005c:961500" && bSpace.BimId == "Fl4201050001afd0f3e3dce811e8a553f5b22da96b1b:964782")
+            {
+                MessageShow.Infomation("端点");
+            }
             if (ClosedIntersect(aFSpace.ZeroCurves, bSpace.ZeroCurves))
             {
                 result = AdjanceElementType.Vertical;

+ 3 - 5
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerContext.cs

@@ -140,12 +140,10 @@ namespace SAGA.GplotRelationComputerManage
                 return;
             SpaceData spaceData = new SpaceData();
             spaceData.FloorDatas = SpaceComputeData.FloorDatas ?? new List<FloorSpaceData>();
-            var levels = SpaceComputeData.Levels.OrderBy(c => c.Elevation).ToList();
-            var levelNames = levels.Select(l => l.Name).ToList();
-            spaceData.LevelNames = levelNames;
+            //var levels = SpaceComputeData.Levels.OrderBy(c => c.Elevation).ToList();
+            //var levelNames = levels.Select(l => l.Name).ToList();
+            //spaceData.LevelNames = levelNames;
             SpaceComputerDataUtil.SaveData(spaceData);
-            //暂时放开,全部更新完了要删除
-            //DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>(spaceData.FloorDatas) , spaceData.LevelNames);
         }
     }
 }

+ 13 - 1
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs

@@ -27,12 +27,24 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="context"></param>
         public void Computer(SpaceComputerContext context)
         {
+            List<string> testFiles = new List<string>();
+#if DEBUG
+            //testFiles.Add("Fl420105000119b7c08edcee11e8a553abe8a598be93.rvt");
+            testFiles.Add("Fl42010500016dc07b43dcf111e8a553e7c23f5c005c.rvt");
+            testFiles.Add("Fl4201050001afd0f3e3dce811e8a553f5b22da96b1b.rvt");
+#endif
             var fileInfos = RevitModelPath.GetAllRevitFiles();
+            //遍历时,可以不分建筑
             foreach (var fileInfo in fileInfos)
             {
                 if (File.Exists(fileInfo))
                 {
-                    Trace.Write(fileInfo);
+#if DEBUG
+                    //if (testFiles.All(f => !fileInfo.Contains(f)))
+                    //{
+                    //    continue;
+                    //}
+#endif
                     FloorSpaceItems floorItems = context.GetFloorItems(fileInfo);
                     floorItems.Parse(context);
                     floorItems.Document.CloseDocSimple();

+ 3 - 36
MBI/SAGA.MBI/Gplot/GplotFilesUpload.cs

@@ -14,37 +14,6 @@ namespace SAGA.MBI.Gplot
 {
     public class GplotFilesUpload
     {
-        public static void Upload()
-        {
-            var dir = SAGA.Models.StaticData.DbDirectory;
-            try
-            {
-                //上传后重命名文件
-                OssHelper.PutObjectFromDir(dir,
-                    (s => s.IndexOf("-new") > -1),
-                    (s =>
-                    {
-                        var newName = Path.GetFileName(s)?.Replace("-new", "");
-                        if (!string.IsNullOrEmpty(newName))
-                            Microsoft.VisualBasic.FileIO.FileSystem.RenameFile
-                                (s, newName);
-                    }));
-            }
-            catch (Exception e)
-            {
-
-            }
-        }
-
-        /// <summary>
-        /// 需要上传的拓扑图
-        /// </summary>
-        /// <returns></returns>
-        public static List<ChangesRelationship> GetNeedUploadGlop()
-        {
-            return DrawDataServer.GetData<List<ChangesRelationship>>()??new List<ChangesRelationship>();
-        }
-
         /// <summary>
         /// 上传拓扑图数据
         /// </summary>
@@ -56,13 +25,11 @@ namespace SAGA.MBI.Gplot
                 Assembly asm = Assembly.GetExecutingAssembly();
                 var path = Path.Combine(Path.GetDirectoryName(asm.Location), "SAGA.GplotManage.exe");
                 Assembly assembly = Assembly.LoadFile(path);
-                var type = assembly.GetType("SAGA.GplotManage.UploadGplotDatas");
+                var type = assembly.GetType("SAGA.GplotManage.RelationDataManager");
                 if (type != null)
                 {
-                    var obj = type.Assembly.CreateInstance(type.FullName);
-                    MethodInfo method = type.GetMethod("UploadGplotData");
-
-                    method.Invoke(obj, new object[] { graphTypes });
+                    MethodInfo method = type.GetMethod("ComputerRelations", new Type[2]{typeof(List<string>),typeof(bool)});
+                    method.Invoke(null,new object[] { graphTypes ,false});
                 }
             }
             catch (Exception e)

+ 25 - 46
MBI/SAGA.Models/AcWater.cs

@@ -2,64 +2,43 @@
 using System;
 using System.Collections.Generic;
 using System.Windows;
-using SAGA.Models;
-using SAGA.RevitUtils.MEP;
-
 namespace SAGA.Models {
-    [Serializable]
-    [TableName("AcWaters")]
-    public class AcWater : AbData {
-        public List<FloorData> FloorDatas { get; set; }=new List<FloorData>();
-        public DateTime CreateDate { get; set; }=DateTime.Now;
-    }
-  
-    [TableName("SpaceDatas")]
-    [Serializable]
-    public class SpaceData : AbData {
+    public class SpaceData : AbData
+    {
         public List<FloorSpaceData> FloorDatas { get; set; } = new List<FloorSpaceData>();
-        public DateTime CreateDate { get; set; } = DateTime.Now;
-        /// <summary>
-        /// 楼层名称
-        /// </summary>
-        public List<string> LevelNames { get; set; }=new List<string>();
-    }
-    [Serializable]
-    public class FloorData: AbData { 
-
-        public List<List<Point>> Lines { get; set; }=new List<List<Point>>();
-        /// <summary>
-        /// 虚拟墙
-        /// </summary>
-         public List<List<Point>> VirLines { get; set; }=new List<List<Point>>();
-        public List<SgElement> EndPoints  { get; set; }=new List<SgElement>();
-        public List<SgElementTreeNode> MEPCurveData { get; set; }=new List<SgElementTreeNode>();
-        /// <summary>
-        /// 数据类型
-        /// </summary>
-        public string DataType { get; set; }
-
-        public bool IsSelected { get; set; }
     }
-    public class FloorSpaceData : AbData {
-
+    public class FloorSpaceData : AbData
+    {
         /// <summary>
         /// 层所在标高
         /// </summary>
         public string LevelName { get; set; }
-        public List<List<Point>> Lines { get; set; } = new List<List<Point>>();
+        /// <summary>
+        /// 标高的高低
+        /// </summary>
+        public double LevelElevation { get; set; }
         public List<SgSpace> EndPoints { get; set; } = new List<SgSpace>();
-
     }
-    [Serializable]
-    public abstract class AbData {
+    public class BuildingItem
+    {
+        public BuildingItem()
+        {
+            FloorDataItems = new List<FloorSpaceData>();
+            Levels = new List<string>();
+        }
         public string Id { get; set; }
         public string Name { get; set; }
+        public List<string> Levels { get; private set; }
+        public List<FloorSpaceData> FloorDataItems { get; private set; }
     }
-    [TableName("WallDatas")]
     [Serializable]
-    public class WallData : AbData
-    {
-        public List<FloorData> FloorDatas { get; set; }=new List<FloorData>();
-        public DateTime CreateDate { get; set; }=DateTime.Now;
+    public abstract class AbData {
+        public string Id { get; set; }
+        public string Name { get; set; }
+        public string BuildingId { get; set; }
+        public string BuildingName { get; set; }
+        public string ProjectId { get; set; }
+        public string ProjectName { get; set; }
     }
+   
 }

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

@@ -55,7 +55,7 @@ namespace SAGA.Models {
         /// </summary>
         public string Type { get; set; }
         public DataNode Parent { get; set; }
-        public List<DataNode> Childrens { get; set; }
+        public List<DataNode> Childrens { get; set; } = new List<DataNode>();
         public Point Postition { get; set; }
 
         /// <summary>

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

@@ -111,8 +111,6 @@
     <Compile Include="MBIItem\MBIBuiltInParameterName.cs" />
     <Compile Include="ResponseClasses.cs" />
     <Compile Include="DataNode.cs" />
-    <Compile Include="DrawDataServer.cs" />
-    <Compile Include="Enums.cs" />
     <Compile Include="ExtendMethods.cs" />
     <Compile Include="DbHelper.cs" />
     <Compile Include="LogicNode.cs" />

+ 5 - 0
MBI/SAGA.RevitUtils/Extends/CurveExtend.cs

@@ -197,6 +197,11 @@ namespace SAGA.RevitUtils.Extends
         /// <returns></returns>
         public static bool IsContain(this Curve curve, XYZ pt, double tolerance = 0.0)
         {
+            if (pt == null)
+            {
+                return false;
+            }
+
             if (curve.IsArc() && curve.GetArc().Center.IsEqual2(pt, tolerance))
             {
                 return false;

+ 6 - 1
MBI/SAGA.RevitUtils/Extends/ElementExtend.cs

@@ -1169,7 +1169,12 @@ namespace SAGA.RevitUtils.Extends
         /// <returns></returns>
         public static XYZ GetLocationPoint(this Element element)
         {
-            return element.Location.GetPoint();
+            var result= element.Location.GetPoint();
+            if (result == null)
+            {
+                result = element.GetBoxCenter();
+            }
+            return result;
         }
 
         /// <summary>

+ 7 - 0
MBI/SAGA.RevitUtils/Extends/LocationExtend.cs

@@ -15,7 +15,14 @@ namespace SAGA.RevitUtils.Extends
         {
             XYZ point = null;
             if (loc is LocationPoint lp)
+            {
                 point = lp?.Point;
+            }
+            else if(loc is LocationCurve lc)
+            {
+                point = lc.Curve.MiddlePoint();
+            }
+              
             return point;
         }