Material Usage Record
Introduction
MaterialUsageRecordActivity is a MES-specific material usage record node used to record material usage and execute material deduction when a product leaves the station. This node automatically deducts corresponding material inventory based on material parameters in trace data.
Configuration Items
Configuration Properties
| Property Name | Display Name | Type | Default Value | Description |
|---|---|---|---|---|
| ExecuteImmediately | Execute Immediately | bool | false | Whether to execute deduction synchronously. Asynchronously if false. |
Input Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| ApplicationData | FlowItemCollection.ApplicationData | ProcessModel | Process Model |
| ProductModel | FlowItemCollection.ProductModel | AssociationProductModel | Product Model |
| TraceModel | FlowItemCollection.TraceModel | TraceModel | Trace Model |
| ParameterCollectData | FlowItemCollection.ParameterCollectData | IReadOnlyDictionary | Parameter Collection Data |
Business Logic
Execution Flow
┌─────────────────────────────────────────────────────────────┐
│ MaterialUsageRecordActivity │
├─────────────────────────────────────────────────────────────┤
│ ExecuteActionAsync - Execution Phase │
│ ├─ Get process model, product model, trace model │
│ ├─ Verify existence of necessary data │
│ └─ Execute Material Deduction │
│ ├─ ExecuteImmediately = true → Synchronous execution │
│ └─ ExecuteImmediately = false → Asynchronous execution │
├─────────────────────────────────────────────────────────────┤
│ DecreaseMaterialAsync - Deduction Processing │
│ ├─ Traverse material parameters in process config │
│ ├─ Get material barcode from trace data │
│ ├─ Check if there is independent deduction flow │
│ │ └─ Has trigger signal config → Skip (Handled by Ded. Flow)│
│ ├─ Get Usage Quantity (Read from param in Equipment Mode) │
│ └─ Call Material Service to Execute Deduction │
└─────────────────────────────────────────────────────────────┘
Deduction Logic
-
Traverse Material Parameters
- Get material list from
MaterialParametersof process configuration. - Skip materials with empty names.
- Get material list from
-
Get Material Barcode
- Get corresponding material barcode from
MaterialParamsof trace model.
- Get corresponding material barcode from
-
Check Deduction Flow
- If process is configured with independent material deduction flow (Type = 10008).
- And material is configured with trigger signal, then skip (Handled by
MaterialDeductionActivity).
-
Get Usage Quantity
- Equipment Mode: Read usage variable from parameter collection data.
- Other Modes: Use system default usage.
-
Execute Deduction
- Call
IMaterialProvider.DeductionAsyncto execute deduction.
- Call
Usage Example
Basic Configuration
{
"Name": "Material Usage Record",
"Type": "MaterialUsageRecordActivity",
"ExecuteImmediately": false
}
Typical Outbound Flow
┌──────────────────┐
│OutboundInitialize│
│ Outbound Init │
└────────┬─────────┘
│
▼
┌──────────────────┐
│QualificationJudgment│
│ Qualification │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ParameterCollect │
│ Param Collect │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Trace Save │
└────────┬─────────┘
│
▼
┌──────────────────┐
│MaterialUsageRecordActivity│ ← Material Usage Record
│ Material Usage │
└──────────────────┘
Error Handling
| Error Scenario | Handling Method |
|---|---|
| Process Model Empty | Do not execute deduction |
| Product Model Empty | Do not execute deduction |
| Trace Model Empty | Do not execute deduction |
| Deduction Exception | Record error log, do not interrupt flow |
Notes
- Data Dependency: Requires Process Model, Product Model, and Trace Model to exist.
- Execution Timing: Usually executed after trace record saving.
- Deduction Conflict: Skips if material is configured with trigger signal (avoids double deduction).
- Async Execution: Defaults to asynchronous execution, does not block outbound flow.
- Error Handling: Deduction exception does not interrupt flow, only logs.
- Trace Data: Material barcode is obtained from trace data.