소스 검색

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

mengxiangge 6 년 전
부모
커밋
e82092425d
30개의 변경된 파일537개의 추가작업 그리고 126개의 파일을 삭제
  1. 7 3
      MBI/CEFSharpWPF/ModifyResponseFilter.cs
  2. 0 18
      MBI/SAGA.GplotDrawData/DBView/BaseMapManager.cs
  3. 1 1
      MBI/SAGA.GplotDrawData/DBView/FloorSystemGraphView.cs
  4. 1 1
      MBI/SAGA.GplotDrawData/DBView/MachineRoomGraphView.cs
  5. 2 1
      MBI/SAGA.GplotDrawData/DBView/PipeEndGraphView.cs
  6. 4 20
      MBI/SAGA.GplotDrawData/DBView/SpaceGraphView.cs
  7. 0 1
      MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj
  8. 1 1
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml
  9. 10 2
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs
  10. 4 3
      MBI/SAGA.GplotManage/GplotCommand.cs
  11. 120 28
      MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs
  12. 93 0
      MBI/SAGA.GplotRelationComputerManage/BaseMap/BaseMapManager.cs
  13. 43 0
      MBI/SAGA.GplotRelationComputerManage/BaseMap/FloorMapData.cs
  14. 46 0
      MBI/SAGA.GplotRelationComputerManage/BaseMap/FloorMapDataCheck.cs
  15. 2 2
      MBI/SAGA.GplotRelationComputerManage/Common/ComputerFileSetting.cs
  16. 25 10
      MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs
  17. 1 1
      MBI/SAGA.GplotRelationComputerManage/DataServer/TimeVersionFile.cs
  18. 1 0
      MBI/SAGA.GplotRelationComputerManage/RelationType/RelationTypeManager.cs
  19. 0 21
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs
  20. 1 1
      MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParseSetting.cs
  21. 4 0
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  22. 1 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemCalcUtil.cs
  23. 1 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs
  24. 40 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/BinaryRelationItem.cs
  25. 9 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/SystemDrawItems.cs
  26. 17 7
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs
  27. 5 0
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/MachineRoomDrawRecord.cs
  28. 4 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  29. 4 1
      MBI/SAGA.MBI/SAGA.MBI.csproj
  30. 90 0
      MBI/SAGA.MBI/TestCommand.cs

+ 7 - 3
MBI/CEFSharpWPF/ModifyResponseFilter.cs

@@ -11,6 +11,7 @@ using System.IO;
 using System.Linq;
 using System.Runtime.InteropServices;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using CefSharp;
 using Newtonsoft.Json;
@@ -28,7 +29,7 @@ namespace CEFSharpWPF
         {
 
         }
-        private int bufferLength = 2048*10;
+        private int bufferLength = 2048*50;
         private BinaryReader r;      
         public FilterStatus Filter(Stream dataIn, out long dataInRead, Stream dataOut, out long dataOutWritten)
         {
@@ -62,8 +63,10 @@ namespace CEFSharpWPF
 
 
                 int size = 0;
-                byte[] buffer = new byte[bufferLength];
-                size = r.Read(buffer, 0, bufferLength);
+                //dataOut.SetLength(bufferLength);
+                var useLength = dataOut.Length;
+                byte[] buffer = new byte[useLength];
+                size = r.Read(buffer, 0, (int)useLength);
                 dataOut.Write(buffer, 0, size);
 
                 dataOutWritten = size;
@@ -78,6 +81,7 @@ namespace CEFSharpWPF
                 dataOutWritten = 0;
             }
             r = null;
+            Thread.Sleep(200);
             return FilterStatus.Done;
         }
 

+ 0 - 18
MBI/SAGA.GplotDrawData/DBView/BaseMapManager.cs

@@ -47,23 +47,5 @@ namespace SAGA.GplotDrawData
             var exportDb=manager.ExportMbiEelemntDB(ExportDataBuilder.CreateExportData(elements));
             return exportDb.ToJsonObject();
         }
-        /// <summary>
-        /// 初始化当前楼层信息
-        /// </summary>
-        public static void InitCurrentProjectFloor()
-        {
-            //var fileInfos = RevitModelPath.GetAllRevitFiles();
-            ////所有项目中所有文档
-            //List<Element> startElements = new List<Element>();
-            //Dictionary<Document, List<Element>> allDatas = new Dictionary<Document, List<Element>>();
-            //foreach (var tPath in fileInfos)
-            //{
-            //    if (File.Exists(tPath))
-            //    {
-            //        Document linkDoc = ExternalDataWrapper.Current.App.OpenDocumentFile(tPath);
-            //        startElements.AddRange(startManager.GetStartElements(linkDoc));
-            //    }
-            //}
-        }
     }
 }

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

