Files
AutoBOM/VBA/ClassModules/clsCategory.cls
Misaka_Company a9b3188d23 refactor: integrate [领料配置] into [平台配置清单] and add category selection conditions
Major changes:
- Remove dependency on separate [领料配置] sheet
- Load all data from [平台配置清单] in a single pass
- Add "类别选用条件" (CategorySelectCondition) field to support dynamic category filtering
- Add "66代码" (Code66) field for 66-system integration
- Refactor completeness check logic to only verify required categories

Data model changes:
- clsMaterialItem: Add CategorySelectCondition and Code66 properties
- clsCategory: Add CategorySelectCondition property and IsRequiredForModel() method
- clsBOMManager: Refactor LoadData() to use single data source
- clsBOMManager: Add GetRequiredCategories() method
- clsBOMManager: Update GetValidMaterialsByModel() to use category selection conditions

New workflow:
- LoadData() now takes only wsPlatform parameter (removed wsConfig)
- Categories are filtered by "类别选用条件" before completeness check
- Categories with empty selection condition are always required
- Categories with non-empty condition are checked against model specifications

Documentation:
- Update CLAUDE.md with new sheet structure
- Add comprehensive refactoring plan document
- Add v2.0 LoadData flow analysis with Mermaid diagrams
- Add platform configuration sheet reference

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 10:25:28 +08:00

84 lines
2.8 KiB
OpenEdge ABL

' ========================================
' 类模块: clsCategory
' 用途: 表示物料类别及其层级关系
' ========================================
Option Explicit
Public categoryName As String
Public ParentCategoryName As String
Public materials As collection ' 存储 clsMaterialItem 对象
Public SubCategories As collection ' 存储子类别 clsCategory 对象
Public IsLeafCategory As Boolean ' 是否叶子类别(无子类别)
Public CategorySelectCondition As String ' 类别选用条件(用于判断该类别是否需要)
Private Sub Class_Initialize()
Set materials = New collection
Set SubCategories = New collection
IsLeafCategory = True
End Sub
' 添加物料
Public Sub AddMaterial(mat As clsMaterialItem)
materials.Add mat, mat.code
End Sub
' 添加子类别
Public Sub AddSubCategory(cat As clsCategory)
SubCategories.Add cat, cat.categoryName
IsLeafCategory = False
End Sub
' 获取物料(按代号)
Public Function GetMaterial(code As String) As clsMaterialItem
On Error Resume Next
Set GetMaterial = materials(code)
On Error GoTo 0
End Function
' 检查是否有子类别
Public Function HasSubCategories() As Boolean
HasSubCategories = (SubCategories.Count > 0)
End Function
' ========================================
' IsRequiredForModel 方法
' 功能: 根据型号条件判断该类别是否需要
' 参数:
' conditions - 从型号提取的条件字典 (Dictionary对象)
' 返回:
' True - 该类别需要
' False - 该类别不需要
'
' 判断逻辑:
' 1. 如果 CategorySelectCondition 为空字符串
' → 该类别总是需要(无条件限制)
' 2. 如果 CategorySelectCondition 不为空
' → 使用 clsConditionMatcher 匹配条件
' → 匹配成功 → 需要
' → 匹配失败 → 不需要
'
' 示例:
' 假设型号条件为: lcfw=M16, gclj=M20
'
' 1: CategorySelectCondition = ""
' → IsRequiredForModel(conditions) = True
'
' 2: CategorySelectCondition = "lcfw=M16"
' → IsRequiredForModel(conditions) = True (匹配)
'
' 3: CategorySelectCondition = "lcfw=M02"
' → IsRequiredForModel(conditions) = False (不匹配)
'
' 4: CategorySelectCondition = "gclj=M20 AND jycz=1"
' → IsRequiredForModel(conditions) = True (匹配)
' ========================================
Public Function IsRequiredForModel(conditions As Object) As Boolean
If Me.CategorySelectCondition = "" Then
' 选用条件为空,该类别总是需要
IsRequiredForModel = True
Else
' conditions CategorySelectCondition
Dim matcher As New clsConditionMatcher
IsRequiredForModel = matcher.IsMatch(Me.CategorySelectCondition, conditions)
End If
End Function