fix(overseas): repair pallet transitions and transfer queries
This commit is contained in:
+4
-3
@@ -18,6 +18,7 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@@ -102,15 +103,15 @@ public class WarehousePalletTransitionService {
|
||||
WarehouseLocationEntity target;
|
||||
if (sourceLocationId <= targetLocationId) {
|
||||
source = requireLocation(warehouseId, sourceLocationId);
|
||||
target = sourceLocationId == targetLocationId ? source : requireLocation(warehouseId, targetLocationId);
|
||||
target = Objects.equals(sourceLocationId, targetLocationId) ? source : requireLocation(warehouseId, targetLocationId);
|
||||
} else {
|
||||
target = requireLocation(warehouseId, targetLocationId);
|
||||
source = requireLocation(warehouseId, sourceLocationId);
|
||||
}
|
||||
requireLocationMatchesPallet(source, pallet.getStatus());
|
||||
if (sourceLocationId != targetLocationId) requireAvailableTarget(target, targetStatus);
|
||||
if (!Objects.equals(sourceLocationId, targetLocationId)) requireAvailableTarget(target, targetStatus);
|
||||
|
||||
if (sourceLocationId == targetLocationId) {
|
||||
if (Objects.equals(sourceLocationId, targetLocationId)) {
|
||||
transitionSameLocation(warehouseId, source, pallet.getStatus(), targetStatus);
|
||||
} else {
|
||||
releaseSourceLocation(warehouseId, source, pallet.getStatus());
|
||||
|
||||
+16
@@ -48,6 +48,22 @@ class WarehousePalletTransitionServiceTest {
|
||||
assertEquals(4, captor.getValue().getBeforeVersion());
|
||||
}
|
||||
|
||||
@Test void releasesOccupiedPalletAtSameLargeLocationId() {
|
||||
long locationId = 2104611550538616833L;
|
||||
when(mapper.lockPublicPallet(88L, 10L)).thenReturn(pallet("P-LARGE", "OCCUPIED", 4, locationId));
|
||||
when(mapper.lockPublicLocation(88L, locationId)).thenReturn(location(locationId, "STORAGE", "OCCUPIED"));
|
||||
when(mapper.transitionLocation(88L, locationId, "OCCUPIED", "IDLE")).thenReturn(1);
|
||||
when(mapper.transition(88L, 10L, "IDLE", locationId, 4)).thenReturn(1);
|
||||
|
||||
var response = service.apply(10L, new PalletTransitionRequests.Apply(
|
||||
88L, 4, "IDLE", locationId, "large-location-release", "swap"));
|
||||
|
||||
assertEquals("IDLE", response.afterStatus());
|
||||
assertEquals(locationId, response.afterLocationId());
|
||||
verify(mapper, times(1)).lockPublicLocation(88L, locationId);
|
||||
verify(mapper).transitionLocation(88L, locationId, "OCCUPIED", "IDLE");
|
||||
}
|
||||
|
||||
@Test void exactReplayDoesNotMutatePhysicalPalletAgain() {
|
||||
WarehousePalletOperationEntity existing = operation();
|
||||
when(mapper.findOperation("operation-1")).thenReturn(existing);
|
||||
|
||||
Reference in New Issue
Block a user