@@ -45,7 +45,7 @@ namespace SAGA.GplotDrawData
             var floorName = floorId;
             try
             {
-                var jsObject = BaseMapManager.GetFloorInfo(floorName);
+                var jsObject = BaseMapManager.GetFloorInfoWithCache(floorName);
                 db.RefJObjects.Add(jsObject);
             }
             catch (Exception ex)

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

@@ -31,7 +31,7 @@ namespace SAGA.GplotDrawData
             }
             foreach (var curve in drawItem.Curves)
             {
-                GLine gline = new GLine(curve.Points[0].ConvertToPoint3D(), curve.Points[0].ConvertToPoint3D());
+                GLine gline = new GLine(curve.Points[0].ConvertToPoint3D(), curve.Points[1].ConvertToPoint3D());
                 gline.ElementColor = Colors.Red;
                 db.Elements.Add(gline);
             }

+ 2 - 1
MBI/SAGA.GplotDrawData/DBView/PipeEndGraphView.cs

@@ -8,6 +8,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Media;
+using SAGA.GplotRelationComputerManage;
 
 namespace SAGA.GplotDrawData
 {
@@ -69,7 +70,7 @@ namespace SAGA.GplotDrawData
             var floorName = fd.Id.Split('-')[1];
             try
             {
-                var jsObject = BaseMapManager.GetFloorInfo(floorName);
+                var jsObject = BaseMapManager.GetFloorInfoWithCache(floorName);
                 db.RefJObjects.Add(jsObject);
             }
             catch (Exception ex)

+ 4 - 20
MBI/SAGA.GplotDrawData/DBView/SpaceGraphView.cs

@@ -1,4 +1,5 @@
-using SAGA.Models;
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models;
 using SAGA.Models.Graphs;
 using System;
 using System.Collections.Generic;
@@ -49,30 +50,13 @@ namespace SAGA.GplotDrawData
             var floorName = fd.Id.Split('-')[1];
             try
             {
-                var jsObject = BaseMapManager.GetFloorInfo(floorName);
+                var jsObject = BaseMapManager.GetFloorInfoWithCache(floorName);
                 db.RefJObjects.Add(jsObject);
             }
             catch (Exception ex)
             {
 
-            }
-            //var walls = DrawDataServer.GetWallData().FloorDatas?.FirstOrDefault(t => t.Id == floorName);;         
-            //foreach (var line in walls.Lines)
-            //{
-            //    var path=line.ConvertToGPath();
-            //    if (!path.Data.Any())
-            //        continue;
-            //    path.Thickness = 7;
-            //    db.Elements.Add(path);
-            //}
-            //foreach (var line in walls.VirLines)
-            //{
-            //    var path = line.ConvertToGPath();
-            //    if (!path.Data.Any())
-            //        continue;
-            //    path.ElementColor = Colors.Green;
-            //    db.Elements.Add(path);
-            //}    
+            }    
             #endregion
             return db;
         }

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

@@ -67,7 +67,6 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="Common\WebGplotSettings.cs" />
-    <Compile Include="DBView\BaseMapManager.cs" />
     <Compile Include="DBView\EquipmentGraphView.cs" />
     <Compile Include="DBView\FloorSystemGraphView.cs" />
     <Compile Include="DBView\IGraphDBView.cs" />

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

@@ -29,7 +29,7 @@
                 </Style>
             </TreeView.ItemContainerStyle>
             <TreeView.ItemTemplate>
-                <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
+                <HierarchicalDataTemplate ItemsSource="{Binding Path=Childrens}">
                     <TextBlock Name="Block" Text="{Binding EName}"></TextBlock>
 
                     <HierarchicalDataTemplate.Triggers>

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

@@ -63,9 +63,17 @@ namespace SAGA.GplotDrawData.View
             {
                 foreach (var drawRecord in drawData)
                 {
-                    var recordNode= new DataNode(drawRecord.RelationName);
+                    if (drawRecord.DrawIems.IsEmpty)
+                        continue;
+                    var relationNode = treeDataSource.FirstOrDefault(d => d.EName == drawRecord.RelationName);
+                    if (relationNode == null)
+                    {
+                        relationNode= new DataNode(drawRecord.RelationName);
+                        treeDataSource.Add(relationNode);
+                    }
+                    var recordNode= new DataNode(drawRecord.FloorName);
                     recordNode.SetData(drawRecord);
-                    treeDataSource.Add(recordNode);
+                    relationNode.Childrens.Add(recordNode);
                 }
             }
            this.TreeRootNode.ItemsSource = treeDataSource;

