/* ==============================================================================
* 功能描述:数据检查规范
* 创 建 者:Garrett
* 创建日期:2018/11/7 15:40:23
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using SAGA.DotNetUtils;
using SAGA.DotNetUtils.NPOI;
using ServiceRevitLib.Common;
namespace ServiceRevitLib.Utils
{
///
/// DataCheckRule
///
class DataCheckRule
{
public static string MCRPath = Path.Combine(MBIConst.MBIResourcePath, @"DataCheck\模型检查结果输出格式-模版.xlsx");
///
/// 获取设备编码检查Cateogry 列表
///
///
public static List GetCodeCheckCategories()
{
var list = NPOIHelper
.ConvertExcelSheetToModel(MCRPath);
return list;
}
///
/// 获取预定义的连接件类
///
///
public static List GetPreDefineConnectors()
{
var list = NPOIHelper
.ConvertExcelSheetToModel(MCRPath);
return list;
}
///
/// 获取可识别的管道系统名称
///
///
public static List GetMepSystems()
{
var list = NPOIHelper
.ConvertExcelSheetToModel(MCRPath);
return list;
}
///
/// 获取设备关联的系统类型
///
///
public static List GetEquipReferSystems()
{
var list = NPOIHelper
.ConvertExcelSheetToModel(MCRPath);
List> tuples = new List>();
//将集合转化为:系统名称-设备名称
list.ForEach(t => t.Equips.ForEach(tt => tuples.Add(new Tuple(t.SystemName, tt))));
//将集合转化为:设备名称-多个系统名称
var newList = tuples.GroupBy(t => t.Item2).Select(tt => new DCR_EquipReferSystem()
{ EquipName = tt.Key, Systems = tt.Select(t => t.Item1).ToList() }).ToList();
return newList;
}
}
///
/// 参考-可识别的系统名称
///
[SheetInfo(SheetName = "参考-可识别的系统名称", RowStartIndex = 0)]
public class DCR_MEPSystem
{
[CellIndex(0)]
public string Name { get; set; }
}
///
/// 参考-revit分类
///
[SheetInfo(SheetName = "参考-revit分类", RowStartIndex = 0)]
public class DCR_CodeCheckCategory
{
[CellIndex(0)]
public string Name { get; set; }
}
///
/// 设备类是否有连接件
///
[SheetInfo(SheetName = "参考-连接件对照表", RowStartIndex = 1)]
public class DCR_Connector
{
[CellIndex(4)]
public string Name { get; set; }
[CellIndex(5)]
public string Code { get; set; }
[CellIndex(6)]
public string PName { get; set; }
[CellIndex(7)]
public string PCode { get; set; }
[CellIndex(8)]
public string HvacConnector { get; set; }
[CellIndex(9)]
public string PipeConnector { get; set; }
}
///
/// 参考-管网与相关设备
///
[SheetInfo(SheetName = "参考-管网及相关设备", RowStartIndex = 3)]
public class DCR_SystemReferEquip
{
[CellIndex(3)]
public string SystemName { get; set; }
[CellIndex(4)]
public string ReferEquipName { get; set; }
private List m_Equips;
public List Equips
{
get
{
if (m_Equips == null)
m_Equips = ConverToList(ReferEquipName);
return m_Equips;
}
}
public List ConverToList(string str)
{
var list = new List();
if (str.IsNotNullEmpty())
{
Regex regex = new Regex(@"^[A-Z]{4}");
list = str.Split(new[] { ',', ',' })
.Where(t => Regex.IsMatch(t, $"{RegexConstPattern.IsEquip}"))
.Select(tt => regex.Match(tt).Value).ToList();
}
return list;
}
}
///
/// 设备关联的系统
///
public class DCR_EquipReferSystem
{
///
/// 设备名称
///
public string EquipName { get; set; }
///
/// 系统名称
///
public List Systems { get; set; }
}
}