diff --git a/firstleg/src/main/java/com/baiyue/firstleg/service/DropshipPalletizationService.java b/firstleg/src/main/java/com/baiyue/firstleg/service/DropshipPalletizationService.java index 1b1563f31..e57c853bc 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/service/DropshipPalletizationService.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/service/DropshipPalletizationService.java @@ -231,7 +231,8 @@ public class DropshipPalletizationService { values.stream().map(v->v.carton().getBoxCode()).toList());}).toList(); int discrepancies=(int)cartons.stream().filter(c->"ACCEPTED_VARIANCE".equals(c.getDiscrepancyStatus())).count(); PalletMetrics metrics=mapper.metrics(row.getId()); - return new Pallet(row.getId(),row.getPalletNo(),row.getPalletStatus(),cartons.size(),items.size(),discrepancies, + int skuCount=(int)items.stream().map(SkuItem::skuCode).distinct().count(); + return new Pallet(row.getId(),row.getPalletNo(),row.getPalletStatus(),cartons.size(),skuCount,discrepancies, metrics==null?BigDecimal.ZERO:metrics.weightKg(),metrics==null?BigDecimal.ZERO:metrics.volumeCbm(),row.getVersion(),items, cartons.stream().map(c->cartonView(c,c.getInboundCode(),false,null)).toList(),row.getCompletedAt()); } diff --git a/firstleg/src/main/resources/openapi/dropship-palletization-v1.yaml b/firstleg/src/main/resources/openapi/dropship-palletization-v1.yaml index 692e5367f..5ce98de85 100644 --- a/firstleg/src/main/resources/openapi/dropship-palletization-v1.yaml +++ b/firstleg/src/main/resources/openapi/dropship-palletization-v1.yaml @@ -163,7 +163,7 @@ components: palletNo: {$ref: '#/components/schemas/PalletNo'} status: {type: string, enum: [OPEN, SEALED]} cartonCount: {type: integer, minimum: 0} - skuCount: {type: integer, minimum: 0} + skuCount: {type: integer, minimum: 0, description: '整托按 SKU 编码去重的种类数,包含合托全部入仓码,不是商品件数或入仓明细数'} discrepancyCartons: {type: integer, minimum: 0} weightKg: {type: number, minimum: 0} volumeCbm: {type: number, minimum: 0} diff --git a/firstleg/src/test/java/com/baiyue/firstleg/service/DropshipPalletizationServiceTest.java b/firstleg/src/test/java/com/baiyue/firstleg/service/DropshipPalletizationServiceTest.java index 76fb2f81c..1920dd6be 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/service/DropshipPalletizationServiceTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/service/DropshipPalletizationServiceTest.java @@ -26,6 +26,26 @@ class DropshipPalletizationServiceTest { private final DropshipPalletizationService service=new DropshipPalletizationService(); DropshipPalletizationServiceTest(){ ReflectionTestUtils.setField(service,"mapper",mapper); ReflectionTestUtils.setField(service,"documentNumbers",numbers); when(mapper.labelSkus(anyLong(),anyLong())).thenAnswer(call -> java.util.List.of(labelSku())); when(mapper.cartonSkus(anyLong())).thenAnswer(call -> java.util.List.of(cartonSku())); } + @Test void sharedPalletCountsDistinctSkuCodesWithoutMergingInboundDetails(){ + when(mapper.inboundCode(1L,30L)).thenReturn("IN-1"); + when(mapper.palletsByInbound(1L,30L)).thenReturn(java.util.List.of(pallet())); + CartonRow first=carton(),second=carton(); second.setId(61L); second.setInboundId(31L); second.setBoxCode("BOX-2"); + CartonSkuRow sameSku=cartonSku(); sameSku.setInboundDetailId(41L); + CartonSkuRow differentSku=cartonSku(); differentSku.setInboundDetailId(42L); differentSku.setSkuCode("SKU-2"); + when(mapper.cartons(20L)).thenReturn(java.util.List.of(first,second)); + when(mapper.cartonSkus(61L)).thenReturn(java.util.List.of(sameSku)); + var shared=service.inboundPallets(1L,30L).get(0); + assertThat(shared.cartonCount()).isEqualTo(2); + assertThat(shared.skuCount()).isEqualTo(1); + assertThat(shared.items()).hasSize(2); + when(mapper.cartonSkus(61L)).thenReturn(java.util.List.of(sameSku,differentSku)); + assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isEqualTo(2); + when(mapper.cartons(20L)).thenReturn(java.util.List.of(first)); + assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isEqualTo(1); + when(mapper.cartons(20L)).thenReturn(java.util.List.of()); + assertThat(service.inboundPallets(1L,30L).get(0).skuCount()).isZero(); + } + @Test void reviewCreatesExpectedNumberOfPrintablePalletCodes(){ InboundOrderEntity inbound=dropshipInbound(); when(mapper.insertTask(anyLong(),eq(1L),eq(30L),eq(100L),eq(8))).thenReturn(1); when(numbers.next("DP")).thenReturn("DP-260911-0001","DP-260911-0002");