+ 4 - 3
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -64,7 +64,8 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            //RelationTypeManager.GetSystemRelationTypeNames() 
+            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames();//new List<string>() { "ChillWaterLoop" };
             SystemComputerHandler handler1 = new SystemComputerHandler();
             handler1.ComputerWidthCache(useRelations);
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
@@ -89,7 +90,7 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames(); 
             SystemComputerHandler handler1 = new SystemComputerHandler();
             handler1.ComputerWidthCache(useRelations);
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
@@ -114,7 +115,7 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            List<string> useRelations = new List<string>() { "ChillWaterLoop" };
+            List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames(); 
             SystemComputerHandler handler1 = new SystemComputerHandler();
             handler1.ComputerWidthCache(useRelations);
             WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);

+ 120 - 28
MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs

@@ -21,6 +21,7 @@ namespace SAGA.GplotManage
         public static List<ReleateData> BuildRelations(LoadRelationData relationData)
         {
             #region 说明
+
             /*
              * 数据关联项:
              * 机房设备---特殊阀门
@@ -28,11 +29,15 @@ namespace SAGA.GplotManage
              * 立管--立管
              * 立管---平面设备;由此=》机房设备---平面设备
              */
+
             #endregion
+
             List<ReleateData> result = new List<ReleateData>();
             List<BinaryRelationItem> roomRelations = new List<BinaryRelationItem>();
             List<BinaryRelationItem> floorRelations = new List<BinaryRelationItem>();
+
             #region 机房关系数据
+
             var machineRoomData = relationData.MachineRoomRelationRecords;
             foreach (var machineRelation in machineRoomData)
             {
@@ -48,8 +53,11 @@ namespace SAGA.GplotManage
                     }
                 }
             }
+
             #endregion
+
             #region 平面关系数据
+
             foreach (var floorRelation in relationData.FloorRelationRecords)
             {
                 foreach (var item in floorRelation.RelationItems)
@@ -60,26 +68,34 @@ namespace SAGA.GplotManage
                     }
                     else
                     {
-                        roomRelations.Add(item);
+                        floorRelations.Add(item);
                     }
                 }
             }
+
             #endregion
 
             var verticalSets = relationData.VerticalRelationRecords;
 
             #region 机房和平面关联
+
             /*
              * 前提不是全设备
+             * 产生关系方式 源--端--立管--源--端,源--端--立管--端,源--端
              */
             foreach (var roomRelation in roomRelations)
             {
                 EquipmentNode equipmentNode, linkNode;
-                if(!roomRelation.From.IsRealEquipment&&!roomRelation.To.IsRealEquipment)
+                var systemName = roomRelation.RelationType;
+
+                #region 源
+
+                if (!roomRelation.From.IsRealEquipment && !roomRelation.To.IsRealEquipment)
                 {
                     continue;
                 }
-                if(roomRelation.From.IsRealEquipment)
+
+                if (roomRelation.From.IsRealEquipment)
                 {
                     equipmentNode = roomRelation.From;
                     linkNode = roomRelation.To;
@@ -89,38 +105,113 @@ namespace SAGA.GplotManage
                     equipmentNode = roomRelation.To;
                     linkNode = roomRelation.From;
                 }
-                List<string> useLinks = new List<string>();
-                var useSet = verticalSets.FirstOrDefault(s => s.RelationItems.Any(item => item == linkNode.BimId));
-                if(useSet==null)
-                {
-                    useLinks.Add(linkNode.BimId);
-                }
-                else
-                {
-                    useLinks.AddRange(useSet.RelationItems);
-                }
-                foreach (var useLink in useLinks)
+
+                #endregion
+
+                #region 端
+
+                foreach (var endRelation in floorRelations)
                 {
-                   var floorRelation= floorRelations.FirstOrDefault(c => c.From.BimId == useLink || c.To.BimId == useLink);
-                    BinaryRelationItem newRelationItem = new BinaryRelationItem();
-                    newRelationItem.From = equipmentNode;
-                    newRelationItem.To = floorRelation.From.BimId != useLink ? floorRelation.From : floorRelation.To;
-                    newRelationItem.RelationType = floorRelation.RelationType;
-
-                    //加入关系数据
-                    result.Add(CreateRelationData(newRelationItem));
+                    var mathFlag = endRelation.TryGetNode(n => n.BimId == linkNode.BimId, out EquipmentNode refNode);
+                    if (mathFlag > -1)
+                    {
+                        var anotherNode = endRelation.GetAnotherNode(n => n.BimId == refNode.BimId);
+                        if (anotherNode.IsRealEquipment)
+                        {
+                            //第三种情况
+                            BinaryRelationItem newRelationItem = new BinaryRelationItem();
+                            newRelationItem.From = equipmentNode;
+                            newRelationItem.To = anotherNode;
+                            newRelationItem.RelationType = systemName;
+                            result.Add(CreateRelationData(newRelationItem));
+                        }
+                        else
+                        {
+                            var verticalSet = verticalSets.FirstOrDefault(s =>
+                                s.RelationItems.Any(item => item == anotherNode.BimId));
+                            if (verticalSet == null)
+                                continue;
+                            var verticalIds = new List<string>(verticalSet.RelationItems);
+                            foreach (var verticalId in verticalIds)
+                            {
+                                bool findV = false;
+
+                                #region 立管找端
+
+                                foreach (var vEndRelation in floorRelations)
+                                {
+                                    var vAnother = vEndRelation.GetAnotherNode(n => n.BimId == verticalId);
+                                    if (vAnother == null || !vAnother.IsRealEquipment)
+                                    {
+                                        continue;
+                                    }
+
+                                    //第二种情况
+                                    BinaryRelationItem newRelationItem = new BinaryRelationItem();
+                                    newRelationItem.From = equipmentNode;
+                                    newRelationItem.To = vAnother;
+                                    newRelationItem.RelationType = systemName;
+                                    result.Add(CreateRelationData(newRelationItem));
+                                    findV = true;
+                                }
+
+                                #endregion
+
+                                if (findV)
+                                {
+                                    continue;
+                                }
+
+                                #region 立管找源
+
+                                foreach (var vSourceRelation in roomRelations)
+                                {
+                                    var vAnother = vSourceRelation.GetAnotherNode(n => n.BimId == verticalId);
+                                    if (vAnother == null)
+                                    {
+                                        continue;
+                                    }
+
+                                    #region 源找端
+
+                                    foreach (var floorRelation in floorRelations)
+                                    {
+                                        var sa = floorRelation.GetAnotherNode(n => n.BimId == vAnother.BimId);
+                                        if (sa == null || !sa.IsRealEquipment)
+                                        {
+                                            //第一种情况
+                                            BinaryRelationItem newRelationItem = new BinaryRelationItem();
+                                            newRelationItem.From = equipmentNode;
+                                            newRelationItem.To = sa;
+                                            newRelationItem.RelationType = systemName;
+                                            result.Add(CreateRelationData(newRelationItem));
+                                        }
+                                    }
+
+                                    #endregion
+                                }
+
+                                #endregion
+                            }
+                        }
+                    }
                 }
 
+                #endregion
             }
