feat(iace): Erweiterungen 2-4 — FMEA Worksheet, Delta Modal, Textil+Agri
Build + Deploy / build-admin-compliance (push) Successful in 2m5s
Build + Deploy / build-backend-compliance (push) Successful in 3m2s
Build + Deploy / build-ai-sdk (push) Failing after 35s
Build + Deploy / build-developer-portal (push) Successful in 1m6s
Build + Deploy / build-tts (push) Successful in 1m31s
Build + Deploy / build-document-crawler (push) Successful in 41s
Build + Deploy / build-dsms-gateway (push) Successful in 27s
Build + Deploy / build-dsms-node (push) Successful in 17s
CI / branch-name (push) Has been skipped
Build + Deploy / trigger-orca (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 16s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m25s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 40s
CI / test-python-backend (push) Successful in 36s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 21s
CI / validate-canonical-controls (push) Successful in 13s
Build + Deploy / build-admin-compliance (push) Successful in 2m5s
Build + Deploy / build-backend-compliance (push) Successful in 3m2s
Build + Deploy / build-ai-sdk (push) Failing after 35s
Build + Deploy / build-developer-portal (push) Successful in 1m6s
Build + Deploy / build-tts (push) Successful in 1m31s
Build + Deploy / build-document-crawler (push) Successful in 41s
Build + Deploy / build-dsms-gateway (push) Successful in 27s
Build + Deploy / build-dsms-node (push) Successful in 17s
CI / branch-name (push) Has been skipped
Build + Deploy / trigger-orca (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 16s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m25s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 40s
CI / test-python-backend (push) Successful in 36s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 21s
CI / validate-canonical-controls (push) Successful in 13s
Erweiterung 2: FMEA-Worksheet Tab (/fmea) - Tabelle: Komponente | Typ | Fehlerart | Auswirkung | S | O | D | RPZ | Bewertung - RPZ-Farbcodierung: >200 Kritisch, >100 Handlungsbedarf, >50 Beobachten - Stats: Gesamt, Kritisch, Handlungsbedarf, Akzeptabel Erweiterung 3: DeltaPreviewModal (wiederverwendbar) - Modal zeigt +/- Patterns, Hazards, Massnahmen bei Aenderungen - Nutzt POST /delta-analysis Endpoint - Summary Grid + detaillierte Listen Erweiterung 4: Textilmaschinen (EN ISO 11111) + Landmaschinen (ISO 4254) - 21 neue Patterns: HP1550-HP1559 (Textil), HP1565-HP1575 (Agri) - 23 neue Massnahmen: M452-M460 (Textil), M461-M474 (Agri) - Walzenspalt, Zapfwelle, ROPS, autonomer Traktor, Siloexplosion etc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
export interface FailureMode {
|
||||
id: string
|
||||
component_type: string
|
||||
mode: string
|
||||
name_de: string
|
||||
name_en: string
|
||||
effect: string
|
||||
detection_hint: string
|
||||
default_severity: number
|
||||
default_occurrence: number
|
||||
default_detection: number
|
||||
}
|
||||
|
||||
export interface Component {
|
||||
id: string
|
||||
name: string
|
||||
component_type: string
|
||||
}
|
||||
|
||||
export interface FMEARow {
|
||||
component: Component
|
||||
failureMode: FailureMode
|
||||
severity: number
|
||||
occurrence: number
|
||||
detection: number
|
||||
rpz: number
|
||||
}
|
||||
|
||||
export function useFMEA(projectId: string) {
|
||||
const [rows, setRows] = useState<FMEARow[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
loadData()
|
||||
}, [projectId]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
async function loadData() {
|
||||
try {
|
||||
// Load project components
|
||||
const compRes = await fetch(`/api/sdk/v1/iace/projects/${projectId}/components`)
|
||||
if (!compRes.ok) return
|
||||
const compJson = await compRes.json()
|
||||
const components: Component[] = (compJson.components || compJson || []).map(
|
||||
(c: Record<string, unknown>) => ({
|
||||
id: c.id as string,
|
||||
name: c.name as string,
|
||||
component_type: c.component_type as string || 'mechanical',
|
||||
})
|
||||
)
|
||||
|
||||
// Load failure modes for each component type (deduplicated)
|
||||
const types = [...new Set(components.map((c) => c.component_type))]
|
||||
const fmByType: Record<string, FailureMode[]> = {}
|
||||
|
||||
await Promise.all(
|
||||
types.map(async (type) => {
|
||||
const res = await fetch(`/api/sdk/v1/iace/failure-modes?component_type=${type}`)
|
||||
if (res.ok) {
|
||||
const json = await res.json()
|
||||
fmByType[type] = json.failure_modes || []
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// Also load general failure modes (no type filter)
|
||||
const allRes = await fetch('/api/sdk/v1/iace/failure-modes')
|
||||
let allFMs: FailureMode[] = []
|
||||
if (allRes.ok) {
|
||||
const json = await allRes.json()
|
||||
allFMs = json.failure_modes || []
|
||||
}
|
||||
|
||||
// Build FMEA rows: each component × its matching failure modes
|
||||
const fmeaRows: FMEARow[] = []
|
||||
for (const comp of components) {
|
||||
const compFMs = fmByType[comp.component_type] || []
|
||||
// Use type-specific FMs, or fallback to first 3 general FMs
|
||||
const relevantFMs = compFMs.length > 0 ? compFMs : allFMs.slice(0, 3)
|
||||
|
||||
for (const fm of relevantFMs) {
|
||||
const s = fm.default_severity || 5
|
||||
const o = fm.default_occurrence || 5
|
||||
const d = fm.default_detection || 5
|
||||
fmeaRows.push({
|
||||
component: comp,
|
||||
failureMode: fm,
|
||||
severity: s,
|
||||
occurrence: o,
|
||||
detection: d,
|
||||
rpz: s * o * d,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by RPZ descending (highest risk first)
|
||||
fmeaRows.sort((a, b) => b.rpz - a.rpz)
|
||||
setRows(fmeaRows)
|
||||
} catch (err) {
|
||||
console.error('Failed to load FMEA data:', err)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const stats = {
|
||||
total: rows.length,
|
||||
critical: rows.filter((r) => r.rpz > 200).length,
|
||||
actionRequired: rows.filter((r) => r.rpz > 100 && r.rpz <= 200).length,
|
||||
acceptable: rows.filter((r) => r.rpz <= 100).length,
|
||||
}
|
||||
|
||||
return { rows, loading, stats }
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
'use client'
|
||||
|
||||
import { useParams } from 'next/navigation'
|
||||
import { useFMEA, type FMEARow } from './_hooks/useFMEA'
|
||||
|
||||
const COMP_TYPE_LABELS: Record<string, string> = {
|
||||
mechanical: 'Mechanisch', electrical: 'Elektrisch', sensor: 'Sensor',
|
||||
actuator: 'Aktor', software: 'Software', firmware: 'Firmware',
|
||||
ai_model: 'KI-Modell', hmi: 'HMI', network: 'Netzwerk',
|
||||
hydraulic: 'Hydraulik', pneumatic: 'Pneumatik', safety: 'Sicherheit',
|
||||
}
|
||||
|
||||
function rpzColor(rpz: number): string {
|
||||
if (rpz > 200) return 'bg-red-100 text-red-800 border-red-200'
|
||||
if (rpz > 100) return 'bg-orange-100 text-orange-800 border-orange-200'
|
||||
if (rpz > 50) return 'bg-yellow-100 text-yellow-800 border-yellow-200'
|
||||
return 'bg-green-100 text-green-800 border-green-200'
|
||||
}
|
||||
|
||||
function rpzLabel(rpz: number): string {
|
||||
if (rpz > 200) return 'Kritisch'
|
||||
if (rpz > 100) return 'Handlungsbedarf'
|
||||
if (rpz > 50) return 'Beobachten'
|
||||
return 'Akzeptabel'
|
||||
}
|
||||
|
||||
export default function FMEAPage() {
|
||||
const { projectId } = useParams<{ projectId: string }>()
|
||||
const { rows, loading, stats } = useFMEA(projectId)
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div>
|
||||
<h1 className="text-xl font-bold text-gray-900 dark:text-white">FMEA-Worksheet</h1>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mt-0.5">
|
||||
Fehlermoeglich­keits- und Einflussanalyse — RPZ = Severity x Occurrence x Detection
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="grid grid-cols-4 gap-3">
|
||||
<StatCard label="Gesamt" value={stats.total} color="gray" />
|
||||
<StatCard label="Kritisch (RPZ > 200)" value={stats.critical} color="red" />
|
||||
<StatCard label="Handlungsbedarf (RPZ > 100)" value={stats.actionRequired} color="orange" />
|
||||
<StatCard label="Akzeptabel (RPZ ≤ 100)" value={stats.acceptable} color="green" />
|
||||
</div>
|
||||
|
||||
{/* RPZ Threshold Info */}
|
||||
<div className="p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 text-xs text-amber-800 dark:text-amber-300">
|
||||
<strong>RPZ-Schwellen:</strong> Kritisch > 200 | Handlungsbedarf > 100 | Beobachten > 50 | Akzeptabel ≤ 50.
|
||||
Massnahmen sind erforderlich ab RPZ > 100.
|
||||
</div>
|
||||
|
||||
{/* FMEA Table */}
|
||||
{rows.length === 0 ? (
|
||||
<div className="text-center py-12 text-gray-500">
|
||||
Keine Failure Modes gefunden. Bitte zuerst Komponenten erfassen.
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full">
|
||||
<thead>
|
||||
<tr className="bg-gray-50 dark:bg-gray-750 border-b border-gray-200 dark:border-gray-700">
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Komponente</th>
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Typ</th>
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Fehlerart</th>
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Auswirkung</th>
|
||||
<th className="px-3 py-2.5 text-center text-xs font-medium text-gray-500 uppercase w-12">S</th>
|
||||
<th className="px-3 py-2.5 text-center text-xs font-medium text-gray-500 uppercase w-12">O</th>
|
||||
<th className="px-3 py-2.5 text-center text-xs font-medium text-gray-500 uppercase w-12">D</th>
|
||||
<th className="px-3 py-2.5 text-center text-xs font-medium text-gray-500 uppercase w-16">RPZ</th>
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Bewertung</th>
|
||||
<th className="px-3 py-2.5 text-left text-xs font-medium text-gray-500 uppercase">Erkennung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200 dark:divide-gray-700">
|
||||
{rows.map((row, idx) => (
|
||||
<FMEATableRow key={`${row.component.id}-${row.failureMode.id}-${idx}`} row={row} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function FMEATableRow({ row }: { row: FMEARow }) {
|
||||
const color = rpzColor(row.rpz)
|
||||
return (
|
||||
<tr className={`hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors ${row.rpz > 100 ? 'bg-red-50/30 dark:bg-red-900/10' : ''}`}>
|
||||
<td className="px-3 py-2.5 text-sm font-medium text-gray-900 dark:text-white">{row.component.name}</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<span className="text-xs px-2 py-0.5 rounded bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300">
|
||||
{COMP_TYPE_LABELS[row.component.component_type] || row.component.component_type}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<div className="text-sm text-gray-900 dark:text-white">{row.failureMode.name_de}</div>
|
||||
<div className="text-[10px] text-gray-400">{row.failureMode.id}</div>
|
||||
</td>
|
||||
<td className="px-3 py-2.5 text-xs text-gray-600 dark:text-gray-400 max-w-[200px] truncate" title={row.failureMode.effect}>
|
||||
{row.failureMode.effect}
|
||||
</td>
|
||||
<td className="px-3 py-2.5 text-sm text-center font-medium text-gray-900 dark:text-white">{row.severity}</td>
|
||||
<td className="px-3 py-2.5 text-sm text-center font-medium text-gray-900 dark:text-white">{row.occurrence}</td>
|
||||
<td className="px-3 py-2.5 text-sm text-center font-medium text-gray-900 dark:text-white">{row.detection}</td>
|
||||
<td className="px-3 py-2.5 text-center">
|
||||
<span className={`inline-flex items-center px-2 py-0.5 rounded-full text-sm font-bold border ${color}`}>
|
||||
{row.rpz}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<span className={`text-xs px-2 py-0.5 rounded-full ${color}`}>{rpzLabel(row.rpz)}</span>
|
||||
</td>
|
||||
<td className="px-3 py-2.5 text-xs text-gray-500 dark:text-gray-400 max-w-[150px] truncate" title={row.failureMode.detection_hint}>
|
||||
{row.failureMode.detection_hint || '-'}
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
function StatCard({ label, value, color }: { label: string; value: number; color: string }) {
|
||||
const colors: Record<string, string> = {
|
||||
gray: 'bg-gray-50 text-gray-700 border-gray-200',
|
||||
red: 'bg-red-50 text-red-700 border-red-200',
|
||||
orange: 'bg-orange-50 text-orange-700 border-orange-200',
|
||||
green: 'bg-green-50 text-green-700 border-green-200',
|
||||
}
|
||||
return (
|
||||
<div className={`rounded-xl border p-4 ${colors[color] || colors.gray}`}>
|
||||
<div className="text-2xl font-bold">{value}</div>
|
||||
<div className="text-xs mt-1">{label}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user