From c4d3933061edd339dddc60927f014810fb4b9753 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 21 Mar 2025 16:19:09 +0100 Subject: [PATCH] Add entities for calculations, countries, rates, and nodes Introduced several domain model classes for the application including `CalculationJob` and its related entities, `Country`, `RegionCode`, `ContainerRate`, and `DistanceMatrix`. These classes provide comprehensive data structures for logistics calculations, geographical mappings, and rate management. --- .../model/calculations/CalculationJob.java | 106 +++++++ .../CalculationJobAirfreight.java | 85 +++++ .../calculations/CalculationJobCustom.java | 72 +++++ .../calculations/CalculationJobHandling.java | 70 ++++ .../calculations/CalculationJobInventory.java | 108 +++++++ .../calculations/CalculationJobRisk.java | 48 +++ .../CalculationJobRouteSection.java | 184 +++++++++++ .../calculations/CalculationJobSink.java | 141 +++++++++ .../calculations/CalculationJobState.java | 5 + .../CalculationJobTransportation.java | 117 +++++++ .../CalculationJobTransportationRuleType.java | 5 + .../CalculationJobTransportationType.java | 5 + .../de/avatic/lcc/model/country/Country.java | 70 ++++ .../de/avatic/lcc/model/country/IsoCode.java | 50 +++ .../avatic/lcc/model/country/RegionCode.java | 57 ++++ .../avatic/lcc/model/materials/Material.java | 80 +++++ .../lcc/model/nodes/DistanceMatrix.java | 136 ++++++++ .../lcc/model/nodes/DistanceMatrixState.java | 5 + .../java/de/avatic/lcc/model/nodes/Node.java | 174 ++++++++++ .../lcc/model/nodes/NodePredecessor.java | 35 ++ .../model/nodes/OutboundCountryMapping.java | 33 ++ .../lcc/model/packaging/DimensionUnit.java | 16 + .../avatic/lcc/model/packaging/Packaging.java | 176 +++++++++++ .../model/packaging/PackagingProperty.java | 22 ++ .../packaging/PackagingPropertyType.java | 53 ++++ .../lcc/model/packaging/PackagingType.java | 6 + .../lcc/model/packaging/WeightUnit.java | 19 ++ .../avatic/lcc/model/premisses/Premiss.java | 299 ++++++++++++++++++ .../lcc/model/premisses/PremissRoute.java | 87 +++++ .../lcc/model/premisses/PremissRouteNode.java | 135 ++++++++ .../model/premisses/PremissRouteSection.java | 122 +++++++ .../premisses/PremissRouteSectionType.java | 5 + .../lcc/model/premisses/PremissSink.java | 63 ++++ .../lcc/model/premisses/PremissState.java | 6 + .../lcc/model/properties/CountryProperty.java | 45 +++ .../model/properties/CountryPropertyType.java | 77 +++++ .../model/properties/PropertyDataType.java | 6 + .../lcc/model/properties/PropertySet.java | 30 ++ .../model/properties/PropertySetState.java | 5 + .../lcc/model/properties/SystemProperty.java | 47 +++ .../model/properties/SystemPropertyType.java | 68 ++++ .../avatic/lcc/model/rates/ContainerRate.java | 111 +++++++ .../lcc/model/rates/ContainerRateType.java | 5 + .../lcc/model/rates/CountryMatrixRate.java | 59 ++++ .../lcc/model/rates/ValidityPeriod.java | 33 ++ .../de/avatic/lcc/model/user/SysGroup.java | 23 ++ .../de/avatic/lcc/model/user/SysUser.java | 94 ++++++ .../lcc/model/user/SysUserGroupMapping.java | 35 ++ .../de/avatic/lcc/model/user/SysUserNode.java | 83 +++++ src/main/resources/schema.sql | 220 ++++++------- 50 files changed, 3429 insertions(+), 107 deletions(-) create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJob.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobAirfreight.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobCustom.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobHandling.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobInventory.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobRisk.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobRouteSection.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobSink.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobState.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportation.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationRuleType.java create mode 100644 src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationType.java create mode 100644 src/main/java/de/avatic/lcc/model/country/Country.java create mode 100644 src/main/java/de/avatic/lcc/model/country/IsoCode.java create mode 100644 src/main/java/de/avatic/lcc/model/country/RegionCode.java create mode 100644 src/main/java/de/avatic/lcc/model/materials/Material.java create mode 100644 src/main/java/de/avatic/lcc/model/nodes/DistanceMatrix.java create mode 100644 src/main/java/de/avatic/lcc/model/nodes/DistanceMatrixState.java create mode 100644 src/main/java/de/avatic/lcc/model/nodes/Node.java create mode 100644 src/main/java/de/avatic/lcc/model/nodes/NodePredecessor.java create mode 100644 src/main/java/de/avatic/lcc/model/nodes/OutboundCountryMapping.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/DimensionUnit.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/Packaging.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/PackagingProperty.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/PackagingPropertyType.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/PackagingType.java create mode 100644 src/main/java/de/avatic/lcc/model/packaging/WeightUnit.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/Premiss.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissRoute.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissRouteNode.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissRouteSection.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissRouteSectionType.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissSink.java create mode 100644 src/main/java/de/avatic/lcc/model/premisses/PremissState.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/CountryProperty.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/CountryPropertyType.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/PropertyDataType.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/PropertySet.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/PropertySetState.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/SystemProperty.java create mode 100644 src/main/java/de/avatic/lcc/model/properties/SystemPropertyType.java create mode 100644 src/main/java/de/avatic/lcc/model/rates/ContainerRate.java create mode 100644 src/main/java/de/avatic/lcc/model/rates/ContainerRateType.java create mode 100644 src/main/java/de/avatic/lcc/model/rates/CountryMatrixRate.java create mode 100644 src/main/java/de/avatic/lcc/model/rates/ValidityPeriod.java create mode 100644 src/main/java/de/avatic/lcc/model/user/SysGroup.java create mode 100644 src/main/java/de/avatic/lcc/model/user/SysUser.java create mode 100644 src/main/java/de/avatic/lcc/model/user/SysUserGroupMapping.java create mode 100644 src/main/java/de/avatic/lcc/model/user/SysUserNode.java diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJob.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJob.java new file mode 100644 index 0000000..3487a0d --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJob.java @@ -0,0 +1,106 @@ +package de.avatic.lcc.model.calculations; + +import de.avatic.lcc.model.premisses.Premiss; +import de.avatic.lcc.model.properties.PropertySet; +import de.avatic.lcc.model.user.SysUser; +import de.avatic.lcc.model.rates.ValidityPeriod; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.time.OffsetDateTime; +import java.util.Set; + + +@Table(name = "calculation_job") +public class CalculationJob { + + @Id + private Integer id; + + @NotNull + private OffsetDateTime calculationDate; + + private CalculationJobState jobState; + + @NotNull + private AggregateReference premiss; + + @NotNull + private AggregateReference validityPeriod; + + @NotNull + private AggregateReference propertySet; + + @NotNull + private AggregateReference user; + + @MappedCollection(idColumn = "calculation_job_id") + private Set sinks; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public OffsetDateTime getCalculationDate() { + return calculationDate; + } + + public void setCalculationDate(OffsetDateTime calculationDate) { + this.calculationDate = calculationDate; + } + + public CalculationJobState getJobState() { + return jobState; + } + + public void setJobState(CalculationJobState jobState) { + this.jobState = jobState; + } + + public AggregateReference getPremiss() { + return premiss; + } + + public void setPremiss(AggregateReference premiss) { + this.premiss = premiss; + } + + public AggregateReference getValidityPeriod() { + return validityPeriod; + } + + public void setValidityPeriod(AggregateReference validityPeriod) { + this.validityPeriod = validityPeriod; + } + + public AggregateReference getPropertySet() { + return propertySet; + } + + public void setPropertySet(AggregateReference propertySet) { + this.propertySet = propertySet; + } + + public AggregateReference getUser() { + return user; + } + + public void setUser(AggregateReference user) { + this.user = user; + } + + public Set getSinks() { + return sinks; + } + + public void setSinks(Set sinks) { + this.sinks = sinks; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobAirfreight.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobAirfreight.java new file mode 100644 index 0000000..39421f1 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobAirfreight.java @@ -0,0 +1,85 @@ +package de.avatic.lcc.model.calculations; + + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_airfreight") +public class CalculationJobAirfreight { + + @Id + private Integer id; + + @NotNull + @Digits(integer = 7, fraction = 4) + private BigDecimal airFreightShareMax; + + @NotNull + @Digits(integer = 7, fraction = 4) + private BigDecimal airFreightShare; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal airFreightVolumetricWeight; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal airFreightWeight; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualCost; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getAirFreightShareMax() { + return airFreightShareMax; + } + + public void setAirFreightShareMax(BigDecimal airFreightShareMax) { + this.airFreightShareMax = airFreightShareMax; + } + + public BigDecimal getAirFreightShare() { + return airFreightShare; + } + + public void setAirFreightShare(BigDecimal airFreightShare) { + this.airFreightShare = airFreightShare; + } + + public BigDecimal getAirFreightVolumetricWeight() { + return airFreightVolumetricWeight; + } + + public void setAirFreightVolumetricWeight(BigDecimal airFreightVolumetricWeight) { + this.airFreightVolumetricWeight = airFreightVolumetricWeight; + } + + public BigDecimal getAirFreightWeight() { + return airFreightWeight; + } + + public void setAirFreightWeight(BigDecimal airFreightWeight) { + this.airFreightWeight = airFreightWeight; + } + + public BigDecimal getAnnualCost() { + return annualCost; + } + + public void setAnnualCost(BigDecimal annualCost) { + this.annualCost = annualCost; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobCustom.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobCustom.java new file mode 100644 index 0000000..a402195 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobCustom.java @@ -0,0 +1,72 @@ +package de.avatic.lcc.model.calculations; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_custom") +public class CalculationJobCustom { + + @Id + private Integer id; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal customValue; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal customDuties; + + @NotNull + @Digits(integer = 7, fraction = 4) + private BigDecimal customRate; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualCost; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getCustomValue() { + return customValue; + } + + public void setCustomValue(BigDecimal customValue) { + this.customValue = customValue; + } + + public BigDecimal getCustomDuties() { + return customDuties; + } + + public void setCustomDuties(BigDecimal customDuties) { + this.customDuties = customDuties; + } + + public BigDecimal getCustomRate() { + return customRate; + } + + public void setCustomRate(BigDecimal customRate) { + this.customRate = customRate; + } + + public BigDecimal getAnnualCost() { + return annualCost; + } + + public void setAnnualCost(BigDecimal annualCost) { + this.annualCost = annualCost; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobHandling.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobHandling.java new file mode 100644 index 0000000..50d699b --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobHandling.java @@ -0,0 +1,70 @@ +package de.avatic.lcc.model.calculations; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_handling") +public class CalculationJobHandling { + + @Id + private Integer id; + + private Boolean isSmallUnit; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualRepackingCost; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualHandlingCost; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualDisposalCost; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Boolean getSmallUnit() { + return isSmallUnit; + } + + public void setSmallUnit(Boolean smallUnit) { + isSmallUnit = smallUnit; + } + + public BigDecimal getAnnualRepackingCost() { + return annualRepackingCost; + } + + public void setAnnualRepackingCost(BigDecimal annualRepackingCost) { + this.annualRepackingCost = annualRepackingCost; + } + + public BigDecimal getAnnualHandlingCost() { + return annualHandlingCost; + } + + public void setAnnualHandlingCost(BigDecimal annualHandlingCost) { + this.annualHandlingCost = annualHandlingCost; + } + + public BigDecimal getAnnualDisposalCost() { + return annualDisposalCost; + } + + public void setAnnualDisposalCost(BigDecimal annualDisposalCost) { + this.annualDisposalCost = annualDisposalCost; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobInventory.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobInventory.java new file mode 100644 index 0000000..89a5232 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobInventory.java @@ -0,0 +1,108 @@ +package de.avatic.lcc.model.calculations; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_inventory") +public class CalculationJobInventory { + + @Id + private Integer id; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal operationalStock; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal safetyStock; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal stockedInventory; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal inTransportStock; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal stockBeforePayment; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualCapitalCost; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualStorageCost; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getOperationalStock() { + return operationalStock; + } + + public void setOperationalStock(BigDecimal operationalStock) { + this.operationalStock = operationalStock; + } + + public BigDecimal getSafetyStock() { + return safetyStock; + } + + public void setSafetyStock(BigDecimal safetyStock) { + this.safetyStock = safetyStock; + } + + public BigDecimal getStockedInventory() { + return stockedInventory; + } + + public void setStockedInventory(BigDecimal stockedInventory) { + this.stockedInventory = stockedInventory; + } + + public BigDecimal getInTransportStock() { + return inTransportStock; + } + + public void setInTransportStock(BigDecimal inTransportStock) { + this.inTransportStock = inTransportStock; + } + + public BigDecimal getStockBeforePayment() { + return stockBeforePayment; + } + + public void setStockBeforePayment(BigDecimal stockBeforePayment) { + this.stockBeforePayment = stockBeforePayment; + } + + public BigDecimal getAnnualCapitalCost() { + return annualCapitalCost; + } + + public void setAnnualCapitalCost(BigDecimal annualCapitalCost) { + this.annualCapitalCost = annualCapitalCost; + } + + public BigDecimal getAnnualStorageCost() { + return annualStorageCost; + } + + public void setAnnualStorageCost(BigDecimal annualStorageCost) { + this.annualStorageCost = annualStorageCost; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRisk.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRisk.java new file mode 100644 index 0000000..55fe8ca --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRisk.java @@ -0,0 +1,48 @@ +package de.avatic.lcc.model.calculations; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_risk") +public class CalculationJobRisk { + + @Id + private Integer id; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualRiskCost; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualChanceCost; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getAnnualRiskCost() { + return annualRiskCost; + } + + public void setAnnualRiskCost(BigDecimal annualRiskCost) { + this.annualRiskCost = annualRiskCost; + } + + public BigDecimal getAnnualChanceCost() { + return annualChanceCost; + } + + public void setAnnualChanceCost(BigDecimal annualChanceCost) { + this.annualChanceCost = annualChanceCost; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRouteSection.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRouteSection.java new file mode 100644 index 0000000..8b714ba --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobRouteSection.java @@ -0,0 +1,184 @@ + package de.avatic.lcc.model.calculations; + +import de.avatic.lcc.model.premisses.PremissRouteSection; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_route_section") +public class CalculationJobRouteSection { + + @Id + private Integer id; + + private CalculationJobTransportationRuleType usedRule; + + private Boolean isUnmixedPrice; + + private Boolean isCbmPrice; + + private Boolean isWeightPrice; + + private Boolean isStacked; + + private Boolean isPreRun; + + private Boolean isMainRun; + + private Boolean isPostRun; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal rate; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal distance; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal cbmPrice; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal weightPrice; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualCost; + + @NotNull + @Digits(integer = 15, fraction = 2) + private Integer transitTime; + + @NotNull + private AggregateReference premissRouteSection; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public CalculationJobTransportationRuleType getUsedRule() { + return usedRule; + } + + public void setUsedRule(CalculationJobTransportationRuleType usedRule) { + this.usedRule = usedRule; + } + + public Boolean getUnmixedPrice() { + return isUnmixedPrice; + } + + public void setUnmixedPrice(Boolean unmixedPrice) { + isUnmixedPrice = unmixedPrice; + } + + public Boolean getCbmPrice() { + return isCbmPrice; + } + + public void setCbmPrice(BigDecimal cbmPrice) { + this.cbmPrice = cbmPrice; + } + + public void setCbmPrice(Boolean cbmPrice) { + isCbmPrice = cbmPrice; + } + + public Boolean getWeightPrice() { + return isWeightPrice; + } + + public void setWeightPrice(BigDecimal weightPrice) { + this.weightPrice = weightPrice; + } + + public BigDecimal getAnnualCost() { + return annualCost; + } + + public void setAnnualCost(BigDecimal annualCost) { + this.annualCost = annualCost; + } + + public Integer getTransitTime() { + return transitTime; + } + + public void setTransitTime(Integer transitTime) { + this.transitTime = transitTime; + } + + public AggregateReference getPremissRouteSection() { + return premissRouteSection; + } + + public void setPremissRouteSection(AggregateReference premissRouteSection) { + this.premissRouteSection = premissRouteSection; + } + + public void setWeightPrice(Boolean weightPrice) { + isWeightPrice = weightPrice; + } + + public Boolean getStacked() { + return isStacked; + } + + public void setStacked(Boolean stacked) { + isStacked = stacked; + } + + public Boolean getPreRun() { + return isPreRun; + } + + public void setPreRun(Boolean preRun) { + isPreRun = preRun; + } + + public Boolean getMainRun() { + return isMainRun; + } + + public void setMainRun(Boolean mainRun) { + isMainRun = mainRun; + } + + public Boolean getPostRun() { + return isPostRun; + } + + public void setPostRun(Boolean postRun) { + isPostRun = postRun; + } + + public BigDecimal getRate() { + return rate; + } + + public void setRate(BigDecimal rate) { + this.rate = rate; + } + + public BigDecimal getDistance() { + return distance; + } + + public void setDistance(BigDecimal distance) { + this.distance = distance; + } + + + +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobSink.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobSink.java new file mode 100644 index 0000000..921f897 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobSink.java @@ -0,0 +1,141 @@ +package de.avatic.lcc.model.calculations; + +import de.avatic.lcc.model.premisses.PremissSink; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "calculation_job_sink") +public class CalculationJobSink { + + @Id + private Integer id; + + @Unsigned + private Integer safetyStock; + + @Unsigned + private Integer shippingFrequency; + + @Digits(integer = 15, fraction = 2) + private BigDecimal totalCost; + + @NotNull + private AggregateReference premissSink; + + @MappedCollection + + @Column("calculation_job_transportation_id") + private CalculationJobTransportation transportation; + + @Column("calculation_job_airfreight_id") + private CalculationJobAirfreight airfreight; + + @Column("calculation_job_custom_id") + private CalculationJobCustom custom; + + @Column("calculation_job_inventory_id") + private CalculationJobInventory inventory; + + @Column("calculation_job_handling_id") + private CalculationJobHandling handling; + + @Column("calculation_job_risk_id") + private CalculationJobRisk risk; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getSafetyStock() { + return safetyStock; + } + + public void setSafetyStock(Integer safetyStock) { + this.safetyStock = safetyStock; + } + + public Integer getShippingFrequency() { + return shippingFrequency; + } + + public void setShippingFrequency(Integer shippingFrequency) { + this.shippingFrequency = shippingFrequency; + } + + public BigDecimal getTotalCost() { + return totalCost; + } + + public void setTotalCost(BigDecimal totalCost) { + this.totalCost = totalCost; + } + + public AggregateReference getPremissSink() { + return premissSink; + } + + public void setPremissSink(AggregateReference premissSink) { + this.premissSink = premissSink; + } + + public CalculationJobTransportation getTransportation() { + return transportation; + } + + public void setTransportation(CalculationJobTransportation transportation) { + this.transportation = transportation; + } + + public CalculationJobAirfreight getAirfreight() { + return airfreight; + } + + public void setAirfreight(CalculationJobAirfreight airfreight) { + this.airfreight = airfreight; + } + + public CalculationJobCustom getCustom() { + return custom; + } + + public void setCustom(CalculationJobCustom custom) { + this.custom = custom; + } + + public CalculationJobInventory getInventory() { + return inventory; + } + + public void setInventory(CalculationJobInventory inventory) { + this.inventory = inventory; + } + + public CalculationJobHandling getHandling() { + return handling; + } + + public void setHandling(CalculationJobHandling handling) { + this.handling = handling; + } + + public CalculationJobRisk getRisk() { + return risk; + } + + public void setRisk(CalculationJobRisk risk) { + this.risk = risk; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobState.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobState.java new file mode 100644 index 0000000..17cb276 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobState.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.calculations; + +public enum CalculationJobState { + CREATED, SCHEDULED, VALID, INVALIDATED, EXCEPTION +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportation.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportation.java new file mode 100644 index 0000000..9976029 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportation.java @@ -0,0 +1,117 @@ +package de.avatic.lcc.model.calculations; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; +import java.util.Set; + + +@Table(name = "calculation_job_transportation") +public class CalculationJobTransportation { + + @Id + private Integer id; + + private CalculationJobTransportationType transportationType; + + @Unsigned + @NotNull + private Integer huPerLayer; + + @NotNull + private String layerStructure; + + @Unsigned + @NotNull + private Integer layerCount; + + private Boolean transportWeightExceeded; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal transportsPerYear; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal annualCost; + + @MappedCollection(idColumn = "calculation_job_transportation_id") + private Set sections; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public CalculationJobTransportationType getTransportationType() { + return transportationType; + } + + public void setTransportationType(CalculationJobTransportationType transportationType) { + this.transportationType = transportationType; + } + + public Integer getHuPerLayer() { + return huPerLayer; + } + + public void setHuPerLayer(Integer huPerLayer) { + this.huPerLayer = huPerLayer; + } + + public String getLayerStructure() { + return layerStructure; + } + + public void setLayerStructure(String layerStructure) { + this.layerStructure = layerStructure; + } + + public Integer getLayerCount() { + return layerCount; + } + + public void setLayerCount(Integer layerCount) { + this.layerCount = layerCount; + } + + public Boolean getTransportWeightExceeded() { + return transportWeightExceeded; + } + + public void setTransportWeightExceeded(Boolean transportWeightExceeded) { + this.transportWeightExceeded = transportWeightExceeded; + } + + public BigDecimal getTransportsPerYear() { + return transportsPerYear; + } + + public void setTransportsPerYear(BigDecimal transportsPerYear) { + this.transportsPerYear = transportsPerYear; + } + + public BigDecimal getAnnualCost() { + return annualCost; + } + + public void setAnnualCost(BigDecimal annualCost) { + this.annualCost = annualCost; + } + + public Set getSections() { + return sections; + } + + public void setSections(Set sections) { + this.sections = sections; + } +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationRuleType.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationRuleType.java new file mode 100644 index 0000000..9dac908 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationRuleType.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.calculations; + +public enum CalculationJobTransportationRuleType { + CONTAINER, MATRIX +} diff --git a/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationType.java b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationType.java new file mode 100644 index 0000000..6f0e47e --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/calculations/CalculationJobTransportationType.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.calculations; + +public enum CalculationJobTransportationType { + TEU, FEU, HC, TRUCK +} diff --git a/src/main/java/de/avatic/lcc/model/country/Country.java b/src/main/java/de/avatic/lcc/model/country/Country.java new file mode 100644 index 0000000..86e43ef --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/country/Country.java @@ -0,0 +1,70 @@ +package de.avatic.lcc.model.country; + + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table("country") +public class Country { + + @Id + private Integer id; + + @NotNull + @Size(max=2) + private IsoCode isoCode; + + @NotNull + @Size(max=5) + private RegionCode regionCode; + + @NotNull + @Size(max=128) + private String name; + + @NotNull + private Boolean isDeprecated; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public IsoCode getIsoCode() { + return isoCode; + } + + public void setIsoCode(IsoCode isoCode) { + this.isoCode = isoCode; + } + + public RegionCode getRegionCode() { + return regionCode; + } + + public void setRegionCode(RegionCode regionCode) { + this.regionCode = regionCode; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getDeprecated() { + return isDeprecated; + } + + public void setDeprecated(Boolean deprecated) { + isDeprecated = deprecated; + } +} diff --git a/src/main/java/de/avatic/lcc/model/country/IsoCode.java b/src/main/java/de/avatic/lcc/model/country/IsoCode.java new file mode 100644 index 0000000..340fc57 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/country/IsoCode.java @@ -0,0 +1,50 @@ +package de.avatic.lcc.model.country; + +/** + * Represents ISO 3166-1 Alpha-2 country codes. + * These codes consist of two letters and uniquely identify a country or territory. + */ + +public enum IsoCode { + AD, AE, AF, AG, AI, AL, AM, AO, AQ, AR, AS, AT, AU, AW, AX, AZ, + BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BR, BS, BT, BV, BW, BY, BZ, + CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, + DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FM, FO, FR, + GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GU, GW, GY, + HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, + KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, + MA, MC, MD, ME, MF, MG, MH, MK, ML, MM, MN, MO, MP, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, + NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PR, PS, PT, PW, PY, + QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, + TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, + VA, VC, VE, VG, VI, VN, VU, WF, WS, YE, YT, ZA, ZM, ZW; + + /** + * Converts a string to the corresponding IsoCode enum value. + * + * @param code The ISO code as a string + * @return The corresponding enum value + * @throws IllegalArgumentException if the specified code is invalid + */ + + public static IsoCode fromString(String code) { + if (code != null) { + try { + return valueOf(code.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Ungültiger ISO-Code: " + code, e); + } + } + throw new IllegalArgumentException("ISO-Code darf nicht null sein"); + } + + /** + * Returns the ISO code as a string. + * + * @return The ISO code as a string + */ + + public String getCode() { + return name(); + } +} \ No newline at end of file diff --git a/src/main/java/de/avatic/lcc/model/country/RegionCode.java b/src/main/java/de/avatic/lcc/model/country/RegionCode.java new file mode 100644 index 0000000..0d5579f --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/country/RegionCode.java @@ -0,0 +1,57 @@ +package de.avatic.lcc.model.country; + +/** + * Repräsentiert die geografischen Regionen für Länderklassifizierungen. + * EMEA - Europa, Mittlerer Osten und Afrika + * APAC - Asien und Pazifikraum + * LATAM - Lateinamerika + * NAM - Nordamerika + */ +public enum RegionCode { + EMEA("Europa, Mittlerer Osten und Afrika"), + APAC("Asien und Pazifikraum"), + LATAM("Lateinamerika"), + NAM("Nordamerika"); + + private final String beschreibung; + + RegionCode(String beschreibung) { + this.beschreibung = beschreibung; + } + + /** + * Gibt die Beschreibung der Region zurück. + * + * @return Die ausführliche Beschreibung der Region + */ + public String getBeschreibung() { + return beschreibung; + } + + /** + * Konvertiert einen String in den entsprechenden RegionCode Enum-Wert. + * + * @param code Der Regions-Code als String + * @return Der entsprechende Enum-Wert + * @throws IllegalArgumentException wenn der angegebene Code ungültig ist + */ + public static RegionCode fromString(String code) { + if (code != null) { + try { + return valueOf(code.toUpperCase()); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Ungültiger Regions-Code: " + code, e); + } + } + throw new IllegalArgumentException("Regions-Code darf nicht null sein"); + } + + /** + * Gibt den Regions-Code als String zurück. + * + * @return Der Regions-Code als String + */ + public String getCode() { + return name(); + } +} \ No newline at end of file diff --git a/src/main/java/de/avatic/lcc/model/materials/Material.java b/src/main/java/de/avatic/lcc/model/materials/Material.java new file mode 100644 index 0000000..fe270f1 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/materials/Material.java @@ -0,0 +1,80 @@ +package de.avatic.lcc.model.materials; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table("material") +public class Material { + + @Id + private Integer id; + + @NotNull + @Size(max = 12) + private String partNumber; + + @NotNull + @Size(max = 12) + private String normalizedPartNumber; + + @Size(max = 8) + private String hsCode; + + @NotNull + @Size(max = 500) + private String name; + + @NotNull + private Boolean isDeprecated; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } + + public String getNormalizedPartNumber() { + return normalizedPartNumber; + } + + public void setNormalizedPartNumber(String normalizedPartNumber) { + this.normalizedPartNumber = normalizedPartNumber; + } + + public String getHsCode() { + return hsCode; + } + + public void setHsCode(String hsCode) { + this.hsCode = hsCode; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getDeprecated() { + return isDeprecated; + } + + public void setDeprecated(Boolean deprecated) { + isDeprecated = deprecated; + } +} diff --git a/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrix.java b/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrix.java new file mode 100644 index 0000000..7687764 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrix.java @@ -0,0 +1,136 @@ +package de.avatic.lcc.model.nodes; + + +import jakarta.validation.constraints.*; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; + + +@Table(name = "distance_matrix") +public class DistanceMatrix { + + @Id + private Integer id; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-90.0000") + @DecimalMax("90.0000") + private BigDecimal fromGeoLat; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-180.0000") + @DecimalMax("180.0000") + private BigDecimal fromGeoLng; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-90.0000") + @DecimalMax("90.0000") + private BigDecimal toGeoLat; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-180.0000") + @DecimalMax("180.0000") + private BigDecimal toGeoLng; + + @Digits(integer = 15, fraction = 2) + @NotNull + private BigDecimal distance; + + private OffsetDateTime updatedAt; + + @Size(max = 10) + private String state; + + @NotNull + @Column("from_node_id") + private AggregateReference fromNode; + + @NotNull + @Column("to_node_id") + private AggregateReference toNode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getFromGeoLat() { + return fromGeoLat; + } + + public void setFromGeoLat(BigDecimal fromGeoLat) { + this.fromGeoLat = fromGeoLat; + } + + public BigDecimal getFromGeoLng() { + return fromGeoLng; + } + + public void setFromGeoLng(BigDecimal fromGeoLng) { + this.fromGeoLng = fromGeoLng; + } + + public BigDecimal getToGeoLat() { + return toGeoLat; + } + + public void setToGeoLat(BigDecimal toGeoLat) { + this.toGeoLat = toGeoLat; + } + + public BigDecimal getToGeoLng() { + return toGeoLng; + } + + public void setToGeoLng(BigDecimal toGeoLng) { + this.toGeoLng = toGeoLng; + } + + public BigDecimal getDistance() { + return distance; + } + + public void setDistance(BigDecimal distance) { + this.distance = distance; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public AggregateReference getFromNode() { + return fromNode; + } + + public void setFromNode(AggregateReference fromNode) { + this.fromNode = fromNode; + } + + public AggregateReference getToNode() { + return toNode; + } + + public void setToNode(AggregateReference toNode) { + this.toNode = toNode; + } +} diff --git a/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrixState.java b/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrixState.java new file mode 100644 index 0000000..943fe36 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/nodes/DistanceMatrixState.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.nodes; + +public enum DistanceMatrixState { + VALID, STALE +} diff --git a/src/main/java/de/avatic/lcc/model/nodes/Node.java b/src/main/java/de/avatic/lcc/model/nodes/Node.java new file mode 100644 index 0000000..22f4d5f --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/nodes/Node.java @@ -0,0 +1,174 @@ +package de.avatic.lcc.model.nodes; + +import de.avatic.lcc.model.country.Country; +import jakarta.validation.constraints.*; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Set; + + +@Table(name = "node") +public class Node { + + @Id + private Integer id; + + @NotNull + @Size(max = 255) + private String name; + + @NotNull + @Size(max = 500) + private String address; + + @Size(max = 32) + private String externalMappingId; + + @NotNull + private Boolean predecessorRequired; + + private Boolean isSink; + + private Boolean isSource; + + private Boolean isIntermediate; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-90.0000") + @DecimalMax("90.0000") + private BigDecimal geoLat; + + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-180.0000") + @DecimalMax("180.0000") + private BigDecimal geoLng; + + @NotNull + private OffsetDateTime updatedAt; + + @NotNull + private Boolean isDeprecated; + + @Column("country_id") + @NotNull + private AggregateReference country; + + @MappedCollection(idColumn = "node_id", keyColumn = "sequence_number") + private List nodePredecessors; + + @MappedCollection(idColumn = "node_id") + private Set outboundCountryMapping; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getExternalMappingId() { + return externalMappingId; + } + + public void setExternalMappingId(String externalMappingId) { + this.externalMappingId = externalMappingId; + } + + public Boolean getPredecessorRequired() { + return predecessorRequired; + } + + public void setPredecessorRequired(Boolean predecessorRequired) { + this.predecessorRequired = predecessorRequired; + } + + public Boolean getSink() { + return isSink; + } + + public void setSink(Boolean sink) { + isSink = sink; + } + + public Boolean getSource() { + return isSource; + } + + public void setSource(Boolean source) { + isSource = source; + } + + public Boolean getIntermediate() { + return isIntermediate; + } + + public void setIntermediate(Boolean intermediate) { + isIntermediate = intermediate; + } + + public BigDecimal getGeoLat() { + return geoLat; + } + + public void setGeoLat(BigDecimal geoLat) { + this.geoLat = geoLat; + } + + public BigDecimal getGeoLng() { + return geoLng; + } + + public void setGeoLng(BigDecimal geoLng) { + this.geoLng = geoLng; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public Boolean getDeprecated() { + return isDeprecated; + } + + public void setDeprecated(Boolean deprecated) { + isDeprecated = deprecated; + } + + public AggregateReference getCountry() { + return country; + } + + public void setCountry(AggregateReference country) { + this.country = country; + } +} diff --git a/src/main/java/de/avatic/lcc/model/nodes/NodePredecessor.java b/src/main/java/de/avatic/lcc/model/nodes/NodePredecessor.java new file mode 100644 index 0000000..f6949ca --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/nodes/NodePredecessor.java @@ -0,0 +1,35 @@ +package de.avatic.lcc.model.nodes; + + +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +@Table(name = "node_predecessor") +public class NodePredecessor { + + @Id + private Integer id; + + @NotNull + @Column("predecessor_node_id") + private AggregateReference predecessorNode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public AggregateReference getPredecessorNode() { + return predecessorNode; + } + + public void setPredecessorNode(AggregateReference predecessorNode) { + this.predecessorNode = predecessorNode; + } +} diff --git a/src/main/java/de/avatic/lcc/model/nodes/OutboundCountryMapping.java b/src/main/java/de/avatic/lcc/model/nodes/OutboundCountryMapping.java new file mode 100644 index 0000000..9216daf --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/nodes/OutboundCountryMapping.java @@ -0,0 +1,33 @@ +package de.avatic.lcc.model.nodes; + +import de.avatic.lcc.model.country.Country; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table(name = "outbound_country_mapping") +public class OutboundCountryMapping { + + @Id + private Integer id; + + @NotNull + private Country country; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country = country; + } +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/DimensionUnit.java b/src/main/java/de/avatic/lcc/model/packaging/DimensionUnit.java new file mode 100644 index 0000000..53e2275 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/DimensionUnit.java @@ -0,0 +1,16 @@ +package de.avatic.lcc.model.packaging; + + +/** + * Represents the supported dimensional units in the system. + * This enum is used to specify the unit of measurement for dimensions + * in packaging-related classes and operations. + *

+ * The supported dimensional units are: + * - M: Meters + * - CM: Centimeters + * - MM: Millimeters + */ +public enum DimensionUnit { + M, CM, MM +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/Packaging.java b/src/main/java/de/avatic/lcc/model/packaging/Packaging.java new file mode 100644 index 0000000..462b40a --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/Packaging.java @@ -0,0 +1,176 @@ +package de.avatic.lcc.model.packaging; + +import de.avatic.lcc.model.materials.Material; +import de.avatic.lcc.model.nodes.Node; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.util.Set; + + +/** + * Represents a packaging entity in the system. This class defines various + * attributes related to a packaging, including its dimensions, weight, type, + * and associations with other entities such as material and supplier nodes. + * It is used to manage packaging details in the application. + * + * The packaging entity contains details about its size, weight, and content, + * as well as its hierarchical relationship with other packaging or a parent + * packaging. + */ +@Table(name = "packaging") +public class Packaging { + + @Id + private Integer id; + + @NotNull + @Size(max = 3) + private PackagingType type; + + @Unsigned + @NotNull + private Integer length; + + @Unsigned + @NotNull + private Integer width; + + @Unsigned + @NotNull + private Integer height; + + @NotNull + private DimensionUnit displayedDimensionUnit; + + @NotNull + private Integer weight; + + @NotNull + private WeightUnit displayedWeightUnit; + + @NotNull + private Integer contentUnitCount; + + private Boolean isDeprecated; + + @NotNull + private AggregateReference supplierNode; + + @NotNull + private AggregateReference material; + + private AggregateReference parent; + + @MappedCollection(idColumn = "packaging_id") + private Set properties; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public PackagingType getType() { + return type; + } + + public void setType(PackagingType type) { + this.type = type; + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public DimensionUnit getDisplayedDimensionUnit() { + return displayedDimensionUnit; + } + + public void setDisplayedDimensionUnit(DimensionUnit displayedDimensionUnit) { + this.displayedDimensionUnit = displayedDimensionUnit; + } + + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + public WeightUnit getDisplayedWeightUnit() { + return displayedWeightUnit; + } + + public void setDisplayedWeightUnit(WeightUnit displayedWeightUnit) { + this.displayedWeightUnit = displayedWeightUnit; + } + + public Integer getContentUnitCount() { + return contentUnitCount; + } + + public void setContentUnitCount(Integer contentUnitCount) { + this.contentUnitCount = contentUnitCount; + } + + public Boolean getDeprecated() { + return isDeprecated; + } + + public void setDeprecated(Boolean deprecated) { + isDeprecated = deprecated; + } + + public AggregateReference getSupplierNode() { + return supplierNode; + } + + public void setSupplierNode(AggregateReference supplierNode) { + this.supplierNode = supplierNode; + } + + public AggregateReference getMaterial() { + return material; + } + + public void setMaterial(AggregateReference material) { + this.material = material; + } + + public AggregateReference getParent() { + return parent; + } + + public void setParent(AggregateReference parent) { + this.parent = parent; + } +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/PackagingProperty.java b/src/main/java/de/avatic/lcc/model/packaging/PackagingProperty.java new file mode 100644 index 0000000..5538ca5 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/PackagingProperty.java @@ -0,0 +1,22 @@ +package de.avatic.lcc.model.packaging; + + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Table; + +@Table(name = "packaging_property") +public class PackagingProperty { + + @Id + private Integer id; + + @Size(max = 500) + private String propertyValue; + + @NotNull + private AggregateReference packagingPropertyType; + +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/PackagingPropertyType.java b/src/main/java/de/avatic/lcc/model/packaging/PackagingPropertyType.java new file mode 100644 index 0000000..8e00ae6 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/PackagingPropertyType.java @@ -0,0 +1,53 @@ +package de.avatic.lcc.model.packaging; + + +import de.avatic.lcc.model.properties.PropertyDataType; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +/** + * Represents the type of a property used in packaging. + * This includes details such as its name, data type, validation rules, and whether the property is required. + */ +@Table("packaging_property_type") +public class PackagingPropertyType { + + @Id + /** + * Unique identifier for the packaging property type. + */ + private Integer id; + + @NotNull + @Size(max = 255) + /** + * Name of the property type. + * Must not be null and must not exceed 255 characters. + */ + private String name; + + @Size(max = 16) + /** + * The data type of the property, defining the kind of value it holds. + * Must not exceed 16 characters. + */ + private PropertyDataType dataType; + + @Size(max = 64) + /** + * Optional validation rule specifying restrictions or patterns for this property type. + * Must not exceed 64 characters. + */ + private String validationRule; + + @NotNull + /** + * Indicates whether the property is mandatory (true) or optional (false). + * Must not be null. + */ + private Boolean isRequired; + +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/PackagingType.java b/src/main/java/de/avatic/lcc/model/packaging/PackagingType.java new file mode 100644 index 0000000..9d3144e --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/PackagingType.java @@ -0,0 +1,6 @@ +package de.avatic.lcc.model.packaging; + + +public enum PackagingType { + SHU, HU +} diff --git a/src/main/java/de/avatic/lcc/model/packaging/WeightUnit.java b/src/main/java/de/avatic/lcc/model/packaging/WeightUnit.java new file mode 100644 index 0000000..cbe00c6 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/packaging/WeightUnit.java @@ -0,0 +1,19 @@ +package de.avatic.lcc.model.packaging; + + +/** + * Represents the supported units of weight measurement in the system. + * This enum is utilized to specify the weight unit for various entities + * such as packaging and related operations. + *

+ * The supported weight units are: + * - T: Tons + * - KG: Kilograms + * - G: Grams + */ +public enum WeightUnit { + T, + KG, + G + +} \ No newline at end of file diff --git a/src/main/java/de/avatic/lcc/model/premisses/Premiss.java b/src/main/java/de/avatic/lcc/model/premisses/Premiss.java new file mode 100644 index 0000000..f70fa65 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/Premiss.java @@ -0,0 +1,299 @@ +package de.avatic.lcc.model.premisses; + +import de.avatic.lcc.model.materials.Material; +import de.avatic.lcc.model.nodes.Node; +import de.avatic.lcc.model.packaging.DimensionUnit; +import de.avatic.lcc.model.packaging.Packaging; +import de.avatic.lcc.model.packaging.WeightUnit; +import de.avatic.lcc.model.user.SysUser; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.Set; + + +@Table(name = "premiss") +public class Premiss { + + @Id + private Integer id; + + private OffsetDateTime createdAt; + + private OffsetDateTime updatedAt; + + @Digits(integer = 15, fraction = 2) + private BigDecimal materialCost; + + private Boolean isFcaEnabled; + + @Digits(integer = 7, fraction = 2) + private BigDecimal overseaShare; + + @Size(max = 8) + private String hsCode; + + @Digits(integer = 7, fraction = 2) + private BigDecimal customRate; + + @Size(max = 16) + private PremissState state; + + @Unsigned + private Integer individualHuLength; + + @Unsigned + private Integer individualHuHeight; + + @Unsigned + private Integer individualHuWidth; + + @Unsigned + private Integer individualHuWeight; + + @Size(max = 2) + private DimensionUnit huDisplayedDimensionUnit; + + @Size(max = 2) + private WeightUnit huDisplayedWeightUnit; + + @Unsigned + private Integer huUnitCount; + + + private Boolean huStackable; + + private Boolean huMixable; + + + @MappedCollection(idColumn = "premiss_id") + private Set sinks; + + @NotNull + @Column("material_id") + private AggregateReference material; + + @Column("supplier_node_id") + private AggregateReference supplierNode; + + @Column("user_supplier_node_id") + private AggregateReference userSupplierNode; + + @Column("packaging_id") + private AggregateReference packaging; + + @NotNull + private AggregateReference user; + + @MappedCollection(idColumn = "premiss_id") + private Set premissPremissSinks; + + public Set getSinks() { + return sinks; + } + + public void setSinks(Set sinks) { + this.sinks = sinks; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public BigDecimal getMaterialCost() { + return materialCost; + } + + public void setMaterialCost(BigDecimal materialCost) { + this.materialCost = materialCost; + } + + public Boolean getFcaEnabled() { + return isFcaEnabled; + } + + public void setFcaEnabled(Boolean fcaEnabled) { + isFcaEnabled = fcaEnabled; + } + + public BigDecimal getOverseaShare() { + return overseaShare; + } + + public void setOverseaShare(BigDecimal overseaShare) { + this.overseaShare = overseaShare; + } + + public String getHsCode() { + return hsCode; + } + + public void setHsCode(String hsCode) { + this.hsCode = hsCode; + } + + public BigDecimal getCustomRate() { + return customRate; + } + + public void setCustomRate(BigDecimal customRate) { + this.customRate = customRate; + } + + public PremissState getState() { + return state; + } + + public void setState(PremissState state) { + this.state = state; + } + + public Integer getIndividualHuLength() { + return individualHuLength; + } + + public void setIndividualHuLength(Integer individualHuLength) { + this.individualHuLength = individualHuLength; + } + + public Integer getIndividualHuHeight() { + return individualHuHeight; + } + + public void setIndividualHuHeight(Integer individualHuHeight) { + this.individualHuHeight = individualHuHeight; + } + + public Integer getIndividualHuWidth() { + return individualHuWidth; + } + + public void setIndividualHuWidth(Integer individualHuWidth) { + this.individualHuWidth = individualHuWidth; + } + + public Integer getIndividualHuWeight() { + return individualHuWeight; + } + + public void setIndividualHuWeight(Integer individualHuWeight) { + this.individualHuWeight = individualHuWeight; + } + + public DimensionUnit getHuDisplayedDimensionUnit() { + return huDisplayedDimensionUnit; + } + + public void setHuDisplayedDimensionUnit(DimensionUnit huDisplayedDimensionUnit) { + this.huDisplayedDimensionUnit = huDisplayedDimensionUnit; + } + + public WeightUnit getHuDisplayedWeightUnit() { + return huDisplayedWeightUnit; + } + + public void setHuDisplayedWeightUnit(WeightUnit huDisplayedWeightUnit) { + this.huDisplayedWeightUnit = huDisplayedWeightUnit; + } + + public Integer getHuUnitCount() { + return huUnitCount; + } + + public void setHuUnitCount(Integer huUnitCount) { + this.huUnitCount = huUnitCount; + } + + public Boolean getHuStackable() { + return huStackable; + } + + public void setHuStackable(Boolean huStackable) { + this.huStackable = huStackable; + } + + public Boolean getHuMixable() { + return huMixable; + } + + public void setHuMixable(Boolean huMixable) { + this.huMixable = huMixable; + } + + public AggregateReference getMaterial() { + return material; + } + + public void setMaterial(AggregateReference material) { + this.material = material; + } + + public AggregateReference getSupplierNode() { + return supplierNode; + } + + public void setSupplierNode(AggregateReference supplierNode) { + this.supplierNode = supplierNode; + } + + public AggregateReference getUserSupplierNode() { + return userSupplierNode; + } + + public void setUserSupplierNode(AggregateReference userSupplierNode) { + this.userSupplierNode = userSupplierNode; + } + + public AggregateReference getPackaging() { + return packaging; + } + + public void setPackaging(AggregateReference packaging) { + this.packaging = packaging; + } + + public AggregateReference getUser() { + return user; + } + + public void setUser(AggregateReference user) { + this.user = user; + } + + public Set getPremissPremissSinks() { + return premissPremissSinks; + } + + public void setPremissPremissSinks(Set premissPremissSinks) { + this.premissPremissSinks = premissPremissSinks; + } +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissRoute.java b/src/main/java/de/avatic/lcc/model/premisses/PremissRoute.java new file mode 100644 index 0000000..55f3ab7 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissRoute.java @@ -0,0 +1,87 @@ +package de.avatic.lcc.model.premisses; + +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.util.List; +import java.util.Set; + + +@Table(name = "premiss_route") +public class PremissRoute { + + @Id + private Integer id; + + private Boolean isFastest; + + private Boolean isCheapest; + + private Boolean isSelected; + + @MappedCollection + private PremissSink premissSink; + + @MappedCollection(idColumn = "premiss_route_id", keyColumn = "list_position") + private List sections; + + @MappedCollection(idColumn = "premiss_route_id") + private Set nodes; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Boolean getFastest() { + return isFastest; + } + + public void setFastest(Boolean fastest) { + isFastest = fastest; + } + + public Boolean getCheapest() { + return isCheapest; + } + + public void setCheapest(Boolean cheapest) { + isCheapest = cheapest; + } + + public Boolean getSelected() { + return isSelected; + } + + public void setSelected(Boolean selected) { + isSelected = selected; + } + + public PremissSink getPremissSink() { + return premissSink; + } + + public void setPremissSink(PremissSink premissSink) { + this.premissSink = premissSink; + } + + public List getSections() { + return sections; + } + + public void setSections(List sections) { + this.sections = sections; + } + + public Set getNodes() { + return nodes; + } + + public void setNodes(Set nodes) { + this.nodes = nodes; + } +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissRouteNode.java b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteNode.java new file mode 100644 index 0000000..cb35bf9 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteNode.java @@ -0,0 +1,135 @@ +package de.avatic.lcc.model.premisses; + +import de.avatic.lcc.model.nodes.Node; +import de.avatic.lcc.model.user.SysUserNode; +import jakarta.validation.constraints.*; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "premiss_route_node") +public class PremissRouteNode { + + @Id + private Integer id; + + @NotNull + @Size(max = 255) + private String name; + + @Size(max = 500) + private String address; + + private Boolean isSink; + + private Boolean isIntermediate; + + private Boolean isSource; + + @DecimalMin("-90") + @DecimalMax("90") + @Digits(integer = 7, fraction = 4) + private BigDecimal geoLat; + + @DecimalMin("-180") + @DecimalMax("180") + @Digits(integer = 7, fraction = 4) + private BigDecimal geoLng; + + private Boolean isOutdated; + + private AggregateReference node; + + private AggregateReference userNode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public Boolean getSink() { + return isSink; + } + + public void setSink(Boolean sink) { + isSink = sink; + } + + public Boolean getIntermediate() { + return isIntermediate; + } + + public void setIntermediate(Boolean intermediate) { + isIntermediate = intermediate; + } + + public Boolean getSource() { + return isSource; + } + + public void setSource(Boolean source) { + isSource = source; + } + + public BigDecimal getGeoLat() { + return geoLat; + } + + public void setGeoLat(BigDecimal geoLat) { + this.geoLat = geoLat; + } + + public BigDecimal getGeoLng() { + return geoLng; + } + + public void setGeoLng(BigDecimal geoLng) { + this.geoLng = geoLng; + } + + public Boolean getOutdated() { + return isOutdated; + } + + public void setOutdated(Boolean outdated) { + isOutdated = outdated; + } + + public AggregateReference getNode() { + return node; + } + + public void setNode(AggregateReference node) { + this.node = node; + } + + public AggregateReference getUserNode() { + return userNode; + } + + public void setUserNode(AggregateReference userNode) { + this.userNode = userNode; + } +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSection.java b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSection.java new file mode 100644 index 0000000..72cca40 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSection.java @@ -0,0 +1,122 @@ +package de.avatic.lcc.model.premisses; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "premiss_route_section") +public class PremissRouteSection { + + @Id + private Integer id; + + @Unsigned + @NotNull + private Integer listPosition; + + @Size(max = 16) + private PremissRouteSectionType transportType; + + @Digits(integer = 15, fraction = 2) + private BigDecimal rateD2d; + + private Boolean isPreRun; + + private Boolean isMainRun; + + private Boolean isPostRun; + + private Boolean isOutdated; + + @NotNull + private PremissRouteNode fromRouteNode; + + @NotNull + private PremissRouteNode toRouteNode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getListPosition() { + return listPosition; + } + + public void setListPosition(Integer listPosition) { + this.listPosition = listPosition; + } + + public PremissRouteSectionType getTransportType() { + return transportType; + } + + public void setTransportType(PremissRouteSectionType transportType) { + this.transportType = transportType; + } + + public BigDecimal getRateD2d() { + return rateD2d; + } + + public void setRateD2d(BigDecimal rateD2d) { + this.rateD2d = rateD2d; + } + + public Boolean getPreRun() { + return isPreRun; + } + + public void setPreRun(Boolean preRun) { + isPreRun = preRun; + } + + public Boolean getMainRun() { + return isMainRun; + } + + public void setMainRun(Boolean mainRun) { + isMainRun = mainRun; + } + + public Boolean getPostRun() { + return isPostRun; + } + + public void setPostRun(Boolean postRun) { + isPostRun = postRun; + } + + public Boolean getOutdated() { + return isOutdated; + } + + public void setOutdated(Boolean outdated) { + isOutdated = outdated; + } + + public PremissRouteNode getFromRouteNode() { + return fromRouteNode; + } + + public void setFromRouteNode(PremissRouteNode fromRouteNode) { + this.fromRouteNode = fromRouteNode; + } + + public PremissRouteNode getToRouteNode() { + return toRouteNode; + } + + public void setToRouteNode(PremissRouteNode toRouteNode) { + this.toRouteNode = toRouteNode; + } +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSectionType.java b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSectionType.java new file mode 100644 index 0000000..370e06d --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissRouteSectionType.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.premisses; + +public enum PremissRouteSectionType { + RAIL, SEA, POST_RUN, ROAD, D2D +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissSink.java b/src/main/java/de/avatic/lcc/model/premisses/PremissSink.java new file mode 100644 index 0000000..5a28176 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissSink.java @@ -0,0 +1,63 @@ +package de.avatic.lcc.model.premisses; + +import de.avatic.lcc.model.nodes.Node; +import jakarta.validation.constraints.NotNull; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.util.Set; + + +@Table(name = "premiss_sink") +public class PremissSink { + + @Id + private Integer id; + + @Unsigned + @NotNull + private Integer annualAmount; + + @NotNull + @Column("sink_node_id") + private AggregateReference sinkNode; + + @MappedCollection(idColumn = "premiss_sink_id") + private Set routes; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getAnnualAmount() { + return annualAmount; + } + + public void setAnnualAmount(Integer annualAmount) { + this.annualAmount = annualAmount; + } + + public AggregateReference getSinkNode() { + return sinkNode; + } + + public void setSinkNode(AggregateReference sinkNode) { + this.sinkNode = sinkNode; + } + + public Set getRoutes() { + return routes; + } + + public void setRoutes(Set routes) { + this.routes = routes; + } +} diff --git a/src/main/java/de/avatic/lcc/model/premisses/PremissState.java b/src/main/java/de/avatic/lcc/model/premisses/PremissState.java new file mode 100644 index 0000000..becb570 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/premisses/PremissState.java @@ -0,0 +1,6 @@ +package de.avatic.lcc.model.premisses; + + +public enum PremissState { + DRAFT, COMPLETED, ARCHIVED, DELETED +} diff --git a/src/main/java/de/avatic/lcc/model/properties/CountryProperty.java b/src/main/java/de/avatic/lcc/model/properties/CountryProperty.java new file mode 100644 index 0000000..8bfaba5 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/CountryProperty.java @@ -0,0 +1,45 @@ +package de.avatic.lcc.model.properties; + + +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +@Table(name = "country_property") +public class CountryProperty { + + @Id + private Integer id; + + @Size(max = 500) + private String propertyValue; + + @Column("country_property_type") + private AggregateReference type; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getPropertyValue() { + return propertyValue; + } + + public void setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + } + + public AggregateReference getType() { + return type; + } + + public void setType(AggregateReference type) { + this.type = type; + } +} diff --git a/src/main/java/de/avatic/lcc/model/properties/CountryPropertyType.java b/src/main/java/de/avatic/lcc/model/properties/CountryPropertyType.java new file mode 100644 index 0000000..974900b --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/CountryPropertyType.java @@ -0,0 +1,77 @@ +package de.avatic.lcc.model.properties; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table("country_property_type") +public class CountryPropertyType { + + @Id + private Integer id; + + @NotNull + @Size(max = 255) + private String name; + + @Size(max = 16) + private String externalMappingId; + + @NotNull + private PropertyDataType dataType; + + @Size(max = 64) + private String validationRule; + + private Boolean isRequired; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExternalMappingId() { + return externalMappingId; + } + + public void setExternalMappingId(String externalMappingId) { + this.externalMappingId = externalMappingId; + } + + public PropertyDataType getDataType() { + return dataType; + } + + public void setDataType(PropertyDataType dataType) { + this.dataType = dataType; + } + + public String getValidationRule() { + return validationRule; + } + + public void setValidationRule(String validationRule) { + this.validationRule = validationRule; + } + + public Boolean getRequired() { + return isRequired; + } + + public void setRequired(Boolean required) { + isRequired = required; + } +} diff --git a/src/main/java/de/avatic/lcc/model/properties/PropertyDataType.java b/src/main/java/de/avatic/lcc/model/properties/PropertyDataType.java new file mode 100644 index 0000000..359a837 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/PropertyDataType.java @@ -0,0 +1,6 @@ +package de.avatic.lcc.model.properties; + + +public enum PropertyDataType { + INT, BOOLEAN, CURRENCY, ENUMERATION, TEXT +} diff --git a/src/main/java/de/avatic/lcc/model/properties/PropertySet.java b/src/main/java/de/avatic/lcc/model/properties/PropertySet.java new file mode 100644 index 0000000..59ff99d --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/PropertySet.java @@ -0,0 +1,30 @@ +package de.avatic.lcc.model.properties; + +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.time.OffsetDateTime; +import java.util.Set; + + +@Table(name = "property_set") +public class PropertySet { + + @Id + private Integer id; + + private OffsetDateTime startDate; + + private OffsetDateTime endDate; + + private PropertySetState state; + + @MappedCollection(idColumn = "property_set_id") + private Set systemProperties; + + @MappedCollection(idColumn = "property_set_id") + private Set countryProperties; + + +} diff --git a/src/main/java/de/avatic/lcc/model/properties/PropertySetState.java b/src/main/java/de/avatic/lcc/model/properties/PropertySetState.java new file mode 100644 index 0000000..c14d133 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/PropertySetState.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.properties; + +public enum PropertySetState { + DRAFT, VALID, INVALID, EXPIRED +} diff --git a/src/main/java/de/avatic/lcc/model/properties/SystemProperty.java b/src/main/java/de/avatic/lcc/model/properties/SystemProperty.java new file mode 100644 index 0000000..028d109 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/SystemProperty.java @@ -0,0 +1,47 @@ +package de.avatic.lcc.model.properties; + + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +@Table(name = "system_property") +public class SystemProperty { + + @Id + private Integer id; + + @Size(max = 500) + private String propertyValue; + + @NotNull + @Column("system_property_type_id") + private AggregateReference type; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getPropertyValue() { + return propertyValue; + } + + public void setPropertyValue(String propertyValue) { + this.propertyValue = propertyValue; + } + + public AggregateReference getType() { + return type; + } + + public void setType(AggregateReference type) { + this.type = type; + } +} diff --git a/src/main/java/de/avatic/lcc/model/properties/SystemPropertyType.java b/src/main/java/de/avatic/lcc/model/properties/SystemPropertyType.java new file mode 100644 index 0000000..52f1249 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/properties/SystemPropertyType.java @@ -0,0 +1,68 @@ +package de.avatic.lcc.model.properties; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table("system_property_type") +public class SystemPropertyType { + + @Id + private Integer id; + + @NotNull + @Size(max = 255) + private String name; + + @Size(max = 16) + private String externalMappingId; + + @NotNull + private PropertyDataType dataType; + + @Size(max = 64) + private String validationRule; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExternalMappingId() { + return externalMappingId; + } + + public void setExternalMappingId(String externalMappingId) { + this.externalMappingId = externalMappingId; + } + + public PropertyDataType getDataType() { + return dataType; + } + + public void setDataType(PropertyDataType dataType) { + this.dataType = dataType; + } + + public String getValidationRule() { + return validationRule; + } + + public void setValidationRule(String validationRule) { + this.validationRule = validationRule; + } +} diff --git a/src/main/java/de/avatic/lcc/model/rates/ContainerRate.java b/src/main/java/de/avatic/lcc/model/rates/ContainerRate.java new file mode 100644 index 0000000..ad41bf5 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/rates/ContainerRate.java @@ -0,0 +1,111 @@ +package de.avatic.lcc.model.rates; + +import de.avatic.lcc.model.nodes.Node; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jdk.jfr.Unsigned; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "container_rate") +public class ContainerRate { + + @Id + private Integer id; + + @Column("container_rate_type") + private ContainerRateType type; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal rateTeu; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal rateFeu; + + @NotNull + @Digits(integer = 15, fraction = 2) + private BigDecimal rateHc; + + @Unsigned + @NotNull + private Integer leadTime; + + @NotNull + @Column("from_node_id") + private AggregateReference fromNode; + + @NotNull + @Column("to_node_id") + private AggregateReferencetoNode; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public ContainerRateType getType() { + return type; + } + + public void setType(ContainerRateType type) { + this.type = type; + } + + public BigDecimal getRateTeu() { + return rateTeu; + } + + public void setRateTeu(BigDecimal rateTeu) { + this.rateTeu = rateTeu; + } + + public BigDecimal getRateFeu() { + return rateFeu; + } + + public void setRateFeu(BigDecimal rateFeu) { + this.rateFeu = rateFeu; + } + + public BigDecimal getRateHc() { + return rateHc; + } + + public void setRateHc(BigDecimal rateHc) { + this.rateHc = rateHc; + } + + public Integer getLeadTime() { + return leadTime; + } + + public void setLeadTime(Integer leadTime) { + this.leadTime = leadTime; + } + + public AggregateReference getFromNode() { + return fromNode; + } + + public void setFromNode(AggregateReference fromNode) { + this.fromNode = fromNode; + } + + public AggregateReference getToNode() { + return toNode; + } + + public void setToNode(AggregateReference toNode) { + this.toNode = toNode; + } +} diff --git a/src/main/java/de/avatic/lcc/model/rates/ContainerRateType.java b/src/main/java/de/avatic/lcc/model/rates/ContainerRateType.java new file mode 100644 index 0000000..ab216b9 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/rates/ContainerRateType.java @@ -0,0 +1,5 @@ +package de.avatic.lcc.model.rates; + +public enum ContainerRateType { + RAIL, SEA, POST_RUN, ROAD +} diff --git a/src/main/java/de/avatic/lcc/model/rates/CountryMatrixRate.java b/src/main/java/de/avatic/lcc/model/rates/CountryMatrixRate.java new file mode 100644 index 0000000..fa65697 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/rates/CountryMatrixRate.java @@ -0,0 +1,59 @@ +package de.avatic.lcc.model.rates; + +import de.avatic.lcc.model.country.Country; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + + +@Table(name = "country_matrix_rate") +public class CountryMatrixRate { + + @Id + private Integer id; + + @Digits(integer = 15, fraction = 2) + private BigDecimal rate; + + @NotNull + private AggregateReference fromCountry; + + @NotNull + private AggregateReference toCountry; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public BigDecimal getRate() { + return rate; + } + + public void setRate(BigDecimal rate) { + this.rate = rate; + } + + public AggregateReference getFromCountry() { + return fromCountry; + } + + public void setFromCountry(AggregateReference fromCountry) { + this.fromCountry = fromCountry; + } + + public AggregateReference getToCountry() { + return toCountry; + } + + public void setToCountry(AggregateReference toCountry) { + this.toCountry = toCountry; + } +} diff --git a/src/main/java/de/avatic/lcc/model/rates/ValidityPeriod.java b/src/main/java/de/avatic/lcc/model/rates/ValidityPeriod.java new file mode 100644 index 0000000..f0ee5eb --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/rates/ValidityPeriod.java @@ -0,0 +1,33 @@ +package de.avatic.lcc.model.rates; + +import de.avatic.lcc.model.properties.PropertySetState; +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.time.OffsetDateTime; +import java.util.Set; + + +@Table(name = "validity_period") +public class ValidityPeriod { + + @Id + private Integer id; + + @NotNull + private OffsetDateTime startDate; + + @NotNull + private OffsetDateTime endDate; + + private PropertySetState state; + + @MappedCollection(idColumn = "validity_period_id") + private Set containerRates; + + @MappedCollection(idColumn = "validity_period_id") + private Set countryMatrixRates; + +} diff --git a/src/main/java/de/avatic/lcc/model/user/SysGroup.java b/src/main/java/de/avatic/lcc/model/user/SysGroup.java new file mode 100644 index 0000000..528360f --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/user/SysGroup.java @@ -0,0 +1,23 @@ +package de.avatic.lcc.model.user; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + + +@Table(name = "sys_group") +public class SysGroup { + + @Id + private Integer id; + + @NotNull + @Size(max = 64) + private String groupName; + + @NotNull + @Size(max = 128) + private String groupDescription; + +} diff --git a/src/main/java/de/avatic/lcc/model/user/SysUser.java b/src/main/java/de/avatic/lcc/model/user/SysUser.java new file mode 100644 index 0000000..95f28a5 --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/user/SysUser.java @@ -0,0 +1,94 @@ +package de.avatic.lcc.model.user; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +import java.util.Set; + + +@Table(name = "sys_user") +public class SysUser { + + @Id + private Integer id; + + @NotNull + @Size(max = 32) + private String workdayId; + + @NotNull + @Size(max = 254) + private String email; + + @NotNull + @Size(max = 100) + private String firstname; + + @NotNull + @Size(max = 100) + private String lastname; + + @MappedCollection(idColumn = "user_id") + private Set groups ; + + private Boolean isActive; + + public Integer getId() { + return id; + } + + public void setId(final Integer id) { + this.id = id; + } + + public String getWorkdayId() { + return workdayId; + } + + public void setWorkdayId(final String workdayId) { + this.workdayId = workdayId; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(final String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(final String lastname) { + this.lastname = lastname; + } + + public Set getGroups() { + return groups; + } + + public void setGroups(Set groups) { + this.groups = groups; + } + + public Boolean getActive() { + return isActive; + } + + public void setActive(Boolean active) { + isActive = active; + } +} diff --git a/src/main/java/de/avatic/lcc/model/user/SysUserGroupMapping.java b/src/main/java/de/avatic/lcc/model/user/SysUserGroupMapping.java new file mode 100644 index 0000000..b6d72ea --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/user/SysUserGroupMapping.java @@ -0,0 +1,35 @@ +package de.avatic.lcc.model.user; + + +import jakarta.validation.constraints.NotNull; +import org.springframework.data.annotation.Id; +import org.springframework.data.jdbc.core.mapping.AggregateReference; +import org.springframework.data.relational.core.mapping.Column; +import org.springframework.data.relational.core.mapping.Table; + +@Table(name = "sys_user_group_mapping") +public class SysUserGroupMapping { + + @Id + private Integer id; + + @NotNull + @Column("group_id") + private AggregateReference group; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public AggregateReference getGroup() { + return group; + } + + public void setGroup(AggregateReference group) { + this.group = group; + } +} diff --git a/src/main/java/de/avatic/lcc/model/user/SysUserNode.java b/src/main/java/de/avatic/lcc/model/user/SysUserNode.java new file mode 100644 index 0000000..406c6ce --- /dev/null +++ b/src/main/java/de/avatic/lcc/model/user/SysUserNode.java @@ -0,0 +1,83 @@ +package de.avatic.lcc.model.user; + + +import jakarta.validation.constraints.*; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.math.BigDecimal; + +@Table(name = "sys_user_node") +public class SysUserNode { + + @Id + private Integer id; + + @NotNull + @Size(max = 254) + private String name; + + @NotNull + @Size(max = 500) + private String address; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-90.0000") + @DecimalMax("90.0000") + private BigDecimal geoLat; + + @Digits(integer = 7, fraction = 4) + @DecimalMin("-180.0000") + @DecimalMax("180.0000") + private BigDecimal geoLng; + + private Boolean isDeprecated; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public BigDecimal getGeoLat() { + return geoLat; + } + + public void setGeoLat(BigDecimal geoLat) { + this.geoLat = geoLat; + } + + public BigDecimal getGeoLng() { + return geoLng; + } + + public void setGeoLng(BigDecimal geoLng) { + this.geoLng = geoLng; + } + + public Boolean getDeprecated() { + return isDeprecated; + } + + public void setDeprecated(Boolean deprecated) { + isDeprecated = deprecated; + } +} diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 61d1f13..fffaeb1 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -210,9 +210,9 @@ CREATE TABLE container_rate from_node_id INT NOT NULL, to_node_id INT NOT NULL, container_rate_type CHAR(8) CHECK (container_rate_type IN ('RAIL', 'SEA', 'POST-RUN', 'ROAD')), - rate_20 DECIMAL(15, 2) NOT NULL COMMENT 'rate for 20ft container in EUR', - rate_40 DECIMAL(15, 2) NOT NULL COMMENT 'rate for 40ft container in EUR', - rate_40_hc DECIMAL(15, 2) NOT NULL COMMENT 'rate for 40ft HQ container in EUR', + rate_teu DECIMAL(15, 2) NOT NULL COMMENT 'rate for 20ft container in EUR', + rate_feu DECIMAL(15, 2) NOT NULL COMMENT 'rate for 40ft container in EUR', + rate_hc DECIMAL(15, 2) NOT NULL COMMENT 'rate for 40ft HQ container in EUR', lead_time INT UNSIGNED NOT NULL COMMENT 'lead time in days', validity_period_id INT NOT NULL, FOREIGN KEY (from_node_id) REFERENCES node (id), @@ -284,7 +284,7 @@ CREATE TABLE packaging_property_type `name` VARCHAR(255) NOT NULL, `data_type` VARCHAR(16), `validation_rule` VARCHAR(64), - `is_required` BOOLEAN NOT NULl DEFAULT FALSE, + `is_required` BOOLEAN NOT NULL DEFAULT FALSE, CONSTRAINT `chk_packaging_data_type_values` CHECK (`data_type` IN ('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION', 'TEXT')) @@ -304,29 +304,29 @@ CREATE TABLE packaging_property CREATE TABLE premiss ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - material_id INT NOT NULL, + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + material_id INT NOT NULL, supplier_node_id INT, user_supplier_node_id INT, - packaging_id INT DEFAULT NULL, - user_id INT NOT NULL, - createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + packaging_id INT DEFAULT NULL, + user_id INT NOT NULL, + createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, material_cost DECIMAL(15, 2) COMMENT 'aka MEK_A in EUR', - is_fca_enabled BOOLEAN DEFAULT FALSE, + is_fca_enabled BOOLEAN DEFAULT FALSE, oversea_share DECIMAL(7, 4), hs_code CHAR(8), custom_rate DECIMAL(7, 4), - state CHAR(10), - individual_hu_length INT UNSIGNED NOT NULL COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', - individual_hu_height INT UNSIGNED NOT NULL COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', - individual_hu_width INT UNSIGNED NOT NULL COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', - individual_hu_weight INT UNSIGNED NOT NULL COMMENT 'user entered weight in g (if system-wide packaging is used, packaging weight are copied here after creation)', - hu_displayed_dimension_unit CHAR(2) DEFAULT 'MM', - hu_displayed_weight_unit CHAR(2) DEFAULT 'G', - hu_unit_count INT UNSIGNED DEFAULT NULL, - hu_stackable BOOLEAN DEFAULT TRUE, - hu_mixable BOOLEAN DEFAULT TRUE, + state CHAR(10) DEFAULT 'DRAFT', + individual_hu_length INT UNSIGNED COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', + individual_hu_height INT UNSIGNED COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', + individual_hu_width INT UNSIGNED COMMENT 'user entered dimensions in mm (if system-wide packaging is used, packaging dimensions are copied here after creation)', + individual_hu_weight INT UNSIGNED COMMENT 'user entered weight in g (if system-wide packaging is used, packaging weight are copied here after creation)', + hu_displayed_dimension_unit CHAR(2) DEFAULT 'MM', + hu_displayed_weight_unit CHAR(2) DEFAULT 'G', + hu_unit_count INT UNSIGNED DEFAULT NULL, + hu_stackable BOOLEAN DEFAULT TRUE, + hu_mixable BOOLEAN DEFAULT TRUE, FOREIGN KEY (material_id) REFERENCES material (id), FOREIGN KEY (supplier_node_id) REFERENCES node (id), FOREIGN KEY (user_supplier_node_id) REFERENCES sys_user_node (id), @@ -370,22 +370,19 @@ CREATE TABLE premiss_route CREATE TABLE premiss_route_node ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - premiss_route_id INT NOT NULL, - node_id INT DEFAULT NULL, - user_node_id INT DEFAULT NULL, - name VARCHAR(255) NOT NULL, - address VARCHAR(500), - is_sink BOOLEAN DEFAULT FALSE, - is_intermediate BOOLEAN DEFAULT FALSE, - is_source BOOLEAN DEFAULT FALSE, - geo_lat DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90), - geo_lng DECIMAL(7, 4) CHECK (geo_lng BETWEEN -180 AND 180), - is_outdated BOOLEAN DEFAULT FALSE, - FOREIGN KEY (premiss_route_id) REFERENCES premiss_route (id), + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + node_id INT DEFAULT NULL, + user_node_id INT DEFAULT NULL, + name VARCHAR(255) NOT NULL, + address VARCHAR(500), + is_sink BOOLEAN DEFAULT FALSE, + is_intermediate BOOLEAN DEFAULT FALSE, + is_source BOOLEAN DEFAULT FALSE, + geo_lat DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90), + geo_lng DECIMAL(7, 4) CHECK (geo_lng BETWEEN -180 AND 180), + is_outdated BOOLEAN DEFAULT FALSE, FOREIGN KEY (node_id) REFERENCES node (id), FOREIGN KEY (user_node_id) REFERENCES sys_user_node (id), - INDEX idx_premiss_route_id (premiss_route_id), INDEX idx_node_id (node_id), INDEX idx_user_node_id (user_node_id), CONSTRAINT `chk_node` CHECK (`user_node_id` IS NULL OR `node_id` IS NULL) @@ -439,55 +436,73 @@ CREATE TABLE calculation_job CREATE TABLE calculation_job_sink ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_id INT NOT NULL, - premiss_sink_id INT NOT NULL, - safety_stock INT UNSIGNED COMMENT 'safety stock in single pieces ?!?!', - shipping_frequency INT UNSIGNED COMMENT 'annual shipping frequency', - total_cost DECIMAL(15, 2) COMMENT 'aka MEK_B in EUR', + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + calculation_job_id INT NOT NULL, + premiss_sink_id INT NOT NULL, + safety_stock INT UNSIGNED COMMENT 'safety stock in single pieces ?!?!', + shipping_frequency INT UNSIGNED COMMENT 'annual shipping frequency', + total_cost DECIMAL(15, 2) COMMENT 'aka MEK_B in EUR', + calculation_job_custom_id INT NOT NULL, + calculation_job_inventory_id INT NOT NULL, + calculation_job_handling_id INT NOT NULL, + calculation_job_risk_id INT NOT NULL, + calculation_job_material_id INT NOT NULL, + calculation_job_transportation_id INT NOT NULL, + calculation_job_airfreight_id INT NOT NULL, FOREIGN KEY (calculation_job_id) REFERENCES calculation_job (id), FOREIGN KEY (premiss_sink_id) REFERENCES premiss_sink (id), + FOREIGN KEY (calculation_job_custom_id) REFERENCES calculation_job_custom (id), + FOREIGN KEY (calculation_job_inventory_id) REFERENCES calculation_job_inventory (id), + FOREIGN KEY (calculation_job_handling_id) REFERENCES calculation_job_handling (id), + FOREIGN KEY (calculation_job_risk_id) REFERENCES calculation_job_risk (id), + FOREIGN KEY (calculation_job_material_id) REFERENCES calculation_job_material (id), + FOREIGN KEY (calculation_job_transportation_id) REFERENCES calculation_job_transportation (id), + FOREIGN KEY (calculation_job_airfreight_id) REFERENCES calculation_job_airfreight (id), INDEX idx_calculation_job_id (calculation_job_id), INDEX idx_premiss_sink_id (premiss_sink_id) ); +CREATE TABLE calculation_job_material +( + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + material_cost DECIMAL(15, 2) NOT NULL, + fca_cost DECIMAL(15, 2) NOT NULL +); + CREATE TABLE calculation_job_transportation ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - transportation_type CHAR(8) CHECK (transportation_type IN - ('20', '40', '40HC', 'TRUCK')), - hu_per_layer INT UNSIGNED NOT NULL COMMENT 'number of handling units per layer', - layer_structure JSON NOT NULL COMMENT 'json representation of a single layer', - layer_count INT UNSIGNED NOT NULL COMMENT 'number of layers per full container or truck', - transport_weight_exceeded BOOLEAN DEFAULT FALSE COMMENT 'limiting factor: TRUE if weight limited or FALSE if volume limited', - transports_per_year DECIMAL(15, 2) NOT NULL COMMENT 'TODO: what is this?!', - annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'total annual transportation costs in EUR', - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id), - INDEX idx_calculation_job_sink_id (calculation_job_sink_id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + transportation_type CHAR(8) CHECK (transportation_type IN + ('TEU', 'FEU', 'HC', 'TRUCK')), + hu_per_layer INT UNSIGNED NOT NULL COMMENT 'number of handling units per layer', + layer_structure JSON NOT NULL COMMENT 'json representation of a single layer', + layer_count INT UNSIGNED NOT NULL COMMENT 'number of layers per full container or truck', + transport_weight_exceeded BOOLEAN DEFAULT FALSE COMMENT 'limiting factor: TRUE if weight limited or FALSE if volume limited', + transports_per_year DECIMAL(15, 2) NOT NULL COMMENT 'TODO: what is this?!', + annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'total annual transportation costs in EUR' ); CREATE TABLE calculation_job_route_section ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - premiss_route_section_id INT NOT NULL, + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + premiss_route_section_id INT NOT NULL, calculation_job_transportation_id INT NOT NULL, - used_rule CHAR(8) CHECK (used_rule IN - ('CONTAINER', 'MATRIX')), - is_unmixed_price BOOLEAN DEFAULT FALSE, - is_cbm_price BOOLEAN DEFAULT FALSE, - is_weight_price BOOLEAN DEFAULT FALSE, - is_stacked BOOLEAN DEFAULT FALSE, - is_pre_run BOOLEAN DEFAULT FALSE, - is_main_run BOOLEAN DEFAULT FALSE, - is_post_run BOOLEAN DEFAULT FALSE, - rate DECIMAL(15, 2) NOT NULL COMMENT 'copy of the container rate resp. price matrix in EUR (depends on used_rule)', - distance DECIMAL(15, 2) DEFAULT NULL COMMENT 'distance of this route section im meters', - cbm_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per cubic meter', - weight_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per kilogram', - annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'annual costs for this route section, result depends on calculation method (mixed or unmixed, stacked or unstacked, per volume/per weight resp. container rate/price matrix)', - transit_time INT UNSIGNED NOT NULL, + used_rule CHAR(8) CHECK (used_rule IN + ('CONTAINER', 'MATRIX')), + is_unmixed_price BOOLEAN DEFAULT FALSE, + is_cbm_price BOOLEAN DEFAULT FALSE, + is_weight_price BOOLEAN DEFAULT FALSE, + is_stacked BOOLEAN DEFAULT FALSE, + is_pre_run BOOLEAN DEFAULT FALSE, + is_main_run BOOLEAN DEFAULT FALSE, + is_post_run BOOLEAN DEFAULT FALSE, + rate DECIMAL(15, 2) NOT NULL COMMENT 'copy of the container rate resp. price matrix in EUR (depends on used_rule)', + distance DECIMAL(15, 2) DEFAULT NULL COMMENT 'distance of this route section im meters', + cbm_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per cubic meter', + weight_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per kilogram', + annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'annual costs for this route section, result depends on calculation method (mixed or unmixed, stacked or unstacked, per volume/per weight resp. container rate/price matrix)', + transit_time INT UNSIGNED NOT NULL, FOREIGN KEY (premiss_route_section_id) REFERENCES premiss_route_section (id), FOREIGN KEY (calculation_job_transportation_id) REFERENCES calculation_job_transportation (id), INDEX idx_premiss_route_section_id (premiss_route_section_id), @@ -499,57 +514,48 @@ CREATE TABLE calculation_job_route_section CREATE TABLE calculation_job_airfreight ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - air_freight_share_max DECIMAL(7, 4) NOT NULL, - air_freight_share DECIMAL(7, 4) NOT NULL, - air_freight_volumetric_weight DECIMAL(15, 2) NOT NULL, - air_freight_weight DECIMAL(15, 2) NOT NULL, - annual_cost DECIMAL(15, 2) NOT NULL, - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + air_freight_share_max DECIMAL(7, 4) NOT NULL, + air_freight_share DECIMAL(7, 4) NOT NULL, + air_freight_volumetric_weight DECIMAL(15, 2) NOT NULL, + air_freight_weight DECIMAL(15, 2) NOT NULL, + annual_cost DECIMAL(15, 2) NOT NULL + ); CREATE TABLE calculation_job_custom ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - custom_value DECIMAL(15, 2) NOT NULL,-- Zollwert, - custom_duties DECIMAL(15, 2) NOT NULL,-- Zollabgaben, - custom_rate DECIMAL(7, 4) NOT NULL,-- Zollsatz, - annual_cost DECIMAL(15, 2) NOT NULL,-- Zollabgaben inkl. Einmalkosten, - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + custom_value DECIMAL(15, 2) NOT NULL,-- Zollwert, + custom_duties DECIMAL(15, 2) NOT NULL,-- Zollabgaben, + custom_rate DECIMAL(7, 4) NOT NULL,-- Zollsatz, + annual_cost DECIMAL(15, 2) NOT NULL-- Zollabgaben inkl. Einmalkosten, ); CREATE TABLE calculation_job_inventory ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - operational_stock DECIMAL(15, 2) NOT NULL COMMENT 'operational stock in single pieces', - safety_stock DECIMAL(15, 2) NOT NULL COMMENT 'safety stock in single pieces', - stocked_inventory DECIMAL(15, 2) NOT NULL COMMENT 'sum of operational and safety stock ?!', - in_transport_stock DECIMAL(15, 2) NOT NULL, - stock_before_payment DECIMAL(15, 2) NOT NULL, - annual_capital_cost DECIMAL(15, 2) NOT NULL, - annual_storage_cost DECIMAL(15, 2) NOT NULL, -- Flächenkosten, - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + operational_stock DECIMAL(15, 2) NOT NULL COMMENT 'operational stock in single pieces', + safety_stock DECIMAL(15, 2) NOT NULL COMMENT 'safety stock in single pieces', + stocked_inventory DECIMAL(15, 2) NOT NULL COMMENT 'sum of operational and safety stock ?!', + in_transport_stock DECIMAL(15, 2) NOT NULL, + stock_before_payment DECIMAL(15, 2) NOT NULL, + annual_capital_cost DECIMAL(15, 2) NOT NULL, + annual_storage_cost DECIMAL(15, 2) NOT NULL -- Flächenkosten, ); CREATE TABLE calculation_job_handling ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - is_small_unit BOOLEAN DEFAULT FALSE COMMENT 'small unit equals KLT, volume of a handling unit is smaller than 0.08 cbm ', - annual_repacking_cost DECIMAL(15, 2) NOT NULL, - annual_handling_cost DECIMAL(15, 2) NOT NULL, - annual_disposal_cost DECIMAL(15, 2) NOT NULL, - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + is_small_unit BOOLEAN DEFAULT FALSE COMMENT 'small unit equals KLT, volume of a handling unit is smaller than 0.08 cbm ', + annual_repacking_cost DECIMAL(15, 2) NOT NULL, + annual_handling_cost DECIMAL(15, 2) NOT NULL, + annual_disposal_cost DECIMAL(15, 2) NOT NULL ); CREATE TABLE calculation_job_risk ( - id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - calculation_job_sink_id INT NOT NULL, - annual_risk_cost DECIMAL(15, 2) NOT NULL COMMENT 'complete calculation with globally stored worst case container rates', - annual_chance_cost DECIMAL(15, 2) NOT NULL COMMENT 'complete calculation with globally stored best case container rates', - FOREIGN KEY (calculation_job_sink_id) REFERENCES calculation_job_sink (id) + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + annual_risk_cost DECIMAL(15, 2) NOT NULL COMMENT 'complete calculation with globally stored worst case container rates', + annual_chance_cost DECIMAL(15, 2) NOT NULL COMMENT 'complete calculation with globally stored best case container rates' );