-            #endregion
+
             return result;
+
+            #endregion
         }
+
+
         /// <summary>
-        /// 创建上传关系数据
-        /// </summary>
-        /// <param name="relationType"></param>
-        /// <returns></returns>
-        public static List<ReleateData> BuildRelations(string  relationType)
+            /// 创建上传关系数据
+            /// </summary>
+            /// <param name="relationType"></param>
+            /// <returns></returns>
+            public static List<ReleateData> BuildRelations(string  relationType)
         {
             LoadRelationData data = new LoadRelationData(relationType);
             data.LoadData();
@@ -139,6 +230,7 @@ namespace SAGA.GplotManage
             relation.from_id = relationItem.From.MbiId;
             relation.to_id = relationItem.To.MbiId;
             relation.rel_type = relationItem.RelationType;
+            relation.infos = new Info() {info1 = relationItem.From.BimId, info2 = relationItem.To.BimId};
             return relation;
         }
         #endregion

+ 93 - 0
MBI/SAGA.GplotRelationComputerManage/BaseMap/BaseMapManager.cs

@@ -0,0 +1,93 @@
+using Autodesk.Revit.DB;
+using Newtonsoft.Json.Linq;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.RevitExport;
+using SAGA.RevitUtils.Extends;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 底图管理
+    /// </summary>
+    public static class BaseMapManager
+    {
+        /*
+         * 静态方法传相关参数
+         */
+        public const string BaseMapDirectoryName = "BaseMap";
+        /// <summary>
+        /// 获取带缓存的楼层底图数据
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public static JObject GetFloorInfoWithCache(string floorId)
+        {
+            FloorMapDataCheck check = new FloorMapDataCheck(floorId);
+            var filePath = DalProjectTree.GetFloorByFloorId(floorId)?.FullPath;
+            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
+            {
+                return new JObject();
+            }
+            bool isComputer = false;
+            #region 监测缓存
+            if (check.IsMissData())
+            {
+                //文件缺失,则重新计算
+                isComputer = true;
+            }
+            else
+            {
+                DateTime dateTime = File.GetLastWriteTime(filePath);
+                //过期则重新计算
+                isComputer = check.IsExpired(dateTime);
+            } 
+            #endregion
+            JObject result = null;
+            FloorMapData floorMap = new FloorMapData(floorId);
+            if (isComputer)
+            {
+                result = GetFloorMap(filePath);
+             
+                floorMap.FloorMap = result;
+                floorMap.SaveData();
+            }
+            else
+            {
+                floorMap.LoadData();
+                result = floorMap.FloorMap;
+            }
+            return result;
+        }
+        #region 辅助方法
+        public static string RealKey(string floorId)
+        {
+            var key=  ComputerFileSetting.GetRealKey(floorId, ComputerFileSetting.FloorMap);
+            return Path.Combine(BaseMapDirectoryName, key);
+        }
+        /// <summary>
+        /// 获取指定路径下的值
+        /// </summary>
+        /// <param name="filePath"></param>
+        /// <returns></returns>
+        public static JObject GetFloorMap(string filePath)
+        {
+            List<Element> elements = new List<Element>();
+            if (string.IsNullOrEmpty(filePath) || File.Exists(filePath))
+            {
+                Document linkDoc = ExternalDataWrapper.Current.App.OpenDocumentFile(filePath);
+                elements = linkDoc.GetElements<Wall>().ToList<Element>();
+                elements.AddRange(linkDoc.GetElements<CurveElement>(BuiltInCategory.OST_MEPSpaceSeparationLines).ToList<Element>());
+            }
+            MbiElementManager manager = new MbiElementManager();
+            var exportDb = manager.ExportMbiEelemntDB(ExportDataBuilder.CreateExportData(elements));
+            return exportDb.ToJsonObject();
+        }
+        #endregion
+    }
+}

