Fix for (Issue #81). Layers should be stored now correctly

This commit is contained in:
Jan 2025-12-14 16:49:57 +01:00
parent dd4ce8879b
commit 6b73e4afdf
3 changed files with 5 additions and 5 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); var containerCalculation = containerCalculationService.doCalculation(setId, premiseToHuService.createHuFromPremise(premise), ContainerType.FEU, premise.getHuMixable());
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)); containerCalculation.put(containerType, containerCalculationService.doCalculation(setId, hu, containerType, premise.getHuMixable()));
} }
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) { public ContainerCalculationResult doCalculation(Integer setId, PackagingDimension hu, ContainerType containerType, boolean mixable) {
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 = getLayerCount(dimensions, containerType); int layers = mixable ? 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

@ -83,7 +83,7 @@ public class RouteSectionCostCalculationService {
// Calculate price and annual cost // Calculate price and annual cost
BigDecimal huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(containerCalculation.getHu().getContentUnitCount()), 2, RoundingMode.HALF_UP); BigDecimal huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(containerCalculation.getHu().getContentUnitCount()), 2, RoundingMode.HALF_UP);
BigDecimal utilization = getUtilization(setId, RateType.CONTAINER); /* D2D is always 40ft container */ BigDecimal utilization = getUtilization(setId, RateType.CONTAINER); /* D2D is always 40ft container */
BigDecimal annualVolume =huAnnualAmount.multiply(BigDecimal.valueOf(containerCalculation.getHu().getVolume(DimensionUnit.M))); BigDecimal annualVolume = huAnnualAmount.multiply(BigDecimal.valueOf(containerCalculation.getHu().getVolume(DimensionUnit.M)));
BigDecimal annualWeight = huAnnualAmount.multiply(BigDecimal.valueOf(containerCalculation.getHu().getWeight(WeightUnit.KG))); BigDecimal annualWeight = huAnnualAmount.multiply(BigDecimal.valueOf(containerCalculation.getHu().getWeight(WeightUnit.KG)));
PriceCalculationResult prices = calculatePrices( PriceCalculationResult prices = calculatePrices(