Files
AutoBOM/VBA_BOMConverter/Modules/M04_Config.bas
Misaka_Company 093a2d0a3b
All checks were successful
NTFY Notification / notify (push) Successful in 11s
feat: implement BOM auto-extraction system
Add complete BOM auto-extraction system with the following modules:

- M06_ModelParser: Parse product model strings to extract parameters
  (azxs, bkxs, gclj, jycz, lcfw, fjgn)
  - Extracts header part from full model (ignores dial/attachment parts)
  - Splits process connection and material code (G123 -> G12, 3)
  - Supports multiple additional features with comma/dot separators

- M07_BOMMatcher: Match materials in BOM library
  - Exact match, wildcard (empty cell), negative match (!=)
  - Special fjgn contains matching logic
  - Array-based performance optimization for bulk operations

- M08_ComponentProcessor: Handle component material special logic
  - Component inventory check (interface reserved)
  - Sub-component extraction (joint + elastic element)
  - Combination validation rules (1 component OR 1 joint + 1 element)

- M09_BOMExtractor: Main extraction orchestrator
  - Reads input models from worksheet
  - Processes each model and matches all material types
  - Outputs to "BOM提取结果" worksheet
  - Error reporting and non-blocking design

- M06B_TestRunner: Comprehensive unit tests
  - 8 test cases for model parsing
  - 5 test cases for BOM matching
  - 5 test cases for component processing

- M04_Config: Add BOM extraction constants
  - BOM library filename and configuration
  - Input/output column definitions
  - Output column enumeration

- M01_Main: Add RunBOMExtraction entry point

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 13:02:14 +08:00

79 lines
3.1 KiB
QBasic
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
' ==============================================================================
' 模块: M04_Config
' 职责: 系统配置、常量定义
' ==============================================================================
Option Explicit
' 源数据列号定义 (根据你的描述)
Public Const COL_IDX_CODE As Long = 3 ' 代号 (C列)
Public Const COL_IDX_NAME As Long = 4 ' 名称 (D列)
Public Const COL_IDX_QTY As Long = 5 ' 数量 (E列)
Public Const COL_IDX_COND As Long = 6 ' 选择条件 (F列)
Public Const COL_IDX_CAT As Long = 8 ' 类别 (H列)
Public Const SRC_START_ROW As Long = 4 ' 数据起始行
' ------------------------------------------------------------------------------
' BOM自动提取系统配置常量
' ------------------------------------------------------------------------------
' BOM库配置
Public Const BOMLIB_FILENAME As String = "BOM库.xlsx"
Public Const BOMLIB_START_ROW As Long = 2 ' BOM库数据起始行第1行是表头
Public Const OUTPUT_SHEET_NAME As String = "BOM提取结果"
' 输入列名称配置
Public Const INPUT_COL_MODEL As String = "型号"
Public Const INPUT_COL_PRODUCT_MODEL As String = "产品型号"
' 输出列枚举
Public Enum OutputColumns
oc_OriginalModel = 1 ' 原始产品型号
oc_Azxs = 2 ' 安装形式
oc_Bkxs = 3 ' 表壳形式
oc_Gclj = 4 ' 过程连接
oc_Jycz = 5 ' 接液材质
oc_Lcfw = 6 ' 量程范围
oc_Fjgn = 7 ' 附加功能
oc_MaterialType = 8 ' 物料类型
oc_MaterialName = 9 ' 物料名称
oc_MaterialCode = 10 ' 物料编码
oc_MaterialQty = 11 ' 物料数量
oc_Remarks = 12 ' 提取备注
End Enum
' 型号解析常量
Public Const MODEL_SEPARATOR_PIPELINE As String = "|" ' 管道符分隔符
Public Const MODEL_SEPARATOR_DOT As String = "." ' 点号分隔符
Public Const MODEL_SEPARATOR_CARET As String = "^" ' 插入符分隔符(法兰隔膜)
Public Const MODEL_HEADER_MIN_SEGMENTS As Long = 6 ' 表头最小段数
' BOM库工作表列表需要遍历的工作表
Public Const BOMLIB_SHEET_JOINT As String = "接头"
Public Const BOMLIB_SHEET_ELEMENT As String = "弹性元件"
Public Const BOMLIB_SHEET_MOVEMENT As String = "机芯"
Public Const BOMLIB_SHEET_COMPONENT As String = "部件"
Public Const BOMLIB_SHEET_EDGE As String = "边"
' 获取表头排序索引 (越小越靠前)
Public Function GetHeaderPriority(key As String) As Long
Dim vList As Variant
Dim i As Long
' 定义标准排序顺序
vList = Array("azxs", "bkxs", "gclj", "jycz", "lcdw", "lcfw", _
"fjgn", "btcy", "bp", "dskd", "nqlc", "bptx", _
"jddj", "cpdm", "tsjz", "tsyq", "bpts", "kdxh")
Dim sKey As String
sKey = LCase(Trim(key))
For i = LBound(vList) To UBound(vList)
If sKey = LCase(vList(i)) Then
GetHeaderPriority = i
Exit Function
End If
Next i
' 未知变量排在最后
GetHeaderPriority = 999
End Function