|
@@ -0,0 +1,189 @@
|
|
|
+/* ==============================================================================
|
|
|
+ * 功能描述:业务空间所在楼层与设备所在楼层一致性检查
|
|
|
+ * 创 建 者: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.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 SpaceEquipFloorCheck : DataCheckBase
|
|
|
+ {
|
|
|
+ public SpaceEquipFloorCheck()
|
|
|
+ {
|
|
|
+ Name = "业务空间所在楼层与设备所在楼层一致性检查";
|
|
|
+ }
|
|
|
+ [DataCheckProcessAspect]
|
|
|
+ public override bool Check()
|
|
|
+ {
|
|
|
+ IsRight = GetCheckResult();
|
|
|
+ return IsRight;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void Correct()
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ #region CheckMethod
|
|
|
+
|
|
|
+ private List<GraphRelationType> m_BusinessSpaceTypes;
|
|
|
+ /// <summary>
|
|
|
+ /// 对比信息点是否一致
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool GetCheckResult()
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ m_BusinessSpaceTypes = DalSpace.GetBusinessSpaceTypes();
|
|
|
+ var floors = DalProjectTree.GetSelectedFloors(true);
|
|
|
+ foreach (var mfloor in floors)
|
|
|
+ {
|
|
|
+ Results.AddRange(GetCheckResult(mfloor));
|
|
|
+ }
|
|
|
+ return Results.All(t => t.IsRight);
|
|
|
+ }
|
|
|
+ private List<MissDutyOrModeCheckResult> GetCheckResult(MFloor mFloor)
|
|
|
+ {
|
|
|
+ List<MissDutyOrModeCheckResult> list = new List<MissDutyOrModeCheckResult>();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //本层下的设备和部件
|
|
|
+ var equips = DalCommon.DownLoadCouldData(mFloor.Id, new[] {"Eq", "Ec"});
|
|
|
+ //本层下的业务空间
|
|
|
+ foreach (GraphRelationType businessSpaceType in m_BusinessSpaceTypes)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //忽略的信息点
|
|
|
+ private List<string> m_IgnoreList=new List<string>(){ "EquipID" ,"EquipName"};
|
|
|
+ private DutyFMInfoCheckResult GetCheckResult(MRevitEquipBase duty, MEquipFM fm)
|
|
|
+ {
|
|
|
+ DutyFMInfoCheckResult result = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var dutyJObject = duty.CloundJObject;
|
|
|
+ var fmJson = fm.FMJson;
|
|
|
+ var fmJObject = JObject.Parse(fmJson);
|
|
|
+
|
|
|
+ PropertyDefineTb pdtb = PEPCodeConvert.GetPropertyDefineTb(duty.EquipClassCode);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ foreach (KeyValuePair<string, JToken> pair in dutyJObject)
|
|
|
+ {
|
|
|
+ string key = pair.Key;
|
|
|
+ //不检查的信息点
|
|
|
+ if(m_IgnoreList.Contains(key))continue;
|
|
|
+ string dutyValue = pair.Value.ToString();
|
|
|
+ string fmValue = fmJObject.GetValueEx(key);
|
|
|
+ if (dutyValue.IsNotNullEmptyExt() && fmValue.IsNotNullEmptyExt() && !dutyValue.Equals(fmValue))
|
|
|
+ {
|
|
|
+ var define = pdtb.PropertyDefineItems.FirstOrDefault(t => t.CodeName == key);
|
|
|
+ sb.Append($"{define?.Name??key}、");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result = new DutyFMInfoCheckResult();
|
|
|
+ result.FloorName = DalProjectTree.GetFloorNameByFloorId(duty.FloorId);
|
|
|
+ result.DutyId = duty.Id;
|
|
|
+ result.DutyName = duty.ToString();
|
|
|
+ result.BIMID = duty.BimID.GetBIMID().ToString();
|
|
|
+ result.FMId = fm.Id;
|
|
|
+ result.FMName = fm.ToString();
|
|
|
+ result.IsRight = sb.Length == 0;
|
|
|
+ result.RMessage = result.IsRight ? "" : $"值不一致的信息点有:{sb}";
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #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;
|
|
|
+ //添加 共检查XXX条数据,未通过检查的如下 提示
|
|
|
+ IRow rowTip = sheet.CreateRow(index - 1);
|
|
|
+ rowTip.AddCell(0, $"总检查{Results.Count}条数据,未通过检查的如下", DataCheckNPOIStyle.Title);
|
|
|
+ //IRow row4 = sheet.CreateRow(index);
|
|
|
+ //row4.HeightInPoints = 15;
|
|
|
+
|
|
|
+ //row4.AddCell(0, "楼层本地名称", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(1, "文件名", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(2, "文件地址", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(3, "族名称", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(4, "类型", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(5, "ID", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(6, "通过", DataCheckNPOIStyle.Title);
|
|
|
+ //row4.AddCell(7, "备注(失败原因)", DataCheckNPOIStyle.Title);
|
|
|
+ foreach (DutyFMInfoCheckResult 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.FMId, style);
|
|
|
+ rowN.AddCell(i++, result.FMName, 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|