- Update IModuleProcessor interface to accept targetBOMs collection instead of targetItemName string - Remove filtering logic from strategy implementations (AppendOnly, CloneNew) - Add LoadData method to mSpecAdditionManager for UI initialization - Rename ExecuteAddition to ExecutePipeline with refined parameters - Enhance test suite to simulate fine-grained UI selection behavior - Enable precise row-level control by delegating filtering to UI layer This refactoring achieves better separation of concerns where: - Strategy layer focuses purely on execution logic - UI layer handles selection and filtering - Manager layer coordinates the pipeline flow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
2.3 KiB
QBasic
58 lines
2.3 KiB
QBasic
' ==============================================================================
|
|
' 模块名称: mSpecAdditionManager
|
|
' 模块类别: 标准模块 (Standard Module)
|
|
' 模块职责: 整个架构的主控大脑,负责协调各层组件,完成端到端的数据处理流水线
|
|
' ==============================================================================
|
|
Option Explicit
|
|
|
|
' ------------------------------------------------------------------------------
|
|
' 过程名称: LoadData
|
|
' 过程功能: 供 UI 初始化时调用,加载总库数据
|
|
' ------------------------------------------------------------------------------
|
|
Public Function LoadData(ByVal ws As Worksheet) As Collection
|
|
Set LoadData = mBOMRepository.LoadAllBOMs(ws)
|
|
End Function
|
|
|
|
' ------------------------------------------------------------------------------
|
|
' 过程名称: ExecutePipeline
|
|
' 过程功能: 执行完整的新增规格流水线
|
|
' 参数说明:
|
|
' ws - 目标工作表对象 (保存时需要)
|
|
' allBOMs - 内存中的总库集合
|
|
' targetBOMs - UI层过滤组装好的【精准目标集合】
|
|
' paramName - 要修改的参数名 (如 "lcfw")
|
|
' newValue - 新增的规格值 (如 "M19")
|
|
' strategyType - UI选择的执行策略 (如 "APPEND" 或 "CLONE")
|
|
' ------------------------------------------------------------------------------
|
|
Public Sub ExecutePipeline( _
|
|
ByVal ws As Worksheet, _
|
|
ByRef allBOMs As Collection, _
|
|
ByRef targetBOMs As Collection, _
|
|
ByVal paramName As String, _
|
|
ByVal newValue As String, _
|
|
ByVal strategyType As String)
|
|
|
|
' 如果没有选中任何目标,直接中断退出
|
|
If targetBOMs Is Nothing Then Exit Sub
|
|
If targetBOMs.count = 0 Then Exit Sub
|
|
|
|
Dim engine As cConditionEngine
|
|
Dim processor As IModuleProcessor
|
|
|
|
' [步骤 1] 初始化核心手术刀引擎
|
|
Set engine = New cConditionEngine
|
|
|
|
' [步骤 2] 从工厂获取用户指定的策略
|
|
Set processor = mProcessorFactory.GetProcessor(strategyType)
|
|
|
|
' [步骤 3] 将总库、精准目标集合扔给策略对象执行
|
|
processor.ProcessSpec allBOMs, targetBOMs, paramName, newValue, engine
|
|
|
|
' [步骤 4] 将修改过的数据批量写回 Excel (只写 IsDirty=True 的对象)
|
|
mBOMRepository.SaveAll ws, allBOMs
|
|
|
|
' 释放资源
|
|
Set processor = Nothing
|
|
Set engine = Nothing
|
|
|
|
End Sub |