123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /* ==============================================================================
- * 功能描述:拓扑计算系统名称检查
- * 创 建 者:Garrett
- * 创建日期:2018/10/23 15:08:55
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Autodesk.Revit.DB;
- using Autodesk.Revit.DB.Mechanical;
- using NPOI.SS.UserModel;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.Others;
- using SAGA.RevitUtils.MEP;
- namespace Saga.PlugIn.ModelCheck
- {
- /// <summary>
- /// UnitCheck
- /// </summary>
- [ParseIndex(Index = 8)]
- class SystemCheck : ModeCheckBase
- {
- public SystemCheck()
- {
- Name = "系统类型名称检查";
- RSPecificationSheet.Add("参考-可识别的系统名称");
- }
- public override bool Check()
- {
- if (!RBase.IsRight)
- {
- IsRight = RBase.IsRight;
- return IsRight;
- }
- IsRight = GetCheckResult();
- return IsRight;
- }
- private bool GetCheckResult()
- {
- bool unitResult = true;
- m_MEPSystems = DataCheckRule.GetMepSystems();
- foreach (SagaSignCheckResult signResult in RBase.Results)
- {
- var list = Check(signResult);
- Results.AddRange(list);
- }
- return Results.All(t => t.IsRight);
- }
- private List<DCR_MEPSystem> m_MEPSystems;
- /// <summary>
- /// 获取本楼层的检查结果
- /// </summary>
- /// <param name="document"></param>
- /// <returns></returns>
- private List<ModeCheckResultBase> Check(SagaSignCheckResult signResult)
- {
- List<ModeCheckResultBase> list = new List<ModeCheckResultBase>();
- var mepsystemTypes = new List<MEPSystemType>();
- mepsystemTypes.AddRange(signResult.RDocument.GetMechanicalSystemTypes());
- mepsystemTypes.AddRange(signResult.RDocument.GetPipingSystemTypes());
- mepsystemTypes.ForEach(t=>
- {
- var result = GetCheckResult(t);
- result.RBase = signResult;
- list.Add(result);
- });
- return list;
- }
- /// <summary>
- /// 获取检测结果
- /// </summary>
- /// <param name="fi"></param>
- /// <returns></returns>
- private ModeCheckResultBase GetCheckResult(MEPSystemType system)
- {
- var result = new SystemCheckResult();
- string systemName = system.Name;
- result.RSystemName = systemName;
- result.Type = system is MechanicalSystemType ? "风管系统" : "管道系统";
- result.IsRight = true;
- var item = m_MEPSystems.Where(t => SystemNameIsEqual(systemName,t.Name));
- if (!item.Any())
- {
- result.IsRight = false;
- result.RMessage = $"未知的系统名称,请按照系统类型命名规范修改";
- }
- return result;
- }
- /// <summary>
- /// 系统名称相等
- /// </summary>
- /// <param name="originName"></param>
- /// <param name="targetName"></param>
- /// <returns></returns>
- private bool SystemNameIsEqual(string originName,string targetName)
- {
- bool result = false;
- string n1 = originName.ToLower();
- string n2 = targetName.ToLower();
- return n1.Equals(n2);
- }
- public override void Export()
- {
- try
- {
- IWorkbook book = DCRExport.GetWorkbook();
- //ISheet sheet = book.CreateSheet(Name);
- ISheet sheet = book.GetSheet(Name);
- #region 添加数据
- int index = 3;
- foreach (SystemCheckResult result in Results)
- {
- SagaSignCheckResult rbase = result.RBase as SagaSignCheckResult;
- if (rbase == null)
- continue;
- index++;
- IRow rowN = sheet.CreateRow(index);
- DataCheckNPOIStyle style = result.IsRight ? DataCheckNPOIStyle.Content : DataCheckNPOIStyle.Error;
- int j = -1;
- rowN.AddCell(++j, result.RSystemName, style);
- rowN.AddCell(++j, result.Type, style);
- string rowN4 = result.IsRight ? "通过" : "不通过";
- rowN.AddCell(++j, rowN4, style);
- rowN.AddCell(++j, result.RMessage, style);
- }
- #endregion
- }
- catch (Exception e)
- {
- MessageShowBase.Show(e);
- }
- }
- }
- class SystemCheckResult : ModeCheckResultBase
- {
- public string RSystemName { get; set; }
- public string Type { get; set; }
- }
- }
|