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;
}
const performDownload = async (requestingStore, url, expectResponse = true, expectedException = null) => {
const performDownload = async (url, expectResponse = true, expectedException = null) => {
const params = {
method: 'GET',

View file

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

View file

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

View file

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

View file

@ -136,7 +136,7 @@ public class PremisesService {
var jobResult = future.get();
if (jobResult.getState().equals(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 {
postCalculationCheckService.doPostcheck(jobResult);

View file

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

View file

@ -142,6 +142,9 @@ public class RouteSectionCostCalculationService {
MatrixRate matrixRate = findMatrixRate(fromNode, toNode);
rate = matrixRate.getRate().multiply(BigDecimal.valueOf(distance));
transitTime = 3; // Default transit time for matrix rate
} else if (RateType.NEAR_BY == section.getRateType()) {
rate = BigDecimal.ZERO;
transitTime = 0;
} else {
throw new IllegalArgumentException("Unsupported rate type: " + section.getRateType());
}
@ -236,10 +239,11 @@ public class RouteSectionCostCalculationService {
private BigDecimal getUtilization(RateType rateType) {
BigDecimal utilization;
if (rateType == RateType.CONTAINER) {
if (rateType == RateType.NEAR_BY) {
utilization = BigDecimal.valueOf(Double.parseDouble(propertyRepository.getPropertyByMappingId(SystemPropertyMappingId.CONTAINER_UTIL).orElseThrow().getCurrentValue()));
}
else if (rateType == RateType.MATRIX) {
} else if (rateType == RateType.CONTAINER) {
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()));
} else
throw new IllegalArgumentException("Unknown rate type");
@ -272,11 +276,10 @@ public class RouteSectionCostCalculationService {
}
/**
* 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
('RAIL', 'SEA', 'ROAD', 'POST_RUN')),
rate_type CHAR(16) CHECK (rate_type IN
('CONTAINER', 'MATRIX')),
('CONTAINER', 'MATRIX', 'NEAR_BY')),
is_pre_run BOOLEAN DEFAULT FALSE,
is_main_run BOOLEAN DEFAULT FALSE,
is_post_run BOOLEAN DEFAULT FALSE,