|
@@ -16,6 +16,7 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
|
|
+using SAGA.GplotRelationComputerManage;
|
|
using MainWindow = SAGA.GplotDrawData.MainWindow;
|
|
using MainWindow = SAGA.GplotDrawData.MainWindow;
|
|
|
|
|
|
namespace SAGA.GplotRelationComputerManage
|
|
namespace SAGA.GplotRelationComputerManage
|
|
@@ -58,227 +59,38 @@ namespace SAGA.GplotRelationComputerManage
|
|
{
|
|
{
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
{
|
|
- var result = ComputerFromServer();
|
|
|
|
- if (result[0].Childrens.Count > 0)
|
|
|
|
|
|
+
|
|
|
|
+ #region 核心
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- // MainWindow window = new MainWindow(result[0].Childrens, result[1].Childrens);
|
|
|
|
-
|
|
|
|
- //window.UcShow.ComputerAction = () =>
|
|
|
|
- //{
|
|
|
|
- // result = ComputerFromServer();
|
|
|
|
- // window.ReLoad(result[0].Childrens, result[1].Childrens);
|
|
|
|
- //};
|
|
|
|
- //window.Title = "配电拓扑图:配电柜--配电柜";
|
|
|
|
- //window.Show();
|
|
|
|
-
|
|
|
|
- if (result[0].Childrens.Any())
|
|
|
|
|
|
+ DistributionRelationshipHandler handler = new DistributionRelationshipHandler();
|
|
|
|
+ var re = handler.GetViewData(new PowerComputerContext());
|
|
|
|
+ if (re[0].Childrens.Any())
|
|
{
|
|
{
|
|
- WinEquipmentRelation_Web window = new WinEquipmentRelation_Web(result[0].Childrens, result[1].Childrens);
|
|
|
|
|
|
+ WinEquipmentRelation_Web window =
|
|
|
|
+ new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
|
|
window.Title = "配电拓扑图:配电柜--配电柜";
|
|
window.Title = "配电拓扑图:配电柜--配电柜";
|
|
window.Show();
|
|
window.Show();
|
|
}
|
|
}
|
|
- }
|
|
|
|
- return Result.Succeeded;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 计算
|
|
|
|
- /// </summary>
|
|
|
|
- public void Computer()
|
|
|
|
- {
|
|
|
|
- ComputerFromServer();
|
|
|
|
- }
|
|
|
|
- public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
|
|
- {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Dictionary<string, string> floorNameAndId;
|
|
|
|
- /// <summary>
|
|
|
|
- /// 计算服务端配电
|
|
|
|
- /// </summary>
|
|
|
|
- public List<DataNode> ComputerFromServer()
|
|
|
|
- {
|
|
|
|
- var str = new[] { "TDHS", "TDLS", "TDTF", "TDLSDW" };
|
|
|
|
- List<JObject> datas = CommonConvert.QueryObjectInfoByTypes(str);
|
|
|
|
- var result = new List<DataNode>();
|
|
|
|
- floorNameAndId = DalProjectTree.GetFloorNameAndId();
|
|
|
|
- var allDataNodes = ConvertToDataNode(datas);
|
|
|
|
-
|
|
|
|
- DealServerDatas(allDataNodes);
|
|
|
|
- //独立树形:有子节点,父节点为空
|
|
|
|
- var incomingCabinet = allDataNodes.Where(t => t.Childrens.Count != 0 && t.Parent == null).ToList();
|
|
|
|
- //孤立节点:无父无子
|
|
|
|
- var orphanNodes = allDataNodes.Where(t => t.Childrens.Count == 0 && t.Parent == null).ToList();
|
|
|
|
- DrawDataServer.SaveAsFile<DataNode>(new DataNode("root") { Childrens = incomingCabinet }, "LUDistribution");
|
|
|
|
|
|
|
|
-
|
|
|
|
- result.Add(new DataNode() { Childrens = incomingCabinet });
|
|
|
|
- result.Add(new DataNode() { Childrens = orphanNodes });
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
- public void SaveData(List<DataNode> datas)
|
|
|
|
- {
|
|
|
|
- var orphanNodes = DealDatas(datas, out var incomingCabinet);
|
|
|
|
- if (incomingCabinet.Count > 0)
|
|
|
|
- {
|
|
|
|
- //将数据保存到数据库
|
|
|
|
- DataNode dn = new DataNode("低压配电");
|
|
|
|
- incomingCabinet.ToList().ForEach(t => dn.Childrens.Add(t));
|
|
|
|
- DbHelper.SaveAsFile<DataNode>(dn);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- private List<DataNode> DealDatas(List<DataNode> familyInstances, out List<DataNode> incomingCabinet)
|
|
|
|
- {
|
|
|
|
- var allDataNodes = familyInstances;
|
|
|
|
- //无信息节点的孤儿节点
|
|
|
|
- var orphanNodes = allDataNodes.Where(t => t.Sno == "" || t.Type == "" || t.EName == "").ToList();
|
|
|
|
- //正常数据
|
|
|
|
- var dataNodes = allDataNodes.Where(t => t.Sno != "" && t.Type != "" && t.EName != "").ToList();
|
|
|
|
- //找出所有出线柜(outgoingCubicle)
|
|
|
|
- //找出所有进线柜
|
|
|
|
- incomingCabinet = dataNodes.Where(t => t.Type == "进线柜" || t.Type == "母联柜").ToList();
|
|
|
|
- //总数据里面移除所有进线柜,并移除进线柜中非根节点的进线柜(进线柜的进线号为变压器)
|
|
|
|
- for (var i = 0; i < incomingCabinet.Count; i++)
|
|
|
|
- {
|
|
|
|
- var node = incomingCabinet[i];
|
|
|
|
- if ((dataNodes.Any(t => t.Sno == node.InLineNo && t.Type == "低压变压器") || node.Type == "母联柜" ||
|
|
|
|
- node.InLineNo == "") && node.EName != "")
|
|
|
|
- {
|
|
|
|
- dataNodes.Remove(node);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- incomingCabinet.Remove(node);
|
|
|
|
- i--;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- //incomingCabinet.ForEach(d => );
|
|
|
|
- //List<DataNode> incomingCabinetNode =
|
|
|
|
- incomingCabinet.ForEach(d =>
|
|
|
|
|
|
+ catch (Exception ex)
|
|
{
|
|
{
|
|
- if (d.Type != "母联柜")
|
|
|
|
- {
|
|
|
|
- GetRelationNode(d, dataNodes);
|
|
|
|
- }
|
|
|
|
- RemoveNode(d, dataNodes); //剩余的节点中去除已成数列的节点
|
|
|
|
- });
|
|
|
|
|
|
|
|
- //剩余节点中找到进线号不存在或者为空的节点,作为孤立点的子节点
|
|
|
|
- var oroot = dataNodes.Where(t => t.InLineNo == "" || dataNodes.All(o => o.Sno != t.InLineNo)).ToList();
|
|
|
|
- oroot.ForEach(d => { GetRelationNode(d, dataNodes); });
|
|
|
|
- orphanNodes.AddRange(oroot);
|
|
|
|
- return orphanNodes;
|
|
|
|
- }
|
|
|
|
- private void DealServerDatas(List<DataNode> familyInstances)
|
|
|
|
- {
|
|
|
|
- var count = familyInstances.Count;
|
|
|
|
- for (int i = 0; i < familyInstances.Count; i++)
|
|
|
|
- {
|
|
|
|
- var dn = familyInstances[i];
|
|
|
|
- GetRelationNodes(dn, familyInstances);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- public List<DataNode> ConvertToDataNode(List<JObject> datas)
|
|
|
|
- {
|
|
|
|
- var allDataNodes = datas.Select(f =>
|
|
|
|
- {
|
|
|
|
- var node = new DataNode(GetValue(f, "EquipLocalName"))//设备本地名称,
|
|
|
|
- {
|
|
|
|
- EId = GetValue(f, "EquipID"),
|
|
|
|
- Sno = GetValue(f, "EquipLocalID"),//设备本地编码
|
|
|
|
- InLineNo = GetValue(f, "ctm-MainPower"), //进线号,主电
|
|
|
|
- InLineNo1 = GetValue(f, "ctm-StandbyPower"), //进线号,主电
|
|
|
|
- FloorName = GetFloorNameByBimId(GetValue(f, "BIMID")), //+ //+ f.GetParameterString("所属柜号"),
|
|
|
|
- Infos = f,
|
|
|
|
- Type = (f["category"] + "").Remove(0, 2)//设备类型编码
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- return node;
|
|
|
|
- });
|
|
|
|
- return allDataNodes.ToList();
|
|
|
|
- }
|
|
|
|
- string GetFloorNameByBimId(string bimId)
|
|
|
|
- {
|
|
|
|
- if (string.IsNullOrEmpty(bimId)) return "";
|
|
|
|
- var id = bimId.Split(':')[0];
|
|
|
|
- if (floorNameAndId.ContainsKey(id))
|
|
|
|
- return floorNameAndId[id];
|
|
|
|
- return id;
|
|
|
|
- }
|
|
|
|
- public string GetValue(JObject equip, string propertyName)
|
|
|
|
- {
|
|
|
|
- string result = "";
|
|
|
|
- if (equip != null)
|
|
|
|
- {
|
|
|
|
- result = equip["infos"][propertyName] + "";
|
|
|
|
- //本地名称为空显示设备名称
|
|
|
|
- if (propertyName == "EquipLocalName" && result == "")
|
|
|
|
- {
|
|
|
|
- result = equip["infos"]["EquipName"] + "";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
- public List<DataNode> ConvertToDataNode(List<FamilyInstance> familyInstances)
|
|
|
|
- {
|
|
|
|
- var allDataNodes = familyInstances.Select(f =>
|
|
|
|
- {
|
|
|
|
- var node = new DataNode(f.GetParameterString("设备本地名称"))
|
|
|
|
- {
|
|
|
|
- EId = f.Id.ToString(),
|
|
|
|
- Sno = f.GetParameterString("设备本地编码"),
|
|
|
|
- InLineNo = f.GetParameterString("进线号") + f.GetParameterString("所属柜号"),
|
|
|
|
- Type = f.GetFamilySymbol().Name
|
|
|
|
- };
|
|
|
|
- return node;
|
|
|
|
- });
|
|
|
|
- return allDataNodes.ToList();
|
|
|
|
- }
|
|
|
|
- void GetRelationNode(DataNode dn, List<DataNode> datas)
|
|
|
|
- {
|
|
|
|
- var nodes = datas.Where(t => t.InLineNo == dn.Sno).ToList();
|
|
|
|
- if (nodes.Count > 0)
|
|
|
|
- {
|
|
|
|
- dn.Childrens.AddRange(nodes);
|
|
|
|
- datas.Remove(dn);
|
|
|
|
- foreach (var dataNode in nodes)
|
|
|
|
- {
|
|
|
|
- GetRelationNode(dataNode, datas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- void GetRelationNodes(DataNode dn, List<DataNode> datas)
|
|
|
|
- {
|
|
|
|
- var nodes = datas.Where(t => t.InLineNo == dn.Sno && dn.Sno != "").ToList();
|
|
|
|
- if (nodes.Count > 0 && dn.Childrens.Count == 0)
|
|
|
|
- {
|
|
|
|
- dn.Childrens.AddRange(nodes);
|
|
|
|
-
|
|
|
|
- foreach (var dataNode in nodes)
|
|
|
|
- {
|
|
|
|
- dataNode.Parent = dn;
|
|
|
|
- if (dataNode.Childrens.Count > 0) continue;//已查找过子节点
|
|
|
|
- GetRelationNodes(dataNode, datas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ MessageShow.Show(ex);
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ return Result.Succeeded;
|
|
}
|
|
}
|
|
- void RemoveNode(DataNode dn, List<DataNode> datas)
|
|
|
|
|
|
+ public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
{
|
|
{
|
|
- datas.Remove(dn);
|
|
|
|
- if (dn.Childrens.Count > 0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- foreach (var dataNode in dn.Childrens)
|
|
|
|
- {
|
|
|
|
- RemoveNode(dataNode, datas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 配电关系图--配电柜与配电设备
|
|
/// 配电关系图--配电柜与配电设备
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -288,179 +100,23 @@ namespace SAGA.GplotRelationComputerManage
|
|
{
|
|
{
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
{
|
|
- var result = ComputerFromServer();
|
|
|
|
- //if (result[0].Childrens.Count > 0)
|
|
|
|
- //{
|
|
|
|
- // MainWindow window = new MainWindow(result[0].Childrens, result[1].Childrens);
|
|
|
|
- // window.UcShow.ComputerAction = () =>
|
|
|
|
- // {
|
|
|
|
- // result = ComputerFromServer();
|
|
|
|
- // window.ReLoad(result[0].Childrens, result[1].Childrens);
|
|
|
|
- // };
|
|
|
|
- // window.Title = "配电拓扑图:配电柜--末端";
|
|
|
|
- // window.Show();
|
|
|
|
- //}
|
|
|
|
- if (result[0].Childrens.Any())
|
|
|
|
|
|
+ #region 核心处理
|
|
|
|
+ EquipPowerRelationshipHandler handler = new EquipPowerRelationshipHandler();
|
|
|
|
+ var re = handler.GetViewData(new PowerComputerContext());
|
|
|
|
+ if (re[0].Childrens.Any())
|
|
{
|
|
{
|
|
- WinEquipmentRelation_Web window = new WinEquipmentRelation_Web(result[0].Childrens, result[1].Childrens);
|
|
|
|
|
|
+ WinEquipmentRelation_Web window =
|
|
|
|
+ new WinEquipmentRelation_Web(re[0].Childrens, re[1].Childrens);
|
|
window.Title = "配电拓扑图:配电柜--末端";
|
|
window.Title = "配电拓扑图:配电柜--末端";
|
|
window.Show();
|
|
window.Show();
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
return Result.Succeeded;
|
|
return Result.Succeeded;
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 计算
|
|
|
|
- /// </summary>
|
|
|
|
- public void Computer()
|
|
|
|
- {
|
|
|
|
- ComputerFromServer();
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- /// <summary>
|
|
|
|
- /// 计算服务端配电
|
|
|
|
- /// </summary>
|
|
|
|
- public List<DataNode> ComputerFromServer()
|
|
|
|
- {
|
|
|
|
- List<DataNode> result = new List<DataNode>();
|
|
|
|
- //查询所有设备
|
|
|
|
- var str = new string[] { "Eq", "Si" };//元空间为Si
|
|
|
|
- List<JObject> datas = CommonConvert.QueryObjectInfoByTypes(str);
|
|
|
|
- floorNameAndId = DalProjectTree.GetFloorNameAndId();
|
|
|
|
- var allDataNodes = ConvertToDataNode(datas);
|
|
|
|
- DealServerDatas(allDataNodes);
|
|
|
|
-
|
|
|
|
- //查询低压开关柜,有父级的去掉。此功能只查看或检测有配电柜与设备的关系
|
|
|
|
- allDataNodes = allDataNodes.Where(t => t.Childrens.Count == 0 || t.Childrens.Any(n => n.Type != "TDLS"))
|
|
|
|
- .ToList();
|
|
|
|
- var incomingCabinet = allDataNodes.Where(t => t.Childrens.Count != 0 && t.Parent == null).ToList();
|
|
|
|
- var orphanNodes = allDataNodes.Where(t => t.Childrens.Count == 0 && t.Parent == null).ToList();
|
|
|
|
-
|
|
|
|
- //保存数据
|
|
|
|
- DrawDataServer.SaveAsFile<DataNode>(new DataNode("root") { Childrens = incomingCabinet }, "EquipPower");
|
|
|
|
- result.Add(new DataNode() { Childrens = incomingCabinet });
|
|
|
|
- result.Add(new DataNode() { Childrens = orphanNodes });
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 处理配电数据
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="familyInstances"></param>
|
|
|
|
- private void DealServerDatas(List<DataNode> familyInstances)
|
|
|
|
- {
|
|
|
|
- var tdls = familyInstances.Where(t => t.Type == "TDLS").ToList();
|
|
|
|
- var eqs = familyInstances.Where(t => t.Type != "TDLS").ToList();
|
|
|
|
- foreach (var dn in tdls)
|
|
|
|
- {
|
|
|
|
- GetRelationNodes(dn, eqs);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 转换数据
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="datas"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public List<DataNode> ConvertToDataNode(List<JObject> datas)
|
|
|
|
- {
|
|
|
|
- //参与配电拓扑计算的必须是配置主电自定义信息点的设备
|
|
|
|
- var allDataNodes = datas.Where(t => ((JObject)t["infos"]).Property("ctm-MainPower") != null).Select(f =>
|
|
|
|
- {
|
|
|
|
- DataNode node;
|
|
|
|
- //空间
|
|
|
|
- if (((JObject)f["infos"]).Property("RoomID") != null)
|
|
|
|
- {
|
|
|
|
- node = new DataNode(GetValue(f, "RoomLocalName"))//设备本地名称,
|
|
|
|
- {
|
|
|
|
- EId = GetValue(f, "RoomID"),
|
|
|
|
- Sno = "",// GetValue(f, "EquipLocalID"),//设备本地编码
|
|
|
|
- InLineNo = GetValue(f, "ctm-MainPower"), //进线号,主电
|
|
|
|
- InLineNo1 = GetValue(f, "ctm-StandbyPower"), //进线号,主电
|
|
|
|
- FloorName = GetFloorNameByBimId(GetValue(f, "BIMID")), //+ f.GetParameterString("所属柜号"),
|
|
|
|
- Type = "Si",//设备类型编码
|
|
|
|
- Infos = f
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- node = new DataNode(GetValue(f, "EquipLocalName"))//设备本地名称,
|
|
|
|
- {
|
|
|
|
- EId = GetValue(f, "EquipID"),
|
|
|
|
- Sno = GetValue(f, "EquipLocalID"),//设备本地编码
|
|
|
|
- InLineNo = GetValue(f, "ctm-MainPower").Split(' ')[0], //进线号,主电
|
|
|
|
- InLineNo1 = GetValue(f, "ctm-StandbyPower"), //进线号,主电
|
|
|
|
- FloorName = GetFloorNameByBimId(GetValue(f, "BIMID")), //+ //+ f.GetParameterString("所属柜号"),
|
|
|
|
- Type = (f["category"] + "").Remove(0, 2),//设备类型编码
|
|
|
|
- Infos = f
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return node;
|
|
|
|
- });
|
|
|
|
- return allDataNodes.ToList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 获取属性值
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="equip"></param>
|
|
|
|
- /// <param name="propertyName"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public string GetValue(JObject equip, string propertyName)
|
|
|
|
- {
|
|
|
|
- return RelationshipTools.GetValue(equip,propertyName);
|
|
|
|
- }
|
|
|
|
- /// <summary>
|
|
|
|
- /// 楼层名称与ID对应字典
|
|
|
|
- /// </summary>
|
|
|
|
- private Dictionary<string, string> floorNameAndId;
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 根据Id获取楼层名称
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="bimId"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- string GetFloorNameByBimId(string bimId)
|
|
|
|
- {
|
|
|
|
- {
|
|
|
|
- if (string.IsNullOrEmpty(bimId)) return "";
|
|
|
|
- var id = bimId.Split(':')[0];
|
|
|
|
- if (floorNameAndId.ContainsKey(id))
|
|
|
|
- return floorNameAndId[id];
|
|
|
|
- return id;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 处理对应关系
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="dn"></param>
|
|
|
|
- /// <param name="datas"></param>
|
|
|
|
- void GetRelationNodes(DataNode dn, List<DataNode> datas)
|
|
|
|
- {
|
|
|
|
- var nodes = datas.Where(t => (t.InLineNo == dn.Sno || t.InLineNo1 == dn.Sno) && dn.Sno != "").ToList();
|
|
|
|
- if (nodes.Count > 0 && dn.Childrens.Count == 0)
|
|
|
|
- {
|
|
|
|
- dn.Childrens.AddRange(nodes);
|
|
|
|
-
|
|
|
|
- foreach (var dataNode in nodes)
|
|
|
|
- {
|
|
|
|
- dataNode.Parent = dn;
|
|
|
|
- if (dataNode.Childrens.Count > 0) continue;
|
|
|
|
- GetRelationNodes(dataNode, datas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {//移除已有父节点的叶子节点
|
|
|
|
- if (dn.Parent != null)
|
|
|
|
- datas.Remove(dn);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -473,373 +129,26 @@ namespace SAGA.GplotRelationComputerManage
|
|
{
|
|
{
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
{
|
|
- var result = ComputerFromServer();
|
|
|
|
- if (result[0].Childrens.Count > 0)
|
|
|
|
|
|
+
|
|
|
|
+ #region 核心处理
|
|
|
|
+ ObjectControlRelationshipHandler handler = new ObjectControlRelationshipHandler();
|
|
|
|
+ var re = handler.GetViewData(new PowerComputerContext());
|
|
|
|
+ if (re[0].Childrens.Any())
|
|
{
|
|
{
|
|
- //WinControlRelation window = new WinControlRelation(result[0].Childrens, result[1].Childrens);
|
|
|
|
- WinControlRelation_Web window = new WinControlRelation_Web(result[0].Childrens, result[1].Childrens);
|
|
|
|
-
|
|
|
|
- //window.ComputerAction = () =>
|
|
|
|
- //{
|
|
|
|
- // result = ComputerFromServer();
|
|
|
|
- // window.ReLoad(result[0].Childrens, result[1].Childrens);
|
|
|
|
- //};
|
|
|
|
|
|
+ WinControlRelation_Web window =
|
|
|
|
+ new WinControlRelation_Web(re[0].Childrens, re[1].Childrens);
|
|
window.Title = "对象受控关系图";
|
|
window.Title = "对象受控关系图";
|
|
window.Show();
|
|
window.Show();
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
return Result.Succeeded;
|
|
return Result.Succeeded;
|
|
}
|
|
}
|
|
|
|
|
|
- public void Computer()
|
|
|
|
- {
|
|
|
|
- ComputerFromServer();
|
|
|
|
- }
|
|
|
|
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- /// <summary>
|
|
|
|
- /// 计算服务端配电
|
|
|
|
- /// </summary>
|
|
|
|
- public List<DataNode> ComputerFromServer()
|
|
|
|
- {
|
|
|
|
- List<DataNode> result = new List<DataNode>();
|
|
|
|
- //查询所有设备
|
|
|
|
- // var str = new string[] { "Eq", "BACP","BANC" };
|
|
|
|
- var str = new string[] { "BACP", "BANC" };
|
|
|
|
- List<JObject> ctrollersDatas = CommonConvert.QueryObjectInfoByTypes(str);
|
|
|
|
- var eqs = CommonConvert.QueryObjectInfoByTypes(new[] { "Eq" });
|
|
|
|
- floorNameAndId = DalProjectTree.GetFloorNameAndId();
|
|
|
|
- var cotrollersNodes = ConvertToDataNode(ctrollersDatas);
|
|
|
|
- var eqsNodes = ConvertEqToDataNode(eqs);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- foreach (var dn in cotrollersNodes)
|
|
|
|
- {
|
|
|
|
- GetRelationNodes(dn, eqsNodes);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //查询低压开关柜,有父级的去掉。此功能只查看或检测有配电柜与设备的关系
|
|
|
|
- cotrollersNodes = cotrollersNodes.Where(t => t.Childrens.Count == 0 || t.Childrens.Any(n => n.Type != "TDLS"))
|
|
|
|
- .ToList();
|
|
|
|
- var incomingCabinet = cotrollersNodes.Where(t => t.Childrens.Count != 0 && t.Parent == null).ToList();
|
|
|
|
-
|
|
|
|
- var orphanNodes = eqsNodes.Where(t => t.Childrens.Count == 0 && t.Parent == null).ToList();
|
|
|
|
- orphanNodes.AddRange(cotrollersNodes.Where(t => t.Childrens.Count == 0 && t.Parent == null).ToList());
|
|
|
|
-
|
|
|
|
- //保存数据到本地
|
|
|
|
- DrawDataServer.SaveAsFile<DataNode>(new DataNode("root") { Childrens = incomingCabinet }, "ControlRelation");
|
|
|
|
- result.Add(new DataNode() { Childrens = incomingCabinet });
|
|
|
|
- result.Add(new DataNode() { Childrens = orphanNodes });
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 转换数据
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="datas"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public List<DataNode> ConvertEqToDataNode(List<JObject> datas)
|
|
|
|
- {
|
|
|
|
- //参与配电拓扑计算的必须是配置主电自定义信息点的设备
|
|
|
|
- var allDataNodes = datas.Where(t => ((JObject)t["infos"]).Property("ctm-MainCtrl") != null).Select(f =>
|
|
|
|
- {
|
|
|
|
- DataNode node;
|
|
|
|
-
|
|
|
|
- node = new DataNode(GetValue(f, "EquipLocalName"))//设备本地名称,
|
|
|
|
- {
|
|
|
|
- EId = GetValue(f, "EquipID"),
|
|
|
|
- Sno = GetValue(f, "EquipLocalID"),//设备本地编码
|
|
|
|
- InLineNo = GetValue(f, "ctm-MainCtrl").Split(' ')[0], //进线号,主电
|
|
|
|
- InLineNo1 = GetValue(f, "ctm-StandbyCtrl"), //进线号,主电
|
|
|
|
- FloorName = GetFloorNameByBimId(GetValue(f, "BIMID")), //+ //+ f.GetParameterString("所属柜号"),
|
|
|
|
- Type = (f["category"] + "").Remove(0, 2),//设备类型编码
|
|
|
|
- Infos = f
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- return node;
|
|
|
|
- });
|
|
|
|
- return allDataNodes.ToList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static string GetValue(JObject equip, string propertyName)
|
|
|
|
- {
|
|
|
|
- return RelationshipTools.GetValue(equip, propertyName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<DataNode> ConvertToDataNode(List<JObject> datas)
|
|
|
|
- {
|
|
|
|
- //参与配电拓扑计算的必须是配置主电自定义信息点的设备
|
|
|
|
- var allDataNodes = datas.Select(f =>
|
|
|
|
- {
|
|
|
|
- DataNode node;
|
|
|
|
-
|
|
|
|
- node = new DataNode(GetValue(f, "EquipLocalName"))//设备本地名称,
|
|
|
|
- {
|
|
|
|
- EId = GetValue(f, "EquipID"),
|
|
|
|
- Sno = GetValue(f, "EquipLocalID"),//设备本地编码
|
|
|
|
- InLineNo = GetValue(f, "ctm-MainCtrl").Split(' ')[0], //进线号,主电
|
|
|
|
- InLineNo1 = GetValue(f, "ctm-StandbyCtrl"), //进线号,主电
|
|
|
|
- FloorName = GetFloorNameByBimId(GetValue(f, "BIMID")), //+ //+ f.GetParameterString("所属柜号"),
|
|
|
|
- Type = (f["category"] + "").Remove(0, 2),//设备类型编码
|
|
|
|
- Infos = f
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- return node;
|
|
|
|
- });
|
|
|
|
- return allDataNodes.ToList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private Dictionary<string, string> floorNameAndId;
|
|
|
|
- string GetFloorNameByBimId(string bimId)
|
|
|
|
- {
|
|
|
|
- {
|
|
|
|
- if (string.IsNullOrEmpty(bimId)) return "";
|
|
|
|
- var id = bimId.Split(':')[0];
|
|
|
|
- if (floorNameAndId.ContainsKey(id))
|
|
|
|
- return floorNameAndId[id];
|
|
|
|
- return id;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- void GetRelationNodes(DataNode dn, List<DataNode> datas)
|
|
|
|
- {
|
|
|
|
- var nodes = datas.Where(t => (t.InLineNo == dn.Sno || t.InLineNo1 == dn.Sno) && dn.Sno != "").ToList();
|
|
|
|
- if (nodes.Count > 0 && dn.Childrens.Count == 0)
|
|
|
|
- {
|
|
|
|
- dn.Childrens.AddRange(nodes);
|
|
|
|
-
|
|
|
|
- foreach (var dataNode in nodes)
|
|
|
|
- {
|
|
|
|
- dataNode.Parent = dn;
|
|
|
|
- if (dataNode.Childrens.Count > 0) continue;
|
|
|
|
- GetRelationNodes(dataNode, datas);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {//移除已有父节点的叶子节点
|
|
|
|
- if (dn.Parent != null)
|
|
|
|
- datas.Remove(dn);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 参数设置
|
|
|
|
- /// </summary>
|
|
|
|
- [Transaction(TransactionMode.Manual)]
|
|
|
|
- [Regeneration(RegenerationOption.Manual)]
|
|
|
|
- public class SettingCommand : ExternalCommand
|
|
|
|
- {
|
|
|
|
- public SettingCommand()
|
|
|
|
- {
|
|
|
|
- IsShowNoDocument = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Document linkDoc;
|
|
|
|
- public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
|
|
- {
|
|
|
|
- base.Execute(commandData, ref message, elements);
|
|
|
|
- var uiApp = ExternalDataWrapper.Current.UiApp;
|
|
|
|
- //打开所有楼层数据
|
|
|
|
- var fileInfos = RevitModelPath.GetAllRevitFiles();
|
|
|
|
- //所有项目中所有文档
|
|
|
|
- // Document linkDoc = uiApp.Application.OpenDocumentFile(@"C:\Users\sagacloud\Documents\项目1.rvt");
|
|
|
|
- linkDoc = ExternalDataWrapper.Current.Doc;
|
|
|
|
- using (Transaction trans = new Transaction(linkDoc, "读取风管系统"))
|
|
|
|
- {
|
|
|
|
- trans.Start();
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- var element = uiApp.PickElement("选择空间", typeof(SpatialElement));
|
|
|
|
- // GplotRelationComputerManage.ReadSpaceCommand cmd = new ReadSpaceCommand();
|
|
|
|
-
|
|
|
|
- // type = linkDoc.GetElements<ConduitType>().FirstOrDefault();
|
|
|
|
-
|
|
|
|
- List<Space> rooms = linkDoc.GetElements<SpatialElement>().OfType<Space>().ToList();
|
|
|
|
- // var zls = new ReleSpace(rooms.FirstOrDefault(t => t.Id.IntegerValue==329732)
|
|
|
|
- //);
|
|
|
|
- if (element is Space space)
|
|
|
|
- {
|
|
|
|
- var zls = rooms.FirstOrDefault();
|
|
|
|
- var curves = zls.GetBoundaryCurves();
|
|
|
|
- var combin = curves;// CombinCurves(curves);
|
|
|
|
- //foreach (var curve in combin)
|
|
|
|
- //{
|
|
|
|
- // curve.NewDetailCurve();
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- ReadSpaceCommand cmd = new ReadSpaceCommand();
|
|
|
|
- var s = cmd.ConvertSpace(space);
|
|
|
|
- foreach (var edgeInfo in s)
|
|
|
|
- {
|
|
|
|
- var line = edgeInfo.SegEdge.NewDetailCurve();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- //zls.DoorLocation = zls.RoomCenter;
|
|
|
|
- //level = zls.Room.Level;
|
|
|
|
- //cmd.Test(zls, rooms);
|
|
|
|
- //Connection(zls);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var zls = rooms.FirstOrDefault();
|
|
|
|
- // var curves = zls.GetBoundaryCurves();
|
|
|
|
- //var combin = curves;// CombinCurves(curves);
|
|
|
|
- foreach (var ss in rooms)
|
|
|
|
- {
|
|
|
|
- ReadSpaceCommand cmd = new ReadSpaceCommand();
|
|
|
|
- var s = cmd.ConvertSpace(ss);
|
|
|
|
- foreach (var edgeInfo in s)
|
|
|
|
- {
|
|
|
|
- var line = edgeInfo.SegEdge.NewDetailCurve();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- trans.Commit();
|
|
|
|
- }
|
|
|
|
- catch (Exception ex)
|
|
|
|
- {
|
|
|
|
- MessageBox.Show(ex.StackTrace);
|
|
|
|
- trans.RollBack();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return Result.Succeeded;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- public List<Curve> CombinCurves(List<Curve> closeCurves)
|
|
|
|
- {
|
|
|
|
- List<Curve> curves = new List<Curve>();
|
|
|
|
- var first = closeCurves.FirstOrDefault();
|
|
|
|
- closeCurves.Remove(first);
|
|
|
|
- var start = first.StartPoint();
|
|
|
|
- var end = first.EndPoint();
|
|
|
|
- while (closeCurves.Count > 0)
|
|
|
|
- {
|
|
|
|
- var second = closeCurves.FirstOrDefault(t => t.StartPoint().IsEqual(start) || t.EndPoint().IsEqual(start));
|
|
|
|
- if (second == null) return curves;
|
|
|
|
- if (first.IsParallel(second)) //平行且共点合并
|
|
|
|
- {
|
|
|
|
- start = start.IsEqual(second.StartPoint()) ? second.EndPoint() : second.StartPoint();
|
|
|
|
- //拼接成新的直线
|
|
|
|
- curves.Add(start.NewLine(end));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- end = start;
|
|
|
|
- start = start.IsEqual(second.StartPoint()) ? second.EndPoint() : second.StartPoint();
|
|
|
|
- curves.Add(second);
|
|
|
|
- }
|
|
|
|
- closeCurves.Remove(second);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return curves;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// 参数设置
|
|
|
|
- /// </summary>
|
|
|
|
- [Transaction(TransactionMode.Manual)]
|
|
|
|
- [Regeneration(RegenerationOption.Manual)]
|
|
|
|
- public class GetBoundSegsCommand : ExternalCommand
|
|
|
|
- {
|
|
|
|
- public GetBoundSegsCommand()
|
|
|
|
- {
|
|
|
|
- IsShowNoDocument = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private Document linkDoc;
|
|
|
|
-
|
|
|
|
- public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
|
|
- {
|
|
|
|
- base.Execute(commandData, ref message, elements);
|
|
|
|
- var uiApp = ExternalDataWrapper.Current.UiApp;
|
|
|
|
- //打开所有楼层数据
|
|
|
|
- var fileInfos = RevitModelPath.GetAllRevitFiles();
|
|
|
|
- //所有项目中所有文档
|
|
|
|
- // Document linkDoc = uiApp.Application.OpenDocumentFile(@"C:\Users\sagacloud\Documents\项目1.rvt");
|
|
|
|
- linkDoc = ExternalDataWrapper.Current.Doc;
|
|
|
|
- using (Transaction trans = new Transaction(linkDoc, "读取风管系统"))
|
|
|
|
- {
|
|
|
|
- trans.Start();
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- var element = uiApp.PickElement("选择空间", typeof(SpatialElement));
|
|
|
|
- // GplotRelationComputerManage.ReadSpaceCommand cmd = new ReadSpaceCommand();
|
|
|
|
-
|
|
|
|
- // type = linkDoc.GetElements<ConduitType>().FirstOrDefault();
|
|
|
|
-
|
|
|
|
- List<Space> rooms = linkDoc.GetElements<SpatialElement>().OfType<Space>().ToList();
|
|
|
|
- // var zls = new ReleSpace(rooms.FirstOrDefault(t => t.Id.IntegerValue==329732)
|
|
|
|
- //);
|
|
|
|
- if (element is Space space)
|
|
|
|
- {
|
|
|
|
- var zls = rooms.FirstOrDefault();
|
|
|
|
- var curves = zls.GetBoundaryCurves();
|
|
|
|
- var combin = curves; // CombinCurves(curves);
|
|
|
|
- //foreach (var curve in combin)
|
|
|
|
- //{
|
|
|
|
- // curve.NewDetailCurve();
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- ReadSpaceCommand cmd = new ReadSpaceCommand();
|
|
|
|
- var s = cmd.ConvertSpace(space);
|
|
|
|
- foreach (var edgeInfo in s)
|
|
|
|
- {
|
|
|
|
- var line = edgeInfo.SegEdge.NewDetailCurve();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //zls.DoorLocation = zls.RoomCenter;
|
|
|
|
- //level = zls.Room.Level;
|
|
|
|
- //cmd.Test(zls, rooms);
|
|
|
|
- //Connection(zls);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var zls = rooms.FirstOrDefault();
|
|
|
|
-
|
|
|
|
- foreach (var room in rooms)
|
|
|
|
- {
|
|
|
|
- var curves = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
|
|
|
|
- var combin = curves; // CombinCurves(curves);
|
|
|
|
- foreach (var curve in curves)
|
|
|
|
- {
|
|
|
|
- foreach (var boundarySegment in curve)
|
|
|
|
- {
|
|
|
|
- var elem = linkDoc.GetElement(boundarySegment.ElementId);
|
|
|
|
- if (elem is Wall wall)
|
|
|
|
- {
|
|
|
|
- var wallLine = wall.Location.GetCurve();
|
|
|
|
- wallLine.NewDetailCurve();
|
|
|
|
- }
|
|
|
|
- else if (elem is ModelCurve modelCurve)
|
|
|
|
- {
|
|
|
|
- var wallLine = modelCurve.GetCurve();
|
|
|
|
- wallLine.NewDetailCurve();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- trans.Commit();
|
|
|
|
- }
|
|
|
|
- catch (Exception ex)
|
|
|
|
- {
|
|
|
|
- MessageBox.Show(ex.StackTrace);
|
|
|
|
- trans.RollBack();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return Result.Succeeded;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|