feat(O): UI-Vollständigkeit + v3-Workflows + OCC-Kantenanalyse

Backend:
- Phase I: notification_configs router (GET/PUT/{event}/{channel}/POST reset)
  war bereits in notifications.py — add-alias endpoint in uploads.py ergänzt
- OutputType schema: workflow_definition_id + workflow_name fields;
  PATCH unterstützt Workflow-Zuweisung; _enrich_workflow_names() batch query
- Dispatch-Integration: orders.py dispatch_renders() → dispatch_render_with_workflow()
  mit Legacy-Fallback; neues Logging
- uploads.py: POST /validations/{id}/add-alias für Material-Lücken

Pipeline:
- step_processor.py: extract_mesh_edge_data() via OCC — berechnet Dihedralwinkel
  aller Kanten, liefert suggested_smooth_angle + sharp_edge_midpoints
  Integriert in extract_cad_metadata() und process_cad_file()
- domains/rendering/tasks.py: apply_asset_library_materials_task (K3),
  export_gltf_for_order_line_task → Blender export_gltf.py (K4),
  export_blend_for_order_line_task → export_blend.py fix (K5)
- render-worker/scripts/still_render.py: _mark_sharp_and_seams() mit
  OCC midpoint KD-tree matching + UV-Seam-Markierung
- render-worker/scripts/blender_render.py: identische Funktion + mesh_attributes parsing

