返回博客

制造业 Ontology 建模:从产线到产品的全链路数字化

制造企业的系统全景:

Coomia发布于 2025年8月20日14 分钟阅读
分享本文Twitter / X

制造业 Ontology 建模:从产线到产品的全链路数字化

系列:S4 本体建模 · 第 16 篇 | 难度:中级 | 阅读时间:18 分钟

#TL;DR

  • 制造业 Ontology 围绕"物料 → 工序 → 产品"三元组展开——BOM(物料清单)、工艺路线、设备状态、质量检测构成核心模型,coomia-dip 将它们统一为 ObjectType 网络,打通 MES、ERP、SCADA 的数据孤岛。
  • 设备 Ontology 结合实时 Metrics 实现预测性维护——每台设备是一个 ObjectType 实例,振动、温度、电流等传感器数据作为 Metric 属性接入,派生属性自动计算健康度评分,Action 自动触发维护工单。
  • 质量追溯链通过 RelationType 实现"一键回溯"——从不合格产品出发,沿关系链追溯到批次、工序、设备、操作员、原材料批号,秒级完成传统需要数小时的质量追溯。

#1. 制造业数据挑战

#1.1 典型数据孤岛

Code
制造企业的系统全景:

┌─────────────────────────────────────────────────┐
│  ERP(SAP/Oracle)                               │
│  ├── 物料主数据                                  │
│  ├── BOM 清单                                    │
│  ├── 采购订单                                    │
│  └── 成本核算                                    │
├─────────────────────────────────────────────────┤
│  MES(制造执行系统)                              │
│  ├── 工单管理                                    │
│  ├── 工艺路线                                    │
│  ├── 在制品追踪                                  │
│  └── 操作员记录                                  │
├─────────────────────────────────────────────────┤
│  SCADA / IoT 平台                                │
│  ├── 设备状态监控                                │
│  ├── 传感器数据                                  │
│  ├── 能耗数据                                    │
│  └── 环境数据                                    │
├─────────────────────────────────────────────────┤
│  QMS(质量管理系统)                              │
│  ├── 检验标准                                    │
│  ├── 检验记录                                    │
│  ├── 不合格品处理                                │
│  └── SPC 统计过程控制                             │
├─────────────────────────────────────────────────┤
│  WMS(仓储管理系统)                              │
│  ├── 库存管理                                    │
│  ├── 出入库记录                                  │
│  └── 库位管理                                    │
└─────────────────────────────────────────────────┘

问题:
├── 5 个系统,5 种数据模型,5 种 API
├── "这批产品用了哪批原料?" → 需要跨 ERP + MES + WMS 查询
├── "设备故障和产品不良率有没有关系?" → 需要跨 SCADA + QMS 分析
├── "产线停机造成了多少损失?" → 需要跨 MES + ERP 计算
└── 每次分析都要 IT 部门写定制报表

#2. 核心 ObjectType 设计

#2.1 物料与 BOM

Code
ObjectType: Material(物料)
  properties:
    materialId: STRING (PK)
    materialName: STRING
    materialType: ENUM [RAW, SEMI_FINISHED, FINISHED, PACKAGING]
    unit: STRING
    specification: STRING
    safetyStock: INT
    leadTimeDays: INT
    cost: DECIMAL
    supplier: RELATION → Supplier
  metrics:
    currentStock: METRIC(gauge, source=wms_db)
    monthlyConsumption: METRIC(counter, source=erp_db)
    avgPurchasePrice: METRIC(gauge, source=erp_db)
  derivedProperties:
    stockCoverageDays: currentStock / (monthlyConsumption / 30)
    isLowStock: currentStock < safetyStock

ObjectType: BOM(物料清单)
  properties:
    bomId: STRING (PK)
    productMaterial: RELATION → Material
    version: STRING
    status: ENUM [DRAFT, ACTIVE, OBSOLETE]
    effectiveDate: DATE
    components: RELATION[] → BOMItem

