feat: add component priority support to MainModule

Update MainModule to support component priority field:
- Read component priority from column E of [产品订单] worksheet
- Pass component priority to ProcessSingleModel function
- Apply category exclusion logic based on priority flag:
  - When "否"/"0"/"FALSE", exclude "部件" category
  - Only extract sub-category materials when disabled
- Consistent with BIPUploadModule implementation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-02-01 22:35:25 +08:00
parent c5f2d804fb
commit c7c12838b2

View File

@@ -75,10 +75,12 @@ Public Sub ProcessProductModels()
' 假设产品型号在第1列,从第2行开始
For i = 2 To lastRow
modelString = Trim(inputSheet.Cells(i, 2).value)
Dim componentPriority As String
componentPriority = Trim(inputSheet.Cells(i, 5).value) ' E列部件优先
If modelString <> "" Then
' 处理单个型号
outputRow = ProcessSingleModel(modelString, BomExtractor, outputSheet, outputRow)
outputRow = ProcessSingleModel(modelString, componentPriority, BomExtractor, outputSheet, outputRow)
processedCount = processedCount + 1
End If
Next i
@@ -106,12 +108,14 @@ End Sub
' 函数: ProcessSingleModel
' 功能: 处理单个产品型号
' 参数: modelString - 产品型号字符串
' componentPriority - 部件优先标志("是"或"否"
' bomExtractor - BOM提取器对象
' outputSheet - 输出工作表
' startRow - 起始行号
' 返回: Long - 下一个可用行号
'=====================================================================
Private Function ProcessSingleModel(modelString As String, _
componentPriority As String, _
BomExtractor As BomExtractor, _
outputSheet As Worksheet, _
startRow As Long) As Long
@@ -120,6 +124,14 @@ Private Function ProcessSingleModel(modelString As String, _
Dim currentRow As Long
currentRow = startRow
' 根据部件优先设置排除类别
BomExtractor.ClearExcludeCategories
If UCase(componentPriority) = "否" Or componentPriority = "0" Or componentPriority = "FALSE" Then
Dim excludeCats As New collection
excludeCats.Add "部件"
BomExtractor.SetExcludeCategories excludeCats
End If
' 解析产品型号
Dim parser As ProductModelParser
Set parser = New ProductModelParser