Bugfix: shipping frequency custom calculation. Stacking in container calcualtion

This commit is contained in:
Jan 2025-12-16 22:16:03 +01:00
parent a83c49bc70
commit 1be35b5a8d
4 changed files with 8 additions and 6 deletions

View file

@ -142,7 +142,7 @@ public class CalculationExecutionService {
BigDecimal leadTime = null; BigDecimal leadTime = null;
if (destination.getD2d()) { if (destination.getD2d()) {
var containerCalculation = containerCalculationService.doCalculation(setId, premiseToHuService.createHuFromPremise(premise), ContainerType.FEU, premise.getHuMixable()); var containerCalculation = containerCalculationService.doCalculation(setId, premiseToHuService.createHuFromPremise(premise), ContainerType.FEU, premise.getHuMixable(), premise.getHuStackable());
sections = List.of(new SectionInfo(null, routeSectionCostCalculationService.doD2dCalculation(setId, periodId, premise, destination, containerCalculation), containerCalculation)); sections = List.of(new SectionInfo(null, routeSectionCostCalculationService.doD2dCalculation(setId, periodId, premise, destination, containerCalculation), containerCalculation));
leadTime = BigDecimal.valueOf(destination.getLeadTimeD2d()); leadTime = BigDecimal.valueOf(destination.getLeadTimeD2d());
usedContainerType = ContainerType.FEU; usedContainerType = ContainerType.FEU;
@ -246,7 +246,7 @@ public class CalculationExecutionService {
// Get container calculation // Get container calculation
for (var containerType : ContainerType.values()) { for (var containerType : ContainerType.values()) {
containerCalculation.put(containerType, containerCalculationService.doCalculation(setId, hu, containerType, premise.getHuMixable())); containerCalculation.put(containerType, containerCalculationService.doCalculation(setId, hu, containerType, premise.getHuMixable(), premise.getHuStackable()));
} }
for (var containerType : ContainerType.values()) { for (var containerType : ContainerType.values()) {

View file

@ -49,7 +49,7 @@ public class ContainerCalculationService {
* @param containerType The type of container to be loaded * @param containerType The type of container to be loaded
* @return ContainerCalculationResult containing loading pattern and capacity information * @return ContainerCalculationResult containing loading pattern and capacity information
*/ */
public ContainerCalculationResult doCalculation(Integer setId, PackagingDimension hu, ContainerType containerType, boolean mixable) { public ContainerCalculationResult doCalculation(Integer setId, PackagingDimension hu, ContainerType containerType, boolean mixable, boolean stackable) {
var weightInKg = BigDecimal.valueOf(WeightUnit.KG.convertFromG(hu.getWeight())); var weightInKg = BigDecimal.valueOf(WeightUnit.KG.convertFromG(hu.getWeight()));
var maxContainerLoad = BigDecimal.valueOf(getMaxContainerLoad(containerType, setId)); var maxContainerLoad = BigDecimal.valueOf(getMaxContainerLoad(containerType, setId));
@ -60,7 +60,7 @@ public class ContainerCalculationService {
var solutionHorizontal = solveLayer(SolutionType.HORIZONTAL, dimensions, containerType.getLength(), containerType.getWidth()); var solutionHorizontal = solveLayer(SolutionType.HORIZONTAL, dimensions, containerType.getLength(), containerType.getWidth());
var solutionVertical = solveLayer(SolutionType.VERTICAL, dimensions, containerType.getWidth(), containerType.getLength()); var solutionVertical = solveLayer(SolutionType.VERTICAL, dimensions, containerType.getWidth(), containerType.getLength());
var bestSolution = solutionHorizontal.getTotal() < solutionVertical.getTotal() ? solutionVertical : solutionHorizontal; var bestSolution = solutionHorizontal.getTotal() < solutionVertical.getTotal() ? solutionVertical : solutionHorizontal;
int layers = mixable ? getLayerCount(dimensions, containerType) : 1; int layers = stackable ? getLayerCount(dimensions, containerType) : 1;
if(PalletType.EURO_PALLET.fitsOn(hu) && bestSolution.getTotal() < containerType.getPalletCount(PalletType.EURO_PALLET)) { if(PalletType.EURO_PALLET.fitsOn(hu) && bestSolution.getTotal() < containerType.getPalletCount(PalletType.EURO_PALLET)) {
return new ContainerCalculationResult(Math.min(containerType.getPalletCount(PalletType.EURO_PALLET)*layers,maxUnitByWeight), layers, null, (containerType.getPalletCount(PalletType.EURO_PALLET)*layers) > maxUnitByWeight, containerType, dimensions, maxContainerLoad.intValueExact()); return new ContainerCalculationResult(Math.min(containerType.getPalletCount(PalletType.EURO_PALLET)*layers,maxUnitByWeight), layers, null, (containerType.getPalletCount(PalletType.EURO_PALLET)*layers) > maxUnitByWeight, containerType, dimensions, maxContainerLoad.intValueExact());

View file

@ -62,7 +62,7 @@ public class CustomCostCalculationService {
var transportationRiskCost = relevantSections.stream().map(s -> s.result().getAnnualRiskCost()).reduce(BigDecimal.ZERO, BigDecimal::add); var transportationRiskCost = relevantSections.stream().map(s -> s.result().getAnnualRiskCost()).reduce(BigDecimal.ZERO, BigDecimal::add);
double huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(relevantSections.getFirst().containerResult().getHuUnitCount()),2, RoundingMode.HALF_UP).doubleValue(); double huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(premise.getHuUnitCount()),0, RoundingMode.CEILING).doubleValue();
return getCustomCalculationResult(setId, premise, destination, getContainerShare(premise, relevantSections.getFirst().containerResult()), huAnnualAmount, transportationCost, transportationChanceCost, transportationRiskCost); return getCustomCalculationResult(setId, premise, destination, getContainerShare(premise, relevantSections.getFirst().containerResult()), huAnnualAmount, transportationCost, transportationChanceCost, transportationRiskCost);
} }
@ -87,7 +87,7 @@ public class CustomCostCalculationService {
var customValue = materialCost.add(fcaFee).add(transportationCost); var customValue = materialCost.add(fcaFee).add(transportationCost);
var customDuties = customValue.multiply(tariffRate); var customDuties = customValue.multiply(tariffRate);
var annualCustomFee = BigDecimal.valueOf(shippingFrequency).multiply(BigDecimal.valueOf(customFee)).multiply(containerShare); var annualCustomFee = BigDecimal.valueOf(shippingFrequency).multiply(BigDecimal.valueOf(customFee));
var annualCost = customDuties.add(annualCustomFee); var annualCost = customDuties.add(annualCustomFee);
var customRiskValue = materialCost.add(fcaFee).add(transportationRiskCost); var customRiskValue = materialCost.add(fcaFee).add(transportationRiskCost);

View file

@ -229,6 +229,8 @@ public class RouteSectionCostCalculationService {
volumePrice = cbmRate.divide(totalVolumeUtilization, 10, RoundingMode.HALF_UP); volumePrice = cbmRate.divide(totalVolumeUtilization, 10, RoundingMode.HALF_UP);
weightPrice = weightRate.divide(totalWeightUtilization, 10, RoundingMode.HALF_UP); weightPrice = weightRate.divide(totalWeightUtilization, 10, RoundingMode.HALF_UP);
utilization = weightExceeded ? totalWeightUtilization : totalVolumeUtilization; utilization = weightExceeded ? totalWeightUtilization : totalVolumeUtilization;
//TODO: wenn shippingfreq > annual hu -> shippingfreq * containerprice.
// gleiches für containercalculation * shippingfreq < annual hu ammount.
} }
return new PriceCalculationResult(volumePrice, weightPrice, utilization); return new PriceCalculationResult(volumePrice, weightPrice, utilization);