ObjectType: BOMItem(BOM 行项)
  properties:
    itemId: STRING (PK)
    parentBom: RELATION → BOM
    componentMaterial: RELATION → Material
    quantity: DECIMAL
    unit: STRING
    substitutes: RELATION[] → Material
    scrapRate: DECIMAL
  derivedProperties:
    effectiveQuantity: quantity * (1 + scrapRate)
    componentCost: componentMaterial.cost * effectiveQuantity

BOM 层级关系:
  成品 A
  ├── 半成品 B (×2)
  │   ├── 原料 D (×3)
  │   └── 原料 E (×1)
  ├── 原料 C (×5)
  └── 包装 F (×1)

通过 coomia-dip 的关系遍历:
  GET /api/v1/objects/BOM/bom-001/expand?depth=3
  → 自动展开所有层级的 BOM 组件

#2.2 工艺路线与工序

Code
ObjectType: ProcessRoute(工艺路线)
  properties:
    routeId: STRING (PK)
    product: RELATION → Material
    version: STRING
    status: ENUM [DRAFT, ACTIVE, OBSOLETE]
    steps: RELATION[] → ProcessStep

ObjectType: ProcessStep(工序)
  properties:
    stepId: STRING (PK)
    route: RELATION → ProcessRoute
    stepNumber: INT
    stepName: STRING
    workCenter: RELATION → WorkCenter
    standardTimeMinutes: DECIMAL
    setupTimeMinutes: DECIMAL
    requiredSkills: STRING[]
    qualityCheckpoints: RELATION[] → QualityCheckpoint
  derivedProperties:
    totalTimeMinutes: standardTimeMinutes + setupTimeMinutes

ObjectType: WorkCenter(工作中心)
  properties:
    workCenterId: STRING (PK)
    name: STRING
    workshopId: RELATION → Workshop
    equipment: RELATION[] → Equipment
    capacity: INT
    operatingHours: STRING
  metrics:
    utilization: METRIC(gauge, source=mes_db)
    oee: METRIC(gauge, source=computed)
  derivedProperties:
    availableCapacity: capacity * (1 - utilization / 100)

#2.3 设备与传感器

Code
ObjectType: Equipment(设备)
  properties:
    equipmentId: STRING (PK)
    equipmentName: STRING
    equipmentType: ENUM [CNC, INJECTION, ASSEMBLY, PACKAGING, TESTING]
    manufacturer: STRING
    model: STRING
    serialNumber: STRING
    installDate: DATE
    lastMaintenanceDate: DATE
    workCenter: RELATION → WorkCenter
    maintenanceSchedule: RELATION → MaintenanceSchedule
  metrics:
    vibration: METRIC(gauge, source=iot_mqtt, unit="mm/s")
    temperature: METRIC(gauge, source=iot_mqtt, unit="°C")
    current: METRIC(gauge, source=iot_mqtt, unit="A")
    spindleSpeed: METRIC(gauge, source=iot_mqtt, unit="RPM")
    powerConsumption: METRIC(counter, source=iot_mqtt, unit="kWh")
    runningHours: METRIC(counter, source=iot_mqtt, unit="h")
    cycleCount: METRIC(counter, source=iot_mqtt)
    errorCount: METRIC(counter, source=iot_mqtt)
  derivedProperties:
    healthScore: DERIVED
      expression: |
        100
        - (IF(metric("vibration","avg","5m") > 8.0, 25, 0))
        - (IF(metric("temperature","avg","5m") > 85, 25, 0))
        - (IF(metric("current","avg","5m") > ratedCurrent * 1.2, 25, 0))
        - (IF(metric("errorCount","sum","1h") > 5, 25, 0))
    status: DERIVED
      expression: |
        CASE
          WHEN healthScore >= 80 THEN "HEALTHY"
          WHEN healthScore >= 50 THEN "WARNING"
          WHEN healthScore >= 20 THEN "DEGRADED"
          ELSE "CRITICAL"
        END
    daysSinceLastMaintenance: TODAY() - lastMaintenanceDate
    predictedFailureDays: DERIVED
      expression: |
        # 基于健康度衰减趋势预测
        LINEAR_REGRESSION(
          metric("healthScore", "avg", "1d"),
          window="30d",
          predictTo=20  # 预测健康度降到 20 时的天数
        )

