Commit Graph

5 Commits

Author SHA1 Message Date
Misaka_Company
7fea574531 refactor: replace row index with production order number in error reports
All checks were successful
NTFY Notification / notify (push) Successful in 12s
Replace "原表行号" (original row number) field with "生产订单号" (production order number) in BOM Extraction System error reporting to improve traceability.

Changes:
- clsErrorLogger: Update Record/RecordWarning signatures to accept OrderNo (String) instead of RowIndex (Long)
- M09_BOMExtractor: Propagate productionOrderNo through validation chain for context-aware error reporting
- M06/M07/M08: Use empty string for system-level errors without production order context
- Error report header: Change column B from "原表行号" to "生产订单号"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-26 10:12:59 +08:00
Misaka_Company
8477792d41 feat: integrate inventory verification for component materials in BOM extraction
All checks were successful
NTFY Notification / notify (push) Successful in 7s
Implement inventory-based component selection logic that accumulates demand
across orders and falls back to sub-components (joint + element) when stock
is insufficient.

**Changes:**
- M04_Config: Add inventory worksheet configuration constants
  - INVENTORY_SHEET_NAME = "现存量"
  - INVENTORY_HEADER_ROW = 3 (headers on row 3)
  - INVENTORY_COL_CODE = "B" (material code)
  - INVENTORY_COL_QTY = "J" (stock quantity)

- M08_ComponentProcessor: Implement inventory tracking and verification
  - Add module-level variables: g_InventoryDict, g_AccumulatedDemandDict
  - Add LoadInventoryData() to load stock from [现存量] worksheet
  - Add InitComponentProcessorWithInventory() for initialization with inventory
  - Rewrite CheckComponentInventory() with actual inventory logic:
    * Calculate cumulative demand = orderQty × bomQty + previousAccumulated
    * Compare with available stock
    * Return True if stock sufficient, False otherwise
    * Update accumulated demand after each order
  - Update ProcessComponentRecord() to accept orderQty parameter

- M09_BOMExtractor: Integrate inventory check into main workflow
  - Modify ReadInputModels() to read 3 columns (orderNo, model, qty)
  - Initialize component processor with inventory support
  - Extract order quantity from column C and pass through call chain
  - Update ProcessSingleModel() and MatchAllMaterialTypesWithValidation()
    signatures to accept orderQty parameter

**Logic Example:**
- 3 orders (PO-001, PO-003, PO-006) use component A
- Each order: quantity=2, BOM qty=1, stock=5
- PO-001: cumulative=2, stock 5>=2 ✓ → return component
- PO-003: cumulative=4, stock 5>=4 ✓ → return component
- PO-006: cumulative=6, stock 5<6 ✗ → return sub-components

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-24 16:21:18 +08:00
Misaka_Company
78241f2b8d fix: component worksheet rowCount false positive validation error
Some checks failed
NTFY Notification / notify (push) Failing after 3s
Fix critical bug in BOM matching validation: when [部件] worksheet matches 1 record
but returns 2 sub-components, system incorrectly reports "matched 2 records".

Root Cause:
- matchResult("rowCount") incorrectly used componentMaterials.count (material count)
- instead of bomMatchResult("rowCount") (worksheet row count)
- Caused 1-row match returning 2 sub-components to be misreported as "2 matches"

Solution:
1. M08_ComponentProcessor.ProcessComponentRecord: Add matchedRowNum parameter,
   receive matched row number from caller, avoid redundant internal matching

2. M09_BOMExtractor: Implement two-phase matching flow
   - Phase 1: Call MatchBOMRecord to get standard match result (with correct rowCount)
   - Phase 2: If match succeeds, call ProcessComponentRecord to process component logic
   - matchResult("rowCount") always uses standard match's rowCount (worksheet row count)

Fix Results:
- Scenario 1: [部件] matches 1 row, returns 1 component → rowCount=1 
- Scenario 2: [部件] matches 1 row, returns 2 sub-components → rowCount=1  (no false positive)
- Scenario 3: [部件] matches 0 rows → rowCount=0, correct error 
- Scenario 4: [部件] matches 2+ rows → rowCount=2, correct error 

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 15:54:50 +08:00
Misaka_Company
867b1979af refactor: improve BOM library matching logic with column-name-based lookup
All checks were successful
NTFY Notification / notify (push) Successful in 3s
- 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>
2026-02-12 13:59:48 +08:00
Misaka_Company
093a2d0a3b feat: implement BOM auto-extraction system
All checks were successful
NTFY Notification / notify (push) Successful in 11s
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>
2026-02-12 13:02:14 +08:00