|
@@ -0,0 +1,137 @@
|
|
|
+/*-------------------------------------------------------------------------
|
|
|
+ * 功能描述:SpaceAirSupplyHandler
|
|
|
+ * 作者:xulisong
|
|
|
+ * 创建时间: 2019/4/12 14:56:14
|
|
|
+ * 版本号:v1.0
|
|
|
+ * -------------------------------------------------------------------------*/
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using SAGA.DotNetUtils.Cache;
|
|
|
+using SAGA.DotNetUtils.Data;
|
|
|
+using SAGA.Models;
|
|
|
+
|
|
|
+namespace SAGA.GplotManage.TopologyApplication
|
|
|
+{
|
|
|
+ public class SpaceAirSupplyHandler
|
|
|
+ {
|
|
|
+ public SpaceAirSupplyHandler()
|
|
|
+ {
|
|
|
+ EquipmentItems = TopologyApplicationUtil.CreateEquipmentItems();
|
|
|
+ Rooms= TopologyApplicationUtil.CreateRoomItems();
|
|
|
+ Floors = TopologyApplicationUtil.CreateFloorItems();
|
|
|
+ }
|
|
|
+ #region 数据获取
|
|
|
+ /// <summary>
|
|
|
+ /// 缓存设备
|
|
|
+ /// </summary>
|
|
|
+ public CacheItems<string, EquipmentItem> EquipmentItems { get; private set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 缓存空间对象
|
|
|
+ /// </summary>
|
|
|
+ public CacheItems<string, RoomItem> Rooms { get; private set; }
|
|
|
+
|
|
|
+ public CacheItems<string, FloorItem> Floors { get; private set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 获取图关系
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="graphType"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private SimpleGraph<string, string> GetGraph(string graphType)
|
|
|
+ {
|
|
|
+ SimpleGraph<string, string> result = TopologyApplicationUtil.GetGraph(graphType);
|
|
|
+ foreach (var resultVertex in result.Vertexes)
|
|
|
+ {
|
|
|
+ var useCategory= EquipmentItems.GetItem(resultVertex.Id)?.Category;
|
|
|
+ if (!string.IsNullOrWhiteSpace(useCategory))
|
|
|
+ {
|
|
|
+ useCategory = useCategory.Remove(0, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ resultVertex.Data = useCategory;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public bool Execute()
|
|
|
+ {
|
|
|
+ /*1、找到数据源 图信息
|
|
|
+ * 2、找到为风口的点
|
|
|
+ * 3、根据风口找与风口相关联的机组设备
|
|
|
+ * 4、查找风口所在的空间信息
|
|
|
+ * 5、产生计算结果数据
|
|
|
+ */
|
|
|
+ List<SpaceAirSupplyResultItem> result = new List<SpaceAirSupplyResultItem>();
|
|
|
+ List<string> supplyEquipmentCategories = new List<string>()
|
|
|
+ {MBIBuiltInCategory.ATAH, MBIBuiltInCategory.ATFC, MBIBuiltInCategory.ATFU};
|
|
|
+ List<string> graphTypes = new List<string>(){ "ACAirNetwork", "FreshAirNetwork" };
|
|
|
+ SimpleGraph<string, string> equipinElementSp = null;
|
|
|
+ foreach (var graphType in graphTypes)
|
|
|
+ {
|
|
|
+ var graph = GetGraph(graphType);
|
|
|
+ var airPorts = graph.Vertexes.Where(v => v.Data == MBIBuiltInCategory.ATIO||v.Data== MBIBuiltInCategory.VTIO).ToList();
|
|
|
+ foreach (var airPort in airPorts)
|
|
|
+ {
|
|
|
+ var paths=graph.GetPaths2(airPort, v => supplyEquipmentCategories.Contains(v.Data));
|
|
|
+ List<SpaceAirSupplyResultItem> useItems = new List<SpaceAirSupplyResultItem>();
|
|
|
+ foreach (var endPathNode in paths)
|
|
|
+ {
|
|
|
+ var useEdge = endPathNode.LastOrDefault();
|
|
|
+ if (useEdge == null)
|
|
|
+ continue;
|
|
|
+ if (supplyEquipmentCategories.Contains((useEdge.NextNode.Data)))
|
|
|
+ {
|
|
|
+ if (equipinElementSp == null)
|
|
|
+ {
|
|
|
+ equipinElementSp = GetGraph("EquipinElementSp");
|
|
|
+ }
|
|
|
+ SpaceAirSupplyResultItem item = new SpaceAirSupplyResultItem();
|
|
|
+ item.AirVent = EquipmentItems.GetItem(airPort.Id);
|
|
|
+ if (item.AirVent != null)
|
|
|
+ {
|
|
|
+ item.Floor = Floors.GetItem(item.AirVent.FloorId);
|
|
|
+ }
|
|
|
+ item.AirSupply = EquipmentItems.GetItem(useEdge.NextNode.Id);
|
|
|
+ var spaceRelations = equipinElementSp.GetOutVertexes(airPort.Id);
|
|
|
+ if (spaceRelations != null && spaceRelations.Any())
|
|
|
+ {
|
|
|
+ item.Space = Rooms.GetItem(spaceRelations[0].Id);
|
|
|
+ }
|
|
|
+ useItems.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!useItems.Any())
|
|
|
+ {
|
|
|
+ SpaceAirSupplyResultItem item = new SpaceAirSupplyResultItem();
|
|
|
+ item.AirVent = EquipmentItems.GetItem(airPort.Id);
|
|
|
+ if (item.AirVent != null)
|
|
|
+ {
|
|
|
+ item.Floor = Floors.GetItem(item.AirVent.FloorId);
|
|
|
+ }
|
|
|
+
|
|
|
+ useItems.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.AddRange(useItems);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SpaceAirSupplyDocUtil.Save(@"E:\airport.xlsx",result);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ public static bool ShellExecute()
|
|
|
+ {
|
|
|
+ //类的静态方法,装饰类的实例方法
|
|
|
+ SpaceAirSupplyHandler handler = new SpaceAirSupplyHandler();
|
|
|
+ return handler.Execute();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|