Refine project overview to include specific business context (Blaidy Company) and the main workbook file. Restructure the architecture section into a layered object-oriented design (Data, Processing, Application layers) and define the responsibilities of core VBA classes. Add new technical documentation sections covering: - Model number format parsing structure - Condition expression language syntax - Category hierarchy logic and picking strategies - Material matching pipeline flow Include VBA code examples for key methods such as CollectAllMaterials and GetMaterialsByCategoryAndModel to illustrate recursive traversal and material retrieval logic. Clarify the structure of key Excel configuration sheets.
4.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
AutoBOM is an automated Bill of Materials (BOM) management system for industrial pressure gauge products at 布莱迪公司 (Blaidy Company). The system parses complex product model numbers, extracts material requirements based on specifications, and generates picking lists for manufacturing.
The main Excel file is YTHN-100.A0.532-BOM-1.2版 Claude.xlsm (macro-enabled workbook), which contains both the VBA code and the business data.
Architecture
Core Components (Layered Object-Oriented Design)
Data Layer (Class Modules)
clsMaterialItem- Individual material entityclsCategory- Hierarchical category container with parent-child relationshipsclsBOMManager- Central controller managing the entire BOM data structure
Processing Layer (Class Modules)
clsModelParser- Parses complex product model strings into structured componentsclsConditionExtractor- Extracts selection conditions from parsed modelsclsConditionMatcher- Evaluates logical expressions for material matching
Application Layer (Standard Modules)
modBOMProcessor- BOM operations and usage examplesmodModelParserTest- Comprehensive test suite (6 test functions)modModelParserExamples- Real-world usage examples
Model Number Format
Product models follow this structure:
[Model]-[Diameter].[Install].[Shell].[Connection].[Range].[Char]|[Dial]|[Accessory]|[Flange]
Example: YTHN-100.A0.532.M203.M16.Y3|BP-095.2312.M16.PA3
The parser uses recursive descent parsing with structure validation.
Condition Expression Language
Materials are selected using logical expressions with variables:
gclj(过程连接 - process connection)jycz(接液材质 - liquid contact material)lcfw(量程范围 - range)
Supported operators: AND, OR, !=, parentheses
Example: lcfw=M16 AND gclj!=M20 OR (lcfw=M02 AND gclj=Z12)
Category Hierarchy Logic
The system supports two picking strategies:
- Parent Category Mode (default): Pick assembled components
- Child Category Mode (fallback): Pick individual parts for assembly
Recursive tree traversal is used for material collection through the category hierarchy.
Material Matching Pipeline
Model String → Parser → Extractor → Conditions Dictionary → Matcher → Filtered Materials
Data Sheets Structure
The Excel workbook contains two key sheets:
领料配置 (Picking Configuration)
- Defines category hierarchy
- Specifies which materials require picking
- Columns: 物料代号, 类别名称, 上层类别名称
平台配置清单 (Platform Configuration)
- Complete material database
- Rows 1-3: Headers
- Row 4+: Data
Testing
Run tests from the VBA editor or Excel macros:
- All tests:
RunAllTests()inmodModelParserTest - Individual tests: Test1-Test6 functions in
modModelParserTest- Test1: Model parser basic functionality
- Test2: Condition extractor
- Test3: Condition matcher (14 test cases)
- Test4: Full workflow test
- Test5: All categories matching
- Test6: Extraction rules display
Development Workflow
- Edit VBA code in Excel VBA Editor (Alt+F11)
- Export modules to
VBA/directory - Update
VBA/vba_metadata.jsonwhen adding/removing modules - Commit changes to git
Note: The main Excel workbook (*.xlsm) is excluded from git by .gitignore.
Code Conventions
Naming
- Classes:
clsprefix (e.g.,clsBOMManager) - Modules:
modprefix (e.g.,modBOMProcessor) - Public properties: PascalCase
- Local variables: camelCase
Comments
- Section headers:
' ======================================== - Chinese comments for business logic (domain-specific)
- English comments for technical implementation
- Detailed parameter/return value documentation
Error Handling
On Error GoTo ErrorHandlerpattern- Conservative: return
NothingorFalseon error
Key Business Logic
- Materials have "selection conditions" expressed as logical formulas
- Not all materials in platform config require picking (filtered by "领料配置" sheet)
- Supports "部件" (component) vs "零件" (part) picking strategies
- Condition extraction is data-driven (new variables can be added)
- Category tree can have arbitrary depth
Documentation
布莱迪公司压力表产品选型大表.md- Complete product model numbering system (716 lines, Chinese)VBA/clsBOMManager使用说明.md- API documentation and usage examples for clsBOMManager (546 lines, Chinese)
Module Registry
VBA/vba_metadata.json maps VBA module names to their file locations in the repository. Update this file when:
- Adding new class modules or standard modules
- Renaming existing modules
- Reorganizing the directory structure