+ 43 - 0
MBI/SAGA.GplotRelationComputerManage/BaseMap/FloorMapData.cs

@@ -0,0 +1,43 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FloorMapData
+ * 作者:xulisong
+ * 创建时间: 2019/1/29 15:52:51
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 楼层数据
+    /// </summary>
+    public class FloorMapData
+    {
+        public FloorMapData(string floorId)
+        {
+            FloorId = floorId;
+        }
+        public string FloorId { get; private set; }
+        public JObject FloorMap { get; set; }
+        /// <summary>
+        /// 保存楼层数据
+        /// </summary>
+        public void SaveData()
+        {
+            DataServerUtil.Current.SaveData(BaseMapManager.RealKey(FloorId), FloorMap??new JObject());            
+        }
+        /// <summary>
+        /// 加载楼层数据
+        /// </summary>
+        public void LoadData()
+        {
+            FloorMap = DataServerUtil.Current.LoadData<JObject>(BaseMapManager.RealKey(FloorId)) ?? new JObject();           
+        }
+    }
+}

+ 46 - 0
MBI/SAGA.GplotRelationComputerManage/BaseMap/FloorMapDataCheck.cs

@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FloorMapDataCheck
+ * 作者:xulisong
+ * 创建时间: 2019/1/29 15:36:04
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 楼层图数据监测
+    /// </summary>
+    public class FloorMapDataCheck
+    {
+        public FloorMapDataCheck(string floorId)
+        {
+            FloorId = floorId;
+        }
+        public string FloorId { get; private set; }
+        /// <summary>
+        /// 判定数据是否过期
+        /// </summary>
+        /// <param name="dateTime"></param>
+        /// <returns></returns>
+        public bool IsExpired(DateTime dateTime)
+        {
+            return DataServerUtil.Current.IsExpired(BaseMapManager.RealKey(FloorId), dateTime);
+        }
+        /// <summary>
+        /// 判断计算数据是否缺失
+        /// </summary>
+        /// <returns></returns>
+        public bool IsMissData()
+        {
+            return !DataServerUtil.Current.GetFile(BaseMapManager.RealKey(FloorId)).Exists();
+        }
+
+
+    }
+}

+ 2 - 2
MBI/SAGA.GplotRelationComputerManage/Common/ComputerFileSetting.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 namespace SAGA.GplotRelationComputerManage
 {
     /// <summary>
-  //
+    /// 计算文件相关数据管理
     /// </summary>
     public class ComputerFileSetting
     {
@@ -17,7 +17,7 @@ namespace SAGA.GplotRelationComputerManage
         public const string VerticalRelation = "VerticalRelation";
         public const string MachineRoomDraw = "MechineRoomDraw";
         public const string MachineRoomRelation = "MechineRoomRelation";
-
+        public const string FloorMap = "FloorMap";
         /// <summary>
         /// 获取通用的文件名称
         /// </summary>

+ 25 - 10
MBI/SAGA.GplotRelationComputerManage/Common/MBIInfoUtil.cs

@@ -81,14 +81,14 @@ namespace SAGA.GplotRelationComputerManage
                 return false;
             }
             string familyName = element.GetFamily()?.Name ?? string.Empty;
-            var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
-            return match.Success;
+            return TryGetEquipmentCategory(familyName, out string category); ;
         }
 
         /// <summary>
         /// 获取设备的分类
         /// </summary>
         /// <param name="element"></param>
+        /// <param name="category"></param>
         /// <returns></returns>
         public static bool TryGetEquipmentCategory(Element element,out string category)
         {
@@ -105,12 +105,7 @@ namespace SAGA.GplotRelationComputerManage
                 return false;
             }
             string familyName = element.GetFamily()?.Name ?? string.Empty;
