Material Association
Introduction
MaterialAssociationActivity is a MES-specific material code association query node used to query the associated product serial number based on the material barcode. This node looks up the product code corresponding to the material barcode in the trace data according to the configured material association rules, realizing material-product association traceability.
Configuration Items
This node is controlled via system configuration and flow context variables.
System Configuration
| Configuration Item | Description |
|---|---|
| MaterialAssociationConfig | Material Association Configuration List |
Material Association Configuration (MaterialAssociationConfig)
| Field | Description |
|---|---|
| WorkSectionCode | Work Section Code |
| WorkSectionId | Work Section ID |
| MaterialName | Material Name |
| MaterialKey | Material Parameter Key |
Input Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| MaterialCode | FlowItemCollection.MaterialCode | string | Material Barcode to Query |
| OrderModel | FlowItemCollection.OrderModel | OrderModel | Order Model (Optional) |
| ProductModel | FlowItemCollection.ProductModel | AssociationProductModel | Product Model (Optional) |
Output Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| SerialNumber | FlowItemCollection.SerialNumber | string | Associated Product Serial Number |
| MaterialCodeAssociationDescriptionValue | FlowItemCollection.MaterialCodeAssociationDescriptionValue | string | Query Result Description |
Business Logic
Execution Flow
┌─────────────────────────────────────────────────────────────┐
│ MaterialAssociationActivity │
├─────────────────────────── ──────────────────────────────────┤
│ EnterAsync - Initialization Phase │
│ └─ Set Association Desc = "Not Initialized" │
├─────────────────────────────────────────────────────────────┤
│ ProcessAsync - Processing Phase │
│ ├─ Get Material Code │
│ │ └─ Empty → Return "Material Code Acquisition Failed" │
│ ├─ Get Material Association Config │
│ │ └─ Not Configured → Return "Material Product Assoc..." │
│ ├─ Get Process Route │
│ ├─ Traverse Assoc Config to Query Product Code │
│ │ ├─ Check if process is in process route │
│ │ └─ Call trace service to query associated product code │
│ └─ Set Query Result │
│ ├─ Found → Set SerialNumber │
│ └─ Not Found → Set Exception Description │
└─────────────────────────────────────────────────────────────┘
Query Logic
-
Configuration Validation
- Check if material association configuration exists.
- Verify if process ID in configuration is valid.
-
Process Route Filtering
- Get process route of current product.
- Only query in processes included in the process route.
-
Association Query
- Traverse material association configuration.
- Call
IProductTraceChecker.GetSerialNumberto query. - Return immediately upon finding the first matching product code.
Usage Example
Basic Flow Configuration
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Scan Material Code│────▶│MaterialAssociation│────▶│InboundInitialize │
│ │ │ Material Assoc │ │ Inbound Init │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Set Material Code
{
"Activities": [
{
"Name": "Read Material Code",
"Type": "VariableReadActivity",
"VariableName": "MaterialCode"
},
{
"Name": "Material Association Query",
"Type": "MaterialAssociationActivity"
},
{
"Name": "Check Query Result",
"Type": "ConditionActivity",
"Condition": "SerialNumber != null && SerialNumber != ''"
}
]
}
Typical Application Scenario
┌──────────────────┐
│ Scan Material Code│
│ Set MaterialCode │
└────────┬─────────┘
│
▼
┌──────────────────┐
│MaterialAssociation│ ← Query product code by material code
│ Material Assoc │
└────────┬─────────┘
│ Set SerialNumber
▼
┌──────────────────┐
│InboundInitialize │ ← Inbound using queried product code
│ Inbound Init │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Subsequent Detect │
└──────────────────┘
Error Handling
| Error Scenario | Description Value | Description |
|---|---|---|
| Material Code Empty | Material Code Acquisition Failed | Input material code is empty |
| Config Not Set | Material Product Association Process Not Configured | System has no material association rules configured |
| Query Exception | Exception Info | Exception occurred during query |
| No Association Found | Material Code Not Bound to Product Code | Material code has no associated product in trace data |
Notes
- Configuration Required: Material association rules need to be set in system configuration.
- Process Route Filtering: Only query in processes included in product process route.
- First Match: Returns upon finding the first matching product code.
- Trace Data Dependency: Query is based on existing trace data.
- Exception Handling: Query exceptions are captured and recorded in description variable.
- Inbound Coordination: Usually used before Inbound Initialization.