优化
This commit is contained in:
@@ -511,16 +511,22 @@ class LoadingPickServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void taskDetailRejectsWarehouseThatDoesNotOwnTheContainer() {
|
||||
void taskDetailDoesNotRecheckWarehouseOwnership() {
|
||||
LoadingPickTaskEntity task = task();
|
||||
when(repository.task(20L)).thenReturn(task);
|
||||
when(repository.items(20L)).thenReturn(List.of(item()));
|
||||
when(repository.items(20L, 999L)).thenReturn(List.of(item()));
|
||||
when(repository.cartonLabels(20L)).thenReturn(List.of());
|
||||
when(repository.inboundOwners(20L)).thenReturn(List.of(
|
||||
new LoadingPickItemMapper.InboundOwner(101L, 50L)));
|
||||
when(palletAllocations.list(101L, 50L)).thenReturn(List.of(allocation(50L, 2, 202L)));
|
||||
|
||||
assertThatThrownBy(() -> service.task(20L, 999L))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("不属于当前仓库");
|
||||
var result = service.task(20L, 999L);
|
||||
|
||||
verify(repository, never()).items(20L, 999L);
|
||||
verify(repository, never()).cartonLabels(20L);
|
||||
verify(completionCommands, never()).latest(20L);
|
||||
assertThat(result.id()).isEqualTo(20L);
|
||||
assertThat(result.items()).hasSize(1);
|
||||
assertThat(result.items().get(0).inventoryResources()).singleElement()
|
||||
.extracting("availablePackageCount").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1308,6 +1314,40 @@ class LoadingPickServiceTest {
|
||||
verify(settlementService, never()).settle(20L, 9L, "operator");
|
||||
}
|
||||
|
||||
@Test
|
||||
void batchUsesConfirmedInboundInventoryWhenContainerLoadsAcrossWarehouses() {
|
||||
LoadingPickTaskEntity task = task();
|
||||
LoadingPickItemEntity item = item();
|
||||
item.setPlannedPackageCount(250);
|
||||
when(repository.taskForUpdate(20L)).thenReturn(task);
|
||||
when(repository.task(20L)).thenReturn(task);
|
||||
when(repository.assignment(20L)).thenReturn(assignment());
|
||||
when(repository.items(20L)).thenReturn(List.of(item));
|
||||
when(repository.items(20L, 101L)).thenReturn(List.of(item));
|
||||
when(repository.inboundOwners(20L)).thenReturn(List.of(
|
||||
new LoadingPickItemMapper.InboundOwner(1L, 50L)));
|
||||
when(palletAllocations.list(1L, 50L)).thenReturn(List.of(allocation(50L, 250, 202L)));
|
||||
when(repository.pick(30L, 250, 0, 101L)).thenReturn(1);
|
||||
when(repository.allTaskItemsResolved(20L)).thenReturn(true);
|
||||
when(repository.touchTask(20L, 0)).thenReturn(1);
|
||||
|
||||
var snapshot = service.inventorySnapshot(20L, 101L);
|
||||
assertThat(snapshot.warehouseId()).isEqualTo(101L);
|
||||
assertThat(snapshot.inbounds()).singleElement().satisfies(inbound -> {
|
||||
assertThat(inbound.availablePackageCount()).isEqualTo(250);
|
||||
assertThat(inbound.resources()).singleElement()
|
||||
.extracting("availablePackageCount")
|
||||
.isEqualTo(250);
|
||||
});
|
||||
|
||||
service.batch(20L, "batch-cross-warehouse", new BatchRequest(
|
||||
101L, 10L, 99L, 0, snapshot.snapshotToken(), List.of(
|
||||
new BatchItemRequest(30L, "PICK", 250, null, 0, null))), 9L, "operator");
|
||||
|
||||
verify(repository).pick(30L, 250, 0, 101L);
|
||||
verify(repository).touchTask(20L, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsBatchTaskVersionConflictBeforeWriting() {
|
||||
LoadingPickTaskEntity task = task();
|
||||
@@ -1457,6 +1497,11 @@ class LoadingPickServiceTest {
|
||||
}
|
||||
|
||||
private static InboundPalletAllocationEntity allocation(long inboundId, int packageCount) {
|
||||
return allocation(inboundId, packageCount, 101L);
|
||||
}
|
||||
|
||||
private static InboundPalletAllocationEntity allocation(long inboundId, int packageCount,
|
||||
long warehouseId) {
|
||||
InboundPalletAllocationEntity allocation = new InboundPalletAllocationEntity();
|
||||
allocation.setId(72L);
|
||||
allocation.setTenantId(1L);
|
||||
@@ -1464,7 +1509,7 @@ class LoadingPickServiceTest {
|
||||
allocation.setBlockId(71L);
|
||||
allocation.setSlotNo(1);
|
||||
allocation.setAllocationNo(1);
|
||||
allocation.setWarehouseId(101L);
|
||||
allocation.setWarehouseId(warehouseId);
|
||||
allocation.setPalletId(73L);
|
||||
allocation.setLocationId(74L);
|
||||
allocation.setLocationCode("A-01");
|
||||
|
||||
Reference in New Issue
Block a user