Frontend:
- Layout.tsx: Upload-Link in Sidebar (alle User); Asset Libraries Link (admin/PM)
- App.tsx: /asset-libraries Route
- AssetLibrary.tsx: neue Seite (Upload, Catalog-Anzeige, Refresh, Toggle, Delete)
- OutputTypeTable.tsx: Workflow-Dropdown + Legacy/Workflow Badge
- ProductDetail.tsx: Geometry-Karte (Volumen, Surface, BBox, Sharp-Winkel)
- api/outputTypes.ts + api/products.ts: neue Felder
- api/imports.ts: ImportValidation API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 23:20:55 +01:00
parent f15b035b88
commit 382a18fd02
18 changed files with 1222 additions and 355 deletions
+13 -2
View File
@@ -1,4 +1,5 @@
import io
import logging
import os
import re
import uuid
@@ -6,6 +7,8 @@ import zipfile
from datetime import datetime
from typing import Optional
logger = logging.getLogger(__name__)
from fastapi import APIRouter, Depends, HTTPException, Query, status
from fastapi.responses import StreamingResponse
from pydantic import BaseModel
@@ -906,9 +909,17 @@ async def dispatch_renders(
)
await db.commit()
from app.tasks.step_tasks import dispatch_order_line_render
from app.domains.rendering.dispatch_service import dispatch_render_with_workflow
for line in lines:
dispatch_order_line_render.delay(str(line.id))
try:
dispatch_render_with_workflow(str(line.id))
except Exception as exc:
logger.warning(
"dispatch_render_with_workflow failed for %s, falling back: %s",
line.id, exc,
)
from app.tasks.step_tasks import dispatch_order_line_render
dispatch_order_line_render.delay(str(line.id))
return {"dispatched": len(lines), "order_status": order.status.value}
+24 -3
View File
@@ -13,6 +13,7 @@ from app.models.output_type import OutputType, VALID_RENDER_BACKENDS
from app.schemas.output_type import OutputTypeCreate, OutputTypeOut, OutputTypePatch
from app.utils.auth import get_current_user, require_admin_or_pm
from app.models.user import User
from app.domains.rendering.models import WorkflowDefinition
router = APIRouter(prefix="/output-types", tags=["output-types"])
@@ -23,9 +24,26 @@ def _ot_to_out(ot: OutputType) -> OutputTypeOut:
if ot.pricing_tier:
out.pricing_tier_name = f"{ot.pricing_tier.category_key}/{ot.pricing_tier.quality_level}"
out.price_per_item = float(ot.pricing_tier.price_per_item)
# workflow_definition_id is mapped via model_validate from the ORM column.
# workflow_name is resolved by _enrich_workflow_names() after the fact.
return out
async def _enrich_workflow_names(db: AsyncSession, items: list[OutputTypeOut]) -> list[OutputTypeOut]:
"""Resolve workflow_name for any OutputTypeOut that has a workflow_definition_id set."""
wf_ids = {item.workflow_definition_id for item in items if item.workflow_definition_id is not None}
if not wf_ids:
return items
wf_result = await db.execute(
select(WorkflowDefinition).where(WorkflowDefinition.id.in_(wf_ids))
)
wf_map: dict[uuid.UUID, str] = {wf.id: wf.name for wf in wf_result.scalars().all()}
for item in items:
if item.workflow_definition_id is not None:
item.workflow_name = wf_map.get(item.workflow_definition_id)
return items
@router.get("", response_model=list[OutputTypeOut])
async def list_output_types(
include_inactive: bool = Query(False),
@@ -50,7 +68,8 @@ async def list_output_types(
)
)
result = await db.execute(stmt)
return [_ot_to_out(ot) for ot in result.scalars().all()]
items = [_ot_to_out(ot) for ot in result.scalars().all()]
return await _enrich_workflow_names(db, items)
@router.post("", response_model=OutputTypeOut, status_code=status.HTTP_201_CREATED)
@@ -74,7 +93,8 @@ async def create_output_type(
result2 = await db.execute(
select(OutputType).options(selectinload(OutputType.pricing_tier)).where(OutputType.id == ot.id)
)
return _ot_to_out(result2.scalar_one())
items = await _enrich_workflow_names(db, [_ot_to_out(result2.scalar_one())])
return items[0]
@router.patch("/{output_type_id}", response_model=OutputTypeOut)
@@ -101,7 +121,8 @@ async def update_output_type(
result2 = await db.execute(
select(OutputType).options(selectinload(OutputType.pricing_tier)).where(OutputType.id == ot.id)
)
return _ot_to_out(result2.scalar_one())
items = await _enrich_workflow_names(db, [_ot_to_out(result2.scalar_one())])
return items[0]
@router.delete("/{output_type_id}", status_code=status.HTTP_204_NO_CONTENT)
+53
View File
@@ -450,3 +450,56 @@ async def get_import_validation(
if not val:
raise HTTPException(404, detail="Validation not found")
return ImportValidationOut.model_validate(val)
class AddAliasRequest(BaseModel):
part_name: str
material_name: str
@router.post("/validations/{validation_id}/add-alias", status_code=status.HTTP_201_CREATED)
async def add_material_alias_from_validation(
validation_id: uuid.UUID,
body: AddAliasRequest,
db: AsyncSession = Depends(get_db),
user: User = Depends(get_current_user),
):
"""Create a MaterialAlias entry mapping part_name to an existing material.
Requires admin or project_manager role.
"""
from app.utils.auth import require_admin_or_pm
from app.domains.imports.models import ImportValidation
from app.domains.materials.models import Material, MaterialAlias
# Gate to admin/PM
if user.role.value not in ("admin", "project_manager"):
raise HTTPException(status_code=403, detail="Admin or project_manager required")
# Verify the validation exists
val_result = await db.execute(select(ImportValidation).where(ImportValidation.id == validation_id))
if not val_result.scalar_one_or_none():
raise HTTPException(404, detail="Validation not found")
# Find the target material by name
mat_result = await db.execute(select(Material).where(Material.name == body.material_name))
material = mat_result.scalar_one_or_none()
if not material:
raise HTTPException(404, detail=f"Material '{body.material_name}' not found in library")
# Check for duplicate alias (case-insensitive)
from sqlalchemy import func as sql_func
dup_result = await db.execute(
select(MaterialAlias).where(
sql_func.lower(MaterialAlias.alias) == body.part_name.lower()
)
)
existing_alias = dup_result.scalar_one_or_none()
if existing_alias:
raise HTTPException(409, detail=f"Alias '{body.part_name}' already exists")
alias = MaterialAlias(material_id=material.id, alias=body.part_name)
db.add(alias)
await db.commit()
await db.refresh(alias)
return {"id": str(alias.id), "alias": alias.alias, "material_id": str(material.id), "material_name": material.name}