入库修改

This commit is contained in:
2026-08-20 13:34:34 +08:00
parent 3b19a1bc16
commit b139255d3b
24 changed files with 528 additions and 62 deletions
@@ -4,6 +4,7 @@ import com.baiyue.lastleg.inboundplan.entity.InboundPlan;
import com.baiyue.lastleg.inboundplan.entity.InboundPlanLine;
import com.baiyue.lastleg.inboundplan.entity.InboundPlanPallet;
import com.baiyue.lastleg.inboundplan.entity.InboundPlanPalletAllocation;
import com.baiyue.lastleg.inboundplan.entity.InboundPlanCarton;
import com.baiyue.lastleg.inboundplan.pda.dto.PdaRequests;
import com.baiyue.lastleg.inboundplan.pda.entity.InboundPalletMerge;
import com.baiyue.lastleg.inboundplan.pda.entity.InboundPdaOperation;
@@ -94,7 +95,8 @@ class InboundPdaWorkflowServiceTest {
targetPallet.setWarehouseResourceLockId(null);
targetPallet.setAssignmentStatus("PENDING_ASSIGNMENT");
when(repository.lockPallet(plan.getId(), targetPallet.getId())).thenReturn(targetPallet);
when(warehouse.reserve("100", 88L, 188L, 288L, "INBOUND_PLAN_PALLET", "LIP1:21", "assign-1"))
when(warehouse.reserve("100", 88L, 188L, 288L, "INBOUND_CONTAINER_DESTINATION_PALLET", "CONT-1:88",
"INBOUND_CONTAINER_DESTINATION_PALLET:CONT-1:88"))
.thenReturn(999L);
when(repository.pallets(plan.getId())).thenReturn(List.of(targetPallet));
@@ -125,6 +127,66 @@ class InboundPdaWorkflowServiceTest {
targetPallet.getWarehouseLocationId(), "assign-wrong-warehouse")));
}
@Test
void cartonScanBindsOnlyExpectedCartonAndRemoveMakesItScannableAgain() {
InboundPlanCarton carton = carton("BOX-001", "UNASSIGNED", targetLine.getId(), "WH-A");
activeTask();
when(repository.lockCarton("100", "BOX-001")).thenReturn(carton);
when(repository.lockPallet(plan.getId(), targetPallet.getId())).thenReturn(targetPallet);
when(repository.line(plan.getId(), targetLine.getId())).thenReturn(targetLine);
when(repository.lockAllocation(plan.getId(), targetLine.getId(), targetPallet.getId())).thenReturn(target);
var scanned = service.scanCarton("100", "LIP1",
new PdaRequests.ScanCarton("BOX-001", targetPallet.getId(), "scan-1", "7", "worker"));
assertEquals("SCANNED", scanned.result());
assertEquals("ON_PALLET", carton.getStatus());
assertEquals(1, carton.getVersion());
assertEquals(1, target.getPickedPackageCount());
verify(repository).update(carton);
var removed = service.removeCarton("100", "LIP1",
new PdaRequests.RemoveCarton("BOX-001", "remove-1", "7", "worker"));
assertEquals("REMOVED", removed.result());
assertEquals("UNASSIGNED", carton.getStatus());
assertEquals(0, target.getPickedPackageCount());
assertEquals(3, targetPallet.getActualPackageCount());
}
@Test
void cartonScanRejectsDuplicateAndWrongDestination() {
InboundPlanCarton repeated = carton("BOX-002", "ON_PALLET", targetLine.getId(), "WH-A");
activeTask();
when(repository.lockCarton("100", "BOX-002")).thenReturn(repeated);
assertThrows(ResponseStatusException.class, () -> service.scanCarton("100", "LIP1",
new PdaRequests.ScanCarton("BOX-002", targetPallet.getId(), "scan-repeat", "7", "worker")));
InboundPlanCarton mismatched = carton("BOX-003", "UNASSIGNED", targetLine.getId(), "WH-B");
when(repository.lockCarton("100", "BOX-003")).thenReturn(mismatched);
when(repository.lockPallet(plan.getId(), targetPallet.getId())).thenReturn(targetPallet);
assertThrows(ResponseStatusException.class, () -> service.scanCarton("100", "LIP1",
new PdaRequests.ScanCarton("BOX-003", targetPallet.getId(), "scan-destination", "7", "worker")));
}
@Test
void cartonScanUsesSourceInboundDetailIdWhenOrdersShareSkuAndDestination() {
InboundPlanCarton carton = carton("BOX-004", "UNASSIGNED", null, "WH-A");
carton.setSkuCode("SKU-SHARED");
carton.setSourceInboundDetailId("SOURCE-DETAIL-SECOND");
activeTask();
when(repository.lockCarton("100", "BOX-004")).thenReturn(carton);
when(repository.lockPallet(plan.getId(), targetPallet.getId())).thenReturn(targetPallet);
when(repository.lineForCarton(plan.getId(), carton)).thenReturn(sourceLine);
when(repository.lockAllocation(plan.getId(), sourceLine.getId(), targetPallet.getId())).thenReturn(null);
service.scanCarton("100", "LIP1",
new PdaRequests.ScanCarton("BOX-004", targetPallet.getId(), "scan-second-order", "7", "worker"));
assertEquals(sourceLine.getId(), carton.getLineId());
assertEquals(sourceLine.getOrderId(), carton.getOrderId());
verify(repository).lineForCarton(plan.getId(), carton);
}
@Test
void countMustPrecedePickAndPickedBoxesDriveActualVolume() {
activeTask();
@@ -313,6 +375,7 @@ class InboundPdaWorkflowServiceTest {
value.setId(1L);
value.setCustomerId("100");
value.setPlanNo("LIP1");
value.setContainerNo("CONT-1");
value.setStatus("ASSIGNED");
return value;
}
@@ -371,4 +434,12 @@ class InboundPdaWorkflowServiceTest {
value.setVersion(0);
return value;
}
private InboundPlanCarton carton(String mark, String status, Long lineId, String warehouseId) {
InboundPlanCarton value = new InboundPlanCarton();
value.setId(41L); value.setCustomerId("100"); value.setPlanId(plan.getId()); value.setLineId(lineId);
value.setCartonMark(mark); value.setDestinationWarehouseId(warehouseId); value.setStatus(status); value.setVersion(0);
if ("ON_PALLET".equals(status)) value.setPlanPalletId(targetPallet.getId());
return value;
}
}