优化
This commit is contained in:
+16
@@ -93,4 +93,20 @@ class DropshipPalletizationSqlContractTest {
|
||||
assertThat(complete).contains("fl_dropship_pallet_carton c JOIN fl_dropship_pallet p")
|
||||
.doesNotContain("p.task_id=#{taskId}");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsealIsAProtectedIdempotentPdaCommandAndBlocksActiveLoadingAssignments() throws Exception {
|
||||
var controller = com.baiyue.firstleg.controller.PlatformDropshipPalletizationController.class;
|
||||
var method = java.util.Arrays.stream(controller.getDeclaredMethods())
|
||||
.filter(item -> item.getName().equals("unseal")).findFirst().orElseThrow();
|
||||
assertThat(method.getAnnotation(org.springframework.security.access.prepost.PreAuthorize.class).value())
|
||||
.isEqualTo("hasAuthority('platform:firstleg:pda:work')");
|
||||
String api = new ClassPathResource("openapi/dropship-palletization-v1.yaml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
assertThat(api).contains("/api/platform/v1/first-leg/pda-dropship/tasks/{taskId}/pallets/{palletId}/unseal:")
|
||||
.contains("$ref: '#/components/schemas/UnsealPalletRequest'");
|
||||
String assignment = DropshipPalletizationMapper.class.getDeclaredMethod("activeLoadingAssignmentCount", long.class)
|
||||
.getAnnotation(Select.class).value()[0];
|
||||
assertThat(assignment).contains("fl_loading_plan_item").contains("deleted=0");
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -4,6 +4,7 @@ import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.CountCartonRequest;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.DiscrepancyAction;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.CountSkuLine;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.UnsealPalletRequest;
|
||||
import com.baiyue.firstleg.entity.InboundOrderEntity;
|
||||
import com.baiyue.firstleg.mapper.DropshipPalletizationMapper;
|
||||
import com.baiyue.firstleg.mapper.DropshipPalletizationMapper.LabelRow;
|
||||
@@ -87,11 +88,46 @@ class DropshipPalletizationServiceTest {
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("预计 2 托");
|
||||
}
|
||||
|
||||
@Test void sealedPalletCanReopenBeforeItEntersALoadingPlan(){
|
||||
TaskRow current=task(); PalletRow sealed=sealedPallet();
|
||||
when(mapper.task(10L,100L)).thenReturn(current); when(mapper.pallet(10L,20L,100L)).thenReturn(sealed);
|
||||
when(mapper.taskIdsByPallet(20L)).thenReturn(java.util.List.of(10L)); when(mapper.unseal(10L,20L,1,100L,"undo-1")).thenReturn(1);
|
||||
when(mapper.palletCount(10L)).thenReturn(2); when(mapper.pallets(10L)).thenReturn(java.util.List.of());
|
||||
var result=service.unseal(10L,20L,new UnsealPalletRequest(100L,"undo-1",1),7L,"张三");
|
||||
assertThat(result.taskStatus()).isEqualTo("CLAIMED");
|
||||
verify(mapper).activeLoadingAssignmentCount(20L); verify(mapper).unseal(10L,20L,1,100L,"undo-1");
|
||||
verify(mapper,never()).reopenTask(anyLong()); verify(mapper,never()).reopenInbound(anyLong(),anyLong(),anyLong());
|
||||
}
|
||||
|
||||
@Test void unsealingACompletedSharedPalletReopensEveryParticipatingInbound(){
|
||||
TaskRow completed=task(); completed.setTaskStatus("COMPLETED"); completed.setProcessStatus("WAIT_SPLIT");
|
||||
TaskRow other=task(); other.setId(11L); other.setTenantId(2L); other.setInboundId(31L); other.setTaskStatus("COMPLETED"); other.setProcessStatus("WAIT_SPLIT");
|
||||
TaskRow reopened=task();
|
||||
when(mapper.task(10L,100L)).thenReturn(completed,completed,reopened);
|
||||
when(mapper.task(11L,100L)).thenReturn(other); when(mapper.pallet(10L,20L,100L)).thenReturn(sealedPallet());
|
||||
when(mapper.taskIdsByPallet(20L)).thenReturn(java.util.List.of(10L,11L)); when(mapper.unseal(10L,20L,1,100L,"undo-2")).thenReturn(1);
|
||||
when(mapper.reopenTask(10L)).thenReturn(1); when(mapper.reopenTask(11L)).thenReturn(1);
|
||||
when(mapper.reopenInbound(1L,30L,7L)).thenReturn(1); when(mapper.reopenInbound(2L,31L,7L)).thenReturn(1);
|
||||
when(mapper.palletCount(10L)).thenReturn(2); when(mapper.pallets(10L)).thenReturn(java.util.List.of());
|
||||
service.unseal(10L,20L,new UnsealPalletRequest(100L,"undo-2",1),7L,"张三");
|
||||
verify(mapper).reopenTask(10L); verify(mapper).reopenTask(11L);
|
||||
verify(mapper).reopenInbound(1L,30L,7L); verify(mapper).reopenInbound(2L,31L,7L);
|
||||
}
|
||||
|
||||
@Test void palletAssignedToALoadingPlanCannotBeUnsealed(){
|
||||
when(mapper.task(10L,100L)).thenReturn(task()); when(mapper.pallet(10L,20L,100L)).thenReturn(sealedPallet());
|
||||
when(mapper.activeLoadingAssignmentCount(20L)).thenReturn(1);
|
||||
assertThatThrownBy(()->service.unseal(10L,20L,new UnsealPalletRequest(100L,"undo-3",1),7L,"张三"))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("已进入装柜计划");
|
||||
verify(mapper,never()).unseal(anyLong(),anyLong(),anyInt(),anyLong(),anyString());
|
||||
}
|
||||
|
||||
private static TaskRow task(){TaskRow t=new TaskRow();t.setId(10L);t.setTenantId(1L);t.setInboundId(30L);t.setWarehouseId(100L);t.setInboundCode("IN-1");t.setTaskStatus("CLAIMED");t.setAssigneeId(7L);t.setProcessStatus("WAIT_PALLETIZE");t.setTotalCartons(2);t.setCountedCartons(0);t.setAllocatedCartons(0);t.setDiscrepancyCartons(0);t.setExpectedPalletCount(2);t.setVersion(1);return t;}
|
||||
private static LabelRow label(){LabelRow l=new LabelRow();l.setCartonLabelId(50L);l.setInboundDetailId(40L);l.setSkuCode("SKU-1");l.setCargoName("货物");l.setUnitsPerCarton(12);l.setInboundCode("IN-1");l.setBoxCode("BOX-1");return l;}
|
||||
private static LabelSkuRow labelSku(){LabelSkuRow l=new LabelSkuRow();l.setInboundDetailId(40L);l.setSkuCode("SKU-1");l.setCargoName("货物");l.setExpectedQuantity(12);l.setLineNo(1);return l;}
|
||||
private static CartonSkuRow cartonSku(){CartonSkuRow l=new CartonSkuRow();l.setInboundDetailId(40L);l.setSkuCode("SKU-1");l.setCargoName("货物");l.setExpectedQuantity(12);l.setActualQuantity(12);l.setDiscrepancyStatus("MATCH");l.setLineNo(1);return l;}
|
||||
private static CountCartonRequest countRequest(String palletNo){return new CountCartonRequest(100L,"BOX-1",java.util.List.of(new CountSkuLine(40L,"SKU-1",12,DiscrepancyAction.MATCH,null)),palletNo,"op-1");}
|
||||
private static PalletRow pallet(){PalletRow p=new PalletRow();p.setId(20L);p.setTaskId(10L);p.setTenantId(1L);p.setInboundId(30L);p.setWarehouseId(100L);p.setPalletNo("DP-260911-0001");p.setPalletStatus("OPEN");p.setVersion(1);return p;}
|
||||
private static PalletRow sealedPallet(){PalletRow p=pallet();p.setPalletStatus("SEALED");return p;}
|
||||
private static CartonRow carton(){CartonRow c=new CartonRow();c.setId(60L);c.setTaskId(10L);c.setPalletId(20L);c.setInboundId(30L);c.setInboundDetailId(40L);c.setPalletNo("DP-260911-0001");c.setSkuCode("SKU-1");c.setCargoName("货物");c.setBoxCode("BOX-1");c.setExpectedSkuQuantity(12);c.setActualSkuQuantity(12);c.setDiscrepancyStatus("MATCH");return c;}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user