Skip to main content
Version: Next

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 NameConstantTypeDescription
GenerateCode_ProductVariable_ValueGenerateCodeProductVariableValuestringProduct Identification Code, used for matching barcode rules
GenerateCode_CustomerNameVariable_ValueGenerateCodeCustomerNameVariableValuestringCustomer Name, used for filtering applicable barcode rules
GenerateCode_BarcodeRuleGenerateCodeBarcodeRulestringSpecified Barcode Rule ID (GUID format)

Output Variables​

Variable NameConstantTypeDescription
GenerateCode_BarcodeVariable_ValueGenerateCodeBarcodeVariableValuestringGenerated Barcode Result
GenerateCode_Description_ValueGenerateCodeDescriptionValuestringGeneration Exception Description (if failed)

Business Logic​

Barcode Rule Matching Priority​

  1. Product Identification Code Matching (Highest Priority)

    • When GenerateCode_ProductVariable_Value has a value.
    • Find product model based on identification code.
    • Match barcode rule combining process and customer name.
  2. Specified Barcode Rule

    • When GenerateCode_BarcodeRule has a value.
    • Directly use the specified barcode rule ID.
  3. 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 ScenarioError MessageSuggestion
Function Not EnabledGenerate Code DisabledEnable Generate Code function in process configuration
Product ID InvalidBarcode Generation Failed: {ID} Product model not foundCheck if product ID code is correct
Barcode Rule Format ErrorBarcode Generation Failed: {Rule} Barcode rule format mismatchEnsure barcode rule is a valid GUID
Product Not FoundBarcode Generation Failed: Product model not foundEnsure valid order or recipe distribution exists
Barcode Rule EmptyBarcode Generation Failed: Generate barcode rule cannot be emptyConfigure barcode rule or ensure product has associated rule