-            var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
-            if (match.Success)
-            {
-                category = match.Groups[1].ToString();
-            }
-            return match.Success;
+            return TryGetEquipmentCategory(familyName, out category);
         }
         /// <summary>
         /// 获取设备的设备分类
@@ -125,12 +120,32 @@ namespace SAGA.GplotRelationComputerManage
                 return category;
             }
             string familyName = fi.GetFamily()?.Name;
-            var match = Regex.Match(familyName, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
+            TryGetEquipmentCategory(familyName,out category);
+            return category;
+        }
+        /// <summary>
+        /// 截取指定字符串的category信息【如果不符合规范返回null】
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public static string GetEquipmentCategory(string name)
+        {
+            string category;
+            TryGetEquipmentCategory(name, out category);
+            return category;
+        }
+
+        public static bool TryGetEquipmentCategory(string name, out string category)
+        {
+            bool result = false;
+            category = null;
+            var match = Regex.Match(name, @"^(?:((?:[A-Z][A-Z]){2,3})\s*-\s*\S*)");
             if (match.Success)
             {
                 category = match.Groups[1].ToString();
+                result = true;
             }
-            return category;
+            return result;
         }
         /// <summary>
         /// 通过标高名称获取楼层名称

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

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

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

@@ -227,6 +227,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public static List<string> GetSystemRelationTypeNames()
         {
+            return new List<string>() { "ChillWaterLoop" };
             return GetSystemRelationTypes().Select(r => r.Type).ToList() ;
         }
     }

+ 0 - 21
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs

@@ -32,9 +32,7 @@ namespace SAGA.GplotRelationComputerManage
                 var baseElement = newStartElements[0];
                 var array = Execute(baseElement);
                 var containElements = array.GetRefElements();
-                //顺序应该有保证吧,
                 newStartElements = newStartElements.Except(containElements, new ElementEqualComparer()).ToList();
-                //要不要去掉不含设备的节点的图
                 arrays.Add(array);
             }
             return arrays;
@@ -60,25 +58,6 @@ namespace SAGA.GplotRelationComputerManage
             LoadEquipmentItem(edges);
             //确定边类型
             LoadEdgeSystem(edges);
-            //var outPutEdges = edges.GetAvailableEdges(null);
-            //var outPutVertexes = edges.GetAvailableVertexes(null);
-            // StringBuilder builders = new StringBuilder();
-            //foreach (var elementsVertex in outPutVertexes)
-            //{
-              
-            //    builders.Append("Id:" + elementsVertex.Id);
-            //    builders.Append("RefIds:" +string.Join(",",elementsVertex.RefData.Select(e=>e.Id.ToString())) );
-            //    builders.AppendLine();
-            //}
-            //foreach (var elementsEdge in outPutEdges)
-            //{
-            //      builders.Append("Id:" + elementsEdge.Id);
-            //     builders.Append("StartId:" + elementsEdge.RealStart.Id);
-            //     builders.Append("EndId:" + elementsEdge.RealEnd.Id);
-            //     builders.AppendLine();
-            //}
-
-            //File.WriteAllText(@"d:\test.txt", builders.ToString());
             #endregion
             #region 重复迭代进行串并联操作
             edges = ElementEdgesArray.ArrangeHandle(edges);

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

@@ -147,7 +147,7 @@ namespace SAGA.GplotRelationComputerManage
                 }
                 if (SystemCalcUtil.IsStartValve(owner))
                 {
-                    result = Regex.IsMatch(connector.Description, AppSetting.EndFlag);// connector.Description != GplotOptions.ValveConnectorDescription;
+                    result = Regex.IsMatch(connector.Description, AppSetting.SourceFlag);// connector.Description != GplotOptions.ValveConnectorDescription;
                     break;
                 } 
                 #endregion

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

@@ -77,6 +77,9 @@
     <Reference Include="WindowsBase" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="BaseMap\BaseMapManager.cs" />
+    <Compile Include="BaseMap\FloorMapData.cs" />
+    <Compile Include="BaseMap\FloorMapDataCheck.cs" />
     <Compile Include="ColdRoom\ColdRoomManager.cs" />
     <Compile Include="ColdRoom\ElementsVertexExtension.cs" />
     <Compile Include="ColdRoom\EquipmentItem.cs" />
@@ -195,5 +198,6 @@
   <ItemGroup>
     <Content Include="RelationType\read.txt" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

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

@@ -144,7 +144,7 @@ namespace SAGA.GplotRelationComputerManage
                 foreach (var jobject in equipDatas)
                 {
                     var item = MBIItemFactory.Create<MBIEquipItem>(jobject);
-                    if (item != null && string.IsNullOrWhiteSpace(item.BimId))
+                    if (item != null && !string.IsNullOrWhiteSpace(item.BimId))
                     {
                         equipmentItems[item.BimId]= item;
                     }

+ 1 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -531,6 +531,7 @@ namespace SAGA.GplotRelationComputerManage
                     SystemCurveItem curveItem = new SystemCurveItem();
                     curveItem.Points.Add(line.StartPoint);
                     curveItem.Points.Add(line.EndPoint);
+                    curveItems.Add(curveItem);
                     continue;
                 }
                 if (element is TText text)

