Add strategy pattern architecture for BOM module processing
- Add IModuleProcessor interface defining the processor contract - Implement cProcessor_AppendOnly strategy for modifying existing BOM rows - Implement cProcessor_CloneNew strategy for creating new BOM rows - Add mProcessorFactory module for creating processor instances - Add mSpecAdditionManager module for coordinating spec addition operations - Enhance test suite with business logic layer and pipeline integration tests This implements the Strategy pattern to allow flexible BOM modification behaviors while maintaining clean separation of concerns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
50
VBA/Modules/mSpecAdditionManager.bas
Normal file
50
VBA/Modules/mSpecAdditionManager.bas
Normal file
@@ -0,0 +1,50 @@
|
||||
' ==============================================================================
|
||||
' 模块名称: mSpecAdditionManager
|
||||
' 模块类别: 标准模块 (Standard Module)
|
||||
' 模块职责: 整个架构的主控大脑,负责协调各层组件,完成端到端的数据处理流水线
|
||||
' ==============================================================================
|
||||
Option Explicit
|
||||
|
||||
' ------------------------------------------------------------------------------
|
||||
' 过程名称: ExecuteAddition
|
||||
' 过程功能: 执行完整的新增规格流水线
|
||||
' 参数说明:
|
||||
' ws - 目标工作表对象
|
||||
' targetItemName - 用户瞄准的物料名称 (如 "径向高压接头")
|
||||
' paramName - 要修改的参数名 (如 "lcfw")
|
||||
' newValue - 新增的规格值 (如 "M19")
|
||||
' strategyType - UI选择的执行策略 (如 "APPEND" 或 "CLONE")
|
||||
' ------------------------------------------------------------------------------
|
||||
Public Sub ExecuteAddition( _
|
||||
ByVal ws As Worksheet, _
|
||||
ByVal targetItemName As String, _
|
||||
ByVal paramName As String, _
|
||||
ByVal newValue As String, _
|
||||
ByVal strategyType As String)
|
||||
|
||||
Dim engine As cConditionEngine
|
||||
Dim bomCollection As Collection
|
||||
Dim processor As IModuleProcessor
|
||||
|
||||
' [步骤 1] 初始化核心手术刀引擎
|
||||
Set engine = New cConditionEngine
|
||||
|
||||
' [步骤 2] 通过数据层将 Excel 读入内存变为对象集合
|
||||
Set bomCollection = mBOMRepository.LoadAllBOMs(ws)
|
||||
|
||||
' [步骤 3] 从工厂获取用户指定的策略
|
||||
Set processor = mProcessorFactory.GetProcessor(strategyType)
|
||||
|
||||
' [步骤 4] 将数据集合与目标扔给策略对象执行
|
||||
' 提示:所有的脏标记 (IsDirty) 会在这一步由对象自己触发记录
|
||||
processor.ProcessSpec bomCollection, targetItemName, paramName, newValue, engine
|
||||
|
||||
' [步骤 5] 将修改过的数据 (IsDirty=True) 批量写回 Excel
|
||||
mBOMRepository.SaveAll ws, bomCollection
|
||||
|
||||
' 释放资源 (VBA 虽然有垃圾回收,但良好习惯可以防止 Excel 卡死)
|
||||
Set processor = Nothing
|
||||
Set bomCollection = Nothing
|
||||
Set engine = Nothing
|
||||
|
||||
End Sub
|
||||
Reference in New Issue
Block a user