Commit Graph

28 Commits

Author SHA1 Message Date
Misaka_Company
ec579b30b2 feat: add azxs preprocessing support for component category
All checks were successful
NTFY Notification / notify (push) Successful in 13s
Extend M05_PreProcessor to support category-specific preprocessing:
- "接头" category: Full preprocessing (azxs + lcfw mapping, OR merging, parentheses simplification)
- "部件" category: Partial preprocessing (azxs mapping only, OR merging, parentheses simplification)
- Other categories: No preprocessing

Add new function ApplyPreprocessingWithoutLcfw() to handle component category preprocessing.

Add unit tests (PP_09 through PP_12) to verify:
- azxs mapping for component category
- lcfw conditions remain unchanged for component category
- OR condition merging and parentheses simplification

Update CLAUDE.md documentation with category-specific preprocessing table.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 09:49:38 +08:00
Misaka_Company
90a62231e0 refactor: remove preprocessing report prompt from workflow
All checks were successful
NTFY Notification / notify (push) Successful in 4s
Simplify the BOM conversion workflow by removing the interactive prompt for preprocessing report generation. This streamlines the main conversion process.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 16:09:41 +08:00
Misaka_Company
7b2bd25d9a feat: add preprocessing report generator for joint category
Some checks failed
NTFY Notification / notify (push) Failing after 7s
Add GeneratePreprocessingReport() function to create a detailed
comparison report showing condition transformations for "接头" category.
Features include:
- Statistics summary (total rows, success count, OR merges, etc.)
- Detailed comparison table (11 columns: row, code, name, qty, category,
  original condition, converted condition, mapping details, description,
  status, errors)
- Color-coded status (green=success, yellow=warning, gray=no change, blue=empty)
- Mapping details column showing field transformations (e.g., azxs=A0 → azxs=径向)
- Integration with main workflow via optional prompt

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 13:56:00 +08:00
Misaka_Company
613d4436de refactor: rewrite M05_PreProcessor using regex expressions
All checks were successful
NTFY Notification / notify (push) Successful in 12s
Replace character-by-character parsing with regex-based implementation
for value mapping and OR condition merging.

Changes:
- Add ApplyRegexMapping() for regex-based value replacement
  * Uses VBScript.RegExp with Late Binding
  * Replaces from back to front to avoid position shifts
  * Uses regex.Replace() method for precise matching
  * Includes EscapeForRegex() to handle special characters
- Add ProcessNestedExpressions() for recursive parenthesis handling
- Add MergeDuplicateORConditions() for OR deduplication
- Add SimplifyParentheses() for smart parenthesis removal
- Remove ProcessAndSimplifyNested() (150+ lines of complex logic)
- Remove ProcessAndSegment(), ProcessAtom(), ParseAtom()
- Remove MergeDuplicateORs(), MaybeRemoveOuterParentheses()
- Remove JoinCollection(), MergeDuplicateAtoms()

Regex patterns used:
- azxs: (azxs)( *=|!= *)([a-zA-Z0-9]{2})
- lcfw: (lcfw)( *=|!= *)([a-zA-Z]\d{1,3})(?=[ \(\)]?)

Processing flow:
1. Apply azxs value mapping (regex)
2. Apply lcfw value mapping (regex)
3. Process nested expressions (recursive OR merge)
4. Merge top-level OR conditions
5. Simplify unnecessary parentheses

Benefits:
- Code reduced from 647 to 553 lines (-15%)
- Core logic simplified significantly
- Better performance: single regex pass vs multiple string traversals
- Improved readability and maintainability
- Precise replacement using regex.Replace() instead of string Replace()
- Preserved late binding and backward compatibility

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 12:28:41 +08:00
Misaka_Company
3a93459002 feat: add preprocessing module for BOM condition transformation
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>
2026-02-09 16:24:41 +08:00
Misaka_Company
220c54d1f6 chore: remove test VBA module
All checks were successful
NTFY Notification / notify (push) Successful in 5s
Remove the test module for status bar color demonstration.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 13:36:35 +08:00
Misaka_Company
58e84ddd25 feat: restore VBA source code modules
All checks were successful
NTFY Notification / notify (push) Successful in 4s
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 11:07:36 +08:00
Misaka_Company
726bbe2118 chore: remove all VBA source files
- Remove all VBA source files from ClassModules, DocumentModules, and Modules
- Remove vba_metadata.json

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 12:26:51 +08:00
Misaka_Company
b412c55654 refactor: update output fields in MainModule
- Add 生产订单号 field from column A of [产品订单] sheet
- Remove 表头型号 field from output
- Reorder columns to place 生产订单号 as first column
- Update ProcessSingleModel and CreateOutputRowArray signatures

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 09:45:28 +08:00
Misaka_Company
dd6ae4c005 feat: add component inventory check module
Implement automatic component inventory verification that marks
orders with insufficient stock as "Component Priority = No".

