All checks were successful
NTFY Notification / notify (push) Successful in 5s
Add M05_PreProcessor module to handle value mapping and condition simplification for "接头" category before parsing. Features: - Value mapping: azxs codes (A0/AT/AH→径向, B0/BT/BZ/BH→下轴向, Z0/ZT/ZZ/ZH→中轴向) and lcfw ranges (M01-M11→低压, M12-M16→高压) - OR condition merging: automatically removes duplicate OR segments - Smart parentheses handling: removes parentheses for single atoms, preserves them when needed for logical structure - Recursive nested expression processing - Graceful degradation when "对照表" worksheet is missing Integration: - Modified M01_Main to initialize preprocessor after M03_Logic - Preprocessing applied only for "接头" category - Updated M99_TestRunner with 8 comprehensive test cases - All tests passing (50 total: 42 core + 8 preprocessing) Documentation: - Added detailed flow documentation for Test_PP_06_FullIntegration with mermaid diagrams in docs/Test_PP_06_FullIntegration_流程详解.md - Updated CLAUDE.md with preprocessing module description and documentation guidelines (docs/ vs reference_docs/) Example transformation: Input: gclj=M16 AND (azxs=A0 OR azxs=AT) AND (lcfw=M01 OR lcfw=M15) Output: gclj=M16 AND azxs=径向 AND (lcfw=低压 OR lcfw=高压) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4.8 KiB
4.8 KiB
Preprocessing Implementation Summary
Implementation Complete ✓
The preprocessing functionality for BOM conditions has been successfully implemented according to the plan.
Files Created
1. M05_PreProcessor.bas
Location: VBA/Modules/M05_PreProcessor.bas
Key Features:
- Loads mapping tables from [对照表] worksheet
- lcfw mapping from columns A:B (rows 3+)
- azxs mapping from columns D:E (rows 3+)
- Preprocesses conditions for "接头" category only
- Replaces values using mappings
- Merges duplicate OR conditions
- Comprehensive error handling with logging
Public Functions:
InitPreProcessor(logger, wsMapping)- Initialize the preprocessorIsInitialized()- Check initialization statusPreprocessCondition(strCondition, strCategory, rowIdx)- Main entry pointGetLcfwMappedValue(key)- Test helper for lcfw mappingGetAzxsMappedValue(key)- Test helper for azxs mapping
Files Modified
1. M01_Main.bas
Changes:
- Added preprocessor initialization (lines 43-53)
- Checks for [对照表] worksheet
- Shows warning if worksheet not found
- Initializes M05_PreProcessor
- Added preprocessing call (lines 81-84)
- Preprocesses conditions before parsing
- Only for "接头" category
- Only when preprocessor is initialized
2. M99_TestRunner.bas
Changes:
- Added module-level variable for test mapping worksheet
- Added 8 comprehensive test cases:
Test_PP_01_AzxsMappingLoad- Tests all 12 azxs valuesTest_PP_02_LcfwMappingLoad- Tests lcfw mappingTest_PP_03_AzxsReplacement- Tests azxs value replacementTest_PP_04_LcfwReplacement- Tests lcfw value replacementTest_PP_05_ORMerging- Tests OR condition mergingTest_PP_06_FullIntegration- Tests integration with M03_LogicTest_PP_07_NonJointCategory- Tests non-"接头" categoriesTest_PP_08_UnmappedValues- Tests unmapped value handling
- Added
SetupPreProcessorTest()helper function
Value Mappings
azxs Mapping (12 values)
径向 (3 values): A0, AT, AH 下轴向 (4 values): B0, BT, BZ, BH 中轴向 (4 values): Z0, ZT, ZZ, ZH
lcfw Mapping
低压: M01 through M11
How to Test
Manual Testing
- Open
YTHN-100.xlsmin Excel - Ensure [对照表] worksheet exists with proper mapping data:
- Columns A:B: lcfw mapping (M01-M11 → 低压)
- Columns D:E: azxs mapping (A0/AT/AH → 径向, etc.)
- Ensure [平台配置清单] has "接头" category data
- Run
M01_Main.RunBOMConversion() - Verify output:
- azxs values are transformed (e.g., A0 → 径向)
- lcfw values are transformed (e.g., M01 → 低压)
- duplicate OR conditions are merged
- non-"接头" categories are unchanged
Automated Testing
- Open VBA Editor (Alt+F11)
- Open Immediate Window (Ctrl+G)
- Run
RunAllTests - Verify all tests pass
Test Coverage Checklist
- All 12 azxs values tested (A0, AT, AH, B0, BT, BZ, BH, Z0, ZT, ZZ, ZH)
- lcfw mapping tested (M01-M11 → 低压)
- OR merging tested with various scenarios
- Integration with M03_Logic tested
- Non-"接头" category tested
- Error handling tested (unmapped values, missing worksheet)
Architecture Notes
Late Binding
- Uses
CreateObject("Scripting.Dictionary")to avoid external reference dependencies - Consistent with existing M03_Logic.bas pattern
Error Handling
- Graceful degradation if [对照表] is missing
- Warning messages for unmapped values
- Non-blocking errors (processing continues)
String Processing
- Parentheses-aware splitting for OR/AND operators
- Whitespace normalization for duplicate detection
- Preserves original condition structure
Integration Points
-
M01_Main.bas (lines 43-53, 81-84)
- Initializes preprocessor after M03_Logic
- Calls preprocessor before ParseRule
-
M03_Logic.bas
- Receives preprocessed conditions
- No changes required
-
clsErrorLogger.cls
- Logs preprocessing warnings
- No changes required
Next Steps
- Test with real data - Run manual testing with actual BOM data
- Verify output - Check that transformed values match expected results
- Update documentation - Update CLAUDE.md if needed to reflect preprocessing functionality
- Commit changes - Create git commit with implementation
Git Commit Message
feat: add preprocessing for BOM conditions in "接头" category
- Add M05_PreProcessor module for value mapping and OR merging
- Map azxs values (A0/AT/AH→径向, B0/BT/BZ/BH→下轴向, Z0/ZT/ZZ/ZH→中轴向)
- Map lcfw values (M01-M11→低压)
- Merge duplicate OR conditions automatically
- Add comprehensive unit tests (8 test cases)
- Integrate with M01_Main workflow
- Graceful degradation if [对照表] is missing
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>