Generate Code
Introduction
GenerateCodeActivity is a MES-specific barcode generation node used to automatically generate product barcodes during production based on configured barcode rules. It supports multiple barcode matching methods, including product identification code matching, specified barcode rules, and automatic matching of the current product.
Configuration Items
This node is configured via flow context variables, no direct property configuration is needed.
Input Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| GenerateCode_ProductVariable_Value | GenerateCodeProductVariableValue | string | Product Identification Code, used for matching barcode rules |
| GenerateCode_CustomerNameVariable_Value | GenerateCodeCustomerNameVariableValue | string | Customer Name, used for filtering applicable barcode rules |
| GenerateCode_BarcodeRule | GenerateCodeBarcodeRule | string | Specified Barcode Rule ID (GUID format) |
Output Variables
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| GenerateCode_BarcodeVariable_Value | GenerateCodeBarcodeVariableValue | string | Generated Barcode Result |
| GenerateCode_Description_Value | GenerateCodeDescriptionValue | string | Generation Exception Description (if failed) |
Business Logic
Barcode Rule Matching Priority
-
Product Identification Code Matching (Highest Priority)
- When
GenerateCode_ProductVariable_Valuehas a value. - Find product model based on identification code.
- Match barcode rule combining process and customer name.
- When
-
Specified Barcode Rule
- When
GenerateCode_BarcodeRulehas a value. - Directly use the specified barcode rule ID.
- When
-
Auto Match Current Product (Default)
- Get product from recipe distribution info.
- Or get product from production order of current process segment.
- Or get product from inspection task.
Usage Example
Basic Flow Configuration
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ InboundInitialize │────▶│ GenerateCodeActivity│────▶│ PrintLabelActivity│
│ Inbound Init │ │ Generate Code │ │ Print Label │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Use Product Identification Code Matching
{
"Activities": [
{
"Name": "Set Product ID Code",
"Type": "VariableWriteActivity",
"VariableName": "GenerateCode_ProductVariable_Value",
"VariableValue": "PROD-001"
},
{
"Name": "Generate Code",
"Type": "GenerateCodeActivity"
}
]
}
Specified Barcode Rule
{
"Activities": [
{
"Name": "Set Barcode Rule",
"Type": "VariableWriteActivity",
"VariableName": "GenerateCode_BarcodeRule",
"VariableValue": "550e8400-e29b-41d4-a716-446655440000"
},
{
"Name": "Generate Code",
"Type": "GenerateCodeActivity"
}
]
}
Error Handling
| Error Scenario | Error Message | Suggestion |
|---|---|---|
| Function Not Enabled | Generate Code Disabled | Enable Generate Code function in process configuration |
| Product ID Invalid | Barcode Generation Failed: {ID} Product model not found | Check if product ID code is correct |
| Barcode Rule Format Error | Barcode Generation Failed: {Rule} Barcode rule format mismatch | Ensure barcode rule is a valid GUID |
| Product Not Found | Barcode Generation Failed: Product model not found | Ensure valid order or recipe distribution exists |
| Barcode Rule Empty | Barcode Generation Failed: Generate barcode rule cannot be empty | Configure barcode rule or ensure product has associated rule |