MaterialDetectionActivity - 物料检测
概述
MaterialDetectionActivity 是一个 MES 专用的物料检测节点,用于在生产过程中验证物料条码的有效性。该节点支持物料条码规则检测、物料状态检测、物料漏工序检测等功能,并可自动将物料条码写入指定变量。
基本信息
| 属性 | 值 |
|---|---|
| 显示名称 | 物料检测 |
| 类名 | MaterialDetectionActivity |
| 命名空间 | CMS.Plugin.MesSuite.Activitys |
| 基类 | ProcessBusinessActivity |
| 分类 | 工序步骤 |
| 排序 | 10 |
| 发布 | 是 |
配置说明
配置属性
| 属性名 | 显示名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|---|
| WriteBrcodeVariable | 写入物料参数 | bool | true | 是否将物料条码写入配置的变量 |
| WriteRetryCount | 写入重试次数 | int | 3 | 写入变量失败时的重试次数 |
| WriteRetryDelay | 写入重试延时 | int | 500 | 写入重试间隔(毫秒) |
工艺配置
| 配置项 | 说明 |
|---|---|
| MaterialDetection2 | 物料检测功能开关 |
| MaterielStateDetection | 物料状态检测触发时机 |
| MaterielMissingProcessDetection | 物料漏工序检测触发时机 |
| MaterialParameters | 物料参数配置列表 |
输入变量
| 变量名 | 常量 | 类型 | 说明 |
|---|---|---|---|
| MaterialDetection_MaterialVariable | FlowItemCollection.MaterialDetectionMaterialVariableKey | string | 待检测的物料条码 |
输出变量
| 变量名 | 常量 | 类型 | 说明 |
|---|---|---|---|
| MaterialDetection_Result | FlowItemCollection.MaterialDetectionResultKey | int | 检测结果:0=未执行,1=成功,2= 失败,3=禁用 |
| MaterialDetection_Description | FlowItemCollection.MaterialDetectionDescriptionKey | string | 检测结果说明 |
| MaterialDetection_MaterialDetailId | FlowItemCollection.MaterialDetectionMaterialDetailIdKey | string | 物料明细 ID |
| MaterialDetection_MaterialName | FlowItemCollection.MaterialDetectionMaterialNameKey | string | 物料名称 |
| MaterialDetection_MaterialParameter | FlowItemCollection.MaterialDetectionMaterialParameterKey | string | 物料参数键 |
| MaterialDetection_ProductModel | FlowItemCollection.MaterialDetectionProductModelKey | AssociationProductModel | 产品型号 |
业务逻辑
执行流程
┌─────────────────────────────────────────────────────────────┐
│ MaterialDetectionActivity │
├─────────────────────────────────────────────────────────────┤
│ EnterAsync - 初始化阶段 │
│ ├─ 设置检测结果 = 0 │
│ ├─ 清空检测说明 │
│ ├─ 清空物料名称 │
│ ├─ 清空物料参数 │
│ └─ 清空产品型号 │
├─────────────────────────────────────────────────────────────┤
│ ProcessAsync - 处理阶段 │
│ ├─ 检查功能是否启用 │
│ │ └─ 未启用 → 结果=3,返回禁用说明 │
│ ├─ 验证物料条码 │
│ │ └─ 为空 → 结果=2,返回错误 │
│ ├─ 获取产品型号 │
│ │ └─ 未找到 → 结果=2,返回错误 │
│ ├─ 物料条码规则检测 │
│ │ └─ 遍历 MaterialParameters 进行验证 │
│ ├─ 物料状态检测(如果启用) │
│ ├─ 物料漏工序检测(如果启用) │
│ ├─ 写入物料变量(如果配置) │
│ └─ 设置检测结果 │
└─────────────────────────────────────────────────────────────┘
检测结果说明
| 结果值 | 说明 |
|---|---|
| 0 | 未执行(初始状态) |
| 1 | 检测成功 |
| 2 | 检测失败 |
| 3 | 功能禁用 |
物料检测流程
-
条码规则检测
- 遍历工艺配置的物料参数列表
- 调用
IMaterialProvider.VerificationAsync验证条码 - 匹配成功则记录物料信息
-
物料状态检测(可选)
- 当
MaterielStateDetection = OnMaterialVerification时执行 - 检测物料在当前工序的状态
- 当
-
物料漏工序检测(可选)
- 当
MaterielMissingProcessDetection = OnMaterialVerification时执行 - 检测物料是否完成前置工序
- 当
产品型号获取
┌─────────────────────────────────────────────────────────────┐
│ 获取产品型号 │
├─────────────────────────────────────────────────────────────┤
│ 1. 从配方应用获取 │
│ └─ 有配方信息 → 返回产品 │
├─────────────────────────────────────────────────────────────┤
│ 2. 从工单获取 │
│ └─ 查询当前工序段的生产工单 → 返回产品 │
├─────────────────────────────────────────────────────────────┤
│ 3. 从点检任务获取 │
│ └─ 存在点检任务 → 返回点检任务中的产品 │
└─────────────────────────────────────────────────────────────┘