xulisong преди 6 години
родител
ревизия
7a09189547

+ 18 - 18
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -141,25 +141,25 @@ 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();
-
-            //}
-            var relationDatas = RelationDataUtil.BuildRelations("ChillWaterLoop");
-            Criteria Criterias = new Criteria
+            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)
             {
-                criterias = relationDatas
-            };
-            var relation = ConvertJsonString(Criterias);
-            MessageShow.Infomation(relation);
+                var graph = gplot;
+                graph.Relationship = graph.ComputerEffectRelationShip;
+                graph.Upload();
+
+            }
+            //var relationDatas = RelationDataUtil.BuildRelations("ChillWaterLoop");
+            //Criteria Criterias = new Criteria
+            //{
+            //    criterias = relationDatas
+            //};
+            //var relation = ConvertJsonString(Criterias);
+            //MessageShow.Infomation(relation);
             return Result.Succeeded;
         }
         private string ConvertJsonString(object object1)

+ 58 - 1
MBI/SAGA.GplotManage/SystemRelation/RelationDataUtil.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using SAGA.DotNetUtils.Data;
 using SAGA.GplotRelationComputerManage;
 
 namespace SAGA.GplotManage
@@ -37,7 +38,6 @@ namespace SAGA.GplotManage
             List<BinaryRelationItem> floorRelations = new List<BinaryRelationItem>();
 
             #region 机房关系数据
