Track product lifecycle through processing stages with automatic CO₂ and distance aggregation.
Entities
ProductTraceability
Field
Type
Description
id
Long
Auto PK
companyProductId
Long
FK to CompanyProduct
totalDistanceKm
Double
Sum of all stage distances (auto-recalculated)
totalCo2Kg
Double
Sum of all stage CO₂ values (auto-recalculated)
status
String
DRAFT, ACTIVE, ARCHIVED
ProcessingStage
Field
Type
Description
id
Long
Auto PK
traceabilityId
Long
FK to ProductTraceability
supplierId
Long
Supplier performing this stage
stageName
String
e.g. Spinning, Dyeing, Cutting
stageOrder
Integer
Sequence position
countryCode
String
ISO alpha-2
distanceKm
Double
Transport from previous stage
co2Kg
Double
CO₂ for this stage
startDate / endDate
LocalDate
Stage date range
Automatic Totals Recalculation
Whenever a ProcessingStage is added, updated, or deleted, ProcessingStageServiceautomatically recalculates the parent ProductTraceability.totalDistanceKm and totalCo2Kg by summing all child stages.