Merge pull request 'Implemented deactivated container types, CalculationExecutionService to handle container type activation logic. Fix destinationEdit store to handle null values in data.' (#107) from dev into main

Reviewed-on: #107
This commit is contained in:
Jan Weber 2026-01-20 08:57:30 +00:00
commit 31acb9c2c6
3 changed files with 33 additions and 5 deletions

View file

@ -105,8 +105,9 @@ export const useDestinationEditStore = defineStore('destinationEdit', {
const toBeDeleted = toBeDeletedMap.get(premiseId);
const filtered = destinations !== null ? destinations.filter(d => !toBeDeleted?.includes(d.destination_node.id)) : [];
this.destinations.set(premiseId, [...filtered, ...data[premiseId]]);
const dataForPremiseId = (data[premiseId] ?? null) === null ? [] : data[premiseId];
this.destinations.set(premiseId, [...filtered, ...dataForPremiseId]);
});
} catch (error) {

View file

@ -123,10 +123,21 @@ public class PropertyService {
}
@SuppressWarnings("unchecked")
public <T> Optional<T> getProperty(SystemPropertyMappingId mappingId, Integer setId) {
var prop = propertyRepository.getPropertyByMappingId(mappingId, setId);
return doCasting(prop);
}
public <T> Optional<T> getProperty(SystemPropertyMappingId mappingId) {
var prop = propertyRepository.getPropertyByMappingId(mappingId);
return doCasting(prop);
}
@SuppressWarnings("unchecked")
private <T> Optional<T> doCasting(Optional<PropertyDTO> prop) {
if (prop.isEmpty())
return Optional.empty();
@ -158,4 +169,6 @@ public class PropertyService {
default -> throw new IllegalArgumentException("Unsupported data type: " + dataType);
};
}
}

View file

@ -20,6 +20,7 @@ import de.avatic.lcc.repositories.premise.PremiseRepository;
import de.avatic.lcc.repositories.premise.RouteRepository;
import de.avatic.lcc.repositories.premise.RouteSectionRepository;
import de.avatic.lcc.repositories.properties.PropertyRepository;
import de.avatic.lcc.service.access.PropertyService;
import de.avatic.lcc.service.calculation.execution.steps.*;
import de.avatic.lcc.service.precalculation.PostCalculationCheckService;
import org.slf4j.Logger;
@ -51,9 +52,10 @@ public class CalculationExecutionService {
private final PostCalculationCheckService postCalculationCheckService;
private final CalculationJobDestinationRepository calculationJobDestinationRepository;
private final CalculationJobRouteSectionRepository calculationJobRouteSectionRepository;
private final PropertyService propertyService;
public CalculationExecutionService(PremiseRepository premiseRepository, DestinationRepository destinationRepository, RouteRepository routeRepository, RouteSectionRepository routeSectionRepository, CustomCostCalculationService customCostCalculationService, RouteSectionCostCalculationService routeSectionCostCalculationService, HandlingCostCalculationService handlingCostCalculationService, InventoryCostCalculationService inventoryCostCalculationService, PropertyRepository propertyRepository, AirfreightCalculationService airfreightCalculationService, PremiseToHuService premiseToHuService, ContainerCalculationService containerCalculationService, ShippingFrequencyCalculationService shippingFrequencyCalculationService, PostCalculationCheckService postCalculationCheckService, CalculationJobDestinationRepository calculationJobDestinationRepository, CalculationJobRouteSectionRepository calculationJobRouteSectionRepository) {
public CalculationExecutionService(PremiseRepository premiseRepository, DestinationRepository destinationRepository, RouteRepository routeRepository, RouteSectionRepository routeSectionRepository, CustomCostCalculationService customCostCalculationService, RouteSectionCostCalculationService routeSectionCostCalculationService, HandlingCostCalculationService handlingCostCalculationService, InventoryCostCalculationService inventoryCostCalculationService, PropertyRepository propertyRepository, AirfreightCalculationService airfreightCalculationService, PremiseToHuService premiseToHuService, ContainerCalculationService containerCalculationService, ShippingFrequencyCalculationService shippingFrequencyCalculationService, PostCalculationCheckService postCalculationCheckService, CalculationJobDestinationRepository calculationJobDestinationRepository, CalculationJobRouteSectionRepository calculationJobRouteSectionRepository, PropertyService propertyService) {
this.premiseRepository = premiseRepository;
this.destinationRepository = destinationRepository;
this.routeRepository = routeRepository;
@ -70,6 +72,7 @@ public class CalculationExecutionService {
this.postCalculationCheckService = postCalculationCheckService;
this.calculationJobDestinationRepository = calculationJobDestinationRepository;
this.calculationJobRouteSectionRepository = calculationJobRouteSectionRepository;
this.propertyService = propertyService;
}
private static ContainerType getBestContainerType(Map<ContainerType, List<SectionInfo>> sectionResults) {
@ -259,6 +262,16 @@ public class CalculationExecutionService {
private BestContainerTypeResult getSectionsFromBestContainerType(Integer setId, Integer periodId, Destination destination, Premise premise) {
PackagingDimension hu = premiseToHuService.createHuFromPremise(premise);
Map<ContainerType, Boolean> active = new HashMap<>() {
{
put(ContainerType.TRUCK, true);
put(ContainerType.FEU, (Boolean)propertyService.getProperty(SystemPropertyMappingId.FEU, setId).orElse(true));
put(ContainerType.TEU, (Boolean)propertyService.getProperty(SystemPropertyMappingId.TEU, setId).orElse(true));
put(ContainerType.HC, (Boolean)propertyService.getProperty(SystemPropertyMappingId.FEU_HQ, setId).orElse(true));
}
};
var route = routeRepository.getSelectedByDestinationId(destination.getId()).orElseThrow();
List<RouteSection> routeSections = routeSectionRepository.getByRouteId(route.getId());
@ -267,11 +280,12 @@ public class CalculationExecutionService {
// Get container calculation
for (var containerType : ContainerType.values()) {
if (!active.get(containerType)) continue;
containerCalculation.put(containerType, containerCalculationService.doCalculation(setId, hu, containerType, premise.getHuMixable(), premise.getHuStackable()));
}
for (var containerType : ContainerType.values()) {
if (!containerType.equals(ContainerType.TRUCK)) {
if (!containerType.equals(ContainerType.TRUCK) && active.get(containerType)) {
var sectionInfo = new ArrayList<SectionInfo>();