feat: add azxs preprocessing support for component category
All checks were successful
NTFY Notification / notify (push) Successful in 13s
All checks were successful
NTFY Notification / notify (push) Successful in 13s
Extend M05_PreProcessor to support category-specific preprocessing: - "接头" category: Full preprocessing (azxs + lcfw mapping, OR merging, parentheses simplification) - "部件" category: Partial preprocessing (azxs mapping only, OR merging, parentheses simplification) - Other categories: No preprocessing Add new function ApplyPreprocessingWithoutLcfw() to handle component category preprocessing. Add unit tests (PP_09 through PP_12) to verify: - azxs mapping for component category - lcfw conditions remain unchanged for component category - OR condition merging and parentheses simplification Update CLAUDE.md documentation with category-specific preprocessing table. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
' ==============================================================================
|
||||
' 模块: M05_PreProcessor
|
||||
' 职责: 预处理条件表达式,用于"接头"类别的值映射和去重
|
||||
' 职责: 预处理条件表达式,支持不同类别的差异化处理
|
||||
' - "接头"类别: 完整预处理(azxs映射 + lcfw映射 + OR合并 + 括号简化)
|
||||
' - "部件"类别: 部分预处理(azxs映射 + OR合并 + 括号简化,不处理lcfw)
|
||||
' - 其他类别: 不进行预处理
|
||||
' 使用正则表达式实现高效的值映射和OR条件合并
|
||||
' ==============================================================================
|
||||
Option Explicit
|
||||
@@ -35,24 +38,32 @@ End Function
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 主入口:预处理条件表达式
|
||||
' 支持的类别:
|
||||
' - "接头": 完整预处理(azxs映射 + lcfw映射 + OR合并 + 括号简化)
|
||||
' - "部件": 部分预处理(azxs映射 + OR合并 + 括号简化,不处理lcfw)
|
||||
' - 其他: 不进行预处理
|
||||
' ------------------------------------------------------------------------------
|
||||
Public Function PreprocessCondition( _
|
||||
ByVal strCondition As String, _
|
||||
ByVal strCategory As String, _
|
||||
ByVal rowIdx As Long _
|
||||
) As String
|
||||
' 仅对"接头"类别进行预处理
|
||||
If strCategory <> "接头" Then
|
||||
PreprocessCondition = strCondition
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
If Not g_IsInitialized Then
|
||||
PreprocessCondition = strCondition
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
PreprocessCondition = ApplyPreprocessing(strCondition, rowIdx)
|
||||
' 根据类别选择处理策略
|
||||
If strCategory = "接头" Then
|
||||
' 完整预处理:azxs + lcfw + OR合并 + 括号简化
|
||||
PreprocessCondition = ApplyPreprocessing(strCondition, rowIdx)
|
||||
ElseIf strCategory = "部件" Then
|
||||
' 部分预处理:azxs + OR合并 + 括号简化(不处理 lcfw)
|
||||
PreprocessCondition = ApplyPreprocessingWithoutLcfw(strCondition, rowIdx)
|
||||
Else
|
||||
' 其他类别:不处理
|
||||
PreprocessCondition = strCondition
|
||||
End If
|
||||
End Function
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
@@ -143,6 +154,35 @@ Private Function ApplyPreprocessing( _
|
||||
ApplyPreprocessing = strCondition
|
||||
End Function
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 应用预处理(不含 lcfw 映射):用于"部件"类别
|
||||
' 执行步骤:azxs 映射 → 嵌套表达式处理 → OR合并 → 括号简化
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Function ApplyPreprocessingWithoutLcfw( _
|
||||
ByVal strCondition As String, _
|
||||
ByVal rowIdx As Long _
|
||||
) As String
|
||||
' 步骤1: 应用 azxs 映射
|
||||
strCondition = ApplyRegexMapping( _
|
||||
strCondition, _
|
||||
"(azxs)( *=|!= *)([a-zA-Z0-9]{2})", _
|
||||
g_AzxsMapping, _
|
||||
rowIdx, _
|
||||
"azxs" _
|
||||
)
|
||||
|
||||
' 步骤2: 递归处理嵌套括号内的表达式(合并OR,简化括号)
|
||||
strCondition = ProcessNestedExpressions(strCondition, rowIdx)
|
||||
|
||||
' 步骤3: 合并顶层重复的OR条件
|
||||
strCondition = MergeDuplicateORConditions(strCondition)
|
||||
|
||||
' 步骤4: 简化不必要的括号
|
||||
strCondition = SimplifyParentheses(strCondition)
|
||||
|
||||
ApplyPreprocessingWithoutLcfw = strCondition
|
||||
End Function
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 递归处理嵌套表达式:先预处理括号内的内容,再进行OR合并
|
||||
' ------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,6 +46,10 @@ Public Sub RunAllTests()
|
||||
Test_PP_06_FullIntegration
|
||||
Test_PP_07_NonJointCategory
|
||||
Test_PP_08_UnmappedValues
|
||||
Test_PP_09_ComponentCategory_AzxsMapping
|
||||
Test_PP_10_ComponentCategory_LcfwUnchanged
|
||||
Test_PP_11_ComponentCategory_ORMerging
|
||||
Test_PP_12_ComponentCategory_ParenthesesSimplification
|
||||
|
||||
' 汇总结果
|
||||
Debug.Print String(50, "-")
|
||||
@@ -369,8 +373,8 @@ Private Sub Test_PP_06_FullIntegration()
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 测试用例 PP_07: 测试非"接头"类别
|
||||
' 验证其他类别不受预处理影响
|
||||
' 测试用例 PP_07: 测试非"接头"/"部件"类别
|
||||
' 验证其他类别(如"弹性元件")不受预处理影响
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Sub Test_PP_07_NonJointCategory()
|
||||
SetupPreProcessorTest
|
||||
@@ -378,9 +382,9 @@ Private Sub Test_PP_07_NonJointCategory()
|
||||
Dim inputCond As String
|
||||
inputCond = "gclj=M20 AND lcfw=M01"
|
||||
|
||||
' 使用"部件"类别
|
||||
' 使用"弹性元件"类别
|
||||
Dim result As String
|
||||
result = M05_PreProcessor.PreprocessCondition(inputCond, "部件", 1)
|
||||
result = M05_PreProcessor.PreprocessCondition(inputCond, "弹性元件", 1)
|
||||
|
||||
' 应该保持不变
|
||||
Assert_Equal result, inputCond, "PP07_NonJoint_Unchanged"
|
||||
@@ -407,6 +411,67 @@ Private Sub Test_PP_08_UnmappedValues()
|
||||
' 注意:这个测试可能需要根据实际日志记录行为调整
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 测试用例 PP_09: 测试"部件"类别的azxs映射
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Sub Test_PP_09_ComponentCategory_AzxsMapping()
|
||||
SetupPreProcessorTest
|
||||
|
||||
Dim result1 As String
|
||||
result1 = M05_PreProcessor.PreprocessCondition("azxs=A0 AND gclj=M20", "部件", 1)
|
||||
Assert_Equal result1, "azxs=径向 AND gclj=M20", "PP09_Component_Azxs_Mapping"
|
||||
|
||||
Dim result2 As String
|
||||
result2 = M05_PreProcessor.PreprocessCondition("gclj=M20 AND azxs=B0", "部件", 2)
|
||||
Assert_Equal result2, "gclj=M20 AND azxs=下轴向", "PP09_Component_Azxs_With_AND"
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 测试用例 PP_10: 测试"部件"类别的lcfw条件保持不变
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Sub Test_PP_10_ComponentCategory_LcfwUnchanged()
|
||||
SetupPreProcessorTest
|
||||
|
||||
Dim result1 As String
|
||||
result1 = M05_PreProcessor.PreprocessCondition("lcfw=M01 AND gclj=M20", "部件", 1)
|
||||
Assert_Equal result1, "lcfw=M01 AND gclj=M20", "PP10_Component_Lcfw_Unchanged"
|
||||
|
||||
Dim result2 As String
|
||||
result2 = M05_PreProcessor.PreprocessCondition("gclj=M20 AND lcfw=M01", "部件", 2)
|
||||
Assert_Equal result2, "gclj=M20 AND lcfw=M01", "PP10_Component_Lcfw_Unchanged_Reverse"
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 测试用例 PP_11: 测试"部件"类别的OR条件合并
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Sub Test_PP_11_ComponentCategory_ORMerging()
|
||||
SetupPreProcessorTest
|
||||
|
||||
Dim result1 As String
|
||||
result1 = M05_PreProcessor.PreprocessCondition("(azxs=A0 OR azxs=AT) AND gclj=M20", "部件", 1)
|
||||
Assert_Equal result1, "azxs=径向 AND gclj=M20", "PP11_Component_OR_Merging_Azxs"
|
||||
|
||||
' 测试精确重复的OR条件合并
|
||||
Dim result2 As String
|
||||
result2 = M05_PreProcessor.PreprocessCondition("azxs=径向 OR azxs=径向", "部件", 2)
|
||||
Assert_Equal result2, "azxs=径向", "PP11_Component_Exact_Duplicate_Merging"
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 测试用例 PP_12: 测试"部件"类别的括号简化
|
||||
' ------------------------------------------------------------------------------
|
||||
Private Sub Test_PP_12_ComponentCategory_ParenthesesSimplification()
|
||||
SetupPreProcessorTest
|
||||
|
||||
Dim result1 As String
|
||||
result1 = M05_PreProcessor.PreprocessCondition("(azxs=A0 OR azxs=AT) AND gclj=M20", "部件", 1)
|
||||
Assert_Equal result1, "azxs=径向 AND gclj=M20", "PP12_Component_Parentheses_Simplified"
|
||||
|
||||
Dim result2 As String
|
||||
result2 = M05_PreProcessor.PreprocessCondition("gclj=M20 AND (azxs=A0 OR azxs=AT)", "部件", 2)
|
||||
Assert_Equal result2, "gclj=M20 AND azxs=径向", "PP12_Component_Parentheses_Simplified_Reverse"
|
||||
End Sub
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 辅助函数:设置预处理测试环境
|
||||
' ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user