-
             var machineRoomData = relationData.MachineRoomRelationRecords;
             foreach (var machineRelation in machineRoomData)
             {
@@ -76,6 +76,63 @@ namespace SAGA.GplotManage
             #endregion
 
             var verticalSets = relationData.VerticalRelationRecords;
+            var cacheFloorDatas = new List<BinaryRelationItem>(floorRelations);
+            List < StringFlag <VerticalRelationRecord>> verticalNodes = new List<StringFlag<VerticalRelationRecord>>();
+            Dictionary<string,EquipmentNode> nodes =new Dictionary<string, EquipmentNode>();
+            List<EAEdge<string>> edges = new List<EAEdge<string>>();
+            #region 初始化立管节点
+            foreach (var verticalRelationRecord in verticalSets)
+            {
+                var newId = Guid.NewGuid().ToString();
+                verticalNodes.Add(new StringFlag<VerticalRelationRecord>()
+                    { Flag = newId, Instance = verticalRelationRecord });
+            }
+            #endregion
+            #region 构建端部临时边集
+            for (int i = cacheFloorDatas.Count - 1; i >= 0; i--)
+            {
+                var currentRecord = cacheFloorDatas[i];
+                //找到立管,创建立管节点。不包含立管,直接将关联关系加入
+                var startId = currentRecord.From.BimId;
+                var endId = currentRecord.To.BimId;
+                nodes[startId] = currentRecord.From;
+                nodes[endId] = currentRecord.To;
+                string replaceStart = null;
+                string replaceEnd = null;
+                for (int j = 0; j < verticalNodes.Count; j++)
+                {
+                    if (replaceStart != null && replaceEnd != null)
+                        break;
+                    var currentVertical = verticalNodes[i];
+
+                    if (currentVertical.Instance.RelationItems.Contains(startId))
+                    {
+                        replaceStart = currentVertical.Flag;
+
+                    }
+                    if (currentVertical.Instance.RelationItems.Contains(endId))
+                    {
+                        replaceEnd = currentVertical.Flag;
+                    }
+                }
+
+                replaceStart = replaceStart ?? startId;
+                replaceEnd = replaceEnd ?? startId;
+                if (!string.IsNullOrWhiteSpace(replaceStart) && !string.IsNullOrWhiteSpace(replaceEnd))
+                {
+                    EAEdge<string> edge = new EAEdge<string>();
+                    edge.StartVertex = replaceStart;
+                    edge.EndVertex = replaceEnd;
+                    edges.Add(edge);
+                }
+            } 
+            #endregion
+
+            foreach (var binaryRelationItem in roomRelations)
+            {
+                
+            }
+
 
             //连接类型,以机房端类型为基准
             #region 机房和平面关联

+ 35 - 31
MBI/SAGA.GplotRelationComputerManage/RelationBll/RelationBll.cs

@@ -1,18 +1,18 @@
-using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using SAGA.DotNetUtils.Http;
 using SAGA.MBI.Common;
-using SAGA.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using SAGA.MBI.RequestData;
+using SAGA.DotNetUtils.Extend;
 
 namespace SAGA.GplotRelationComputerManage
 {
     public class RelationBll
     {
+        private const string MaxTime = "29000101000000";
         #region 地址相关
         /// <summary>
         /// 获取基础地址
@@ -20,7 +20,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public string GetBaseUrl()
         {
-            return $"{ MBIConst.DataPlatformLocalHost}data - platform - 3 / relation / ";
+            return $"{ MBIConst.DataPlatformLocalHost}data-platform-3/relation/";
         }
         /// <summary>
         /// 获取密码相关地址字符串
@@ -48,12 +48,14 @@ namespace SAGA.GplotRelationComputerManage
             var periods = new JArray();
             var timeObject = new JObject();
             timeObject.Add("begin_time", beginTime);
-            timeObject.Add("end_time", "29000101000000");
-            jObject.Add("periods", periods);
-            //string postData = $"{{\"graph_type\":\"{graphType}\",\"periods\":[{{\"begin_time\":\"{begin_time}\",\"end_time\":\"29000101000000\"}}]}}";
+            timeObject.Add("end_time", MaxTime);
+            periods.Add(timeObject);
+            jObject.Add("periods", periods);   
             RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
-
-            return restClient.GetRequest().GetValue("graph_id");
+            string strResult = restClient.GetRequest();
+            string graphId = null; ;
+            RequestResultUtil.HandlerResult(strResult, (obj) => graphId = obj.GetValueEx("graph_id"));
+            return graphId;
         }
 
         /// <summary>
@@ -69,12 +71,16 @@ namespace SAGA.GplotRelationComputerManage
             JObject jObject = new JObject();
             JObject criteria = new JObject();
             jObject.Add("criteria", criteria);
-            criteria.Add("jObjectValue", graphType);
-            //string postData = $"{{\"graph_type\":\"{graphType}\"}}";
-            //postData = $"{{\"criteria\":{{\"graph_type\":\"{graphType}\"}}}}";
+            criteria.Add("graph_type", graphType);
             RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
-            GraphInstance instance = new GraphInstance();
-            var result = restClient.GetRequest();
+            GraphInstance instance =null;
+            var strResult = restClient.GetRequest();
+            RequestResultUtil.HandlerResult(strResult, (obj) =>
+            {
+                var listStr = obj["Content"].ToString();
+                var list = JsonConvert.DeserializeObject<List<GraphInstance>>(listStr);
+                instance = list.FirstOrDefault();
+            });
             return instance;
         }
 
@@ -83,10 +89,10 @@ namespace SAGA.GplotRelationComputerManage
         /// 修改之前的图实例时间,然后创建新的,20171123)
         /// </summary>
         /// <param name="graphId">图类型</param>
-        /// <param name="statrDateTime"></param>
-        /// <param name="endDateTime"></param>
+        /// <param name="biginTime"></param>
+        /// <param name="endTime"></param>
         /// <returns></returns>
-        public  string UpdateGraphInstance(string graphId, string biginTime, string endTime)
+        public bool UpdateGraphInstance(string graphId, string biginTime, string endTime)
         {
             var baseUrl = GetBaseUrl();
             var password = GetPasswordQuerry();
@@ -102,12 +108,11 @@ namespace SAGA.GplotRelationComputerManage
             set.Add("periods", periods);
             var timeObject = new JObject();
             timeObject.Add("begin_time", biginTime);
-            timeObject.Add("end_time", "endTime");
-          
-            //string postData = $"{{\"criteria\":{{\"graph_id\":\"{graphId}\"}},\"set\":{{\"periods\":[{{\"begin_time\":\"{statrDateTime}\",\"end_time\":\"{endDateTime}\"}}]}}}}";
+            timeObject.Add("end_time", endTime);
+            periods.Add(timeObject);
             RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
-
-            return restClient.GetRequest().GetValue("graph_id");
+            var strResult = restClient.GetRequest();
+            return RequestResultUtil.HandlerResult(strResult);
         }
 
         /// <summary>
@@ -131,9 +136,9 @@ namespace SAGA.GplotRelationComputerManage
         /// <summary>
         /// 创建关系数据
         /// </summary>
-        /// <param name="criteria">关系数据</param>
+        /// <param name="items">关系数据</param>
         /// <returns></returns>
-        public  bool CreateRelations(List<GraphRelationItem> items)
+        public bool CreateRelations(List<GraphRelationItem> items)
         {
             var baseUrl = GetBaseUrl();
             var password = GetPasswordQuerry();
@@ -152,9 +157,8 @@ namespace SAGA.GplotRelationComputerManage
             }
             JObject jobject = new JObject();
             jobject.Add("criterias", JArray.FromObject(useItems));
-            RestClient restClient1 = new RestClient(url, HttpVerb.POST, JsonConvert.SerializeObject(jobject).ToString());
-            var result =restClient1.GetRequest().IsSuccess();
-            return result;      
+            RestClient restClient1 = new RestClient(url, HttpVerb.POST, jobject.ToString());
+            return RequestResultUtil.HandlerResult(restClient1.GetRequest()); ;      
         }
 
         /// <summary>

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

