PowerComputerContext.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:PowerComputerContext
  3. * 作者:xulisong
  4. * 创建时间: 2018/12/10 10:19:00
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using SAGA.MBI.DataArrange;
  13. using SAGA.Models;
  14. using MBIEquipItem = SAGA.Models.EquipmentItem;
  15. namespace SAGA.GplotRelationComputerManage
  16. {
  17. /*
  18. * 使用此类,可隔离计算。处理一些局部缓存的项;
  19. * 备用:如果以后分层计算可以使用此类加入控制量
  20. */
  21. /// <summary>
  22. /// 配电计算上下文
  23. /// </summary>
  24. public class PowerComputerContext
  25. {
  26. #region 楼层相关处理
  27. private Dictionary<string,string> m_DicFloorNames { get; set; }
  28. /// <summary>
  29. /// 通过楼层id获取楼层名称
  30. /// </summary>
  31. /// <param name="floorId"></param>
  32. /// <returns></returns>
  33. public string GetFloorName(string floorId)
  34. {
  35. string name = floorId;
  36. if (string.IsNullOrWhiteSpace(floorId))
  37. {
  38. return name;
  39. }
  40. if (m_DicFloorNames == null)
  41. {
  42. m_DicFloorNames= DalProjectTree.GetFloorNameAndId();
  43. }
  44. if (m_DicFloorNames == null)
  45. {
  46. return name;
  47. }
  48. m_DicFloorNames.TryGetValue(floorId, out name);
  49. return (name??floorId)??string.Empty;
  50. }
  51. #endregion
  52. #region 数据转换
  53. /// <summary>
  54. /// 转换成数据节点
  55. /// </summary>
  56. /// <param name="item"></param>
  57. /// <returns></returns>
  58. public DataNode ItemConvert(MBIItem item)
  59. {
  60. DataNode node = new DataNode(item.GetDisplay());
  61. node.EId = item.Id;
  62. node.Sno = item.LocalId;//设备本地编码
  63. node.InLineNo = item.CTM_MainPower?.Split(' ')[0];//进线号,主电
  64. node.InLineNo1 = item.CTM_StandbyPower; //进线号,备电
  65. node.FloorName = GetFloorName(item.FloorId);
  66. if (item is MBIEquipItem mbiItem)
  67. {
  68. node.Type = mbiItem.Category.Remove(0, 2);
  69. }
  70. else
  71. {
  72. node.Type = MBIBuiltInCategory.Si;
  73. }
  74. return node;
  75. }
  76. #endregion
  77. }
  78. }