EquipmentLocationCenterComparer.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* ==============================================================================
  2. * 功能描述:设备部件定位点和中心点对比检查
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/10/23 15:08:55
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Autodesk.Revit.DB;
  12. using NPOI.SS.UserModel;
  13. using SAGA.DotNetUtils.Others;
  14. using SAGA.MBI.DataArrange;
  15. using SAGA.MBI.Tools;
  16. using SAGA.MBI.ToolsData.CheckBase;
  17. using SAGA.RevitUtils.Extends;
  18. namespace SAGA.MBI.ToolsData.ModeCheck
  19. {
  20. /// <summary>
  21. /// UnitCheck
  22. /// </summary>
  23. class EquipmentLocationCenterComparer : ModeCheckBase
  24. {
  25. public EquipmentLocationCenterComparer()
  26. {
  27. Name = "设备定位点检查";
  28. }
  29. [DataCheckProcessAspect]
  30. public override bool Check()
  31. {
  32. if (!RBase.IsRight)
  33. {
  34. IsRight = RBase.IsRight;
  35. return IsRight;
  36. }
  37. IsRight = GetCheckResult();
  38. return IsRight;
  39. }
  40. public override void Correct()
  41. {
  42. throw new NotImplementedException();
  43. }
  44. private bool GetCheckResult()
  45. {
  46. bool unitResult = true;
  47. foreach (SagaSignCheckResult signResult in RBase.Results)
  48. {
  49. var document = signResult.RDocument;
  50. var elements = document.GetFamilyInstances();
  51. var equips = elements.Where(t => t.IsEquipmentPart()||t.IsEquipment());
  52. foreach (FamilyInstance fi in equips)
  53. {
  54. var result = GetCheckResult(fi);
  55. result.RBase = signResult;
  56. Results.Add(result);
  57. }
  58. }
  59. return Results.All(t => t.IsRight);
  60. }
  61. /// <summary>
  62. /// 获取检测结果
  63. /// </summary>
  64. /// <param name="fi"></param>
  65. /// <returns></returns>
  66. private ModeCheckResultBase GetCheckResult(FamilyInstance fi)
  67. {
  68. var result = new EquipmentPartRefEqCheckResult();
  69. result.FamilyName = fi.GetFamily().Name;
  70. result.Id = fi.Id.ToString();
  71. XYZ location = fi.GetLocationPoint();
  72. XYZ origin = fi.GetBoxCenter();
  73. if (location.IsEqual2(origin))
  74. {
  75. result.IsRight = true;
  76. }
  77. else
  78. {
  79. result.IsRight = false;
  80. result.RMessage = "定位点和中心点不重合,请检查";
  81. }
  82. result.LocationXYZ = location.ToString2D();
  83. result.CenterXYZ = origin.ToString2D();
  84. return result;
  85. }
  86. //[DataCheckProcessAspect]
  87. public override void Export()
  88. {
  89. // Check();
  90. try
  91. {
  92. IWorkbook book = DCRExport.GetWorkbook();
  93. //ISheet sheet = book.CreateSheet(Name);
  94. ISheet sheet = book.GetSheet(Name);
  95. #region 添加数据
  96. int index = 3;
  97. //IRow row4 = sheet.CreateRow(index);
  98. //row4.HeightInPoints = 15;
  99. //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
  100. //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
  101. //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
  102. //row4.AddCell(3, "族名称", DataCheckNPOIStyle.Title);
  103. //row4.AddCell(4, "ID", DataCheckNPOIStyle.Title);
  104. //row4.AddCell(4, "定位点", DataCheckNPOIStyle.Title);
  105. //row4.AddCell(4, "中心点", DataCheckNPOIStyle.Title);
  106. //row4.AddCell(5, "通过", DataCheckNPOIStyle.Title);
  107. //row4.AddCell(6, "备注(失败原因)", DataCheckNPOIStyle.Title);
  108. foreach (EquipmentPartRefEqCheckResult result in Results)
  109. {
  110. SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
  111. if (rbase == null)
  112. continue;
  113. index++;
  114. IRow rowN = sheet.CreateRow(index);
  115. DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
  116. int i = 0;
  117. rowN.AddCell(i++, rbase.RFloorName, style);
  118. rowN.AddCell(i++, rbase.RFileName, style);
  119. rowN.AddCell(i++, rbase.RPath, style);
  120. rowN.AddCell(i++, result.FamilyName, style);
  121. rowN.AddCell(i++, result.Id, style);
  122. rowN.AddCell(i++, result.LocationXYZ, style);
  123. rowN.AddCell(i++, result.CenterXYZ, style);
  124. string rowN4 = result.IsRight ? "通过" : "不通过";
  125. rowN.AddCell(i++, rowN4, style);
  126. rowN.AddCell(i++, result.RMessage, style);
  127. }
  128. #endregion
  129. }
  130. catch (Exception e)
  131. {
  132. MessageShowBase.Show(e);
  133. }
  134. }
  135. }
  136. }