+ 40 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/BinaryRelationItem.cs

@@ -49,7 +49,46 @@ namespace SAGA.GplotRelationComputerManage
         {
             return From.IsRealEquipment && To.IsRealEquipment;
         }
+        /// <summary>
+        /// 获取指定条件的Node
+        /// </summary>
+        /// <param name="match"></param>
+        /// <param name="node"></param>
+        /// <returns>-1表示没有,0,From;1,To</returns>
+        public int TryGetNode(Predicate<EquipmentNode> match, out EquipmentNode node)
+        {
+            node = null;
+            var list = new List<EquipmentNode>() {From, To};
+            for (int i = 0; i < list.Count; i++)
+            {
+                if (match(From))
+                {
+                    node = From;
+                    return i;
+                }
+            }
+
+            return -1;
+        }
+        /// <summary>
+        /// 获取匹配元素之外的另一个节点
+        /// </summary>
+        /// <param name="match"></param>
+        /// <returns></returns>
+        public EquipmentNode GetAnotherNode(Predicate<EquipmentNode> match)
+        {
+            //只有有一个相等,才称得上另一个
+            var list = new List<EquipmentNode>() { From, To };
+            for (int i = 0; i < list.Count; i++)
+            {
+                if (match(From))
+                {
+                    
+                    return list[i%2];
+                }
+            }
+            return null;
+        }
 
-       
     }
 }

+ 9 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Data/SystemDrawItems.cs

@@ -25,6 +25,14 @@ namespace SAGA.GplotRelationComputerManage
         /// <summary>
         /// 关联点集合
         /// </summary>
-        public List<SystemPointItem> Points { get; set; }   
+        public List<SystemPointItem> Points { get; set; }
+
+        /// <summary>
+        /// 判断数据是否为空
+        /// </summary>
+        public bool IsEmpty
+        {
+            get { return (Curves == null || !Curves.Any()) && (Points == null || Points.Any()); }
+        }
     }
 }

+ 17 - 7
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -7,16 +7,12 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.RegularExpressions;
-using System.Windows.Media;
 using Autodesk.Revit.DB;
 using Autodesk.Revit.DB.Mechanical;
-using Autodesk.Revit.DB.Plumbing;
 using SAGA.DotNetUtils.Data;
 using SAGA.DotNetUtils.Extend;
 using SAGA.GplotRelationComputerManage.ColdRoom;
 using SAGA.Models;
-using SAGA.Models.GplotElement;
-using SAGA.Models.Graphs;
 using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.MEP;
@@ -240,6 +236,10 @@ namespace SAGA.GplotRelationComputerManage
 
                 var tempIds = SystemParseManager.BuildSystemNode(startNode.Instance, useDomain,
                     (m => !startNode.Flag.Equals(m.GetSystemTypeName())));
+                if (tempIds.Any(d => d == 534844|| d == 534845))
+                {
+
+                }
                 startNode.Instance.PipeSystemTypeName = startNode.Flag;
                 BuildElementNodeData(context, startNode.Instance);
                 useIds.AddRange(tempIds);
@@ -552,14 +552,14 @@ namespace SAGA.GplotRelationComputerManage
             var arrays = parse.Execute(useStartElements);
             arrays.RemoveAll(c => c.GetAvailableVertexes(null).All(v => !v.IsRealEquipment()));
 
-        
-
+       
             #region 生成图形数据
             ColdRoomManager manager = new ColdRoomManager();
             var doc = manager.CreateDocument(new List<ElementEdgesArray>(arrays));
             var drawData = SystemParseManager.CreateRoomDrawing(doc);
             MachineRoomDrawRecord record = new MachineRoomDrawRecord();
             record.RelationName = relationSetting.RelationItem.Name;
+            record.FloorName = MBIInfoUtil.GetFloorNameByLevel(UseLevel.Name);
             record.DrawIems = drawData;
             context[relationType].MachineRoomDrawRecords.Add(record);
             #endregion
@@ -592,9 +592,19 @@ namespace SAGA.GplotRelationComputerManage
         private EquipmentNode ConverEquipmentNode(EquipmentItem item, SystemComputerContext context)
         {
             EquipmentNode result = new EquipmentNode();
+            result.IsRealEquipment = !item.IsVirtual;
             result.RevitId = item.Id;
             result.BimId = CreateBimId(result.RevitId);
-            result.MbiId = context.EquipmentItems.GetItem(result.BimId)?.Id ?? string.Empty;
+            var equipment = context.EquipmentItems.GetItem(result.BimId);
+            if (equipment != null)
+            {
+                result.MbiId = equipment.Id ?? string.Empty;
+                result.Category = equipment.Category;
+            }
+            else
+            {
+                result.Category = MBIInfoUtil.GetEquipmentCategory(item.Name) ?? string.Empty;
+            }
             return result;
         }
         #endregion 解析机房数据

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