设备 Action:
  ActionType: CreateMaintenanceOrder
    trigger: healthScore < 50 OR daysSinceLastMaintenance > 90
    parameters:
      equipmentId: REQUIRED
      maintenanceType: ENUM [PREVENTIVE, CORRECTIVE, PREDICTIVE]
      priority: ENUM [LOW, NORMAL, HIGH, URGENT]
      assignedTechnician: RELATION → Employee

#3. 生产执行模型

#3.1 工单与在制品

Code
ObjectType: ProductionOrder(生产工单)
  properties:
    orderId: STRING (PK)
    product: RELATION → Material
    bom: RELATION → BOM
    processRoute: RELATION → ProcessRoute
    plannedQuantity: INT
    actualQuantity: INT
    plannedStartDate: TIMESTAMP
    plannedEndDate: TIMESTAMP
    actualStartDate: TIMESTAMP
    actualEndDate: TIMESTAMP
    status: ENUM [PLANNED, RELEASED, IN_PROGRESS, COMPLETED, CANCELLED]
    priority: ENUM [LOW, NORMAL, HIGH, URGENT]
  metrics:
    completionRate: METRIC(gauge, source=mes_db)
    defectRate: METRIC(gauge, source=qms_db)
    cycleTime: METRIC(gauge, source=mes_db, unit="min")
  derivedProperties:
    yieldRate: actualQuantity / plannedQuantity * 100
    onTimeStatus: CASE
      WHEN actualEndDate <= plannedEndDate THEN "ON_TIME"
      WHEN actualEndDate IS NULL AND NOW() > plannedEndDate THEN "OVERDUE"
      ELSE "IN_PROGRESS"
    END
    estimatedCompletionTime: DERIVED
      expression: |
        actualStartDate + (cycleTime * plannedQuantity / 60)

ObjectType: WIP(在制品)
  properties:
    wipId: STRING (PK)
    productionOrder: RELATION → ProductionOrder
    material: RELATION → Material
    currentStep: RELATION → ProcessStep
    currentWorkCenter: RELATION → WorkCenter
    quantity: INT
    lotNumber: STRING
    startTime: TIMESTAMP
    status: ENUM [WAITING, IN_PROCESS, QC_PENDING, COMPLETED, REJECTED]
  derivedProperties:
    waitingTime: NOW() - startTime (当 status == WAITING)
    isBottleneck: waitingTime > currentStep.standardTimeMinutes * 2

#3.2 质量管理

Code
ObjectType: QualityInspection(质量检验)
  properties:
    inspectionId: STRING (PK)
    wip: RELATION → WIP
    processStep: RELATION → ProcessStep
    inspector: RELATION → Employee
    inspectionType: ENUM [INCOMING, IN_PROCESS, FINAL, SAMPLING]
    inspectionTime: TIMESTAMP
    result: ENUM [PASS, FAIL, CONDITIONAL]
    measurements: JSON
    defects: RELATION[] → DefectRecord

ObjectType: DefectRecord(缺陷记录)
  properties:
    defectId: STRING (PK)
    inspection: RELATION → QualityInspection
    defectType: ENUM [DIMENSIONAL, SURFACE, FUNCTIONAL, COSMETIC]
    defectCode: STRING
    severity: ENUM [MINOR, MAJOR, CRITICAL]
    description: STRING
    rootCause: STRING
    correctiveAction: STRING
    photos: STRING[]

