Selaa lähdekoodia

xls:部分关系修改

xls 6 vuotta sitten
vanhempi
commit
301166517d

+ 17 - 3
MBI/SAGA.GplotManage/RelationManager/ElectricalRelationUploader.cs

@@ -12,7 +12,7 @@ namespace SAGA.GplotManage
     {
         public ElectricalRelationUploader(string relationType, string relationDisplay) : base(relationType, relationDisplay)
         {
-            CurrentHandler=ElectricalRelationHandlerFactory.Create(relationType);
+            CurrentHandler = ElectricalRelationHandlerFactory.Create(relationType);
         }
         public IElectricalRelationHandler CurrentHandler { get; private set; }
         public override void Upload()
@@ -20,7 +20,7 @@ namespace SAGA.GplotManage
             //计算数据
             if (CurrentHandler == null)
                 return;
-           
+
             //加载数据
             var data = CurrentHandler.GetComputeData(new PowerComputerContext()); ;
 
@@ -30,11 +30,25 @@ namespace SAGA.GplotManage
         public override void Upload(object loadData)
         {
             List<DataNode> dataNodes = loadData as List<DataNode>;
-            if(dataNodes==null)
+            if (dataNodes == null)
             {
                 return;
             }
             //上传数据处理
         }
+
+        #region 数据上传方法
+        private void CreateGraph(DataNode dn, List<ReleateData> data)
+        {
+            if (dn.Childrens.Count > 0)
+            {
+                foreach (var n in dn.Childrens)
+                {
+                    data.Add(GetReleateData(dn.EId, n.EId));
+                    CreateGraph(n, data);
+                }
+            }
+        }
+        #endregion
     }
 }

+ 3 - 1
MBI/SAGA.GplotManage/RelationManager/RelationDataManager.cs

@@ -28,7 +28,9 @@ namespace SAGA.GplotManage
             }
             //计算数据,以后可能合并
             #region 计算空间数据
-
+            SpaceComputerHandler spaceHandler = new SpaceComputerHandler();
+            spaceHandler.ComputerWidthCache();
+            SpaceData=SpaceComputerDataUtil.LoadData();
             #endregion
             #region 计算管道数据
             SystemComputerHandler systemHandler = new SystemComputerHandler();

+ 63 - 4
MBI/SAGA.GplotManage/RelationManager/SpaceRelationUploader.cs

@@ -1,4 +1,6 @@
-using System;
+using SAGA.GplotRelationComputerManage;
+using SAGA.Models;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -16,16 +18,73 @@ namespace SAGA.GplotManage
         public override void Upload()
         {
             //计算数据
-
+            SpaceComputerHandler spaceHandler = new SpaceComputerHandler();
+            spaceHandler.ComputerWidthCache();
             //加载数据
-            var data = string.Empty;
-
+            var data = SpaceComputerDataUtil.LoadData();
             //使用数据
             Upload(data);
         }
+
         public override void Upload(object loadData)
         {
+            SpaceData spaces = loadData as SpaceData;
+            if (spaces == null) return;
+            spaces = GetSpaceData(spaces, GetRelatedEnum());
+            foreach (var floorSpaceData in spaces.FloorDatas)
+            {
+                foreach (var space in floorSpaceData.EndPoints)
+                {
+                    List<AdjacentSpace> relationSpaces = new List<AdjacentSpace>(space.AdjacentSpaces);
+                    relationSpaces.AddRange(space.UpElements);
+                    foreach (var adjacentSpace in relationSpaces)
+                    {
+                        //var rdata = GetReleateData(space.Id, adjacentSpace.Space.Id, ((int)GetRelationType(adjacentSpace.RelatedEnum)) + "");
+                        //this.Criterias.criterias.Add(rdata);
+                    }
+                }
+            }
+        }
 
+
+        #region 准备数据
+        public SpaceRelatedEnum GetRelatedEnum()
+        {
+            #region 获取关联信息
+            switch (RelationType)
+            {
+                case "a":
+                    {
+                        return SpaceRelatedEnum.Adjacent;
+                    }
+                case "b":
+                    {
+                        return SpaceRelatedEnum.Crossing;
+                    }
+                case "c":
+                    {
+                        return SpaceRelatedEnum.Radiation;
+                    }
+                case "d":
+                    {
+                        return SpaceRelatedEnum.Ventilation;
+                    }
+            }
+            return SpaceRelatedEnum.Adjacent; 
+            #endregion
+        }
+        public  SpaceData GetSpaceData(SpaceData spaces,SpaceRelatedEnum spaceRelated)
+        {
+            foreach (var fd in spaces.FloorDatas)
+            {
+                foreach (var space in fd.EndPoints)
+                {
+                    space.AdjacentSpaces = space.AdjacentSpaces.Where(s=>s.RelatedEnum.HasFlag(spaceRelated)).ToList();
+                    space.UpElements = space.UpElements.Where(s => s.RelatedEnum.HasFlag(spaceRelated)).ToList();
+                }
+            }
+            return spaces;
         }
+        #endregion
     }
 }

