using System; using System.Collections.Generic; using System.Linq; namespace CadParamPluging.Common { [Serializable] public class ParamCatalog { public List Items { get; set; } public ParamCatalog() { Items = new List(); } public ParamCatalog Clone() { return new ParamCatalog { Items = (Items ?? new List()).Select(x => x?.Clone()).Where(x => x != null).ToList() }; } public void Normalize() { if (Items == null) { Items = new List(); } 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 { // --- 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 = true, DefaultValue = "一般件", EnumOptions = new List { "一般件", "关键件", "重要件" }, 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 { "Ⅱ", "Ⅱa", "Ⅱ大", "Ⅲ", "Ⅳ" }, Hint = "单选下拉列表", Order = 200, Group = "备注参数" }, new ParamDefinition { Key = "ForgingCategory", Label = "锻件类别", Type = ParamValueType.Enum, Required = false, DefaultValue = "Ⅱ", EnumOptions = new List { "Ⅱ", "Ⅲ", "Ⅳ" }, Hint = "单选下拉列表", Order = 210, Group = "备注参数" }, new ParamDefinition { Key = "HeatTreatmentState", Label = "热处理状态", Type = ParamValueType.Enum, Required = false, DefaultValue = "预备热处理", EnumOptions = new List { "预备热处理", "热处理" }, 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 { "空", "0.8", "1.6", "3.2" }, Hint = "单选下拉列表,默认为空", Order = 320, Group = "备注参数" }, new ParamDefinition { Key = "DesignRevision", Label = "设计图版次", Type = ParamValueType.Enum, Required = false, DefaultValue = "空", EnumOptions = new List { "空", "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 = "备注参数" }, new ParamDefinition { Key = "DrawingScale", Label = "出图比例", Type = ParamValueType.Enum, Required = true, DefaultValue = "1:1", EnumOptions = new List { "1:1", "1:2", "1:5", "1:10", "1:20" }, Hint = "单选下拉列表,决定绘图缩放(1:n)", Order = 10, Group = "模板参数" }, // --- Template key fields (also exist in panel dropdowns) --- new ParamDefinition { Key = "DeliveryStatus", Label = "交付状态", Type = ParamValueType.Enum, Required = false, DefaultValue = "毛料态", EnumOptions = new List { "毛料态", "车加工态" }, Hint = "单选下拉列表,决定后续模板", Order = 400, Group = "模板参数" }, new ParamDefinition { Key = "ProcessMethod", Label = "工艺方法", Type = ParamValueType.Enum, Required = false, DefaultValue = "自由锻", EnumOptions = new List { "自由锻", "轧制" }, Hint = "单选下拉列表,决定后续模板", Order = 410, Group = "模板参数" }, new ParamDefinition { Key = "StructuralFeature", Label = "结构特征", Type = ParamValueType.Enum, Required = false, DefaultValue = "方体", EnumOptions = new List { "方体", "饼盘", "轴杆", "环形" }, Hint = "单选下拉列表,决定后续模板", Order = 420, Group = "模板参数" }, new ParamDefinition { Key = "SpecialCondition", Label = "特殊条件", Type = ParamValueType.Enum, Required = false, DefaultValue = "非中心冲孔", EnumOptions = new List { "非中心冲孔", "中心冲孔", "无圆头", "有圆头", "圆轴", "方轴" }, 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 { "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 { "8", "10" }, Hint = "仅中心冲孔结构:下拉列表(8/10),可手动编辑", Order = 610, 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 = "尺寸-轴杆" }, new ParamDefinition { Key = "ShaftFilletRadiusMax", Label = "未注圆角半径R≤(轴杆)", Type = ParamValueType.Enum, Required = false, DefaultValue = "", EnumOptions = new List { "6", "5", "4" }, Hint = "下拉列表(6/5/4),可手动编辑", Order = 760, Group = "尺寸-轴杆" }, new ParamDefinition { Key = "DiameterPrime", Label = "直径Φ'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 770, Group = "尺寸-轴杆" }, new ParamDefinition { Key = "LengthPrime", Label = "长度L'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 780, Group = "尺寸-轴杆" }, // --- Dimensions: box (方体) --- new ParamDefinition { Key = "BoxSize1", Label = "尺寸1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑", Order = 800, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize1TolPlus", Label = "尺寸1上差a1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 801, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize1TolMinus", Label = "尺寸1下差b1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 802, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize2", Label = "尺寸2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑", Order = 810, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize2TolPlus", Label = "尺寸2上差a2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 811, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize2TolMinus", Label = "尺寸2下差b2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 812, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize3", Label = "尺寸3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑", Order = 820, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize3TolPlus", Label = "尺寸3上差a3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 821, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize3TolMinus", Label = "尺寸3下差b3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 822, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize1Prime", Label = "尺寸1'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 830, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize2Prime", Label = "尺寸2'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 831, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxSize3Prime", Label = "尺寸3'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 832, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxFilletRadiusMax", Label = "未注圆角半径R≤(方体)", Type = ParamValueType.Enum, Required = false, DefaultValue = "", EnumOptions = new List { "6", "5", "4" }, Hint = "下拉列表(6/5/4),可手动编辑", Order = 840, Group = "尺寸-方体" }, new ParamDefinition { Key = "BoxRoundHeadFilletRadiusMax", Label = "圆头处圆角半径≤(方体)", Type = ParamValueType.Enum, Required = false, DefaultValue = "", EnumOptions = new List { "8", "10" }, Hint = "仅方体有圆头结构:下拉列表(8/10),可手动编辑", Order = 841, 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 = "尺寸-饼盘" }, // --- Dimensions: square shaft (方轴) --- new ParamDefinition { Key = "SquareShaftSize1", Label = "尺寸1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑(长度)", Order = 781, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize1TolPlus", Label = "尺寸1上差a1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 782, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize1TolMinus", Label = "尺寸1下差b1", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 783, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize2", Label = "尺寸2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑", Order = 784, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize2TolPlus", Label = "尺寸2上差a2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 785, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize2TolMinus", Label = "尺寸2下差b2", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 786, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize3", Label = "尺寸3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "手动编辑", Order = 787, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize3TolPlus", Label = "尺寸3上差a3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(+2~+7),可手动编辑", Order = 788, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize3TolMinus", Label = "尺寸3下差b3", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "下拉列表(-2~-7),可手动编辑", Order = 789, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftFilletRadiusMax", Label = "未注圆角半径R≤", Type = ParamValueType.Enum, Required = false, DefaultValue = "", EnumOptions = new List { "6", "5", "4" }, Hint = "下拉列表(6/5/4),可手动编辑", Order = 790, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize1Prime", Label = "尺寸1'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸", Order = 791, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize2Prime", Label = "尺寸2'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸", Order = 792, Group = "尺寸-轴杆(方轴)" }, new ParamDefinition { Key = "SquareShaftSize3Prime", Label = "尺寸3'", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸", Order = 793, 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 = "尺寸-饼盘" }, new ParamDefinition { Key = "DiskFilletRadiusMax", Label = "未注圆角半径R≤(饼盘)", Type = ParamValueType.Enum, Required = false, DefaultValue = "", EnumOptions = new List { "6", "5", "4" }, Hint = "下拉列表(6/5/4),可手动编辑", Order = 960, Group = "尺寸-饼盘" }, new ParamDefinition { Key = "DiskDiameterPrime", Label = "直径Φ'(饼盘)", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 970, Group = "尺寸-饼盘" }, new ParamDefinition { Key = "DiskHeightPrime", Label = "高度H'(饼盘)", Type = ParamValueType.Double, Required = false, DefaultValue = "", Hint = "零件尺寸,手动编辑", Order = 980, Group = "尺寸-饼盘" } } }; } } }