质量追溯链(通过关系遍历):

  不合格产品
  │
  ├── QualityInspection(哪次检验发现的?)
  │   ├── inspector(谁检的?)
  │   └── processStep(哪道工序?)
  │       └── workCenter → equipment(哪台设备?)
  │
  ├── WIP(哪个在制品?)
  │   ├── productionOrder(哪个工单?)
  │   └── lotNumber(哪个批次?)
  │
  ├── BOM → BOMItem → Material(用了哪些原料?)
  │   └── supplier(哪个供应商?)
  │       └── incomingInspection(进料检验通过了吗?)
  │
  └── Equipment(设备当时的状态如何?)
      └── metrics.vibration / temperature at inspectionTime

一个 API 调用完成全链路追溯:
  POST /api/v1/objects/DefectRecord/def-001/trace
  {
    "direction": "UPSTREAM",
    "depth": 5,
    "includeMetrics": true,
    "metricsTimeWindow": "inspectionTime ± 1h"
  }

#4. 供应链模型

#4.1 供应商与采购

Code
ObjectType: Supplier(供应商)
  properties:
    supplierId: STRING (PK)
    name: STRING
    category: ENUM [STRATEGIC, PREFERRED, APPROVED, PROBATION]
    materials: RELATION[] → Material
    certifications: STRING[]
    leadTimeDays: INT
    paymentTerms: STRING
  metrics:
    onTimeDeliveryRate: METRIC(gauge, source=erp_db)
    qualityRejectRate: METRIC(gauge, source=qms_db)
    avgLeadTime: METRIC(gauge, source=erp_db)
  derivedProperties:
    supplierScore: DERIVED
      expression: |
        onTimeDeliveryRate * 0.4 +
        (100 - qualityRejectRate) * 0.3 +
        (1 - avgLeadTime / expectedLeadTime) * 100 * 0.3
    riskLevel: CASE
      WHEN supplierScore >= 80 THEN "LOW"
      WHEN supplierScore >= 60 THEN "MEDIUM"
      ELSE "HIGH"
    END

#4.2 库存管理

Code
ObjectType: InventoryLot(库存批次)
  properties:
    lotId: STRING (PK)
    material: RELATION → Material
    quantity: DECIMAL
    warehouse: RELATION → Warehouse
    location: STRING
    receivedDate: DATE
    expiryDate: DATE
    supplier: RELATION → Supplier
    purchaseOrder: RELATION → PurchaseOrder
    qualityStatus: ENUM [PENDING_QC, APPROVED, REJECTED, QUARANTINE]
  derivedProperties:
    daysToExpiry: expiryDate - TODAY()
    isExpiringSoon: daysToExpiry < 30 AND daysToExpiry > 0
    isExpired: daysToExpiry <= 0
    fifoOrder: receivedDate  # 先进先出排序

#5. 生产看板与 KPI

#5.1 车间级看板

Code
ObjectType: Workshop(车间)
  properties:
    workshopId: STRING (PK)
    name: STRING
    workCenters: RELATION[] → WorkCenter
    shiftSchedule: JSON
  derivedProperties(聚合下级指标):
    totalOEE: AVG(WorkCenter.oee)
    activeOrders: COUNT(ProductionOrder WHERE status == "IN_PROGRESS")
    todayOutput: SUM(ProductionOrder.actualQuantity WHERE actualEndDate == TODAY())
    defectRate: AVG(ProductionOrder.defectRate)
    equipmentHealthAvg: AVG(Equipment.healthScore)
    criticalEquipmentCount: COUNT(Equipment WHERE status == "CRITICAL")

车间看板数据模型:
┌─────────────────────────────────────────────────────┐
│  Workshop: 冲压车间                                  │
│                                                      │
│  OEE: 78.5%    活跃工单: 12    今日产量: 4,523       │
│  不良率: 1.2%  设备健康: 85.3  预警设备: 2           │
│                                                      │
│  工单状态:                                          │
│  [PO-001: 进行中 67%] [PO-002: 进行中 34%]          │
│  [PO-003: 等待物料] [PO-004: 计划中]                 │
│                                                      │
│  设备状态:                                          │
│  CNC-01: ✅ 92  CNC-02: ✅ 88  CNC-03: ⚠️ 45        │
│  CNC-04: ✅ 91  CNC-05: ✅ 87  CNC-06: ✅ 95        │
│                                                      │
│  质量趋势:                                          │
│  [过去 7 天不良率趋势图]                              │
└─────────────────────────────────────────────────────┘

