fix: resolve duplicate variable declaration compilation errors
All checks were successful
NTFY Notification / notify (push) Successful in 5s
All checks were successful
NTFY Notification / notify (push) Successful in 5s
- Move shouldExclude declaration to function level in MatchAllMaterialTypesWithValidation - Move rawMat and result declarations to function level in BOMExtraction - Remove duplicate Dim statements inside loops Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,8 @@ Public Function BOMExtraction() As String
|
|||||||
|
|
||||||
Dim i As Long
|
Dim i As Long
|
||||||
Dim totalModels As Long
|
Dim totalModels As Long
|
||||||
|
Dim rawMat As Variant ' 在函数级别声明一次
|
||||||
|
Dim result As Variant ' 在函数级别声明一次
|
||||||
totalModels = UBound(inputModels, 1)
|
totalModels = UBound(inputModels, 1)
|
||||||
|
|
||||||
For i = LBound(inputModels, 1) To UBound(inputModels, 1)
|
For i = LBound(inputModels, 1) To UBound(inputModels, 1)
|
||||||
@@ -159,13 +161,11 @@ Public Function BOMExtraction() As String
|
|||||||
Set modelResults = ProcessSingleModel(modelString, g_BOMWorkbook, g_Logger, productionOrderNo, orderQty, rawMaterials)
|
Set modelResults = ProcessSingleModel(modelString, g_BOMWorkbook, g_Logger, productionOrderNo, orderQty, rawMaterials)
|
||||||
|
|
||||||
' 收集未过滤的物料(用于库存比对)
|
' 收集未过滤的物料(用于库存比对)
|
||||||
Dim rawMat As Variant
|
|
||||||
For Each rawMat In rawMaterials
|
For Each rawMat In rawMaterials
|
||||||
allRawMaterials.Add rawMat
|
allRawMaterials.Add rawMat
|
||||||
Next rawMat
|
Next rawMat
|
||||||
|
|
||||||
' 合并已过滤的结果(用于BOM提取结果和BIP上传)
|
' 合并已过滤的结果(用于BOM提取结果和BIP上传)
|
||||||
Dim result As Variant
|
|
||||||
For Each result In modelResults
|
For Each result In modelResults
|
||||||
allResults.Add result
|
allResults.Add result
|
||||||
Next result
|
Next result
|
||||||
@@ -196,7 +196,6 @@ Public Function BOMExtraction() As String
|
|||||||
Dim componentMaterials As Collection
|
Dim componentMaterials As Collection
|
||||||
Set componentMaterials = New Collection
|
Set componentMaterials = New Collection
|
||||||
|
|
||||||
Dim rawMat As Variant
|
|
||||||
For Each rawMat In allRawMaterials
|
For Each rawMat In allRawMaterials
|
||||||
If rawMat("materialType") = "部件" Then
|
If rawMat("materialType") = "部件" Then
|
||||||
componentMaterials.Add rawMat
|
componentMaterials.Add rawMat
|
||||||
@@ -621,6 +620,9 @@ Private Function MatchAllMaterialTypesWithValidation( _
|
|||||||
' 初始化未过滤集合(用于库存比对工作表)
|
' 初始化未过滤集合(用于库存比对工作表)
|
||||||
Set outRawMaterials = New Collection
|
Set outRawMaterials = New Collection
|
||||||
|
|
||||||
|
' 声明过滤标志变量(在函数级别声明一次)
|
||||||
|
Dim shouldExclude As Boolean
|
||||||
|
|
||||||
If validationResult("valid") Then
|
If validationResult("valid") Then
|
||||||
' 验证通过,收集所有物料
|
' 验证通过,收集所有物料
|
||||||
Dim resultKey As Variant
|
Dim resultKey As Variant
|
||||||
@@ -634,7 +636,6 @@ Private Function MatchAllMaterialTypesWithValidation( _
|
|||||||
outRawMaterials.Add mat
|
outRawMaterials.Add mat
|
||||||
|
|
||||||
' 2. 添加到已过滤集合(排除库存不足的部件标记)
|
' 2. 添加到已过滤集合(排除库存不足的部件标记)
|
||||||
Dim shouldExclude As Boolean
|
|
||||||
shouldExclude = False
|
shouldExclude = False
|
||||||
|
|
||||||
If mat.Exists("isStockSufficient") Then
|
If mat.Exists("isStockSufficient") Then
|
||||||
@@ -661,7 +662,6 @@ Private Function MatchAllMaterialTypesWithValidation( _
|
|||||||
outRawMaterials.Add mat2
|
outRawMaterials.Add mat2
|
||||||
|
|
||||||
' 2. 添加到已过滤集合(排除库存不足的部件标记)
|
' 2. 添加到已过滤集合(排除库存不足的部件标记)
|
||||||
Dim shouldExclude As Boolean
|
|
||||||
shouldExclude = False
|
shouldExclude = False
|
||||||
|
|
||||||
If mat2.Exists("isStockSufficient") Then
|
If mat2.Exists("isStockSufficient") Then
|
||||||
|
|||||||
Reference in New Issue
Block a user