feat(iace): VDA-Format FMEA Excel Export
Build + Deploy / build-admin-compliance (push) Successful in 1m48s
Build + Deploy / build-backend-compliance (push) Successful in 11s
Build + Deploy / build-ai-sdk (push) Successful in 44s
Build + Deploy / build-developer-portal (push) Successful in 11s
Build + Deploy / build-tts (push) Successful in 11s
Build + Deploy / build-document-crawler (push) Successful in 12s
Build + Deploy / build-dsms-gateway (push) Successful in 10s
Build + Deploy / build-dsms-node (push) Successful in 13s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 14s
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 2m36s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 41s
CI / test-python-backend (push) Successful in 37s
CI / test-python-document-crawler (push) Successful in 27s
CI / test-python-dsms-gateway (push) Successful in 22s
CI / validate-canonical-controls (push) Successful in 14s
Build + Deploy / trigger-orca (push) Successful in 2m15s

- GET /projects/:id/fmea/export → xlsx im VDA-Formblatt
- Spalten: Nr, Komponente, Typ, Fehlerart, Fehlerfolge, S, O, D, RPZ, AP, Massnahme
- AP-Zellen farbig: H=rot, M=gelb, L=gruen
- Dependency: github.com/xuri/excelize/v2 (BSD-3-Clause)
- Frontend: "VDA Excel exportieren" Button auf FMEA-Seite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-05-12 09:45:18 +02:00
parent 078f936449
commit 6ce5b4bf41
6 changed files with 257 additions and 9 deletions
@@ -0,0 +1,81 @@
package handlers
import (
"fmt"
"net/http"
"github.com/breakpilot/ai-compliance-sdk/internal/iace"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
// ExportFMEA handles GET /projects/:id/fmea/export
// Returns an xlsx file in VDA FMEA format.
func (h *IACEHandler) ExportFMEA(c *gin.Context) {
projectID, err := uuid.Parse(c.Param("id"))
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid project ID"})
return
}
ctx := c.Request.Context()
project, err := h.store.GetProject(ctx, projectID)
if err != nil || project == nil {
c.JSON(http.StatusNotFound, gin.H{"error": "project not found"})
return
}
// Load components
components, _ := h.store.ListComponents(ctx, projectID)
// Load all failure modes
allFMs := iace.GetFailureModeLibrary()
// Build FMEA rows: each component × matching FMs
var rows []iace.FMEAExportRow
for _, comp := range components {
compType := string(comp.ComponentType)
var compFMs []iace.FailureModeEntry
for _, fm := range allFMs {
if fm.ComponentType == compType {
compFMs = append(compFMs, fm)
}
}
if len(compFMs) == 0 {
// Fallback: mechanical FMs
for _, fm := range allFMs {
if fm.ComponentType == "mechanical" && len(compFMs) < 3 {
compFMs = append(compFMs, fm)
}
}
}
for _, fm := range compFMs {
s, o, d := fm.DefaultSeverity, fm.DefaultOccurrence, fm.DefaultDetection
rows = append(rows, iace.FMEAExportRow{
ComponentName: comp.Name,
ComponentType: compType,
FailureMode: fm.NameDE,
FailureEffect: fm.Effect,
FailureCause: fm.DetectionHint,
Severity: s,
Occurrence: o,
Detection: d,
RPZ: s * o * d,
AP: iace.CalculateAP(s, o, d),
Measure: "",
DetectionHint: fm.DetectionHint,
})
}
}
xlsxBytes, err := iace.GenerateFMEAExcel(project.MachineName, rows)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("Excel generation failed: %v", err)})
return
}
filename := fmt.Sprintf("FMEA-%s.xlsx", project.MachineName)
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
c.Data(http.StatusOK, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", xlsxBytes)
}