Files
AutoBOM/CLAUDE.md
Misaka_Company fd414f7673 docs: reorganize documentation structure and add analysis guidelines
- Move existing documentation files to reference_docs/ directory
- Add documentation guidelines section to CLAUDE.md
- Add clsBOMManager LoadData flow analysis with Mermaid diagrams

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 09:30:29 +08:00

5.4 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 entity
  • clsCategory - Hierarchical category container with parent-child relationships
  • clsBOMManager - Central controller managing the entire BOM data structure

Processing Layer (Class Modules)

  • clsModelParser - Parses complex product model strings into structured components
  • clsConditionExtractor - Extracts selection conditions from parsed models
  • clsConditionMatcher - Evaluates logical expressions for material matching

Application Layer (Standard Modules)

  • modBOMProcessor - BOM operations and usage examples
  • modModelParserTest - 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:

  1. Parent Category Mode (default): Pick assembled components
  2. 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() in modModelParserTest
  • 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

  1. Edit VBA code in Excel VBA Editor (Alt+F11)
  2. Export modules to VBA/ directory
  3. Update VBA/vba_metadata.json when adding/removing modules
  4. Commit changes to git

Note: The main Excel workbook (*.xlsm) is excluded from git by .gitignore.

Code Conventions

Naming

  • Classes: cls prefix (e.g., clsBOMManager)
  • Modules: mod prefix (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 ErrorHandler pattern
  • Conservative: return Nothing or False on 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)

Documentation Guidelines

Analysis Documents

  • When analyzing VBA code, modules, or methods (e.g., creating flow diagrams, architecture explanations), save all generated analysis documents to the reference_docs/ directory
  • Use descriptive filenames that clearly indicate the content (e.g., clsBOMManager_LoadData流程分析.md)
  • Prefer using Mermaid diagrams for visualizing:
    • Flowcharts (method execution flow)
    • Sequence diagrams (interactions between objects)
    • Class diagrams (relationships between classes)
    • State diagrams (state transitions)
  • Keep analysis documents in Chinese when the original code comments are in 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