@@ -165,7 +165,7 @@
     <Compile Include="SystemRelation\Data\BinaryRelationItem.cs" />
     <Compile Include="SystemRelation\Data\EquipmentNode.cs" />
     <Compile Include="SystemRelation\Data\NodeExtendData.cs" />
-    <Compile Include="SystemRelation\Data\SetRelationItem.cs" />
+    <Compile Include="SystemRelation\Data\RelationItemSet.cs" />
     <Compile Include="SystemRelation\Data\SystemCurveItem.cs" />
     <Compile Include="SystemRelation\Data\SystemDrawItems.cs" />
     <Compile Include="SystemRelation\Data\SystemPointItem.cs" />

+ 10 - 3
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemParseManager.cs

@@ -464,7 +464,7 @@ namespace SAGA.GplotRelationComputerManage
                 foreach (var groupPosition in groupSystem.GroupBy(p=>p.DownPoint3D, comparer))
                 {
                     var currentGroupdId = ++groupId ;
-                    SetRelationItem set = new SetRelationItem();
+                    RelationItemSet relationItemSet = new RelationItemSet();
                     #region 处理绘图数据
                     foreach (var groupFloor in groupPosition.GroupBy(p => p.LevelName))
                     {
@@ -483,7 +483,7 @@ namespace SAGA.GplotRelationComputerManage
                         drawRecord.RefPipe = pipe;
                         drawRecord.SystemName = groupSystem.Key;
                         drawRecords.Add(drawRecord);
-                        set.AddRange(groupFloor.Select(v => string.Format("{0}:{1}", floorId, v.Id)));
+                        relationItemSet.AddRange(groupFloor.Select(v => string.Format("{0}:{1}", floorId, v.Id)));
                     }
                     #endregion
 
@@ -491,7 +491,7 @@ namespace SAGA.GplotRelationComputerManage
 
                     VerticalRelationRecord relationRecord = new VerticalRelationRecord();
                     relationRecord.SystemName = groupSystem.Key;
-                    relationRecord.RelationItems = set;
+                    relationRecord.RelationItems = relationItemSet;
                     relationRecords.Add(relationRecord);
                     #endregion
                 }
@@ -576,7 +576,14 @@ namespace SAGA.GplotRelationComputerManage
                     if (equipmentItem != null)
                     {
                         node.Name = equipmentItem.Name;
+                        var fi = elementsVertex.Data.FirstOrDefault(e => e is FamilyInstance);
+                        if (fi != null)
+                        {
+                            node.Location = fi.GetLocationPoint().XYZToPoint3D();
+                        }
+                      
                     }
+                   
                     nodeGraph.Nodes.Add(node);
                 }
                 #region 调整入度为零的点的顺序

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

@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------
- * 功能描述:SetRelationItem
+ * 功能描述:RelationItemSet
  * 作者:xulisong
  * 创建时间: 2019/1/22 16:45:42
  * 版本号:v1.0
@@ -16,7 +16,7 @@ namespace SAGA.GplotRelationComputerManage
     /// <summary>
     /// 集合关系类,其中的元素两两进行相关
     /// </summary>