+ 7 - 3
MBI/SAGA.GplotManage/SAGA.GplotManage.csproj

@@ -129,6 +129,12 @@
     <Compile Include="GplotManage\GplotView\GplotView.cs" />
     <Compile Include="Command\GplotUtil.cs" />
     <Compile Include="GraphTypeEnum.cs" />
+    <Compile Include="RelationManager\ElectricalRelationUploader.cs" />
+    <Compile Include="RelationManager\IRelationUploader.cs" />
+    <Compile Include="RelationManager\RelationDataManager.cs" />
+    <Compile Include="RelationManager\RelationUploader.cs" />
+    <Compile Include="RelationManager\SpaceRelationUploader.cs" />
+    <Compile Include="RelationManager\SystemRelationUploader.cs" />
     <Compile Include="SystemChecks\CheckSystemResultView.xaml.cs">
       <DependentUpon>CheckSystemResultView.xaml</DependentUpon>
     </Compile>
@@ -254,9 +260,7 @@
       <Generator>MSBuild:Compile</Generator>
     </Page>
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="RelationManager\" />
-  </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\MrAdvice.2.5.24\build\MrAdvice.targets" Condition="Exists('..\packages\MrAdvice.2.5.24\build\MrAdvice.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/DistributionRelationshipHandler.cs

@@ -17,7 +17,7 @@ using MBIEquipItem = SAGA.Models.EquipmentItem;
 
 namespace SAGA.GplotRelationComputerManage
 {
-    public sealed class DistributionRelationshipHandler //: IElectricalRelationHandler
+    public sealed class DistributionRelationshipHandler : IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs

@@ -16,7 +16,7 @@ using SAGA.Models;
 using MBIEquipItem = SAGA.Models.EquipmentItem;
 namespace SAGA.GplotRelationComputerManage
 {
-    public class EquipPowerRelationshipHandler //: IElectricalRelationHandler
+    public class EquipPowerRelationshipHandler : IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 1 - 1
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/ObjectControlRelationshipHandler.cs

@@ -17,7 +17,7 @@ using MBIEquipItem = SAGA.Models.EquipmentItem;
 
 namespace SAGA.GplotRelationComputerManage
 {
-    public class ObjectControlRelationshipHandler //: IElectricalRelationHandler
+    public class ObjectControlRelationshipHandler : IElectricalRelationHandler
     {
         public string ElectricalRelationType
         {

+ 15 - 12
MBI/SAGA.GplotRelationComputerManage/RelationBll/RelationBll.cs

@@ -119,19 +119,22 @@ namespace SAGA.GplotRelationComputerManage
         /// 获取图实例ID
         /// </summary>
         /// <returns></returns>
-        public string GetGraphId(string graphyType)
+        public string GetGraphId(string graphType)
         {
-            var instance = QueryGraphInstance(graphyType);
-            var nowTime = DateTime.Now;
-          
-            if (instance.IsValid)
-            {
-                //将图类型的终止时间改成当前时间
-                UpdateGraphInstance(instance.Id, instance.BeginTime, nowTime.ToString("yyyyMMddHHmmss"));
-            }               
-            //创建新的图类型
-            var newGraphId = AddGraphInstance(graphyType, nowTime.ToString("yyyyMMddHHmmss"));
-            return newGraphId;
+            string graphId = null;
+            var baseUrl = GetBaseUrl();
+            var password = GetPasswordQuerry();
+            string url = $"{baseUrl}graph_instance/get?{password}";
+            JObject jObject = new JObject();
+            jObject.Add("graph_type", graphType);
+
+            string postData = jObject.ToString();
+            RestClient client = new RestClient(url, HttpVerb.POST, postData);
+            string request = client.PostRequest();
+            JObject result = JObject.Parse(request);
+            RequestResultUtil.HandlerResult(request, (obj) => graphId = obj.GetValueEx("graph_id"));
+
+            return graphId;
         }
         /// <summary>
         /// 创建关系数据

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

@@ -132,6 +132,7 @@
     <Compile Include="PowerDistribution\Common\PowerComputerContext.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\DistributionRelationshipHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\EquipPowerRelationshipHandler.cs" />
+    <Compile Include="PowerDistribution\ComputerHandler\IElectricalRelationHandler.cs" />
     <Compile Include="PowerDistribution\ComputerHandler\ObjectControlRelationshipHandler.cs" />
     <Compile Include="PumpEnd\DrawEnd.cs" />
     <Compile Include="PumpEnd\DuctTerminalBll.cs" />

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

@@ -143,7 +143,8 @@ namespace SAGA.GplotRelationComputerManage
             var levelNames = levels.Select(l => l.Name).ToList();
             spaceData.LevelNames = levelNames;
             SpaceComputerDataUtil.SaveData(spaceData);
-            //DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>(SpaceData.FloorDatas) , SpaceData.LevelNames);
+            //暂时放开,全部更新完了要删除
+            DrawDataServer.SaveSpaceFloorData(new List<FloorSpaceData>(spaceData.FloorDatas) , spaceData.LevelNames);
         }
     }
 }