所有数据来自 Ontology 的统一查询,
无需从 MES + SCADA + QMS 分别取数。

#6. 预测性维护模型

#6.1 维护策略对比

Code
三种维护策略的 Ontology 实现:

策略 1: 定期维护(Time-Based)
  trigger: daysSinceLastMaintenance >= maintenanceInterval
  缺点:可能过度维护或不足维护

策略 2: 状态维护(Condition-Based)
  trigger: healthScore < 50
  改进:基于实际状态,减少不必要的维护

策略 3: 预测性维护(Predictive)
  trigger: predictedFailureDays < 14
  最优:在故障发生前预测并安排维护

coomia-dip 的预测性维护流程:
  1. 设备传感器数据 → Metric 属性(实时采集)
  2. healthScore 派生属性(每分钟重算)
  3. predictedFailureDays 派生属性(基于趋势分析)
  4. 告警规则:predictedFailureDays < 14
  5. Action: CreateMaintenanceOrder(自动创建维护工单)
  6. 维护完成 → lastMaintenanceDate 更新 → healthScore 重算

闭环自动化,无需人工监控设备状态。

#7. 能耗管理模型

Code
ObjectType: EnergyMeter(能源计量点)
  properties:
    meterId: STRING (PK)
    meterType: ENUM [ELECTRICITY, GAS, WATER, STEAM, COMPRESSED_AIR]
    equipment: RELATION → Equipment (可选)
    workCenter: RELATION → WorkCenter (可选)
    workshop: RELATION → Workshop (可选)
  metrics:
    consumption: METRIC(counter, source=iot_mqtt)
    instantPower: METRIC(gauge, source=iot_mqtt)
    peakDemand: METRIC(gauge, source=iot_mqtt)
  derivedProperties:
    dailyConsumption: metric("consumption", "sum", "1d")
    monthlyConsumption: metric("consumption", "sum", "30d")
    costEstimate: monthlyConsumption * unitPrice
    consumptionPerUnit: monthlyConsumption / workshop.todayOutput

能耗分析层级:
  工厂 → 车间 → 工作中心 → 设备
  每一级自动聚合下级能耗
  自动计算单位产品能耗(Energy Per Unit)

#8. 关系网络全景

Code
制造业 Ontology 的核心关系网络:

Supplier ──supplies──→ Material
Material ──usedIn──→ BOMItem ──partOf──→ BOM
BOM ──definesProductionOf──→ Material (成品)
ProcessRoute ──routeFor──→ Material (成品)
ProcessStep ──partOf──→ ProcessRoute
ProcessStep ──performedAt──→ WorkCenter
WorkCenter ──contains──→ Equipment
WorkCenter ──locatedIn──→ Workshop
ProductionOrder ──produces──→ Material
ProductionOrder ──usesBom──→ BOM
ProductionOrder ──followsRoute──→ ProcessRoute
WIP ──belongsTo──→ ProductionOrder
WIP ──atStep──→ ProcessStep
QualityInspection ──inspects──→ WIP
DefectRecord ──foundIn──→ QualityInspection
InventoryLot ──stores──→ Material
InventoryLot ──from──→ Supplier
Equipment ──monitors──→ EnergyMeter

关系总数:18 种
ObjectType 总数:15 种

#9. 实战:注塑车间建模

#9.1 场景描述

Code
注塑车间 Ontology 建模实例:

车间概况:
├── 20 台注塑机(不同吨位)
├── 年产量 500 万件
├── 3 班倒运行
├── 主要生产汽车内饰件

需要解决的问题:
├── 注塑机健康度监控(减少意外停机)
├── 模具寿命管理(预测何时需要更换)
├── 注塑参数与质量的关联分析
├── 能耗优化(降低单件能耗)
└── 完整的质量追溯链

#9.2 核心模型

