Add new "库存比对" worksheet that displays component inventory status
alongside material requirements for production planning.
Changes:
- M04_Config: Add INVENTORY_COMPARISON_SHEET_NAME constant
- M08_ComponentProcessor: Enhance component processing to return both
component and sub-components when inventory insufficient; add
GetComponentInventoryInfo() read-only function for inventory lookup
- M09_BOMExtractor: Add WriteInventoryComparisonResults() function
to generate inventory comparison worksheet with 7 columns showing
material code, name, required quantity, stock quantity, and status
Output format:
- Columns: 序号, 生产订单号, 物料编码, 物料名称, 所需数量, 库存数量, 库存充足
- Color coding: Green (sufficient) / Red (insufficient)
- Sequence numbering: 10+0, 10+1 per order
Backward compatibility: Existing BOM提取结果 and BIP上传 worksheets
remain unchanged.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit implements the BIP upload worksheet functionality for ERP system integration and fixes a critical bug in quantity calculation.
Changes:
1. Added BIP upload configuration constants to M04_Config.bas
- BIP_UPLOAD_SHEET_NAME = "BIP上传"
- BIP_ROW_NUMBER_BASE = 7000
- BIP_SUPPLY_MODE = "一般发料"
- BIP_ISSUE_ORG = "重庆布莱迪仪器仪表有限公司"
2. Extended input data reading to 4 columns (M09_BOMExtractor.bas)
- Column D: Product Code (产品编码)
- Updated ReadInputModels to read columns A:D
3. Added product code mapping in main flow
- Created productCodeMap Dictionary to store order number -> product code mappings
- Stored product codes during input processing loop
4. Created WriteBIPUploadResults function
- Generates 9-column BIP upload worksheet
- Implements row number generation (7000 + material sequence number)
- Resets sequence counter for each new order
- Includes all rows (including error rows)
- Formats worksheet with borders, column widths, and freeze panes
5. **CRITICAL FIX**: Corrected quantity calculation logic
- Added order quantity lookup from inputModels
- Changed from: materialQty = result(12) (BOM base quantity only)
- Changed to: finalQty = bomQty * currentOrderQty
- Applied fix to both "生产数量" (column 3) and "计划出库数量" (column 9)
- Updated comment to clarify result(12) is BOM base quantity
Output Format (9 columns):
1. 来源单据号 (Source Document Number) - Production Order No
2. 产品编码 (Product Code)
3. 生产数量 (Production Quantity) = Order Qty × Material Qty
4. 行号 (Row Number) = 7000 + sequence (resets per order)
5. 材料编码 (Material Code)
6. 供应方式 (Supply Mode) = "一般发料"
7. 需用日期 (Required Date) = Current date (yyyy/m/d format)
8. 发料组织 (Issue Organization) = "重庆布莱迪仪器仪表有限公司"
9. 计划出库数量 (Planned Output Qty) = Order Qty × Material Qty
Business Rules Implemented:
- Error rows are included (material code is empty, quantities are 0)
- Empty product codes are written as empty strings
- Row numbers reset to 7001 for each new order
- Material quantities are correctly calculated as order quantity × BOM quantity
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add 生产订单号 as the first column in output (13 columns total)
- Read production order number from column A of input worksheet
- Only display production order number on first row for each product model
- Set material code column to text format to preserve leading zeros
- Update OutputColumns enum indices in M04_Config.bas
- Update ReadInputModels to return 2 columns (order number + model)
- Update ProcessSingleModel, GenerateMaterialRow, GenerateErrorRow signatures
- Update WriteExtractionResults to write 13 columns with text formatting
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add COL_IDX_CODE66 constant for column I in M04_Config.bas
- Extend data reading range to include column I in M02_DataIO.ReadSourceData
- Use .Text property for column I to preserve leading zeros
- Update baseInfo array to use column I instead of column C in M01_Main.bas
- Set output code column to text format to prevent numeric conversion
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
- Add BOM library column name constants (名称, 编码, 数量, etc.)
- Add GetBOMConditionFields() and IsConditionField() utility functions
- Refactor ExtractMaterialInfo to use column names instead of hardcoded positions
- Refactor ExtractSingleSubComponent to use column names for 接头/弹性元件
- Refactor ExtractComponentInfo to use column names
- Improve MatchAllMaterialTypes to iterate all worksheets dynamically
- Add debug logging for troubleshooting
This fix resolves issues where worksheets with non-standard column counts
(like 表壳, 罩壳) could not extract material information properly.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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>
Rename VBA/ directory to VBA_BOMConverter/ for better clarity.
This change reflects the module's purpose as the BOM converter component.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>