diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 7fc82a3..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,170 +0,0 @@ -# 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 one main configuration sheet: - -**平台配置清单** (Platform Configuration) -- Complete material database with category hierarchy -- All configuration data in one sheet (simplified from previous two-sheet design) -- Row 1-3: Headers and product info -- Row 4+: Material data - -**Column Structure** (Row 3): -| Column | Field Name | Description | Example | -|--------|-----------|-------------|---------| -| A | 行号 | Line number | 10, 20, 30 | -| B | 模块 | Module name | 316L部件 | -| C | 代号 | Material code | 01011009557 | -| D | 名称 | Material name | 径向低压接头部件 | -| E | 数量 | Quantity | 1.0 | -| F | 选择条件 | Material selection condition | gclj=M20 AND jycz=1 | -| G | 备注 | Remarks | | -| H | 类别 | Category name | 部件 | -| I | 上层类别 | Parent category name | (empty for root categories) | -| J | 类别选用条件 | Category selection condition | lcfw=M02 | -| K | 66代码 | 66-system code | 66021009557 | - -**Category Selection Condition (类别选用条件)**: -- Empty: Category is always required -- Not empty: Category is required only when the condition matches the model specifications -- Uses same syntax as material selection conditions (AND, OR, !=, parentheses) - -## 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 -- Categories have "category selection conditions" to determine if they are required for a given model -- **Completeness Check Logic**: - - First, determine which categories are required by matching "类别选用条件" with model specifications - - Then, check if each required category has exactly one matching material - - Categories not required for the model are excluded from completeness check -- 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 diff --git a/VBA/vba_metadata.json b/VBA/vba_metadata.json deleted file mode 100644 index 1c84df2..0000000 --- a/VBA/vba_metadata.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "source_file": "C:\\Users\\Administrator\\Desktop\\新BOM\\AutoBOM\\YTHN-100.xlsm", - "modules": { - "clsMaterialWithFlag.cls": { - "name": "clsMaterialWithFlag", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsMaterialWithFlag.cls" - }, - "clsCategory.cls": { - "name": "clsCategory", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsCategory.cls" - }, - "clsMaterialItem.cls": { - "name": "clsMaterialItem", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsMaterialItem.cls" - }, - "modBOMProcessor.bas": { - "name": "modBOMProcessor", - "type": "Modules", - "attributes": {}, - "file": "Modules\\modBOMProcessor.bas" - }, - "clsBOMManager.cls": { - "name": "clsBOMManager", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsBOMManager.cls" - }, - "clsModelParser.cls": { - "name": "clsModelParser", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsModelParser.cls" - }, - "clsConditionExtractor.cls": { - "name": "clsConditionExtractor", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsConditionExtractor.cls" - }, - "clsConditionMatcher.cls": { - "name": "clsConditionMatcher", - "type": "ClassModules", - "attributes": {}, - "file": "ClassModules\\clsConditionMatcher.cls" - }, - "modModelParserTest.bas": { - "name": "modModelParserTest", - "type": "Modules", - "attributes": {}, - "file": "Modules\\modModelParserTest.bas" - }, - "modModelParserExamples.bas": { - "name": "modModelParserExamples", - "type": "Modules", - "attributes": {}, - "file": "Modules\\modModelParserExamples.bas" - } - } -} \ No newline at end of file