CheckOperation.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* ==============================================================================
  2. * 功能描述:CheckOperation
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/11/29 17:22:05
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using NPOI.SS.UserModel;
  12. using SAGA.MBI.ToolsData.ModeCheck;
  13. using SAGA.DotNetUtils.Extend;
  14. using SAGA.DotNetUtils.Logger;
  15. using SAGA.MBI.ToolsData.DataCheck;
  16. namespace SAGA.MBI.ToolsData.CheckBase
  17. {
  18. /// <summary>
  19. /// CheckOperation
  20. /// </summary>
  21. public class CheckOperation
  22. {
  23. /// <summary>
  24. /// 获取检查项
  25. /// </summary>
  26. /// <param name="type"></param>
  27. /// <returns></returns>
  28. public static List<ICheckBase> GetCheckItems(CheckType type)
  29. {
  30. List<ICheckBase> list = new List<ICheckBase>();
  31. switch (type)
  32. {
  33. case CheckType.ModeCheck:
  34. list = GetModeCheckItems();
  35. break;
  36. case CheckType.DataCheck:
  37. list = GetDataCheckItems();
  38. break;
  39. }
  40. return list;
  41. }
  42. /// <summary>
  43. /// 获取模型检查的检查项
  44. /// </summary>
  45. /// <returns></returns>
  46. public static List<ICheckBase> GetModeCheckItems()
  47. {
  48. List<ModeCheckBase> list = new List<ModeCheckBase>();
  49. var checkBase = new SagaSignCheck();
  50. list.Add(new FloorMiss());
  51. list.Add(new FloorSequenceCheck());
  52. list.Add(new UnitCheck());
  53. list.Add(new GridCheck());
  54. list.Add(new FamilyNameCheck());
  55. list.Add(new EquipmentPartRefEqCheck());
  56. list.Add(new ColumnCheck());
  57. list.Add(new ElementRangeCheck());
  58. list.Add(new SagaPositionCheck());
  59. list.Add(new ConnectorCheck());
  60. list.Add(new SystemCheck());
  61. list.Add(new EquipmentInSpaceCheck());
  62. list.ForEach(t =>
  63. {
  64. t.SetBaseCheck(checkBase);
  65. t.RIsChecked = true;
  66. });
  67. list.Insert(0, checkBase);
  68. return list.ToList<ICheckBase>();
  69. }
  70. /// <summary>
  71. /// 获取垃圾数据检查的检查项
  72. /// </summary>
  73. /// <returns></returns>
  74. public static List<ICheckBase> GetDataCheckItems()
  75. {
  76. List<DataCheckBase> list = new List<DataCheckBase>();
  77. list.Add(new DutyFMInfoCheck());
  78. list.Add(new QRCodeContextCheck());
  79. list.Add(new MissDutyOrMode());
  80. list.ForEach(t =>
  81. {
  82. t.RIsChecked = true;
  83. });
  84. return list.ToList<ICheckBase>();
  85. }
  86. /// <summary>
  87. /// 执行检查并保存
  88. /// </summary>
  89. /// <param name="list"></param>
  90. /// <param name="context"></param>
  91. public static void Execute(List<ICheckBase> list, CheckContext context)
  92. {
  93. DataCheckProgressBarClient.Start("正在进行数据检查", list.Count(t => t.RIsChecked), false);
  94. //检查
  95. list.ForEach(t => t.Check2(context));
  96. DataCheckProgressBarClient.UpdateBigTip("正在进行数据保存");
  97. //重置workbook准备保存结果
  98. DCRExport.ClearWorkbook();
  99. //保存
  100. list.ForEach(t => t.Export2());
  101. DCRExport.Save(context.SavePath, DCRExport.GetWorkbook());
  102. DataCheckProgressBarClient.UpdateBigTip("结束");
  103. }
  104. /// <summary>
  105. /// 获取保存模版的地址
  106. /// </summary>
  107. /// <param name="type"></param>
  108. /// <returns></returns>
  109. public static string GetSaveTemplatePath(CheckType type)
  110. {
  111. string path = null;
  112. switch (type)
  113. {
  114. case CheckType.DataCheck:
  115. path = DCRExport.DCRPath;
  116. break;
  117. case CheckType.ModeCheck:
  118. path = DCRExport.MCRPath;
  119. break;
  120. }
  121. return path;
  122. }
  123. }
  124. }