|
@@ -0,0 +1,155 @@
|
|
|
|
+/* ==============================================================================
|
|
|
|
+ * 功能描述:检查BimID是否重复,多个岗位对应一个模型
|
|
|
|
+ * 创 建 者:Garrett
|
|
|
|
+ * 创建日期:2018/10/23 15:08:55
|
|
|
|
+ * ==============================================================================*/
|
|
|
|
+
|
|
|
|
+using System;
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Linq;
|
|
|
|
+using System.Text;
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
|
+using Autodesk.Revit.DB;
|
|
|
|
+using Autodesk.Revit.DB.Mechanical;
|
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
+using NPOI.SS.UserModel;
|
|
|
|
+using SAGA.DotNetUtils.Extend;
|
|
|
|
+using SAGA.DotNetUtils.Others;
|
|
|
|
+using SAGA.MBI.Calc;
|
|
|
|
+using SAGA.MBI.DataArrange;
|
|
|
|
+using SAGA.MBI.JsonConvert;
|
|
|
|
+using SAGA.MBI.Model;
|
|
|
|
+using SAGA.MBI.RequestData;
|
|
|
|
+using SAGA.MBI.Tools;
|
|
|
|
+using SAGA.MBI.ToolsData.CheckBase;
|
|
|
|
+using SAGA.MBI.ToolsData.ModeCheck;
|
|
|
|
+using SAGA.RevitUtils.Extends;
|
|
|
|
+
|
|
|
|
+namespace SAGA.MBI.ToolsData.DataCheck
|
|
|
|
+{
|
|
|
|
+ /// <summary>
|
|
|
|
+ ///
|
|
|
|
+ /// </summary>
|
|
|
|
+ class BIMDuplicationCheck : DataCheckBase
|
|
|
|
+ {
|
|
|
|
+ public BIMDuplicationCheck()
|
|
|
|
+ {
|
|
|
|
+ Name = "多个岗位共用一个bimID检查";
|
|
|
|
+ }
|
|
|
|
+ [DataCheckProcessAspect]
|
|
|
|
+ public override bool Check()
|
|
|
|
+ {
|
|
|
|
+ IsRight = GetCheckResult();
|
|
|
|
+ RMessage = IsRight ? "" : "多个岗位对应一个BIMID,请检查。";
|
|
|
|
+ return IsRight;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override void Correct()
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #region CheckMethod
|
|
|
|
+ /// <summary>
|
|
|
|
+ ///
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ private bool GetCheckResult()
|
|
|
|
+ {
|
|
|
|
+ bool result = true;
|
|
|
|
+ var mbuilding = DalProjectTree.GetSelectedBuilding();
|
|
|
|
+ var dutys = DalCommon.GetAllDutys(mbuilding.Id);
|
|
|
|
+ var bybimidGroups = dutys.GroupBy(t => t.BimID);
|
|
|
|
+ var exceptionGroups = bybimidGroups.Where(t => t.Count() >= 2 && !t.Key.IsOnlyDutyNoModelBIMID());
|
|
|
|
+ Results.AddRange(GetCheckResult(exceptionGroups));
|
|
|
|
+ return Results.Count==0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<BIMDuplicationCheckResult> GetCheckResult(IEnumerable<IGrouping<string, MRevitEquipBase>> groups)
|
|
|
|
+ {
|
|
|
|
+ List<BIMDuplicationCheckResult> list = new List<BIMDuplicationCheckResult>();
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ foreach (var group in groups)
|
|
|
|
+ {
|
|
|
|
+ list.AddRange(GetCheckResult(group));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<BIMDuplicationCheckResult> GetCheckResult(IGrouping<string, MRevitEquipBase> group)
|
|
|
|
+ {
|
|
|
|
+ List<BIMDuplicationCheckResult> list = new List<BIMDuplicationCheckResult>();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ string bimid = group.Key;
|
|
|
|
+ string revitId=bimid.GetBIMID().ToString();
|
|
|
|
+ string floorId = bimid.GetFloorId();
|
|
|
|
+ string floorName = DalProjectTree.GetFloorNameByFloorId(floorId);
|
|
|
|
+ foreach (MRevitEquipBase equipBase in group)
|
|
|
|
+ {
|
|
|
|
+ BIMDuplicationCheckResult result=new BIMDuplicationCheckResult();
|
|
|
|
+ result.FloorName = floorName;
|
|
|
|
+ result.DutyId = equipBase.Id;
|
|
|
|
+ result.DutyName = equipBase.ToString();
|
|
|
|
+ result.BIMID = revitId;
|
|
|
|
+ result.IsRight = false;
|
|
|
|
+ list.Add(result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine(e);
|
|
|
|
+ }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ //[DataCheckProcessAspect]
|
|
|
|
+ public override void Export()
|
|
|
|
+ {
|
|
|
|
+ // Check();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ IWorkbook book = DCRExport.GetWorkbook();
|
|
|
|
+ //ISheet sheet = book.CreateSheet(Name);
|
|
|
|
+ ISheet sheet = book.GetSheet(Name);
|
|
|
|
+
|
|
|
|
+ #region 添加数据
|
|
|
|
+ int index = 3;
|
|
|
|
+
|
|
|
|
+ foreach (MissDutyOrModeCheckResult result in Results)
|
|
|
|
+ {
|
|
|
|
+ //数量过多,只显示有问题的
|
|
|
|
+ //if (result.IsRight) continue;
|
|
|
|
+ index++;
|
|
|
|
+ IRow rowN = sheet.CreateRow(index);
|
|
|
|
+ DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
|
|
|
|
+ int i = 0;
|
|
|
|
+ rowN.AddCell(i++, result.FloorName, style);
|
|
|
|
+ rowN.AddCell(i++, result.DutyId, style);
|
|
|
|
+ rowN.AddCell(i++, result.DutyName, style);
|
|
|
|
+ rowN.AddCell(i++, result.BIMID, style);
|
|
|
|
+ string rowN4 = result.IsRight ? "通过" : "不通过";
|
|
|
|
+ rowN.AddCell(i++, rowN4, style);
|
|
|
|
+ rowN.AddCell(i++, result.RMessage, style);
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ MessageShowBase.Show(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|