DataCheckRule.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* ==============================================================================
  2. * 功能描述:数据检查规范
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/11/7 15:40:23
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text.RegularExpressions;
  10. using SAGA.DotNetUtils;
  11. using SAGA.DotNetUtils.NPOI;
  12. namespace Saga.PlugIn.ModelCheck
  13. {
  14. /// <summary>
  15. /// DataCheckRule
  16. /// </summary>
  17. class DataCheckRule
  18. {
  19. /// <summary>
  20. /// 获取设备编码检查Cateogry 列表
  21. /// </summary>
  22. /// <returns></returns>
  23. public static List<DCR_CodeCheckCategory> GetCodeCheckCategories()
  24. {
  25. var list = NPOIHelper
  26. .ConvertExcelSheetToModel<DCR_CodeCheckCategory>(DCRExport.MCRPath);
  27. return list;
  28. }
  29. /// <summary>
  30. /// 获取预定义的连接件类
  31. /// </summary>
  32. /// <returns></returns>
  33. public static List<DCR_Connector> GetPreDefineConnectors()
  34. {
  35. var list = NPOIHelper
  36. .ConvertExcelSheetToModel<DCR_Connector>(DCRExport.MCRPath);
  37. return list;
  38. }
  39. /// <summary>
  40. /// 获取可识别的管道系统名称
  41. /// </summary>
  42. /// <returns></returns>
  43. public static List<DCR_MEPSystem> GetMepSystems()
  44. {
  45. var list = NPOIHelper
  46. .ConvertExcelSheetToModel<DCR_MEPSystem>(DCRExport.MCRPath);
  47. return list;
  48. }
  49. /// <summary>
  50. /// 获取设备关联的系统类型
  51. /// </summary>
  52. /// <returns></returns>
  53. public static List<DCR_EquipReferSystem> GetEquipReferSystems()
  54. {
  55. var list = NPOIHelper
  56. .ConvertExcelSheetToModel<DCR_SystemReferEquip>(DCRExport.MCRPath);
  57. List<Tuple<string, string>> tuples = new List<Tuple<string, string>>();
  58. //将集合转化为:系统名称-设备名称
  59. list.ForEach(t => t.Equips.ForEach(tt => tuples.Add(new Tuple<string, string>(t.SystemName, tt))));
  60. //将集合转化为:设备名称-多个系统名称
  61. var newList = tuples.GroupBy(t => t.Item2).Select(tt => new DCR_EquipReferSystem()
  62. { EquipName = tt.Key, Systems = tt.Select(t => t.Item1).ToList() }).ToList();
  63. return newList;
  64. }
  65. }
  66. /// <summary>
  67. /// 参考-可识别的系统名称
  68. /// </summary>
  69. [SheetInfo(SheetName = "参考-可识别的系统名称", RowStartIndex = 0)]
  70. public class DCR_MEPSystem
  71. {
  72. [CellIndex(0)]
  73. public string Name { get; set; }
  74. }
  75. /// <summary>
  76. /// 参考-revit分类
  77. /// </summary>
  78. [SheetInfo(SheetName = "参考-revit分类", RowStartIndex = 0)]
  79. public class DCR_CodeCheckCategory
  80. {
  81. [CellIndex(0)]
  82. public string Name { get; set; }
  83. }
  84. /// <summary>
  85. /// 设备类是否有连接件
  86. /// </summary>
  87. [SheetInfo(SheetName = "参考-连接件对照表", RowStartIndex = 1)]
  88. public class DCR_Connector
  89. {
  90. [CellIndex(4)]
  91. public string Name { get; set; }
  92. [CellIndex(5)]
  93. public string Code { get; set; }
  94. [CellIndex(6)]
  95. public string PName { get; set; }
  96. [CellIndex(7)]
  97. public string PCode { get; set; }
  98. [CellIndex(8)]
  99. public string HvacConnector { get; set; }
  100. [CellIndex(9)]
  101. public string PipeConnector { get; set; }
  102. }
  103. /// <summary>
  104. /// 参考-管网与相关设备
  105. /// </summary>
  106. [SheetInfo(SheetName = "参考-管网及相关设备", RowStartIndex = 3)]
  107. public class DCR_SystemReferEquip
  108. {
  109. [CellIndex(3)]
  110. public string SystemName { get; set; }
  111. [CellIndex(4)]
  112. public string ReferEquipName { get; set; }
  113. private List<string> m_Equips;
  114. public List<string> Equips
  115. {
  116. get
  117. {
  118. if (m_Equips == null)
  119. m_Equips = ConverToList(ReferEquipName);
  120. return m_Equips;
  121. }
  122. }
  123. public List<string> ConverToList(string str)
  124. {
  125. var list = new List<string>();
  126. if (str.IsNotNullEmpty())
  127. {
  128. Regex regex = new Regex(@"^[A-Z]{4}");
  129. list = str.Split(new[] { ',', ',' })
  130. .Where(t => Regex.IsMatch(t, $"{ModelCheckConst.IsEquip}"))
  131. .Select(tt => regex.Match(tt).Value).ToList();
  132. }
  133. return list;
  134. }
  135. }
  136. /// <summary>
  137. /// 设备关联的系统
  138. /// </summary>
  139. public class DCR_EquipReferSystem
  140. {
  141. /// <summary>
  142. /// 设备名称
  143. /// </summary>
  144. public string EquipName { get; set; }
  145. /// <summary>
  146. /// 系统名称
  147. /// </summary>
  148. public List<string> Systems { get; set; }
  149. }
  150. }