@@ -23,6 +23,10 @@ namespace SAGA.GplotRelationComputerManage
             DrawIems = new SystemDrawItems();
         }
         /// <summary>
+        /// 楼层名称
+        /// </summary>
+        public string FloorName { get; set; }
+        /// <summary>
         /// 关系名称
         /// </summary>
         public string RelationName { get; set; }
@@ -30,5 +34,6 @@ namespace SAGA.GplotRelationComputerManage
         /// 绘图数据
         /// </summary>
         public SystemDrawItems DrawIems { get; set; }
+      
     }
 }

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

@@ -23,12 +23,15 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="context"></param>
         public void Computer(SystemComputerContext context)
         {
+            List<string> testFiles = new List<string>();
+            testFiles.Add("Fl420105000119b7c08edcee11e8a553abe8a598be93.rvt");
+            testFiles.Add("Fl4201050001d4f1ea8fdce711e8a55335c5dd75d7b3.rvt");
             var fileInfos = RevitModelPath.GetAllRevitFiles();
             foreach (var fileInfo in fileInfos)
             {
                 if (File.Exists(fileInfo))
                 {
-                    if (!fileInfo.Contains("Fl420105000189c43312dce811e8a5530301735c51a0.rvt"))
+                    if (testFiles.All(f => !fileInfo.Contains(f)))
                     {
                         continue;
                     }

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

@@ -164,7 +164,10 @@
   </PropertyGroup>
   <PropertyGroup />
   <PropertyGroup>
-    <SignManifests>true</SignManifests>
+    <SignManifests>false</SignManifests>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>false</SignAssembly>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Aliyun.OSS">

+ 90 - 0
MBI/SAGA.MBI/TestCommand.cs

@@ -332,4 +332,94 @@ namespace SAGA.MBI
             return true;
         }
     }
+
+    /// <summary>
+    /// 掉转阀件方向
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class ReDirectionCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            using (Transaction tran = new Transaction(ExternalDataWrapper.Current.Doc, "调整阀门"))
+            {
+                tran.Start();
+                try
+                {
+                    var pickElement = ExternalDataWrapper.Current.UiApp.PickElement("请选择阀件", typeof(FamilyInstance)) as FamilyInstance;
+                    if (pickElement == null)
+                    {
+                        return Result.Succeeded;
+                    }
+
+                    var handling = pickElement.HandOrientation;
+                    var facing = pickElement.FacingOrientation;
+                    var location = pickElement.GetLocationPoint();
+                    var axis = location.NewLine(location + handling.CrossProduct(facing));
+                    var connectors = pickElement.GetAllConnectors();
+                    List<Connector> refConnectors = new List<Connector>();
+                    foreach (var connector in connectors)
+                    {
+                        if (!ConnectorType.Physical.HasFlag(connector.ConnectorType))
+                        {
+                            continue;
+                        }
+                        var tempRefs = connector.GetReferenceConnectors();
+                        foreach (var tempRef in tempRefs)
+                        {
+                            if (ConnectorType.Physical.HasFlag(tempRef.ConnectorType)&& tempRef.IsConnectedTo(connector))
+                            {
+                                connector.DisconnectFrom(tempRef);
+
+                                refConnectors.Add(tempRef);
+                            }
+                        }
+
+                    }
+
+                    ElementTransformUtils.RotateElement(pickElement.Document, pickElement.Id, axis, Math.PI);
+                    pickElement.Document.Regenerate();
+                    connectors = pickElement.GetAllConnectors();
+                    for (int i = 0; i < refConnectors.Count; i++)
+                    {
+                        var refCon = refConnectors[i];
+                        if (refCon == null)
+                            continue;
+                        var maxLength = double.MaxValue;
+                        Connector bConnector = null;
+                        foreach (var connector in connectors)
+                        {
+                            var newLength = refCon.Origin.Subtract(connector.Origin).GetLength();
+                            if (newLength < maxLength&&!connector.IsConnected)
+                            {
+                                maxLength = newLength;
+                                bConnector = connector;
+                            }
+                        }
+
+                        if (bConnector != null)
+                        {
+                            bConnector.ConnectTo(refCon);
+                        }
+                    }
+
+                    tran.Commit();
+                }
+                catch (Exception e)
+                {
+                    tran.RollBack();
+                    MessageShow.Show(e);
+                    return Result.Cancelled;
+                }
+            }
+               
+            return Result.Succeeded;
+        }
+
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
 }