From c7c12838b2f261519a53316e51f9ce5f258137eb Mon Sep 17 00:00:00 2001 From: Misaka Date: Sun, 1 Feb 2026 22:35:25 +0800 Subject: [PATCH] feat: add component priority support to MainModule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- VBA/Modules/MainModule.bas | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/VBA/Modules/MainModule.bas b/VBA/Modules/MainModule.bas index bc7828c..ce89067 100644 --- a/VBA/Modules/MainModule.bas +++ b/VBA/Modules/MainModule.bas @@ -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