feat: add component priority exclusion feature
Add support for excluding "部件" category based on component priority flag: - BomExtractor: Add exclude categories functionality - Add pExcludeCategories collection member - Add SetExcludeCategories() and ClearExcludeCategories() methods - Modify DetermineRequiredCategories() to skip excluded categories - BIPUploadModule: Read and use component priority field - Read component priority from column E of [产品订单] worksheet - Pass component priority to ProcessSingleOrder() - When priority is "否"/"0"/"FALSE", exclude "部件" category - Only extract sub-category materials when component priority is disabled Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ Private pMatchedItems As collection ' 匹配的BOM项
|
||||
Private pRequiredCategories As collection ' 需要的类别
|
||||
Private pCategoryHierarchy As Object ' 类别层次结构 Dictionary(子类别->父类别)
|
||||
Private pErrorMessages As collection
|
||||
Private pExcludeCategories As collection ' 需要排除的类别
|
||||
|
||||
'=====================================================================
|
||||
' 方法: Class_Initialize
|
||||
@@ -26,6 +27,7 @@ Private Sub Class_Initialize()
|
||||
Set pRequiredCategories = New collection
|
||||
Set pCategoryHierarchy = CreateObject("Scripting.Dictionary")
|
||||
Set pErrorMessages = New collection
|
||||
Set pExcludeCategories = New collection
|
||||
End Sub
|
||||
|
||||
'=====================================================================
|
||||
@@ -93,6 +95,23 @@ ErrorHandler:
|
||||
LoadBomData = False
|
||||
End Function
|
||||
|
||||
'=====================================================================
|
||||
' 方法: SetExcludeCategories
|
||||
' 功能: 设置需要排除的类别
|
||||
' 参数: categories - 类别集合
|
||||
'=====================================================================
|
||||
Public Sub SetExcludeCategories(categories As collection)
|
||||
Set pExcludeCategories = categories
|
||||
End Sub
|
||||
|
||||
'=====================================================================
|
||||
' 方法: ClearExcludeCategories
|
||||
' 功能: 清空排除类别列表
|
||||
'=====================================================================
|
||||
Public Sub ClearExcludeCategories()
|
||||
Set pExcludeCategories = New collection
|
||||
End Sub
|
||||
|
||||
'=====================================================================
|
||||
' 方法: ExtractBom
|
||||
' 功能: 根据产品条件提取BOM
|
||||
@@ -141,20 +160,34 @@ Private Sub DetermineRequiredCategories(productConditions As Object)
|
||||
' 遍历所有有效物料,获取唯一类别
|
||||
For Each item In pAllItems
|
||||
If item.IsValidItem Then
|
||||
' 检查类别选用条件
|
||||
Dim categoryRequired As Boolean
|
||||
If Trim(item.CategoryCondition) = "" Then
|
||||
' 无条件,必需类别
|
||||
categoryRequired = True
|
||||
Else
|
||||
' 有条件,评估条件
|
||||
categoryRequired = pConditionEvaluator.Evaluate(item.CategoryCondition, productConditions)
|
||||
End If
|
||||
' 检查是否在排除列表中
|
||||
Dim isExcluded As Boolean
|
||||
isExcluded = False
|
||||
Dim excludeCat As Variant
|
||||
For Each excludeCat In pExcludeCategories
|
||||
If item.category = CStr(excludeCat) Then
|
||||
isExcluded = True
|
||||
Exit For
|
||||
End If
|
||||
Next excludeCat
|
||||
|
||||
If categoryRequired Then
|
||||
If Not uniqueCategories.Exists(item.category) Then
|
||||
uniqueCategories.Add item.category, True
|
||||
pRequiredCategories.Add item.category
|
||||
' 如果不在排除列表中,继续处理
|
||||
If Not isExcluded Then
|
||||
' 检查类别选用条件
|
||||
Dim categoryRequired As Boolean
|
||||
If Trim(item.CategoryCondition) = "" Then
|
||||
' 无条件,必需类别
|
||||
categoryRequired = True
|
||||
Else
|
||||
' 有条件,评估条件
|
||||
categoryRequired = pConditionEvaluator.Evaluate(item.CategoryCondition, productConditions)
|
||||
End If
|
||||
|
||||
If categoryRequired Then
|
||||
If Not uniqueCategories.Exists(item.category) Then
|
||||
uniqueCategories.Add item.category, True
|
||||
pRequiredCategories.Add item.category
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user