-    public class SetRelationItem :List<string>
+    public class RelationItemSet :List<string>
     {
         /*
          * 目前,将立管之间的关系整理成集合关系

+ 5 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/ServerData/VerticalRelationRecord.cs

@@ -18,6 +18,10 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     public class VerticalRelationRecord : ServerData
     {
+        public VerticalRelationRecord()
+        {
+            RelationItems = new RelationItemSet();
+        }
         /// <summary>
         /// 系统名称
         /// </summary>
@@ -25,6 +29,6 @@ namespace SAGA.GplotRelationComputerManage
         /// <summary>
         /// 关联数据信息
         /// </summary>
-        public SetRelationItem RelationItems { get; set; }
+        public RelationItemSet RelationItems { get; set; }
     }
 }

+ 127 - 0
MBI/SAGA.MBI/RequestData/RequestResultUtil.cs

@@ -0,0 +1,127 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:RequestResultUtilcs
+ * 作者:xulisong
+ * 创建时间: 2019/2/22 9:39:16
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace SAGA.MBI.RequestData
+{
+    /// <summary>
+    /// 请求结果数据处理单元
+    /// </summary>
+    public class RequestResultUtil
+    {
+
+        #region 业务结果处理
+        /// <summary>
+        /// 业务结果处理
+        /// </summary>
+        /// <param name="responseResult"></param>
+        /// <param name="success"></param>
+        /// <param name="fail"></param>
+        /// <returns></returns>
+        public static bool HandlerResult(string responseResult, Action<JObject> success, Action<JObject> fail)
+        {
+            JObject result = JObject.Parse(responseResult);
+            RequestResult p = RequestResult.CreatePostResult(result);
+            if (p.IsSuccess)
+            {
+                success?.Invoke(result);
+                return true;
+            }
+
+            fail?.Invoke(result);
+            return false;
+        }
+
+        public static bool HandlerResult(string responseResult, Action<JObject> success)
+        {
+            return HandlerResult(responseResult, success, null);
+        }
+
+        public static bool HandlerResult(string responseResult)
+        {
+            return HandlerResult(responseResult, null, null);
+        }
+
+        #endregion
+    }
+
+    /// <summary>
+    /// 提交信息结果
+    /// </summary>
+    public class RequestResult
+    {
+        private static readonly Dictionary<string, List<string>> m_KeysCollection = new Dictionary<string, List<string>>();
+        static RequestResult()
+        {
+            m_KeysCollection.Add("result", new List<string> { "result", "Result" });
+            m_KeysCollection.Add("resultMsg", new List<string> { "resultMsg", "ResultMsg" });
+        }
+        public RequestResult()
+        {
+        }
+        public RequestResult(JObject jObject)
+        {
+            foreach (var keyCollection in m_KeysCollection)
+            {
+                foreach (string key in keyCollection.Value)
+                {
+                    JToken token = null;
+                    if (jObject.TryGetValue(key, out token))
+                    {
+                        SetValue(keyCollection.Key, token.ToString());
+                        continue;
+                    }
+                }
+            }        
+        }
+        /// <summary>
+        /// 提交结果
+        /// </summary>
+        [JsonProperty("result")]
+        public string Result { get; set; }
+        /// <summary>
+        /// 提交结果信息
+        /// </summary>
+        [JsonProperty("resultMsg")]
+        public string ResultMessage { get; set; }
+
+        /// <summary>
+        /// 是否成功
+        /// </summary>
+        public bool IsSuccess
+        {
+            get { return Result == "success"; }
+        }
+
+        private void SetValue(string propertyName, object value)
+        {
+            if (propertyName.ToUpper() == "Result".ToUpper())
+            {
+                this.Result = value.ToString();
+            }
+            else
+            {
+                this.ResultMessage = value.ToString();
+            }
+        }
+        public static RequestResult CreatePostResult(string str)
+        {
+            return Newtonsoft.Json.JsonConvert.DeserializeObject<RequestResult>(str);
+        }
+        public static RequestResult CreatePostResult(JObject jObject)
+        {
+            return new RequestResult(jObject);
+        }
+    }
+}

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

@@ -328,6 +328,7 @@
     <Compile Include="Model\MBSpace.cs" />
     <Compile Include="Model\MQRCode.cs" />
     <Compile Include="RequestData\QRCodeRequest.cs" />
+    <Compile Include="RequestData\RequestResultUtil.cs" />
     <Compile Include="RevitModelHandle\ParameterDefinitionFactory.cs" />
     <Compile Include="RevitModelHandle\ParameterUtil.cs" />
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />