fix: update modules to use new LoadData interface and fix completeness check logic

Changes:
1. Update all modules to use LoadData(wsPlatform) instead of LoadData(wsConfig, wsPlatform)
   - modModelParserExamples.bas: Update 7 example procedures
   - modBOMProcessor.bas: Update 4 procedures
   - modModelParserTest.bas: Update 2 test procedures

2. Fix completeness check logic in GetValidMaterialsByModel
   - Only check root categories to avoid duplicate checking of subcategories
   - Previously, all required categories (including subcategories) were checked,
     causing subcategories to be added to missing list multiple times
   - Now only checks categories with ParentCategoryName = ""
   - CheckCategoryCompleteness already recursively checks all subcategories

3. Improve completeness judgment logic for categories with subcategories
   - Method 1: Parent category has 1 matching material → Complete
   - Method 2: Parent category has 0 matching materials, but all subcategories are complete → Complete
   - Other cases → Incomplete

Impact:
- Fixes "category missing" errors in Example9_BatchProcessOrders_WithCheck
- Eliminates duplicate entries in missing categories list
- Properly handles category hierarchy where parent categories are satisfied through subcategories

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-01-29 12:38:50 +08:00
parent a9b3188d23
commit c9cf84ed4d
4 changed files with 82 additions and 73 deletions

View File

@@ -1,6 +1,7 @@
' ========================================
' 模块: modBOMTest
' 用途: 测试和使用BOM数据结构
' 模块: modBOMProcessor
' 用途: BOM处理和操作示例
' ⭐ v2.0 更新:所有过程使用新的 LoadData(wsPlatform) 接口
' ========================================
Option Explicit
@@ -8,15 +9,12 @@ Sub TestBOMStructure()
' 初始化BOM管理器
Dim bomMgr As New clsBOMManager
' 加载数据(假设工作表名称)
Dim wsConfig As Worksheet
' 加载数据
Dim wsPlatform As Worksheet
Set wsConfig = ThisWorkbook.Worksheets("领料配置")
Set wsPlatform = ThisWorkbook.Worksheets("平台配置清单")
' 加载数据
bomMgr.LoadData wsConfig, wsPlatform
' ⭐ 使用新接口
bomMgr.LoadData wsPlatform
' 打印类别树结构到新工作表
Dim wsOutput As Worksheet
@@ -47,12 +45,12 @@ End Sub
' 示例: 获取特定类别的物料
Sub GetCategoryMaterials()
Dim bomMgr As New clsBOMManager
Dim wsConfig As Worksheet, wsPlatform As Worksheet
Dim wsPlatform As Worksheet
Set wsConfig = ThisWorkbook.Worksheets("领料配置")
Set wsPlatform = ThisWorkbook.Worksheets("平台配置清单")
bomMgr.LoadData wsConfig, wsPlatform
' ⭐ 使用新接口
bomMgr.LoadData wsPlatform
' 获取"部件"类别的物料(使用父类别)
Dim materials As collection
@@ -77,12 +75,12 @@ End Sub
' 示例: 根据产品型号生成领料清单
Sub GeneratePickingList()
Dim bomMgr As New clsBOMManager
Dim wsConfig As Worksheet, wsPlatform As Worksheet
Dim wsPlatform As Worksheet
Set wsConfig = ThisWorkbook.Worksheets("领料配置")
Set wsPlatform = ThisWorkbook.Worksheets("平台配置清单")
bomMgr.LoadData wsConfig, wsPlatform
' ⭐ 使用新接口
bomMgr.LoadData wsPlatform
' 创建领料清单工作表
Dim wsPickList As Worksheet
@@ -142,12 +140,12 @@ End Sub
' 示例: 查询特定物料信息
Sub QueryMaterialInfo()
Dim bomMgr As New clsBOMManager
Dim wsConfig As Worksheet, wsPlatform As Worksheet
Dim wsPlatform As Worksheet
Set wsConfig = ThisWorkbook.Worksheets("领料配置")
Set wsPlatform = ThisWorkbook.Worksheets("平台配置清单")
bomMgr.LoadData wsConfig, wsPlatform
' ⭐ 使用新接口
bomMgr.LoadData wsPlatform
' 查询特定类别
Dim cat As clsCategory