667 lines
28 KiB
C#
667 lines
28 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
|
||
namespace CadParamPluging.Common
|
||
{
|
||
[Serializable]
|
||
public class ParamCatalog
|
||
{
|
||
public List<ParamDefinition> Items { get; set; }
|
||
|
||
public ParamCatalog()
|
||
{
|
||
Items = new List<ParamDefinition>();
|
||
}
|
||
|
||
public ParamCatalog Clone()
|
||
{
|
||
return new ParamCatalog
|
||
{
|
||
Items = (Items ?? new List<ParamDefinition>()).Select(x => x?.Clone()).Where(x => x != null).ToList()
|
||
};
|
||
}
|
||
|
||
public void Normalize()
|
||
{
|
||
if (Items == null)
|
||
{
|
||
Items = new List<ParamDefinition>();
|
||
}
|
||
|
||
foreach (var it in Items)
|
||
{
|
||
it?.Normalize();
|
||
}
|
||
|
||
Items = Items
|
||
.Where(x => x != null && !string.IsNullOrWhiteSpace(x.Key))
|
||
.GroupBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
|
||
.Select(g => g.First())
|
||
.OrderBy(x => x.Order)
|
||
.ThenBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
|
||
.ToList();
|
||
}
|
||
|
||
public ParamDefinition FindByKey(string key)
|
||
{
|
||
if (string.IsNullOrWhiteSpace(key) || Items == null)
|
||
{
|
||
return null;
|
||
}
|
||
|
||
return Items.FirstOrDefault(x => string.Equals(x.Key, key.Trim(), StringComparison.OrdinalIgnoreCase));
|
||
}
|
||
|
||
public static ParamCatalog CreateDefault()
|
||
{
|
||
return new ParamCatalog
|
||
{
|
||
Items = new List<ParamDefinition>
|
||
{
|
||
// --- Material / classification ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "MaterialGrade",
|
||
Label = "材料牌号",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "数据库下拉列表(支持数据扩充),点选映射",
|
||
Order = 100,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "FeatureCategory",
|
||
Label = "特性分类",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "一般件",
|
||
EnumOptions = new List<string> { "一般件", "关键件", "重要件" },
|
||
Hint = "下拉列表(一般件/关键件/重要件),点选;关键件/重要件需加方框标注",
|
||
Order = 110,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "MaterialTechnicalCondition",
|
||
Label = "材料技术条件",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "多选下拉列表(支持数据扩充),选项用\"或\"连接",
|
||
Order = 120,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "ForgingTechnicalCondition",
|
||
Label = "锻件技术条件",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "多选下拉列表(支持数据扩充),选项用\"或\"连接",
|
||
Order = 130,
|
||
Group = "备注参数"
|
||
},
|
||
|
||
// --- Inspection / heat treatment ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "InspectionCategory",
|
||
Label = "检验类别",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "Ⅱ",
|
||
EnumOptions = new List<string> { "Ⅱ", "Ⅱa", "Ⅱ大", "Ⅲ", "Ⅳ" },
|
||
Hint = "单选下拉列表",
|
||
Order = 200,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "ForgingCategory",
|
||
Label = "锻件类别",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "Ⅱ",
|
||
EnumOptions = new List<string> { "Ⅱ", "Ⅲ", "Ⅳ" },
|
||
Hint = "单选下拉列表",
|
||
Order = 210,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "HeatTreatmentState",
|
||
Label = "热处理状态",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "预备热处理",
|
||
EnumOptions = new List<string> { "预备热处理", "热处理" },
|
||
Hint = "单选下拉列表",
|
||
Order = 220,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "HeatTreatmentProcess",
|
||
Label = "热处理制度",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "数据库下拉列表(支持数据扩充),点选",
|
||
Order = 230,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Hardness",
|
||
Label = "硬度",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "组合选择:硬度符号+连接符+数值,可空",
|
||
Order = 240,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "UltrasonicRequirement",
|
||
Label = "超声波要求",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动输入,可空",
|
||
Order = 250,
|
||
Group = "备注参数"
|
||
},
|
||
|
||
// --- Marking / notes ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "MarkingContent",
|
||
Label = "标刻内容",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "多选下拉列表:零件尾号/零件号、材料牌号、熔炼炉号、锭节号、热处理炉次号、热处理炉批号、批次号",
|
||
Order = 300,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "PartsPerForging",
|
||
Label = "一锻件可做零件数",
|
||
Type = ParamValueType.Int,
|
||
Required = false,
|
||
DefaultValue = "1",
|
||
Hint = "手动编辑,默认为\"1\"",
|
||
Order = 310,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "SurfaceRoughness",
|
||
Label = "表面粗糙度",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "空",
|
||
EnumOptions = new List<string> { "空", "0.8", "1.6", "3.2" },
|
||
Hint = "单选下拉列表,默认为空",
|
||
Order = 320,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DesignRevision",
|
||
Label = "设计图版次",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "空",
|
||
EnumOptions = new List<string> { "空", "A", "B", "C", "D", "E", "F" },
|
||
Hint = "下拉列表(A-F),可手动编辑,支持空选项",
|
||
Order = 330,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "SerialInfo",
|
||
Label = "联号信息",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表模板\"X个A零件和X个B零件或X个C零件\",点选后可编辑",
|
||
Order = 340,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "MachiningSpecimenRequirement",
|
||
Label = "机加试件需求",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表模板\"每批/每*件多投*件\",点选后可编辑",
|
||
Order = 350,
|
||
Group = "备注参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "AdditionalNotes",
|
||
Label = "辅助说明",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "多选下拉列表:传递抗拉强度实测值、机加夹头标注、使用温度300℃以上、每批投产数量限制,点选后可编辑",
|
||
Order = 360,
|
||
Group = "备注参数"
|
||
},
|
||
|
||
// --- Template key fields (also exist in panel dropdowns) ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "DeliveryStatus",
|
||
Label = "交付状态",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "毛料态",
|
||
EnumOptions = new List<string> { "毛料态", "车加工态" },
|
||
Hint = "单选下拉列表,决定后续模板",
|
||
Order = 400,
|
||
Group = "模板参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "ProcessMethod",
|
||
Label = "工艺方法",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "自由锻",
|
||
EnumOptions = new List<string> { "自由锻", "轧制" },
|
||
Hint = "单选下拉列表,决定后续模板",
|
||
Order = 410,
|
||
Group = "模板参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "StructuralFeature",
|
||
Label = "结构特征",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "方体",
|
||
EnumOptions = new List<string> { "方体", "饼盘", "轴杆", "环形" },
|
||
Hint = "单选下拉列表,决定后续模板",
|
||
Order = 420,
|
||
Group = "模板参数"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "SpecialCondition",
|
||
Label = "特殊条件",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "非中心冲孔",
|
||
EnumOptions = new List<string> { "非中心冲孔", "中心冲孔", "无圆头", "有圆头", "圆轴", "方轴" },
|
||
Hint = "单选下拉列表,决定后续模板",
|
||
Order = 430,
|
||
Group = "模板参数"
|
||
},
|
||
|
||
// --- Dimensions: ring (outer/inner/height) ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "OuterDiameter1",
|
||
Label = "外径Φ1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 500,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "OuterDiameter1TolPlus",
|
||
Label = "外径上差a1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "0.5",
|
||
Hint = "车加工态:手动编辑(默认+0.5);毛料态:下拉列表(+2~+7)",
|
||
Order = 510,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "OuterDiameter1TolMinus",
|
||
Label = "外径下差b1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "-0.5",
|
||
Hint = "车加工态:手动编辑(默认-0.5);毛料态:下拉列表(-2~-7)",
|
||
Order = 520,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "InnerDiameter2",
|
||
Label = "内径Φ2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 530,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "InnerDiameter2TolPlus",
|
||
Label = "内径上差a2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "0.5",
|
||
Hint = "车加工态:手动编辑(默认+0.5);毛料态:下拉列表(+2~+7)",
|
||
Order = 540,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "InnerDiameter2TolMinus",
|
||
Label = "内径下差b2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "-0.5",
|
||
Hint = "车加工态:手动编辑(默认-0.5);毛料态:下拉列表(-2~-7)",
|
||
Order = 550,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Height1",
|
||
Label = "高度H1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 560,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Height1TolPlus",
|
||
Label = "高度上差a3",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "0.5",
|
||
Hint = "车加工态:手动编辑(默认+0.5);毛料态:下拉列表(+2~+7)",
|
||
Order = 570,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Height1TolMinus",
|
||
Label = "高度下差b3",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "-0.5",
|
||
Hint = "车加工态:手动编辑(默认-0.5);毛料态:下拉列表(-2~-7)",
|
||
Order = 580,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "MinWallThickness",
|
||
Label = "最小壁厚T",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "自动计算:T=(Φ1-b1+Φ2-a2)/2",
|
||
Order = 590,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "UnspecifiedFilletRadiusMax",
|
||
Label = "未注圆角半径R≤",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
EnumOptions = new List<string> { "6", "5", "4" },
|
||
Hint = "下拉列表(6/5/4),可手动编辑",
|
||
Order = 600,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "InnerRadiusMax",
|
||
Label = "内径半径R≤",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
EnumOptions = new List<string> { "8", "10" },
|
||
Hint = "仅中心冲孔结构:下拉列表(8/10),可手动编辑",
|
||
Order = 610,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "RoundHeadFilletRadiusMax",
|
||
Label = "圆头处圆角半径≤",
|
||
Type = ParamValueType.Enum,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
EnumOptions = new List<string> { "8", "10" },
|
||
Hint = "仅方体有圆头结构:下拉列表(8/10),可手动编辑",
|
||
Order = 620,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "OuterDiameter1Prime",
|
||
Label = "外径Φ'1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 630,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "InnerDiameter2Prime",
|
||
Label = "内径Φ'2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 640,
|
||
Group = "尺寸-环形"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Height1Prime",
|
||
Label = "高度H'1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 650,
|
||
Group = "尺寸-环形"
|
||
},
|
||
|
||
// --- Dimensions: shaft/rod (diameter/length) ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "Diameter",
|
||
Label = "直径Φ",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 700,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiameterTolPlus",
|
||
Label = "直径Φ上差a1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(+2~+7),可手动编辑",
|
||
Order = 710,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiameterTolMinus",
|
||
Label = "直径Φ下差b1",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(-2~-7),可手动编辑",
|
||
Order = 720,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "Length",
|
||
Label = "长度L",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 730,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "LengthTolPlus",
|
||
Label = "长度L上差a2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(+2~+7),可手动编辑",
|
||
Order = 740,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "LengthTolMinus",
|
||
Label = "长度L下差b2",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(-2~-7),可手动编辑",
|
||
Order = 750,
|
||
Group = "尺寸-轴杆"
|
||
},
|
||
|
||
// --- Dimensions: generic multi-size ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "Size123",
|
||
Label = "尺寸1/尺寸2/尺寸3",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 800,
|
||
Group = "尺寸-通用"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "SizeTolPlusA123",
|
||
Label = "尺寸上差a1/a2/a3",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(+2~+7),可手动编辑",
|
||
Order = 810,
|
||
Group = "尺寸-通用"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "SizeTolMinusB123",
|
||
Label = "尺寸下差b1/b2/b3",
|
||
Type = ParamValueType.String,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(-2~-7),可手动编辑",
|
||
Order = 820,
|
||
Group = "尺寸-通用"
|
||
},
|
||
|
||
// --- Dimensions: disk (饼盘) ---
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskDiameter",
|
||
Label = "直径Φ(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 900,
|
||
Group = "尺寸-饼盘"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskDiameterTolPlus",
|
||
Label = "直径Φ上差a1(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(+2~+7),可手动编辑",
|
||
Order = 910,
|
||
Group = "尺寸-饼盘"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskDiameterTolMinus",
|
||
Label = "直径Φ下差b1(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(-2~-7),可手动编辑",
|
||
Order = 920,
|
||
Group = "尺寸-饼盘"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskHeight",
|
||
Label = "高度H(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "手动编辑",
|
||
Order = 930,
|
||
Group = "尺寸-饼盘"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskHeightTolPlus",
|
||
Label = "高度H上差a2(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(+2~+7),可手动编辑",
|
||
Order = 940,
|
||
Group = "尺寸-饼盘"
|
||
},
|
||
new ParamDefinition
|
||
{
|
||
Key = "DiskHeightTolMinus",
|
||
Label = "高度H下差b2(饼盘)",
|
||
Type = ParamValueType.Double,
|
||
Required = false,
|
||
DefaultValue = "",
|
||
Hint = "下拉列表(-2~-7),可手动编辑",
|
||
Order = 950,
|
||
Group = "尺寸-饼盘"
|
||
}
|
||
}
|
||
};
|
||
}
|
||
}
|
||
}
|