docs: improve GetMaterialsByModel documentation

Enhanced the documentation for the GetMaterialsByModel method in clsBOMManager to clarify the core BOM logic. Replaced brief comments with a structured explanation covering the workflow (model parsing, condition extraction, material matching), detailed parameter descriptions, return value specifications (clsMaterialItem properties), and usage notes. This helps developers better understand the interaction between clsModelParser, clsConditionExtractor, and clsConditionMatcher.
This commit is contained in:
Misaka_Company
2026-01-20 15:06:53 +08:00
parent a1347017e3
commit 7f89f37f35

View File

@@ -356,14 +356,50 @@ Private Sub PrintCategory(ws As Worksheet, cat As clsCategory, _
End Sub End Sub
' ======================================== ' ========================================
' GetMaterialsByModel 方法 ' GetMaterialsByModel 方法
' 功能: 根据产品型号获取符合条件的物料清单 '
' 参数: ' 【功能概述】
' 根据产品型号字符串自动解析规格参数,并返回符合这些规格的所有物料清单。
' BOM,"产品型号""物料清单"
'
' 【工作流程】
' 1. 型号解析 (clsModelParser) → 将产品型号字符串拆解为结构化参数
' 2. 条件提取 (clsConditionExtractor) → 从型号参数中提取匹配条件变量
' 3. 物料筛选 (clsConditionMatcher) → 根据条件从物料库中筛选符合条件的物料
'
' 【参数说明】
' modelStr - 产品型号字符串 ' modelStr - 产品型号字符串
' categoryName - 可选,指定类别名称。为空则返回所有类别的物料 ' 格式: [型号]-[口径].[安装].[表壳].[连接].[量程]|[表盘]|[附件]|[法兰]
' 返回: Collection对象包含符合条件的clsMaterialItem对象 ' : "YTHN-100.A0.532.M203.M16.Y3|BP-095.2312.M16.PA3"
' 示例: ' 说明: 必须是完整的型号字符串,不能为空
' Set materials = bomMgr.GetMaterialsByModel("YTHN-100.A0.532.M203.M16.Y3") '
' Set materials = bomMgr.GetMaterialsByModel("YTHN-100.A0.532.M203.M16.Y3", "部件") ' categoryName - 类别名称(可选参数,默认为空字符串)
' "": ()
' 指定类别名: 仅返回该类别下的符合条件物料
' : "部件""表壳""接头""机芯"
'
' 【返回值】
' 返回类型: Collection对象
' 元素类型: Collection中的每个元素都是 clsMaterialItem 对象
'
' clsMaterialItem 对象属性:
' .code - String - (: "01011019001")
' .Name - String - (: "低压接头部件")
' .Quantity - Double - 物料数量(如: 1, 2, 0.5)
' .Condition - String - (: "lcfw=M02 AND gclj=Z12")
' .Category - String - 所属类别名称
' .ParentCategory - String - 上层类别名称
'
' 【注意事项】
' 1. 调用前必须先执行 LoadData() 方法加载BOM数据
' 2. 型号字符串必须完整且符合格式要求
' 3. 返回的Collection可能为空(没有符合条件的物料),需要判断Count属性
' 4. VBA"立即窗口"(Ctrl+G)
' 5. 物料的Condition属性为空表示该物料无条件限制(所有型号都使用)
'
' 【相关方法】
' - GetMaterialsByCategoryAndModel: 结合了类别层级逻辑的物料获取
' - GetMaterialsForPicking: 纯粹按类别获取物料(不进行型号匹配)
' - ParseModelAndExtractConditions: 仅解析型号并返回条件字典
' ======================================== ' ========================================
Public Function GetMaterialsByModel(modelStr As String, _ Public Function GetMaterialsByModel(modelStr As String, _
Optional categoryName As String = "") As collection Optional categoryName As String = "") As collection