fix(lastleg): stock receipts into scanned locations
This commit is contained in:
+10
-1
@@ -15,6 +15,7 @@ import com.baiyue.lastleg.inboundplan.pda.mapper.ReceivingSkuReceiptMapper;
|
|||||||
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandRequests;
|
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandRequests;
|
||||||
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandResponse;
|
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandResponse;
|
||||||
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
||||||
|
import com.baiyue.lastleg.inboundplan.pda.gateway.WarehouseResourceGateway;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||||
@@ -43,6 +44,7 @@ public class InboundStockReceiptService {
|
|||||||
@Resource private InboundStockReceiptMapper receipts;
|
@Resource private InboundStockReceiptMapper receipts;
|
||||||
@Resource private ReceivingSkuReceiptMapper receivingSkuReceipts;
|
@Resource private ReceivingSkuReceiptMapper receivingSkuReceipts;
|
||||||
@Resource private InventoryCommandService inventory;
|
@Resource private InventoryCommandService inventory;
|
||||||
|
@Resource private WarehouseResourceGateway warehouseGateway;
|
||||||
@Resource private DropshipOrderService dropshipOrders;
|
@Resource private DropshipOrderService dropshipOrders;
|
||||||
@Resource private LastlegOrderStatusHistoryMapper orderHistories;
|
@Resource private LastlegOrderStatusHistoryMapper orderHistories;
|
||||||
|
|
||||||
@@ -237,13 +239,20 @@ public class InboundStockReceiptService {
|
|||||||
if (overseasWarehouseId.equals(trim(order.getSourceWarehouseId()))) {
|
if (overseasWarehouseId.equals(trim(order.getSourceWarehouseId()))) {
|
||||||
throw conflict("Actual overseas warehouse must not use the domestic source warehouse");
|
throw conflict("Actual overseas warehouse must not use the domestic source warehouse");
|
||||||
}
|
}
|
||||||
|
WarehouseResourceGateway.WarehouseLocationReference location = warehouseGateway.resolveLocation(
|
||||||
|
Long.parseLong(overseasWarehouseId), pallet.getWarehouseLocationId());
|
||||||
|
if (location == null || location.locationId() != pallet.getWarehouseLocationId()) {
|
||||||
|
throw conflict("Assigned warehouse location could not be resolved for stock-in");
|
||||||
|
}
|
||||||
|
String warehouseLocationCode = required(location.locationCode(),
|
||||||
|
"Assigned warehouse location code is required for stock-in");
|
||||||
InventoryCommandRequests.StockIn stockIn = new InventoryCommandRequests.StockIn(null, customerName,
|
InventoryCommandRequests.StockIn stockIn = new InventoryCommandRequests.StockIn(null, customerName,
|
||||||
overseasWarehouseId, overseasWarehouseCode, overseasWarehouseName,
|
overseasWarehouseId, overseasWarehouseCode, overseasWarehouseName,
|
||||||
line.getDestinationWarehouseId(), destinationCode,
|
line.getDestinationWarehouseId(), destinationCode,
|
||||||
line.getDestinationWarehouseName(), order.getId(), plan.getPlanNo(), line.getInboundCode(),
|
line.getDestinationWarehouseName(), order.getId(), plan.getPlanNo(), line.getInboundCode(),
|
||||||
sku.skuCode(), sku.productNameZh(), sku.productNameEn(),
|
sku.skuCode(), sku.productNameZh(), sku.productNameEn(),
|
||||||
pallet.getWarehousePalletId(), pallet.getPalletNo(), plan.getPlanNo(),
|
pallet.getWarehousePalletId(), pallet.getPalletNo(), plan.getPlanNo(),
|
||||||
pallet.getWarehouseLocationId(), null, packages, order.getOrderNo(),
|
pallet.getWarehouseLocationId(), warehouseLocationCode, packages, order.getOrderNo(),
|
||||||
order.getSourceEventId(), operationKey,
|
order.getSourceEventId(), operationKey,
|
||||||
"PDA inbound completion for " + line.getInboundCode());
|
"PDA inbound completion for " + line.getInboundCode());
|
||||||
InventoryCommandResponse result = Boolean.TRUE.equals(order.getDetained())
|
InventoryCommandResponse result = Boolean.TRUE.equals(order.getDetained())
|
||||||
|
|||||||
+9
@@ -14,6 +14,7 @@ import com.baiyue.lastleg.inboundplan.pda.mapper.ReceivingSkuReceiptMapper;
|
|||||||
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandRequests;
|
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandRequests;
|
||||||
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandResponse;
|
import com.baiyue.lastleg.inventory.command.dto.InventoryCommandResponse;
|
||||||
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
||||||
|
import com.baiyue.lastleg.inboundplan.pda.gateway.WarehouseResourceGateway;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
||||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||||
@@ -50,6 +51,7 @@ class InboundStockReceiptServiceTest {
|
|||||||
@Mock InboundStockReceiptMapper receipts;
|
@Mock InboundStockReceiptMapper receipts;
|
||||||
@Mock ReceivingSkuReceiptMapper receivingSkuReceipts;
|
@Mock ReceivingSkuReceiptMapper receivingSkuReceipts;
|
||||||
@Mock InventoryCommandService inventory;
|
@Mock InventoryCommandService inventory;
|
||||||
|
@Mock WarehouseResourceGateway warehouseGateway;
|
||||||
@Mock DropshipOrderService dropshipOrders;
|
@Mock DropshipOrderService dropshipOrders;
|
||||||
@Mock LastlegOrderStatusHistoryMapper orderHistories;
|
@Mock LastlegOrderStatusHistoryMapper orderHistories;
|
||||||
private InboundStockReceiptService service;
|
private InboundStockReceiptService service;
|
||||||
@@ -62,6 +64,12 @@ class InboundStockReceiptServiceTest {
|
|||||||
ReflectionTestUtils.setField(service, "receipts", receipts);
|
ReflectionTestUtils.setField(service, "receipts", receipts);
|
||||||
ReflectionTestUtils.setField(service, "receivingSkuReceipts", receivingSkuReceipts);
|
ReflectionTestUtils.setField(service, "receivingSkuReceipts", receivingSkuReceipts);
|
||||||
ReflectionTestUtils.setField(service, "inventory", inventory);
|
ReflectionTestUtils.setField(service, "inventory", inventory);
|
||||||
|
ReflectionTestUtils.setField(service, "warehouseGateway", warehouseGateway);
|
||||||
|
org.mockito.Mockito.lenient().when(warehouseGateway.resolveLocation(eq(900L), anyLong())).thenAnswer(invocation -> {
|
||||||
|
long locationId = invocation.getArgument(1);
|
||||||
|
return new WarehouseResourceGateway.WarehouseLocationReference(locationId,
|
||||||
|
"PDA-LAX-" + locationId, "STORAGE", BigDecimal.TEN, "OCCUPIED");
|
||||||
|
});
|
||||||
ReflectionTestUtils.setField(service, "dropshipOrders", dropshipOrders);
|
ReflectionTestUtils.setField(service, "dropshipOrders", dropshipOrders);
|
||||||
ReflectionTestUtils.setField(service, "orderHistories", orderHistories);
|
ReflectionTestUtils.setField(service, "orderHistories", orderHistories);
|
||||||
when(receipts.listTask("100", 2L)).thenReturn(List.of());
|
when(receipts.listTask("100", 2L)).thenReturn(List.of());
|
||||||
@@ -88,6 +96,7 @@ class InboundStockReceiptServiceTest {
|
|||||||
assertEquals("900", request.getValue().overseasWarehouseId());
|
assertEquals("900", request.getValue().overseasWarehouseId());
|
||||||
assertEquals("US-LAX-01", request.getValue().overseasWarehouseCode());
|
assertEquals("US-LAX-01", request.getValue().overseasWarehouseCode());
|
||||||
assertEquals("Los Angeles", request.getValue().overseasWarehouseName());
|
assertEquals("Los Angeles", request.getValue().overseasWarehouseName());
|
||||||
|
assertEquals("PDA-LAX-3001", request.getValue().warehouseLocationCode());
|
||||||
assertEquals("PLT-21", request.getValue().palletNo());
|
assertEquals("PLT-21", request.getValue().palletNo());
|
||||||
ArgumentCaptor<InboundStockReceipt> receipt = ArgumentCaptor.forClass(InboundStockReceipt.class);
|
ArgumentCaptor<InboundStockReceipt> receipt = ArgumentCaptor.forClass(InboundStockReceipt.class);
|
||||||
verify(receipts).insert(receipt.capture());
|
verify(receipts).insert(receipt.capture());
|
||||||
|
|||||||
Reference in New Issue
Block a user