Key features:
- Reads orders from [产品订单] worksheet
- Parses BOM to identify component category materials
- Validates inventory against [现存量] worksheet
- Allocates stock in order sequence
- Handles missing components with warnings instead of errors
- Provides detailed statistics on completion

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 17:55:08 +08:00
Misaka_Company
57adf860ac feat: add additional features (fjgn) support
- Add fjgn (附加功能) field extraction from instrument characteristics
- Extract additional features from model number's instrument feature field
- Merge all fields from index 5 onwards to handle dot separators in features
- Remove oil-fill type (Y+digit) suffix from additional features
- Normalize separators (comma and dot) to comma for consistent parsing
- Implement multi-value matching for fjgn conditions (contains logic)
  - fjgn=N1: true if fjgn contains N1
  - fjgn!=N1: true if fjgn does not contain N1
- Add fjgn to condition config in MainModule and BIPUploadModule

Fixes issue where additional features with dot separators (e.g., N3.N2.Y3)
were incorrectly parsed by merging all fields from index 5 onwards.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 11:04:19 +08:00
Misaka_Company
a22ee42119 chore: remove auto-generated metadata from file headers
- Remove "作者: Auto-generated" and date fields from module headers
- Clean up unnecessary metadata comments

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 10:09:40 +08:00
Misaka_Company
6e45d6bdd2 refactor: standardize variable naming and file formatting
- Rename Quantity to quantity in BomItem for consistent naming convention
- Update references in MainModule to use lowercase quantity
- Add newlines at end of files for consistency
- Update vba_metadata.json with new source path and document module

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-02 10:01:57 +08:00
Misaka
d68dc945bc perf: optimize output logic using batch array writes
Optimize BIPUploadModule and MainModule for better performance:
- Replace cell-by-cell writes with batch array operations
- Collect all output data in memory using Collection objects
- Use WriteBatchData to write all data in single operation
- Add CreateBIPRowArray and CreateOutputRowArray helper functions
- Remove deprecated WriteBIPRow and WriteOutputRow functions

Performance improvement:
- Before: N cell write operations per row (thousands of Excel calls)
- After: 1 batch write operation for all data
- Expected speedup: 10-100x depending on data volume

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 23:06:26 +08:00
Misaka
c7c12838b2 feat: add component priority support to MainModule
Update MainModule to support component priority field:
- Read component priority from column E of [产品订单] worksheet
- Pass component priority to ProcessSingleModel function
- Apply category exclusion logic based on priority flag:
  - When "否"/"0"/"FALSE", exclude "部件" category
  - Only extract sub-category materials when disabled
- Consistent with BIPUploadModule implementation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 22:35:25 +08:00
Misaka
c5f2d804fb feat: add component priority exclusion feature
Add support for excluding "部件" category based on component priority flag:
- BomExtractor: Add exclude categories functionality
  - Add pExcludeCategories collection member
  - Add SetExcludeCategories() and ClearExcludeCategories() methods
  - Modify DetermineRequiredCategories() to skip excluded categories

- BIPUploadModule: Read and use component priority field
  - Read component priority from column E of [产品订单] worksheet
  - Pass component priority to ProcessSingleOrder()
  - When priority is "否"/"0"/"FALSE", exclude "部件" category
  - Only extract sub-category materials when component priority is disabled

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 22:25:10 +08:00
Misaka
8fae8f0389 feat: add BIP upload module for order processing
Add BIPUploadModule to process product orders and generate BIP upload format:
- Read order data from [产品订单] worksheet
- Extract BOM using existing BomExtractor and ProductModelParser
- Output to [BIP上传模板] with formatted fields:
  - Source document number, product code, quantity
  - Line number (base 7000 + index)
  - Material code (66 code from BOM)
  - Supply method, required date, issue organization
  - Planned outbound quantity, remarks for errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 22:07:36 +08:00
Misaka
79dc7cbf72 feat: add core VBA source code modules
Add VBA directory with essential project code including:
- ClassModules: BomExtractor, BomItem, ConditionEvaluator, ProductModelParser
- Modules: MainModule, TestModule
- Forms and DocumentModules
- vba_metadata.json for module metadata

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 16:18:17 +08:00
Misaka_Company
2b9ba2de9c clear 2026-01-29 17:05:28 +08:00
Misaka_Company
c9cf84ed4d fix: update modules to use new LoadData interface and fix completeness check logic
Changes:
1. Update all modules to use LoadData(wsPlatform) instead of LoadData(wsConfig, wsPlatform)
   - modModelParserExamples.bas: Update 7 example procedures
   - modBOMProcessor.bas: Update 4 procedures
   - modModelParserTest.bas: Update 2 test procedures