Code
ObjectType: InjectionMachine(注塑机)
  properties:
    machineId, machineName, tonnage, manufacturer
    mold: RELATION → Mold (当前安装的模具)
  metrics:
    clampingForce, injectionPressure, injectionSpeed
    barrelTemperature, moldTemperature
    cycleTime, cushionLength
    shotWeight, partWeight
    powerConsumption

ObjectType: Mold(模具)
  properties:
    moldId, moldName, cavityCount, material
    maxShotCount, currentShotCount
    lastMaintenanceDate
  derivedProperties:
    remainingLife: (maxShotCount - currentShotCount) / maxShotCount * 100
    estimatedRemainingDays: remainingLife / avgDailyShotCount

ObjectType: InjectionParameter(注塑参数配方)
  properties:
    parameterId, product, mold, machine
    injectionPressure, holdingPressure, backPressure
    injectionSpeed, screwSpeed
    barrelTemp1, barrelTemp2, barrelTemp3, nozzleTemp
    coolingTime, cycleTime

关联分析示例:
  当不良率上升时,自动关联:
  1. 当时的注塑参数是否偏离标准配方
  2. 模具的剩余寿命是否过低
  3. 注塑机的健康度评分
  4. 原料批次是否更换过
  → 自动生成根因分析报告

#10. 与工业 4.0 的对齐

Code
coomia-dip 制造 Ontology 与工业 4.0 概念对齐:

┌──────────────────┬────────────────────────────────┐
│ 工业 4.0 概念     │ coomia-dip 实现                  │
├──────────────────┼────────────────────────────────┤
│ Digital Twin      │ 设备 ObjectType + 实时 Metrics  │
│ Smart Factory     │ 车间/产线 ObjectType 层级       │
│ Predictive Maint  │ 派生属性 + 趋势预测 + Action   │
│ Quality 4.0       │ 质量追溯链 + 关联分析           │
│ Mass Customization│ BOM 版本管理 + 工艺路线变体     │
│ Supply Chain 4.0  │ 供应商 ObjectType + 风险评分    │
│ Energy Management │ 能源计量 ObjectType + 聚合分析  │
│ Traceability      │ 批次 → 工序 → 设备 关系链      │
└──────────────────┴────────────────────────────────┘

核心价值:
  传统方式:5 个系统各管一摊,数据孤岛
  coomia-dip:统一 Ontology 模型,所有数据互联互通
  一个查询就能回答跨系统的复杂问题

#Key Takeaways

  1. 制造业 Ontology 的核心是"物料-工序-产品"三元组——BOM 定义了"用什么做",工艺路线定义了"怎么做",生产工单把两者串联起来,coomia-dip 用 ObjectType 和 RelationType 精确建模。
  2. 设备 Ontology + 实时 Metrics = 数字孪生基础——每台设备的传感器数据作为 Metric 属性实时接入,healthScore 派生属性每分钟自动重算,predictedFailureDays 实现预测性维护。
  3. 质量追溯链是关系网络的典型应用——从不合格品沿关系链追溯到批次、工序、设备、操作员、原材料,一个 API 调用完成传统需要数小时的追溯,是 Ontology 关系建模的核心价值。
  4. 多层聚合实现了从设备到工厂的全视图——设备级指标聚合到工作中心,工作中心聚合到车间,车间聚合到工厂,每一层都有自动计算的 OEE、产量、不良率。
  5. Action 机制实现了闭环自动化——设备健康度下降自动创建维护工单,库存低于安全库存自动触发采购,质量异常自动停线并通知——从"看到问题"到"自动处理"。

#Next Article

下一篇 S4-17 金融风控 Ontology 建模 将讨论如何用 Ontology 模型表达金融领域的复杂关系网络——客户、账户、交易、产品、风险事件,如何用派生属性实时计算风险指标,如何用关系遍历发现隐性关联。

#ontology #manufacturing #industry-4.0 #digital-twin #predictive-maintenance #quality-traceability #bom #mes #oee