fix: finalize smart dispatch drafts
This commit is contained in:
+31
-2
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baiyue.lastleg.dispatch.dto.DispatchRequests;
|
||||
import com.baiyue.lastleg.dispatch.dto.DispatchResponse;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchDraft;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchDraftContainer;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchOrder;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchPalletLock;
|
||||
@@ -32,6 +34,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -160,15 +163,41 @@ class DispatchServiceTest {
|
||||
void preArrangeConvertsOwnedDraftLockInsteadOfInsertingAnotherLock() {
|
||||
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));
|
||||
DispatchPalletLock lock = new DispatchPalletLock();
|
||||
lock.setDraftToken("draft-1"); lock.setOperatorId("7"); lock.setStatus("ACTIVE"); lock.setActiveKey("PLAN:10");
|
||||
lock.setDraftToken("draft-1"); lock.setDraftContainerId(21L); lock.setOperatorId("7"); lock.setStatus("ACTIVE"); lock.setActiveKey("PLAN:10");
|
||||
DispatchDraft draft = new DispatchDraft();
|
||||
draft.setId(31L); draft.setDraftToken("draft-1"); draft.setOperatorId("7"); draft.setStatus("ACTIVE");
|
||||
when(locks.lockActive("100", "PLAN:10")).thenReturn(lock);
|
||||
when(drafts.lockActive("draft-1", "7")).thenReturn(draft);
|
||||
|
||||
service.preArrange("100", "7", new DispatchRequests.PreArrange(List.of(10L), null, null, null, null, "draft-1"));
|
||||
|
||||
assertNotNull(lock.getDispatchOrderId());
|
||||
assertEquals(null, lock.getDraftToken());
|
||||
assertNull(lock.getDraftToken());
|
||||
assertNull(lock.getDraftContainerId());
|
||||
assertEquals("RELEASED", draft.getStatus());
|
||||
assertNotNull(draft.getReleasedAt());
|
||||
verify(locks).updateById(lock);
|
||||
verify(locks, never()).insert(any(DispatchPalletLock.class));
|
||||
verify(draftContainers).delete(any(LambdaQueryWrapper.class));
|
||||
verify(drafts).updateById(draft);
|
||||
}
|
||||
|
||||
@Test
|
||||
void activeDraftOnlyRestoresLocksStillOwnedByThatDraft() {
|
||||
DispatchDraft draft = new DispatchDraft();
|
||||
draft.setDraftToken("draft-1"); draft.setOperatorId("7"); draft.setStatus("ACTIVE");
|
||||
DispatchDraftContainer container = new DispatchDraftContainer();
|
||||
container.setId(21L); container.setDraftToken("draft-1"); container.setCapacity(12);
|
||||
DispatchPalletLock owned = new DispatchPalletLock();
|
||||
owned.setPlanPalletId(10L); owned.setDraftToken("draft-1"); owned.setDraftContainerId(21L);
|
||||
when(drafts.findActiveByOperator("7")).thenReturn(List.of(draft));
|
||||
when(draftContainers.findByToken("draft-1")).thenReturn(List.of(container));
|
||||
when(locks.findActiveByDraftContainer("draft-1", 21L)).thenReturn(List.of(owned));
|
||||
|
||||
var result = service.activeDrafts("7");
|
||||
|
||||
assertEquals(List.of("10"), result.get(0).containers().get(0).palletIds());
|
||||
verify(locks).findActiveByDraftContainer("draft-1", 21L);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user