2. Fix completeness check logic in GetValidMaterialsByModel
   - Only check root categories to avoid duplicate checking of subcategories
   - Previously, all required categories (including subcategories) were checked,
     causing subcategories to be added to missing list multiple times
   - Now only checks categories with ParentCategoryName = ""
   - CheckCategoryCompleteness already recursively checks all subcategories

3. Improve completeness judgment logic for categories with subcategories
   - Method 1: Parent category has 1 matching material → Complete
   - Method 2: Parent category has 0 matching materials, but all subcategories are complete → Complete
   - Other cases → Incomplete

Impact:
- Fixes "category missing" errors in Example9_BatchProcessOrders_WithCheck
- Eliminates duplicate entries in missing categories list
- Properly handles category hierarchy where parent categories are satisfied through subcategories

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 12:38:50 +08:00
Misaka_Company
255bcdb5fe refactor: remove debug output and update order logic
- Commented out verbose Debug.Print statements in `GetMaterialsByModel` and `FilterCategoryWithSubcategories` to reduce console noise.
- Added validation checks to ensure required worksheets ('平台配置清单', '产品订单') exist before loading data.
- Refactored order processing logic to aggregate results into a Collection for structured output generation, including headers.
2026-01-26 09:13:27 +08:00
Misaka_Company
40a9fe99f4 feat: track and return missing material categories in BOM
- Update GetValidMaterialsByModel to aggregate and return missing
  category names under the "MissingCategories" key.
- Remove debug print statements and unused variables to improve
  code cleanliness.
- Enhance result visualization to display completeness status
  with color formatting and detailed material tables.
2026-01-21 09:51:37 +08:00
Misaka_Company
112a89a2a4 feat: Add GetValidMaterialsByModel and completeness check
Implemented logic to retrieve materials based on a model string and verify if the resulting set is complete.

Added:
- `GetValidMaterialsByModel`: Parses the model, extracts conditions, and matches materials against root categories.
- `CheckCategoryCompleteness`: Recursively validates categories to ensure exactly one material match per required category (leaf or parent).

This enables the BOM Manager to return a collection of materials alongside a boolean flag indicating if the collection satisfies the structural completeness rules.
2026-01-20 18:13:11 +08:00
Misaka_Company
f3fc5b4cbd feat(clsBOMManager): add optional autoFallback param
Added the `autoFallback` optional parameter to `GetMaterialsByModel`.
This flag controls whether the search automatically descends to
subcategories when no matches are found in the target category.

- Defaults to True to maintain previous recursive behavior.
- When False, the search is restricted strictly to the specified category.
- Updated documentation with usage examples and logic explanations.
2026-01-20 16:24:49 +08:00
Misaka_Company
388ccc4e7a refactor: add subcategory fallback logic for material filtering
Refactored the material retrieval logic in GetMaterialsByModel to
automatically search within subcategories if no matches are found in the
specified parent category.

- Added FilterCategoryWithSubcategories helper function to handle recursive
  searching and fallback logic.
- Restructured main function to delegate filtering to the new helper.
- Enhanced code comments to clarify the step-by-step matching process.
2026-01-20 15:31:43 +08:00
Misaka_Company
a1347017e3 docs: expand AutoBOM architecture and implementation details
Refine project overview to include specific business context (Blaidy Company) and the main workbook file. Restructure the architecture section into a layered object-oriented design (Data, Processing, Application layers) and define the responsibilities of core VBA classes.

Add new technical documentation sections covering:
- Model number format parsing structure
- Condition expression language syntax
- Category hierarchy logic and picking strategies
- Material matching pipeline flow

Include VBA code examples for key methods such as CollectAllMaterials and GetMaterialsByCategoryAndModel to illustrate recursive traversal and material retrieval logic. Clarify the structure of key Excel configuration sheets.
2026-01-20 13:42:03 +08:00
Misaka_Company
bc5ea92c52 feat: add implementation plan for order material extraction functionality
- Introduced a comprehensive document detailing the project overview, goals, core functionalities, and technical architecture for the order material extraction feature.
- Defined the product model coding rules and extraction logic for selection conditions.
- Designed class structures for model parsing, condition evaluation, and order material list management.
- Outlined implementation steps, testing plans, and risk assessments for the development process.
2026-01-20 10:45:23 +08:00
Misaka_Company
05601ec1fc Add initial implementation of BOM management classes and data structure
- Created clsBOMManager for managing BOM data
- Added clsCategory and clsMaterialItem for category and material representation
- Implemented methods for loading and organizing BOM data from Excel
- Introduced .gitignore to exclude unnecessary files
- Added metadata JSON for module tracking
2026-01-20 08:53:01 +08:00