feat: add preprocessing with value mapping to BOM Extraction System
All checks were successful
NTFY Notification / notify (push) Successful in 4s
All checks were successful
NTFY Notification / notify (push) Successful in 4s
Add a preprocessing step to the BOM Extraction System to enhance parameter extraction with mapping values from "对照表" worksheet. For azxs (安装形式) and lcfw (量程范围), the system now stores both the raw parsed value AND the mapped value from the lookup table, enabling flexible dual-value matching. Changes: - Create M06A_Mapper.bas: New module for value mapping - Load azxs/lcfw mappings from "对照表" worksheet - Return dual-value format "raw,mapped" (e.g., "A0,径向") - Support graceful degradation if "对照表" not found - Define constants locally to avoid VBA cross-module reference issues - Modify M06_ModelParser.bas: - Extract raw parameter values first - Apply mapping via M06A_Mapper if initialized - Store dual values for azxs and lcfw parameters - Modify M07_BOMMatcher.bas: - Update EvaluateCellCondition() to support dual-value matching - Split by comma and check if ANY value matches - Backward compatible with single-value parameters - Modify M09_BOMExtractor.bas: - Initialize M06A_Mapper during RunBOMExtraction() - Add WorksheetExists() helper function - Log warning if "对照表" worksheet not found - Define MAPPING_SHEET_NAME constant locally - Modify M04_Config.bas: - Add mapping table configuration constants - MAPPING_SHEET_NAME, MAPPING_COL_LCFW_KEY, etc. - Update CLAUDE.md: - Document new M06A_Mapper module - Update data flow diagram with mapping step - Document dual-value matching behavior - Update system architecture diagram - Update docs/RunBOMExtraction_运行机制详解.md: - Add M06A_Mapper to all diagrams and documentation - Add detailed value mapping section - Update sequence diagrams with mapping flow - Update parameter examples with dual-value format - Bump documentation version to 3.0 Example: Input: Product model "YTHN-100.A0.531.G123.M04.Y3" Parse: azxs="A0", lcfw="M04" Map: azxs="A0,径向", lcfw="M04,高压" Match: BOM库 with azxs="径向" OR "A0" → MATCH Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
71
CLAUDE.md
71
CLAUDE.md
@@ -27,8 +27,9 @@ The BOM Configuration system follows a modular architecture with clear separatio
|
||||
The BOM Extraction system follows a modular architecture with clear separation of concerns:
|
||||
|
||||
- **M09_BOMExtractor.bas** - Main orchestration and entry point. Run `RunBOMExtraction()` to execute the full workflow. Implements two-phase validation (collect → validate) and generates output worksheets.
|
||||
- **M06_ModelParser.bas** - Product model string parsing. Extracts parameters from full model strings (e.g., `YTHN-100.A0.531.G123.M04.Y3|BP-088.2312.B09.0A3`).
|
||||
- **M07_BOMMatcher.bas** - BOM library matching. Matches extracted parameters against BOM库.xlsx worksheets using parameter-based rules (empty cells = wildcard, "!=" prefix = negative match, fjgn field = substring matching).
|
||||
- **M06_ModelParser.bas** - Product model string parsing. Extracts parameters from full model strings (e.g., `YTHN-100.A0.531.G123.M04.Y3|BP-088.2312.B09.0A3`). Applies value mapping via M06A_Mapper.
|
||||
- **M06A_Mapper.bas** - Value mapping module. Maps azxs and lcfw parameters to their descriptive values from "对照表" worksheet. Returns dual-value format (raw,mapped) for flexible matching.
|
||||
- **M07_BOMMatcher.bas** - BOM library matching. Matches extracted parameters against BOM库.xlsx worksheets using parameter-based rules (empty cells = wildcard, "!=" prefix = negative match, fjgn field = substring matching, dual-value matching for mapped parameters).
|
||||
- **M08_ComponentProcessor.bas** - Special handling for "部件" (component) materials. Handles component inventory logic (component vs sub-components selection).
|
||||
- **M06B_TestRunner.bas** - Unit testing framework for BOM Extraction system. Run tests in VBA Immediate window.
|
||||
|
||||
@@ -49,8 +50,14 @@ New Excel Workbook + Error Report
|
||||
**BOM Extraction System Flow**:
|
||||
```
|
||||
"产品型号" worksheet → M09_BOMExtractor.RunBOMExtraction()
|
||||
→ M06_ModelParser.ParseProductModel() (extract parameters: azxs, bkxs, gclj, jycz, lcfw, fjgn)
|
||||
→ M07_BOMMatcher.MatchBOMRecord() (match in BOM库.xlsx worksheets)
|
||||
→ M06A_Mapper.InitMapper() (load mapping table from "对照表" worksheet)
|
||||
→ M06_ModelParser.ParseProductModel()
|
||||
→ Extract raw parameters: azxs="A0", lcfw="M01"
|
||||
→ M06A_Mapper.MapAzxs() / MapLcfw()
|
||||
→ Return dual values: azxs="A0,径向", lcfw="M01,低压"
|
||||
→ M07_BOMMatcher.MatchBOMRecord()
|
||||
→ EvaluateCellCondition() supports dual-value matching
|
||||
→ Match if BOM库 contains "A0" OR "径向"
|
||||
→ M08_ComponentProcessor.ProcessComponentRecord() (special component handling if applicable)
|
||||
→ Two-phase validation (collect all matches → validate with cross-worksheet rules)
|
||||
→ "BOM提取结果" worksheet + "错误报告" worksheet
|
||||
@@ -149,6 +156,34 @@ Product models follow a structured format that the parser can extract parameters
|
||||
- `gclj` and `jycz` are extracted from single segment (last char is `jycz`)
|
||||
- `fjgn` combines all segments from position 5 onwards with comma separator
|
||||
|
||||
### Value Mapping (M06A_Mapper)
|
||||
|
||||
After parsing raw parameter values, the system applies value mapping from "对照表" worksheet:
|
||||
|
||||
**Dual-Value Format**:
|
||||
- Parameters are stored as "raw,mapped" to support flexible matching
|
||||
- Example: `azxs="A0,径向"` means the parameter can match either "A0" or "径向"
|
||||
- Example: `lcfw="M01,低压"` means the parameter can match either "M01" or "低压"
|
||||
|
||||
**Mapping Table Configuration** (M04_Config):
|
||||
- `MAPPING_SHEET_NAME` = "对照表"
|
||||
- `MAPPING_COL_LCFW_KEY` = 1 (A列) - lcfw raw values
|
||||
- `MAPPING_COL_LCFW_VAL` = 2 (B列) - lcfw mapped values
|
||||
- `MAPPING_COL_AZXS_KEY` = 4 (D列) - azxs raw values
|
||||
- `MAPPING_COL_AZXS_VAL` = 5 (E列) - azxs mapped values
|
||||
- `MAPPING_START_ROW` = 3
|
||||
|
||||
**Graceful Degradation**:
|
||||
- If "对照表" worksheet is not found, system logs a warning and uses raw values only
|
||||
- If a value is not found in mapping table, only the raw value is used (no error)
|
||||
|
||||
**Example Mapping Data**:
|
||||
| Row | A列 (lcfw key) | B列 (lcfw val) | D列 (azxs key) | E列 (azxs val) |
|
||||
|-----|----------------|----------------|----------------|----------------|
|
||||
| 3 | M01 | 低压 | A0 | 径向 |
|
||||
| 4 | M12 | 高压 | AT | 径向 |
|
||||
| 5 | - | - | B0 | 下轴向 |
|
||||
|
||||
### BOM Matching Rules (M07_BOMMatcher)
|
||||
|
||||
The system matches extracted parameters against BOM库.xlsx worksheets using these rules:
|
||||
@@ -157,13 +192,23 @@ The system matches extracted parameters against BOM库.xlsx worksheets using the
|
||||
- **Empty cell**: Wildcard - matches all values
|
||||
- **"!=" prefix**: Negative match - matches when parameter ≠ value (e.g., `!=A0`)
|
||||
- **fjgn field**: Substring matching - matches when fjgn list contains cell value (InStr check)
|
||||
- **Dual-value parameters**: Matches if ANY value matches (e.g., `azxs="A0,径向"` matches both `azxs=A0` and `azxs=径向`)
|
||||
- **Normal values**: Exact match - parameter must equal cell value
|
||||
|
||||
**Logic**: AND across all parameters - all conditions must be satisfied
|
||||
|
||||
**Example**: BOM库 row has `azxs=A0`, `bkxs=`, `gclj=G12`, `fjgn=N1`
|
||||
- Matches: `azxs=A0`, `bkxs=531`, `gclj=G12`, `fjgn=N1,N2`
|
||||
- Reason: `azxs` matches exactly, `bkxs` is empty (wildcard), `gclj` matches exactly, `fjgn` contains "N1"
|
||||
**Examples**:
|
||||
|
||||
1. **Dual-value matching**:
|
||||
- Parameter: `azxs="A0,径向"`
|
||||
- BOM库 has `azxs=径向` → MATCH (because "径向" is in the parameter)
|
||||
- BOM库 has `azxs=A0` → MATCH (because "A0" is in the parameter)
|
||||
- BOM库 has `azxs=AT` → NO MATCH
|
||||
|
||||
2. **Standard matching**:
|
||||
- BOM库 row has `azxs=A0`, `bkxs=`, `gclj=G12`, `fjgn=N1`
|
||||
- Matches: `azxs=A0,径向`, `bkxs=531`, `gclj=G12`, `fjgn=N1,N2`
|
||||
- Reason: `azxs` contains "A0", `bkxs` is empty (wildcard), `gclj` matches exactly, `fjgn` contains "N1"
|
||||
|
||||
### Component Special Handling (M08_ComponentProcessor)
|
||||
|
||||
@@ -223,7 +268,8 @@ The system uses two-phase validation to enable cross-worksheet validation:
|
||||
1. Open the main Excel workbook (e.g., `YTHN-100.xlsm`)
|
||||
2. Ensure "产品型号" worksheet exists with product model data
|
||||
3. Ensure `BOM库.xlsx` is in the same directory as the main workbook
|
||||
4. Run `M09_BOMExtractor.RunBOMExtraction()` or execute from the Excel interface
|
||||
4. (Optional) Ensure "对照表" worksheet exists for azxs/lcfw value mapping
|
||||
5. Run `M09_BOMExtractor.RunBOMExtraction()` or execute from the Excel interface
|
||||
|
||||
**Output**:
|
||||
- "BOM提取结果" worksheet - Contains extracted materials with parameters
|
||||
@@ -288,6 +334,14 @@ The project includes custom skills in `.claude/skills/`:
|
||||
- `OUTPUT_SHEET_NAME` = "BOM提取结果" - Output worksheet name
|
||||
- `BOMLIB_START_ROW` = 2 - BOM库 data starts from row 2 (row 1 is header)
|
||||
|
||||
**Mapping Table Configuration**:
|
||||
- `MAPPING_SHEET_NAME` = "对照表" - Mapping table worksheet name
|
||||
- `MAPPING_COL_LCFW_KEY` = 1 - Column A for lcfw raw values
|
||||
- `MAPPING_COL_LCFW_VAL` = 2 - Column B for lcfw mapped values
|
||||
- `MAPPING_COL_AZXS_KEY` = 4 - Column D for azxs raw values
|
||||
- `MAPPING_COL_AZXS_VAL` = 5 - Column E for azxs mapped values
|
||||
- `MAPPING_START_ROW` = 3 - Mapping data starts from row 3
|
||||
|
||||
**Input Column Configuration**:
|
||||
- `INPUT_COL_MODEL` = "型号"
|
||||
- `INPUT_COL_PRODUCT_MODEL` = "产品型号"
|
||||
@@ -369,6 +423,7 @@ AutoBOM/
|
||||
│ │ ├── M04_Config.bas # Shared - Constants and configuration
|
||||
│ │ ├── M05_PreProcessor.bas # BOM Configuration System - Preprocessing
|
||||
│ │ ├── M06_ModelParser.bas # BOM Extraction System - Model parsing
|
||||
│ │ ├── M06A_Mapper.bas # BOM Extraction System - Value mapping (NEW)
|
||||
│ │ ├── M06B_TestRunner.bas # BOM Extraction System - Unit tests
|
||||
│ │ ├── M07_BOMMatcher.bas # BOM Extraction System - BOM matching
|
||||
│ │ ├── M08_ComponentProcessor.bas # BOM Extraction System - Component handling
|
||||
|
||||
Reference in New Issue
Block a user