贴标申请,仓储转运
This commit is contained in:
+78
@@ -92,6 +92,84 @@ class PdaPalletOperationServiceTest {
|
||||
service.configureTransactions(new NoOpTransactionManager());
|
||||
}
|
||||
|
||||
@Test void returnPalletTotalsFollowCurrentBindingsWithoutCountingRetriesTwice() {
|
||||
var first = new ReturnInventoryCarton(); first.setWeight(new java.math.BigDecimal("5"));
|
||||
first.setLength(new java.math.BigDecimal("30")); first.setWidth(new java.math.BigDecimal("20"));
|
||||
first.setHeight(new java.math.BigDecimal("20")); first.setDestinationWarehouseCode("SCK8");
|
||||
var second = new ReturnInventoryCarton(); second.setWeight(new java.math.BigDecimal("11"));
|
||||
second.setLength(new java.math.BigDecimal("40")); second.setWidth(new java.math.BigDecimal("30"));
|
||||
second.setHeight(new java.math.BigDecimal("30")); second.setDestinationWarehouseCode("SCK8");
|
||||
var pallet = new PalletPhysicalGateway.PalletReference(10L, "TARGET", 88L, null, "OCCUPIED", "SCK8", 2);
|
||||
when(returnCartons.palletCartons("88", "TARGET")).thenReturn(List.of(first), List.of(first, second), List.of(first, second), List.of(first));
|
||||
var before = (com.baiyue.lastleg.palletops.dto.PalletOperationResponses.PalletContent) ReflectionTestUtils.invokeMethod(service, "content", 88L, pallet);
|
||||
assertEquals(0, before.grossWeightKg().compareTo(new java.math.BigDecimal("5")));
|
||||
var added = (com.baiyue.lastleg.palletops.dto.PalletOperationResponses.PalletContent) ReflectionTestUtils.invokeMethod(service, "content", 88L, pallet);
|
||||
assertEquals(2, added.totalPackages());
|
||||
assertEquals(0, added.grossWeightKg().compareTo(new java.math.BigDecimal("16")));
|
||||
assertEquals(0, added.volumeCbm().compareTo(new java.math.BigDecimal("0.048")));
|
||||
assertEquals(added, ReflectionTestUtils.invokeMethod(service, "content", 88L, pallet));
|
||||
assertEquals(before, ReflectionTestUtils.invokeMethod(service, "content", 88L, pallet));
|
||||
}
|
||||
|
||||
@Test void returnRebindingRequiresCurrentRoundBindingAndAddsToExistingPallet() {
|
||||
var workTasks = mock(com.baiyue.lastleg.relabel.pda.mapper.PdaRelabelTaskMapper.class);
|
||||
var workHistory = mock(com.baiyue.lastleg.relabel.pda.mapper.PdaRelabelHistoryMapper.class);
|
||||
ReflectionTestUtils.setField(service, "relabelWorkTasks", workTasks);
|
||||
ReflectionTestUtils.setField(service, "relabelWorkHistory", workHistory);
|
||||
var app = new RelabelApplication(); app.setId(600L); app.setCustomerId("100");
|
||||
var task = new com.baiyue.lastleg.relabel.pda.entity.PdaRelabelTask(); task.setId(700L);
|
||||
when(workTasks.find("100", 600L)).thenReturn(task);
|
||||
var item = new RelabelItem(); item.setReturnCartonId(801L); item.setCartonMark("BOX-1");
|
||||
item.setDestinationFbaWarehouseCode("SCK8"); item.setNotifiedPackageCount(1);
|
||||
var box = new ReturnInventoryCarton(); box.setId(801L); box.setCustomerId("100");
|
||||
box.setPalletCode("SOURCE"); box.setRelabelApplicationId(600L); box.setStatus("RELABEL_PENDING");
|
||||
box.setTotalQuantity(10L); box.setWeight(new java.math.BigDecimal("11"));
|
||||
box.setLength(new java.math.BigDecimal("40")); box.setWidth(new java.math.BigDecimal("30"));
|
||||
box.setHeight(new java.math.BigDecimal("30")); box.setDestinationWarehouseCode("SCK8");
|
||||
var existing = new ReturnInventoryCarton(); existing.setWeight(new java.math.BigDecimal("5"));
|
||||
existing.setLength(new java.math.BigDecimal("30")); existing.setWidth(new java.math.BigDecimal("20"));
|
||||
existing.setHeight(new java.math.BigDecimal("20")); existing.setDestinationWarehouseCode("SCK8");
|
||||
var source = new PalletPhysicalGateway.PalletReference(20L, "SOURCE", 88L, 1020L, "OCCUPIED", "SCK8", 1);
|
||||
var target = new PalletPhysicalGateway.PalletReference(10L, "TARGET", 88L, 1010L, "OCCUPIED", "SCK8", 2);
|
||||
when(returnCartons.lockId(801L)).thenReturn(box);
|
||||
when(returnCartons.palletCartons("88", "TARGET")).thenAnswer(call ->
|
||||
"TARGET".equals(box.getPalletCode()) ? List.of(existing, box) : List.of(existing));
|
||||
var request = new PalletOperationRequests.RelabelDisassemble("rebind-current", "RL-1",
|
||||
new PalletOperationRequests.PalletExpectation("SOURCE", 1),
|
||||
new PalletOperationRequests.PalletExpectation("TARGET", 2), List.of("BOX-1"), "rebind");
|
||||
assertThrows(ResponseStatusException.class, () -> ReflectionTestUtils.invokeMethod(service,
|
||||
"bindReturnRelabelPallet", identity(), app, List.of(item), source, target, request));
|
||||
verifyNoInteractions(physical);
|
||||
var binding = new com.baiyue.lastleg.relabel.pda.entity.PdaRelabelHistory();
|
||||
binding.setDetailJson("{\"round\":\"INITIAL\",\"cartonMarks\":[\"BOX-1\"]}");
|
||||
when(workHistory.selectList(any())).thenReturn(List.of(binding));
|
||||
task.setReviewedAt(LocalDateTime.of(2026, 10, 12, 12, 0));
|
||||
assertThrows(ResponseStatusException.class, () -> ReflectionTestUtils.invokeMethod(service,
|
||||
"bindReturnRelabelPallet", identity(), app, List.of(item), source, target, request));
|
||||
task.setReviewedAt(null);
|
||||
when(physical.resolve("SOURCE")).thenReturn(source);
|
||||
when(physical.resolve("TARGET")).thenReturn(target);
|
||||
var result = (com.baiyue.lastleg.palletops.dto.PalletOperationResponses.Operation)
|
||||
ReflectionTestUtils.invokeMethod(service, "bindReturnRelabelPallet", identity(), app,
|
||||
List.of(item), source, target, request);
|
||||
assertEquals("TARGET", box.getPalletCode());
|
||||
assertEquals(0, result.pallets().get(0).totalPackages());
|
||||
assertEquals(2, result.pallets().get(1).totalPackages());
|
||||
assertEquals(0, result.pallets().get(1).grossWeightKg().compareTo(new java.math.BigDecimal("16")));
|
||||
assertEquals(0, result.pallets().get(1).volumeCbm().compareTo(new java.math.BigDecimal("0.048")));
|
||||
verify(returnCartons).updateById(box);
|
||||
verify(workHistory).insert(any(com.baiyue.lastleg.relabel.pda.entity.PdaRelabelHistory.class));
|
||||
}
|
||||
|
||||
@Test void missingCartonMeasurementDoesNotBecomeZeroWeight() {
|
||||
var box = new ReturnInventoryCarton(); box.setWeight(new java.math.BigDecimal("5"));
|
||||
when(returnCartons.palletCartons("88", "TARGET")).thenReturn(List.of(box));
|
||||
var pallet = new PalletPhysicalGateway.PalletReference(10L, "TARGET", 88L, null, "OCCUPIED", "SCK8", 2);
|
||||
var result = (com.baiyue.lastleg.palletops.dto.PalletOperationResponses.PalletContent) ReflectionTestUtils.invokeMethod(service, "content", 88L, pallet);
|
||||
assertNull(result.volumeCbm());
|
||||
assertEquals(0, result.grossWeightKg().compareTo(new java.math.BigDecimal("5")));
|
||||
}
|
||||
|
||||
@Test void partialReturnRelabelKeepsUnlabelledRemainderOnOriginalPallet() {
|
||||
RelabelApplication app = new RelabelApplication(); app.setId(600L); app.setCustomerId("100"); app.setRelabelNo("RL-1");
|
||||
RelabelItem item = new RelabelItem(); item.setId(701L); item.setSkuCode("SKU-1");
|
||||
|
||||
Reference in New Issue
Block a user