feat: add special validation for edge material based on azxs parameter
All checks were successful
NTFY Notification / notify (push) Successful in 3s

Implement edge material validation logic that behaves differently based on azxs value:
- When azxs is A0, Z0, or B0: Edge material is NOT required (0 matches = OK, 1+ matches = ERROR)
- When azxs is AH, AT, BH, BT, BZ, ZH, ZT, or ZZ: Standard validation applies (exactly 1 match required)
- Supports dual-value azxs format (e.g., "A0,径向" extracts "A0" for validation)

Changes:
- M09_BOMExtractor.bas:
  - Update MatchAllMaterialTypesWithValidation to pass params to validation
  - Update ValidateAllMatchResults signature to accept params parameter
  - Add "边" to special sheets array
  - Implement Phase 3.5: Edge material validation with azxs-based rules
  - Update function header comments

- docs/BOM匹配错误判断机制详解.md:
  - Add section 6.5: Edge material special handling
  - Update error type table with EdgeMaterialError
  - Update function index and version history

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-02-12 18:31:33 +08:00
parent 1d5bad86f7
commit 53b3568412
2 changed files with 245 additions and 7 deletions

View File

@@ -398,6 +398,7 @@ End Function
' 特殊处理:
' - "部件"工作表特殊处理调用M08_ComponentProcessor
' - 部件、接头、弹性元件的交叉验证
' - 边材料基于azxs参数的特殊验证A0/Z0/B0不需要边AH/AT等需要边
' ------------------------------------------------------------------------------
Private Function MatchAllMaterialTypesWithValidation( _
ByVal params As Object, _
@@ -504,7 +505,7 @@ Private Function MatchAllMaterialTypesWithValidation( _
' Phase 2: 统一验证所有匹配结果
' ========================================
Dim validationResult As Object
Set validationResult = ValidateAllMatchResults(resultsDict, logger)
Set validationResult = ValidateAllMatchResults(resultsDict, logger, params)
' ========================================
' Phase 3: 根据验证结果生成最终物料集合
@@ -561,6 +562,7 @@ End Function
' 输入:
' resultsDict - 所有工作表的匹配结果字典
' logger - 错误记录器
' params - 产品型号参数字典(用于边材料验证)
'
' 输出:
' Object - 验证结果对象
@@ -570,17 +572,23 @@ End Function
' 验证规则:
' 1. 基础规则(所有工作表):
' - 恰好匹配1条记录 → 正常
' - 匹配0条记录 → 错误(部件/接头/弹性元件除外)
' - 匹配0条记录 → 错误(部件/接头/弹性元件/边除外)
' - 匹配2+条记录 → 错误
'
' 2. 特殊规则(部件、接头、弹性元件):
' - 互斥关系验证
' - 组合完整性验证
' - 警告处理
'
' 3. 特殊规则(边材料):
' - azxs=A0/Z0/B0 → 不需要边0条=OK1+条=ERROR
' - azxs=AH/AT/BH/BT/BZ/ZH/ZT/ZZ → 需要边1条=OK
' - 支持双值格式(如"A0,径向"
' ------------------------------------------------------------------------------
Private Function ValidateAllMatchResults( _
ByVal resultsDict As Object, _
ByVal logger As clsErrorLogger _
ByVal logger As clsErrorLogger, _
ByVal params As Object _
) As Object
On Error GoTo ErrorHandler
@@ -593,7 +601,7 @@ Private Function ValidateAllMatchResults( _
' 1. 基础验证非特殊工作表必须恰好1条
' ========================================
Dim specialSheets As Variant
specialSheets = Array(BOMLIB_SHEET_COMPONENT, "接头", "弹性元件")
specialSheets = Array(BOMLIB_SHEET_COMPONENT, "接头", "弹性元件", BOMLIB_SHEET_EDGE)
Dim errors As Collection
Set errors = New Collection
@@ -727,6 +735,89 @@ Private Function ValidateAllMatchResults( _
End If
End If
' ========================================
' 3.5. 特殊验证:边 (Edge) 材料
' ========================================
Dim edgeResult As Object
Set edgeResult = Nothing
If resultsDict.Exists(BOMLIB_SHEET_EDGE) Then
Set edgeResult = resultsDict(BOMLIB_SHEET_EDGE)
End If
' 检查azxs参数值
Dim azxsValue As String
Dim rawAzxs As String
azxsValue = ""
rawAzxs = ""
If params.Exists("azxs") Then
azxsValue = CStr(params("azxs"))
' 提取原始azxs值处理双值格式如"A0,径向"
If InStr(azxsValue, ",") > 0 Then
rawAzxs = Trim(CStr(Split(azxsValue, ",")(0)))
Else
rawAzxs = Trim(azxsValue)
End If
End If
' 定义不需要边的azxs值
Dim noEdgeAzxs As Variant
noEdgeAzxs = Array("A0", "Z0", "B0")
' 定义需要边的azxs值有后缀H/T/Z的值
Dim hasEdgeAzxs As Variant
hasEdgeAzxs = Array("AH", "AT", "BH", "BT", "BZ", "ZH", "ZT", "ZZ")
' 检查是否为不需要边的azxs值
Dim isNoEdgeCase As Boolean
isNoEdgeCase = False
Dim az As Variant
For Each az In noEdgeAzxs
If rawAzxs = az Then
isNoEdgeCase = True
Exit For
End If
Next az
' 情况A: azxs为A0/Z0/B0不应该有边
If isNoEdgeCase Then
If Not edgeResult Is Nothing Then
If edgeResult("rowCount") > 0 Then
errors.Add "[边]工作表匹配到" & edgeResult("rowCount") & "条记录但azxs=" & rawAzxs & "不需要边物料"
End If
End If
' 0条匹配是正常的不记录错误或警告
' 情况B: azxs为AH/AT/BH/BT/BZ/ZH/ZT/ZZ走常规判断
Else
' 检查是否为需要边的azxs值
Dim isHasEdgeCase As Boolean
isHasEdgeCase = False
For Each az In hasEdgeAzxs
If rawAzxs = az Then
isHasEdgeCase = True
Exit For
End If
Next az
If isHasEdgeCase Then
' 标准验证恰好1条匹配
If Not edgeResult Is Nothing Then
If edgeResult("rowCount") = 0 Then
errors.Add "[边]未匹配到记录"
ElseIf edgeResult("rowCount") > 1 Then
errors.Add "[边]匹配到" & edgeResult("rowCount") & "条记录"
End If
Else
' 没有边的结果记录
errors.Add "[边]未匹配到记录"
End If
End If
End If
' ========================================
' 4. 处理[部件]工作表的多条匹配
' ========================================