|
@@ -0,0 +1,162 @@
|
|
|
+/* ==============================================================================
|
|
|
+ * 功能描述:岗位和资产信息点一致性检查
|
|
|
+ * 创 建 者:Garrett
|
|
|
+ * 创建日期:2018/10/23 15:08:55
|
|
|
+ * ==============================================================================*/
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
+using System.Windows.Documents;
|
|
|
+using Autodesk.Revit.DB;
|
|
|
+using Autodesk.Revit.DB.Mechanical;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using SAGA.DotNetUtils.Extend;
|
|
|
+using SAGA.DotNetUtils.Logger;
|
|
|
+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 DutyModeCodeDiff : DataCheckBase
|
|
|
+ {
|
|
|
+ public DutyModeCodeDiff()
|
|
|
+ {
|
|
|
+ Name = "模型中的族编码和岗位的设备类编码一致性检查";
|
|
|
+ }
|
|
|
+ [DataCheckProcessAspect]
|
|
|
+ public override bool Check()
|
|
|
+ {
|
|
|
+ IsRight = GetCheckResult();
|
|
|
+ return IsRight;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void Correct()
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ #region CheckMethod
|
|
|
+ /// <summary>
|
|
|
+ /// 对比信息点是否一致
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool GetCheckResult()
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ var floors = DalProjectTree.GetSelectedFloors(true);
|
|
|
+ foreach (var mfloor in floors)
|
|
|
+ {
|
|
|
+ Results.AddRange(GetCheckResult(mfloor));
|
|
|
+ }
|
|
|
+ return Results.All(t => t.IsRight);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DutyModeCodeDiffCheckResult> GetCheckResult(MFloor floor)
|
|
|
+ {
|
|
|
+ List<DutyModeCodeDiffCheckResult> list = new List<DutyModeCodeDiffCheckResult>();
|
|
|
+
|
|
|
+ var context = DalCommon.DownLoadCouldData(floor);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var doc=context.OpenDocument();
|
|
|
+ string floorName = context.MFloor.ToString();
|
|
|
+ //检查空间,逻辑不通,暂时注释掉
|
|
|
+ List<MRevitEquipBase> modes = new List<MRevitEquipBase>();
|
|
|
+ //检查设备
|
|
|
+ modes.AddRange(context.MEquipments);
|
|
|
+ //检查部件
|
|
|
+ modes.AddRange(context.MEquipmentParts);
|
|
|
+ //信标不用检查
|
|
|
+ foreach (var mode in modes)
|
|
|
+ {
|
|
|
+ string cBimId = mode.BimID;
|
|
|
+ if (cBimId.IsNullOrEmpty()) continue;
|
|
|
+ int bimid = cBimId.GetBIMID();
|
|
|
+ FamilyInstance fi = doc.GetElement(bimid) as FamilyInstance;
|
|
|
+ if (fi == null) continue;
|
|
|
+ var code = fi.GetFamilyCode();
|
|
|
+ var cCode = mode.EquipClassCode;
|
|
|
+ if (code != cCode)
|
|
|
+ {
|
|
|
+ DutyModeCodeDiffCheckResult result = new DutyModeCodeDiffCheckResult();
|
|
|
+ result.FloorName = floorName;
|
|
|
+ result.DutyId = mode.Id;
|
|
|
+ result.BIMID = bimid.ToString();
|
|
|
+ result.DCode = cCode;
|
|
|
+ result.MCode = code;
|
|
|
+ result.FamilyName = fi.GetFamily()?.Name;
|
|
|
+ result.IsRight = false;
|
|
|
+ result.RMessage = "模型族编码与岗位设备类编码不一致,请检查模型是否需要更新或使用“族编码同步”命令同步";
|
|
|
+ list.Add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageShowBase.Show(e);
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ context.RevitDoc.CloseDoc();
|
|
|
+ }
|
|
|
+ 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 (DutyModeCodeDiffCheckResult 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.MCode, style);
|
|
|
+ rowN.AddCell(i++, result.FamilyName, style);
|
|
|
+ rowN.AddCell(i++, result.BIMID, style);
|
|
|
+ rowN.AddCell(i++, result.DCode, style);
|
|
|
+ rowN.AddCell(i++, result.DutyId, style);
|
|
|
+ string rowN4 = result.IsRight ? "通过" : "不通过";
|
|
|
+ rowN.AddCell(i++, rowN4, style);
|
|
|
+ rowN.AddCell(i++, result.RMessage, style);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageShowBase.Show(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|