fix: reserve pallet block from declared volume

This commit is contained in:
2026-09-04 13:28:57 +08:00
parent 944ecb2bf3
commit 660e284e25
2 changed files with 33 additions and 4 deletions
@@ -5,6 +5,7 @@ import com.baiyue.common.core.exception.BizException;
import com.baiyue.firstleg.client.WarehousePalletLocationClient;
import com.baiyue.firstleg.config.InboundProperties;
import com.baiyue.firstleg.entity.InboundOrderEntity;
import com.baiyue.firstleg.entity.InboundMeasurementEntity;
import com.baiyue.firstleg.entity.InboundWeightResultEntity;
import com.baiyue.firstleg.repository.InboundMeasurementRepository;
import com.baiyue.firstleg.repository.InboundPalletAllocationRepository;
@@ -136,6 +137,29 @@ class MeasurementLocationOccupationServiceTest {
verify(allocations).bindConfirmedWeights(BUSINESS_TENANT, INBOUND, twoWeights);
}
@Test
void reservesByCustomerDeclaredVolumeBeforeMeasuredVolumeIsFrozen() {
InboundOrderEntity inbound = inbound();
inbound.setActualVolumeCbm(null);
InboundMeasurementEntity measurement = new InboundMeasurementEntity();
measurement.setOriginalVolumeCbm(new BigDecimal("2.5000"));
when(workflow.findOwned(BUSINESS_TENANT, INBOUND)).thenReturn(inbound);
when(measurements.findLatestMeasurement(BUSINESS_TENANT, INBOUND)).thenReturn(measurement);
when(measurements.listWeights(BUSINESS_TENANT, INBOUND))
.thenReturn(confirmedWeights().subList(0, 2));
when(warehouse.reserveBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
org.mockito.ArgumentMatchers.any())).thenReturn(ApiResponse.success(block("RESERVED", 3)));
when(warehouse.confirmBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
org.mockito.ArgumentMatchers.any())).thenReturn(ApiResponse.success(block("OCCUPIED", 3)));
service.ensureForConfirmedWeight(BUSINESS_TENANT, INBOUND, OPERATOR, MEASUREMENT, 3);
verify(warehouse).reserveBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
org.mockito.ArgumentMatchers.argThat(request -> request.requiredSlotCount() == 3));
verify(allocations).replaceBlock(BUSINESS_TENANT, INBOUND, WAREHOUSE,
20, new BigDecimal("2.5000"), block("OCCUPIED", 3));
}
@Test
void rejectsConfirmedWeightWithoutConfirmationTimeInsteadOfDroppingIt() {
InboundWeightResultEntity weight = confirmedWeights().get(0);