diff --git a/VBA/ClassModules/ConditionEvaluator.cls b/VBA/ClassModules/ConditionEvaluator.cls index a26fd5d..bf068e3 100644 --- a/VBA/ClassModules/ConditionEvaluator.cls +++ b/VBA/ClassModules/ConditionEvaluator.cls @@ -146,7 +146,15 @@ Private Function EvaluateSingleCondition(condition As String, Conditions As Obje EvaluateSingleCondition = True Else actualValue = Conditions(varName) - EvaluateSingleCondition = (actualValue <> value) + + ' fjgn字段特殊处理(多值匹配) + If varName = "fjgn" Then + ' fjgn!=N1:检查actualValue中是否不包含value + EvaluateSingleCondition = (InStr(actualValue, value) = 0) + Else + ' 其他字段使用精确匹配 + EvaluateSingleCondition = (actualValue <> value) + End If End If Exit Function End If @@ -164,7 +172,15 @@ Private Function EvaluateSingleCondition(condition As String, Conditions As Obje EvaluateSingleCondition = False Else actualValue = Conditions(varName) - EvaluateSingleCondition = (actualValue = value) + + ' fjgn字段特殊处理(多值匹配) + If varName = "fjgn" Then + ' fjgn=N1:检查actualValue中是否包含value + EvaluateSingleCondition = (InStr(actualValue, value) > 0) + Else + ' 其他字段使用精确匹配 + EvaluateSingleCondition = (actualValue = value) + End If End If Exit Function End If diff --git a/VBA/ClassModules/ProductModelParser.cls b/VBA/ClassModules/ProductModelParser.cls index e89054a..f9c7594 100644 --- a/VBA/ClassModules/ProductModelParser.cls +++ b/VBA/ClassModules/ProductModelParser.cls @@ -150,6 +150,31 @@ Private Function ParseHeader() As Boolean lcfw = Trim(dotParts(4)) pConditions.Add "lcfw", lcfw + ' 仪表特性 - 第6个位置(索引5)及之后的所有部分 + ' 因为仪表特性中可能包含.分隔符(如N3.N2.Y3),所以需要合并从索引5开始的所有部分 + Dim fjgn As String + If UBound(dotParts) >= 5 Then + Dim instrumentFeature As String + Dim i As Long + instrumentFeature = "" + + ' 合并从索引5开始的所有部分,用.连接 + For i = 5 To UBound(dotParts) + If instrumentFeature = "" Then + instrumentFeature = dotParts(i) + Else + instrumentFeature = instrumentFeature & "." & dotParts(i) + End If + Next i + + instrumentFeature = Trim(instrumentFeature) + fjgn = ExtractAdditionalFeatures(instrumentFeature) + Else + ' 如果没有仪表特性字段,fjgn为空 + fjgn = "" + End If + pConditions.Add "fjgn", fjgn + ParseHeader = True Exit Function @@ -229,4 +254,50 @@ Public Function GetAllConditions() As String Next key GetAllConditions = result +End Function + +'===================================================================== +' 方法: ExtractAdditionalFeatures +' 功能: 从仪表特性中提取附加功能 +' 参数: instrumentFeature - 仪表特性字符串(如"N2,N3.Y3"或"Y3") +' 返回: String - 附加功能字符串,多个功能用逗号分隔 +' 说明: +' 1. 识别并去除充油类型(位于最后,格式为Y+一位数字) +' 2. 统一分隔符处理(将.替换为,) +' 3. 去除可能的后缀分隔符 +'===================================================================== +Private Function ExtractAdditionalFeatures(instrumentFeature As String) As String + On Error GoTo ErrorHandler + + Dim result As String + result = Trim(instrumentFeature) + + ' 1. 检查是否以Y+数字结尾(充油类型) + If Len(result) >= 2 Then + Dim lastTwoChars As String + lastTwoChars = Right(result, 2) + + ' 检查最后两位是否为Y+数字 + If UCase(Left(lastTwoChars, 1)) = "Y" And IsNumeric(Right(lastTwoChars, 1)) Then + ' 去掉充油类型 + result = Left(result, Len(result) - 2) + result = Trim(result) + End If + End If + + ' 2. 处理可能的分隔符(,或.) + ' 将可能的.替换为,,统一处理 + result = Replace(result, ".", ",") + + ' 3. 去除可能的后缀分隔符 + If Len(result) > 0 And Right(result, 1) = "," Then + result = Left(result, Len(result) - 1) + End If + + ExtractAdditionalFeatures = Trim(result) + Exit Function + +ErrorHandler: + ' 如果解析出错,返回空字符串 + ExtractAdditionalFeatures = "" End Function \ No newline at end of file diff --git a/VBA/Modules/BIPUploadModule.bas b/VBA/Modules/BIPUploadModule.bas index d539cf5..302df40 100644 --- a/VBA/Modules/BIPUploadModule.bas +++ b/VBA/Modules/BIPUploadModule.bas @@ -9,7 +9,7 @@ Option Explicit ' 常量定义 '===================================================================== ' 提取条件配置 -Private Const CONDITION_CONFIG = "azxs,安装形式|bkxs,表壳形式|gclj,过程连接|jycz,接液材质|lcfw,量程范围" +Private Const CONDITION_CONFIG = "azxs,安装形式|bkxs,表壳形式|gclj,过程连接|jycz,接液材质|lcfw,量程范围|fjgn,附加功能" ' 行号基数 Private Const ROW_NUMBER_BASE = 7000 diff --git a/VBA/Modules/MainModule.bas b/VBA/Modules/MainModule.bas index 3ba97a2..a7aa96b 100644 --- a/VBA/Modules/MainModule.bas +++ b/VBA/Modules/MainModule.bas @@ -9,7 +9,7 @@ Option Explicit ' 常量定义 '===================================================================== ' 提取条件配置(可灵活扩展) -Private Const CONDITION_CONFIG = "azxs,安装形式|bkxs,表壳形式|gclj,过程连接|jycz,接液材质|lcfw,量程范围" +Private Const CONDITION_CONFIG = "azxs,安装形式|bkxs,表壳形式|gclj,过程连接|jycz,接液材质|lcfw,量程范围|fjgn,附加功能" '===================================================================== ' 过程: ProcessProductModels