Merge pull request 'dev' (#106) from dev into main

Reviewed-on: #106
This commit is contained in:
Jan Weber 2026-01-18 21:39:04 +00:00
commit 8be5f34137
3 changed files with 27 additions and 7 deletions

View file

@ -10,7 +10,7 @@
<PhCaretLeft :size="18" /> Previous <PhCaretLeft :size="18" /> Previous
</button> </button>
<!-- First helppages --> <!-- First pages -->
<button <button
v-if="showFirstPage" v-if="showFirstPage"
class="pagination-btn page-number" class="pagination-btn page-number"
@ -23,7 +23,7 @@
<!-- First ellipsis --> <!-- First ellipsis -->
<span v-if="showFirstEllipsis" class="ellipsis">...</span> <span v-if="showFirstEllipsis" class="ellipsis">...</span>
<!-- Page numbers around current helppages --> <!-- Page numbers around current pages -->
<button <button
v-for="pageNum in visiblePages" v-for="pageNum in visiblePages"
:key="pageNum" :key="pageNum"
@ -37,7 +37,7 @@
<!-- Last ellipsis --> <!-- Last ellipsis -->
<span v-if="showLastEllipsis" class="ellipsis">...</span> <span v-if="showLastEllipsis" class="ellipsis">...</span>
<!-- Last helppages --> <!-- Last pages -->
<button <button
v-if="showLastPage" v-if="showLastPage"
class="pagination-btn page-number" class="pagination-btn page-number"
@ -90,7 +90,7 @@ export default {
default: 5 default: 5
} }
}, },
emits: ['helppages-change'], emits: ['page-change'],
computed: { computed: {
visiblePages() { visiblePages() {
const delta = Math.floor(this.maxVisiblePages / 2); const delta = Math.floor(this.maxVisiblePages / 2);
@ -130,7 +130,7 @@ export default {
methods: { methods: {
goToPage(pageNumber) { goToPage(pageNumber) {
if (pageNumber >= 1 && pageNumber <= this.pageCount && pageNumber !== this.page) { if (pageNumber >= 1 && pageNumber <= this.pageCount && pageNumber !== this.page) {
this.$emit('helppages-change', pageNumber); this.$emit('page-change', pageNumber);
} }
} }
} }

View file

@ -177,6 +177,12 @@ public class PremisesService {
premissIds.forEach(id -> { premissIds.forEach(id -> {
var old = premiseRepository.getPremiseById(id).orElseThrow(); var old = premiseRepository.getPremiseById(id).orElseThrow();
var existingPremises = premiseRepository.findByMaterialIdAndSupplierId(old.getMaterialId(), old.getSupplierNodeId(), old.getUserSupplierNodeId(), userId);
var existingDrafts = existingPremises.stream().filter(p -> p.getState().equals(PremiseState.DRAFT)).toList();
this.delete(existingDrafts.stream().map(Premise::getId).toList());
var newId = premiseRepository.insert(old.getMaterialId(), old.getSupplierNodeId(), old.getUserSupplierNodeId(), BigDecimal.valueOf(old.getLocation().getLatitude()), BigDecimal.valueOf(old.getLocation().getLongitude()), old.getCountryId(), userId); var newId = premiseRepository.insert(old.getMaterialId(), old.getSupplierNodeId(), old.getUserSupplierNodeId(), BigDecimal.valueOf(old.getLocation().getLatitude()), BigDecimal.valueOf(old.getLocation().getLongitude()), old.getCountryId(), userId);
premiseRepository.updateMaterial(Collections.singletonList(newId), old.getHsCode(), old.getTariffRate(), old.getTariffUnlocked()); premiseRepository.updateMaterial(Collections.singletonList(newId), old.getHsCode(), old.getTariffRate(), old.getTariffUnlocked());

View file

@ -142,12 +142,14 @@ public class CalculationExecutionService {
CalculationJobDestination destinationCalculationJob = new CalculationJobDestination(); CalculationJobDestination destinationCalculationJob = new CalculationJobDestination();
boolean hasMainRun = true; boolean hasMainRun = true;
BigDecimal leadTime = null; BigDecimal leadTime = null;
boolean isWeightExceeded = false;
if (destination.getD2d()) { if (destination.getD2d()) {
selectedContainerCalculation = containerCalculationService.doCalculation(setId, premiseToHuService.createHuFromPremise(premise), ContainerType.FEU, premise.getHuMixable(), premise.getHuStackable()); selectedContainerCalculation = containerCalculationService.doCalculation(setId, premiseToHuService.createHuFromPremise(premise), ContainerType.FEU, premise.getHuMixable(), premise.getHuStackable());
sections = List.of(new SectionInfo(null, routeSectionCostCalculationService.doD2dCalculation(setId, periodId, premise, destination, selectedContainerCalculation), selectedContainerCalculation)); sections = List.of(new SectionInfo(null, routeSectionCostCalculationService.doD2dCalculation(setId, periodId, premise, destination, selectedContainerCalculation), selectedContainerCalculation));
leadTime = BigDecimal.valueOf(destination.getLeadTimeD2d()); leadTime = BigDecimal.valueOf(destination.getLeadTimeD2d());
usedContainerType = ContainerType.FEU; usedContainerType = ContainerType.FEU;
isWeightExceeded = sections.getFirst().result().isWeightPrice();
} else { } else {
var bestContainerTypeResult = getSectionsFromBestContainerType(setId, periodId, destination, premise); var bestContainerTypeResult = getSectionsFromBestContainerType(setId, periodId, destination, premise);
sections = bestContainerTypeResult.sections; sections = bestContainerTypeResult.sections;
@ -162,6 +164,17 @@ public class CalculationExecutionService {
s.result().setPreRun(false); s.result().setPreRun(false);
s.result().setPostRun(false); s.result().setPostRun(false);
}); });
var containerSections = sections.stream().filter(s -> s.section().getRateType() != RateType.MATRIX).toList();
if(containerSections.size() > 1) {
isWeightExceeded = containerSections.stream().anyMatch(s -> s.result().isWeightPrice());
} else {
isWeightExceeded = sections.getFirst().result().isWeightPrice();
}
} else {
isWeightExceeded = sections.stream().map(SectionInfo::result).filter(CalculationJobRouteSection::getMainRun).anyMatch(CalculationJobRouteSection::isWeightPrice);
} }
selectedContainerCalculation = bestContainerTypeResult.selectedContainerCalculation; selectedContainerCalculation = bestContainerTypeResult.selectedContainerCalculation;
@ -207,7 +220,7 @@ public class CalculationExecutionService {
destinationCalculationJob.setAnnualCustomCost(customCost.getAnnualCost()); destinationCalculationJob.setAnnualCustomCost(customCost.getAnnualCost());
destinationCalculationJob.setAnnualTransportationCost(sections.stream().map(SectionInfo::result).map(CalculationJobRouteSection::getAnnualCost).reduce(BigDecimal.ZERO, BigDecimal::add)); destinationCalculationJob.setAnnualTransportationCost(sections.stream().map(SectionInfo::result).map(CalculationJobRouteSection::getAnnualCost).reduce(BigDecimal.ZERO, BigDecimal::add));
destinationCalculationJob.setTransportWeightExceeded(sections.stream().map(SectionInfo::result).filter(CalculationJobRouteSection::getMainRun).anyMatch(CalculationJobRouteSection::isWeightPrice)); destinationCalculationJob.setTransportWeightExceeded(isWeightExceeded);
destinationCalculationJob.setLayerCount(sections.getFirst().containerResult().getLayer()); destinationCalculationJob.setLayerCount(sections.getFirst().containerResult().getLayer());
destinationCalculationJob.setLayerStructure(null); //TODO generate layer structure destinationCalculationJob.setLayerStructure(null); //TODO generate layer structure
destinationCalculationJob.setHuCount(sections.getFirst().containerResult().getHuUnitCount()); destinationCalculationJob.setHuCount(sections.getFirst().containerResult().getHuUnitCount());
@ -216,10 +229,11 @@ public class CalculationExecutionService {
double huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(premise.getHuUnitCount()),4, RoundingMode.UP ).doubleValue(); double huAnnualAmount = BigDecimal.valueOf(destination.getAnnualAmount()).divide(BigDecimal.valueOf(premise.getHuUnitCount()),4, RoundingMode.UP ).doubleValue();
destinationCalculationJob.setShippingFrequency(Double.valueOf(shippingFrequencyCalculationService.doCalculation(setId, huAnnualAmount, selectedContainerCalculation.getHuPerContainer(),!premise.getHuMixable())).intValue()); destinationCalculationJob.setShippingFrequency((int) Math.round(shippingFrequencyCalculationService.doCalculation(setId, huAnnualAmount, selectedContainerCalculation.getHuPerContainer(), !premise.getHuMixable())));
var commonCost = destinationCalculationJob.getAnnualHandlingCost() var commonCost = destinationCalculationJob.getAnnualHandlingCost()
.add(destinationCalculationJob.getAnnualDisposalCost()) .add(destinationCalculationJob.getAnnualDisposalCost())
.add(destinationCalculationJob.getAnnualRepackingCost())
.add(destinationCalculationJob.getAnnualCapitalCost()) .add(destinationCalculationJob.getAnnualCapitalCost())
.add(destinationCalculationJob.getAnnualStorageCost()) .add(destinationCalculationJob.getAnnualStorageCost())
.add(materialCost.multiply(BigDecimal.valueOf(destination.getAnnualAmount()))) .add(materialCost.multiply(BigDecimal.valueOf(destination.getAnnualAmount())))