Files
AutoBOM/VBA/ClassModules/AGENTS.md
Misaka_Company 787b3f56ab docs: add AGENTS.md documentation files
Add comprehensive AGENTS.md documentation files across the project structure to document the agent architecture and capabilities.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 14:05:56 +08:00

4.5 KiB

ClassModules Knowledge Base

Scope: VBA/ClassModules/ - Domain logic classes

OVERVIEW

4 classes: ProductModelParser (parse model strings), BomItem (data model), ConditionEvaluator (evaluate conditions), BomExtractor (core matching logic).

STRUCTURE

ClassModules/
├── ProductModelParser.cls   # Parse model strings → extract 6 conditions
├── BomItem.cls              # BOM data model (11 fields)
├── ConditionEvaluator.cls   # Evaluate condition expressions
└── BomExtractor.cls         # Core matching + assembly logic

WHERE TO LOOK

Task Location Notes
Parse model string ProductModelParser.cls Parse() method
Extract conditions ProductModelParser.cls Returns azxs, bkxs, gclj, jycz, lcfw, fjgn
Load BOM row BomItem.cls LoadFromRow() with type conversion
Evaluate condition ConditionEvaluator.cls Evaluate(condition, conditions)
Match BOM items BomExtractor.cls ExtractBom() with 4-step process
Assembly logic BomExtractor.cls ApplyAssemblyLogic() parent/child override

CODE MAP

ProductModelParser

Method Role
Parse(modelString) Entry point, validates format
ParseHeader() Splits model string by - and .
ExtractConnectionAndMaterial() Separates gclj and jycz from code
ExtractAdditionalFeatures() Removes oil-fill type (Y+digit) from fjgn

BomItem

Property Type Column
RowNumber Long A
Module String B
code String C
Name String D
quantity Double E
SelectCondition String F
Remark String G
category String H
ParentCategory String I
CategoryCondition String J
Code66 String K

BomExtractor

Method Role
LoadBomData() Loads from row 4 (header row 3)
ExtractBom(conditions) 4-step: determine categories → match → apply assembly → validate
ApplyAssemblyLogic() Parent overrides children if all match
ValidateResult() 双向覆盖检查 (parent/child coverage)

CONVENTIONS

Class Structure

Option Explicit

' Private state
Private pPropertyName As Type

' Initialize
Private Sub Class_Initialize()
    Set pProperty = New Collection
End Sub

' Public methods
Public Function MethodName() As ReturnType
    On Error GoTo ErrorHandler
    ' Logic
    Exit Function
ErrorHandler:
    ' Handle
End Function

Condition Dictionary

All condition methods accept Scripting.Dictionary with keys: azxs, bkxs, gclj, jycz, lcfw, fjgn.

Error Collection Pattern

Private pErrorMessages As Collection
Public Function GetErrorSummary() As String
    ' Join all errors with "; "
End Function

ANTI-PATTERNS (THIS PROJECT)

  • NEVER change BomItem.LoadFromRow() column indices — hardcoded to match platform configuration sheet
  • NEVER remove On Error Resume Next in LoadFromRow() — type conversions fail gracefully
  • NEVER skip validation in ValidateResult() —双向覆盖检查 prevents false negatives
  • DO NOT modify BomExtractor.LoadBomData() row start — must be row 4 (row 3 is header)

UNIQUE STYLES

Assembly Logic Algorithm

' 1. Build parent→child map from CategoryHierarchy
' 2. Count matches per category
' 3. If parent=1 AND all children≥1 → parent covers children
' 4. Output parent only, hide children

Model String Format

[Header]-[Spec1].[Spec2].[Spec3].[Spec4].[Spec5]|[Detail1]|[Detail2]
Example: Y-100-M203.316SS.L100.N2

Parsed conditions:
- azxs (安装形式): M (vertical)
- bkxs (表壳形式): 3
- gclj (过程连接): M20
- jycz (接液材质): 3 (316SS)
- lcfw (量程范围): 0.L100
- fjgn (附加功能): N2 (from .316SS.L100.N2)

Condition Expression Syntax

' Single: "field=value"
' OR: "field1=value1|field2=value2"
' Example: "azxs=M|azxs=L" → vertical OR horizontal

NOTES

Category Hierarchy

Built from ParentCategory field (column I). Example:

  • "接头" → "部件"
  • "弹性元件" → "部件"
  • Result: if "部件" matches AND both children match → output "部件" only

Type Conversion

BomItem.LoadFromRow() uses CLng(), CStr(), CDbl() with On Error Resume Next — invalid conversions become 0 or empty string.

Scripting.Dictionary

Windows-only. All dictionary usage via CreateObject("Scripting.Dictionary").