fix: fall back to order declared volume
This commit is contained in:
+28
@@ -2,6 +2,7 @@ package com.baiyue.firstleg.service;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.firstleg.client.OrderCargoClient;
|
||||
import com.baiyue.firstleg.client.WarehousePalletLocationClient;
|
||||
import com.baiyue.firstleg.config.InboundProperties;
|
||||
import com.baiyue.firstleg.entity.InboundOrderEntity;
|
||||
@@ -45,6 +46,7 @@ class MeasurementLocationOccupationServiceTest {
|
||||
@MockBean private InboundPalletAllocationRepository allocations;
|
||||
@MockBean private InboundWorkflowRepository workflow;
|
||||
@MockBean private InboundMeasurementRepository measurements;
|
||||
@MockBean private OrderCargoClient orderCargo;
|
||||
@Resource private InboundProperties properties;
|
||||
@Resource private MeasurementLocationOccupationService service;
|
||||
|
||||
@@ -160,6 +162,32 @@ class MeasurementLocationOccupationServiceTest {
|
||||
20, new BigDecimal("2.5000"), block("OCCUPIED", 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fallsBackToLatestOrderDeclarationWhenNoMeasurementBatchExists() {
|
||||
InboundOrderEntity inbound = inbound();
|
||||
inbound.setOrderId(77L);
|
||||
inbound.setActualVolumeCbm(null);
|
||||
when(workflow.findOwned(BUSINESS_TENANT, INBOUND)).thenReturn(inbound);
|
||||
when(measurements.findLatestMeasurement(BUSINESS_TENANT, INBOUND)).thenReturn(null);
|
||||
when(orderCargo.measurementDeclaration("internal-token", BUSINESS_TENANT, inbound.getOrderId()))
|
||||
.thenReturn(ApiResponse.success(new OrderCargoClient.MeasurementDeclarationSnapshot(
|
||||
"REF-88", new BigDecimal("100"), new BigDecimal("6.5000"), "货物")));
|
||||
when(measurements.listWeights(BUSINESS_TENANT, INBOUND))
|
||||
.thenReturn(confirmedWeights().subList(0, 1));
|
||||
when(warehouse.reserveBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
|
||||
org.mockito.ArgumentMatchers.any())).thenReturn(ApiResponse.success(block("RESERVED", 6)));
|
||||
when(warehouse.confirmBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
|
||||
org.mockito.ArgumentMatchers.any())).thenReturn(ApiResponse.success(block("OCCUPIED", 6)));
|
||||
|
||||
service.ensureForConfirmedWeight(BUSINESS_TENANT, INBOUND, OPERATOR, MEASUREMENT, 1);
|
||||
|
||||
verify(orderCargo).measurementDeclaration("internal-token", BUSINESS_TENANT, inbound.getOrderId());
|
||||
verify(warehouse).reserveBlock(org.mockito.ArgumentMatchers.eq("internal-token"),
|
||||
org.mockito.ArgumentMatchers.argThat(request -> request.requiredSlotCount() == 6));
|
||||
verify(allocations).replaceBlock(BUSINESS_TENANT, INBOUND, WAREHOUSE,
|
||||
20, new BigDecimal("6.5000"), block("OCCUPIED", 6));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsConfirmedWeightWithoutConfirmationTimeInsteadOfDroppingIt() {
|
||||
InboundWeightResultEntity weight = confirmedWeights().get(0);
|
||||
|
||||
Reference in New Issue
Block a user