BACKEND: fixed near_by routing bug

FRONTEND: added bulk menu
This commit is contained in:
Jan 2025-09-13 21:35:46 +02:00
parent a2822666a6
commit ad5a97ec74
8 changed files with 23 additions and 17 deletions

View file

@ -23,7 +23,7 @@ const performRequest = async (requestingStore, method, url, body, expectResponse
return data; return data;
} }
const performDownload = async (requestingStore, url, expectResponse = true, expectedException = null) => { const performDownload = async (url, expectResponse = true, expectedException = null) => {
const params = { const params = {
method: 'GET', method: 'GET',

View file

@ -96,6 +96,7 @@ export default {
methods: { methods: {
async downloadFile() { async downloadFile() {
const url = `${config.backendUrl}/bulk/upload/${this.exportDataset}/${this.exportType}/` const url = `${config.backendUrl}/bulk/upload/${this.exportDataset}/${this.exportType}/`
this.processId = await performDownload(url); this.processId = await performDownload(url);
}, },
inputFile(event) { inputFile(event) {

View file

@ -1,5 +1,5 @@
package de.avatic.lcc.dto.generic; package de.avatic.lcc.dto.generic;
public enum RateType { public enum RateType {
MATRIX, CONTAINER, D2D MATRIX, CONTAINER, D2D, NEAR_BY
} }

View file

@ -84,6 +84,7 @@ public class CalculationJobRouteSectionRepository {
} }
return switch (rateType) { return switch (rateType) {
case NEAR_BY -> RateType.MATRIX.name();
case MATRIX, D2D -> rateType.name(); case MATRIX, D2D -> rateType.name();
case CONTAINER -> transportType == null ? null : transportType.name(); case CONTAINER -> transportType == null ? null : transportType.name();
}; };

View file

@ -136,7 +136,7 @@ public class PremisesService {
var jobResult = future.get(); var jobResult = future.get();
if (jobResult.getState().equals(CalculationJobState.EXCEPTION)) { if (jobResult.getState().equals(CalculationJobState.EXCEPTION)) {
calculationJobRepository.setStateTo(jobResult.getJobId(), CalculationJobState.EXCEPTION); calculationJobRepository.setStateTo(jobResult.getJobId(), CalculationJobState.EXCEPTION);
throw new InternalErrorException("Execution of calculation was not successful. Please contact Administrator.", new Exception(jobResult.getException())); throw new InternalErrorException("Execution of calculation was not successful. Please contact Administrator.",jobResult.getException().getMessage(), new Exception(jobResult.getException()));
} else { } else {
postCalculationCheckService.doPostcheck(jobResult); postCalculationCheckService.doPostcheck(jobResult);

View file

@ -220,8 +220,9 @@ public class RoutingService {
private RateType mapRateType(TemporaryRateObject rate) { private RateType mapRateType(TemporaryRateObject rate) {
if (Objects.requireNonNull(rate.getType()) == TemporaryRateObject.TemporaryRateObjectType.MATRIX if (Objects.requireNonNull(rate.getType()) == TemporaryRateObject.TemporaryRateObjectType.NEAR_BY) {
|| Objects.requireNonNull(rate.getType()) == TemporaryRateObject.TemporaryRateObjectType.NEAR_BY) { return RateType.NEAR_BY;
} else if (Objects.requireNonNull(rate.getType()) == TemporaryRateObject.TemporaryRateObjectType.MATRIX) {
return RateType.MATRIX; return RateType.MATRIX;
} }
return RateType.CONTAINER; return RateType.CONTAINER;
@ -237,7 +238,7 @@ public class RoutingService {
return TransportType.POST_RUN; return TransportType.POST_RUN;
} }
case MAIN_RUN -> { case MAIN_RUN -> {
return TransportType.valueOf(rate.getContainerRateTye().name()); return TransportType.valueOf(rate.getContainerRateType().name());
} }
} }
@ -498,13 +499,13 @@ public class RoutingService {
same = otherSection.hasSameNodes(section); same = otherSection.hasSameNodes(section);
if(!same && hasNearByRouting && iter.hasNext()) { if (!same && hasNearByRouting && iter.hasNext()) {
lastSection = section; lastSection = section;
section = iter.next(); section = iter.next();
same = section.getType().equals(TemporaryRateObject.TemporaryRateObjectType.NEAR_BY) && otherSection.hasSameNodes(section, lastSection); same = section.getType().equals(TemporaryRateObject.TemporaryRateObjectType.NEAR_BY) && otherSection.hasSameNodes(section, lastSection);
} }
if(!same) { if (!same) {
break; break;
} }
} }
@ -1007,7 +1008,7 @@ public class RoutingService {
return type; return type;
} }
public TransportType getContainerRateTye() { public TransportType getContainerRateType() {
return containerRate.getType(); return containerRate.getType();
} }

View file

@ -142,6 +142,9 @@ public class RouteSectionCostCalculationService {
MatrixRate matrixRate = findMatrixRate(fromNode, toNode); MatrixRate matrixRate = findMatrixRate(fromNode, toNode);
rate = matrixRate.getRate().multiply(BigDecimal.valueOf(distance)); rate = matrixRate.getRate().multiply(BigDecimal.valueOf(distance));
transitTime = 3; // Default transit time for matrix rate transitTime = 3; // Default transit time for matrix rate
} else if (RateType.NEAR_BY == section.getRateType()) {
rate = BigDecimal.ZERO;
transitTime = 0;
} else { } else {
throw new IllegalArgumentException("Unsupported rate type: " + section.getRateType()); throw new IllegalArgumentException("Unsupported rate type: " + section.getRateType());
} }
@ -169,7 +172,7 @@ public class RouteSectionCostCalculationService {
result.setWeightPrice(containerCalculation.isWeightExceeded()); result.setWeightPrice(containerCalculation.isWeightExceeded());
result.setCbmPrice(prices.volumePrice); result.setCbmPrice(prices.volumePrice);
result.setWeightPrice(prices.weightPrice); result.setWeightPrice(prices.weightPrice);
result.setUtilization(!containerCalculation.isWeightExceeded() || !premise.getHuMixable() ? prices.utilization : BigDecimal.valueOf(1.0)); result.setUtilization(!containerCalculation.isWeightExceeded() || !premise.getHuMixable() ? prices.utilization : BigDecimal.valueOf(1.0));
var chanceRiskFactors = changeRiskFactorCalculationService.getChanceRiskFactors(); var chanceRiskFactors = changeRiskFactorCalculationService.getChanceRiskFactors();
@ -236,10 +239,11 @@ public class RouteSectionCostCalculationService {
private BigDecimal getUtilization(RateType rateType) { private BigDecimal getUtilization(RateType rateType) {
BigDecimal utilization; BigDecimal utilization;
if (rateType == RateType.CONTAINER) { if (rateType == RateType.NEAR_BY) {
utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.CONTAINER_UTIL).orElseThrow().getCurrentValue())); utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.CONTAINER_UTIL).orElseThrow().getCurrentValue()));
} } else if (rateType == RateType.CONTAINER) {
else if (rateType == RateType.MATRIX) { utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.CONTAINER_UTIL).orElseThrow().getCurrentValue()));
} else if (rateType == RateType.MATRIX) {
utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.TRUCK_UTIL).orElseThrow().getCurrentValue())); utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.TRUCK_UTIL).orElseThrow().getCurrentValue()));
} else } else
throw new IllegalArgumentException("Unknown rate type"); throw new IllegalArgumentException("Unknown rate type");
@ -272,11 +276,10 @@ public class RouteSectionCostCalculationService {
} }
/** /**
* Simple data class to hold volume and weight price results * Simple data class to hold volume and weight price results
*/ */
private record PriceCalculationResult(BigDecimal volumePrice, BigDecimal weightPrice, BigDecimal utilization) {} private record PriceCalculationResult(BigDecimal volumePrice, BigDecimal weightPrice, BigDecimal utilization) {
}
} }

View file

@ -441,7 +441,7 @@ CREATE TABLE IF NOT EXISTS premise_route_section
transport_type CHAR(16) CHECK (transport_type IN transport_type CHAR(16) CHECK (transport_type IN
('RAIL', 'SEA', 'ROAD', 'POST_RUN')), ('RAIL', 'SEA', 'ROAD', 'POST_RUN')),
rate_type CHAR(16) CHECK (rate_type IN rate_type CHAR(16) CHECK (rate_type IN
('CONTAINER', 'MATRIX')), ('CONTAINER', 'MATRIX', 'NEAR_BY')),
is_pre_run BOOLEAN DEFAULT FALSE, is_pre_run BOOLEAN DEFAULT FALSE,
is_main_run BOOLEAN DEFAULT FALSE, is_main_run BOOLEAN DEFAULT FALSE,
is_post_run BOOLEAN DEFAULT FALSE, is_post_run BOOLEAN DEFAULT FALSE,