1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*-------------------------------------------------------------------------
- * 功能描述:PowerComputerContext
- * 作者:xulisong
- * 创建时间: 2018/12/10 10:19:00
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SAGA.MBI.DataArrange;
- using SAGA.Models;
- using MBIEquipItem = SAGA.Models.EquipmentItem;
- namespace SAGA.GplotRelationComputerManage
- {
- /*
- * 使用此类,可隔离计算。处理一些局部缓存的项;
- * 备用:如果以后分层计算可以使用此类加入控制量
- */
- /// <summary>
- /// 配电计算上下文
- /// </summary>
- public class PowerComputerContext
- {
- #region 楼层相关处理
- private Dictionary<string,string> m_DicFloorNames { get; set; }
- /// <summary>
- /// 通过楼层id获取楼层名称
- /// </summary>
- /// <param name="floorId"></param>
- /// <returns></returns>
- public string GetFloorName(string floorId)
- {
- string name = floorId;
- if (string.IsNullOrWhiteSpace(floorId))
- {
- return name;
- }
- if (m_DicFloorNames == null)
- {
- m_DicFloorNames= DalProjectTree.GetFloorNameAndId();
- }
- if (m_DicFloorNames == null)
- {
- return name;
- }
- m_DicFloorNames.TryGetValue(floorId, out name);
- return (name??floorId)??string.Empty;
- }
- #endregion
- #region 数据转换
- /// <summary>
- /// 转换成数据节点
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- public DataNode ItemConvert(MBIItem item)
- {
- DataNode node = new DataNode(item.GetDisplay());
-
- node.EId = item.Id;
- node.Sno = item.LocalId;//设备本地编码
- node.InLineNo = item.CTM_MainPower?.Split(' ')[0];//进线号,主电
- node.InLineNo1 = item.CTM_StandbyPower; //进线号,备电
- node.FloorName = GetFloorName(item.FloorId);
- if (item is MBIEquipItem mbiItem)
- {
- node.Type = mbiItem.Category.Remove(0, 2);
- }
- else
- {
- node.Type = MBIBuiltInCategory.Si;
- }
- return node;
- }
- #endregion
- }
- }
|