From 0dec690235412f6fe9e74e976a13b0c6714753b1 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sun, 20 Sep 2026 15:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IamCustomerSnapshotService.java | 13 ++++++++++++ .../InboundCartonLabelPrintService.java | 2 +- .../InboundCartonLabelPrintServiceTest.java | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/firstleg/src/main/java/com/baiyue/firstleg/service/IamCustomerSnapshotService.java b/firstleg/src/main/java/com/baiyue/firstleg/service/IamCustomerSnapshotService.java index fa64873bf..56899cc30 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/service/IamCustomerSnapshotService.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/service/IamCustomerSnapshotService.java @@ -52,4 +52,17 @@ public class IamCustomerSnapshotService { throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "客户主数据服务暂不可用"); } } + + /** + * 打印托盘信息单时客户昵称属于展示字段,客户资料尚未补全不应阻断 PDF 生成。 + * 下游服务不可用等基础设施错误仍然向上抛出,避免静默生成不完整数据。 + */ + public String customerNicknameForPrint(long customerId) { + try { + return customerNickname(customerId); + } catch (BizException exception) { + if (exception.getResultCode() == ResultCode.CONFLICT) return "—"; + throw exception; + } + } } diff --git a/firstleg/src/main/java/com/baiyue/firstleg/service/InboundCartonLabelPrintService.java b/firstleg/src/main/java/com/baiyue/firstleg/service/InboundCartonLabelPrintService.java index e3148d064..c4fb97cf8 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/service/InboundCartonLabelPrintService.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/service/InboundCartonLabelPrintService.java @@ -163,7 +163,7 @@ public class InboundCartonLabelPrintService { List inboundRows = inboundFacts.stream() .map(row -> new PrintPdfClient.DropshipPalletInboundRow( row.getInboundCode(), - customerNicknameCache.computeIfAbsent(row.getTenantId(), customerSnapshots::customerNickname), + customerNicknameCache.computeIfAbsent(row.getTenantId(), customerSnapshots::customerNicknameForPrint), number(row.getCartonCount()), number(row.getItemQuantity()))) .toList(); String destinationWarehouse = inboundFacts.stream() diff --git a/firstleg/src/test/java/com/baiyue/firstleg/service/InboundCartonLabelPrintServiceTest.java b/firstleg/src/test/java/com/baiyue/firstleg/service/InboundCartonLabelPrintServiceTest.java index ec288a2f8..0017a7a62 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/service/InboundCartonLabelPrintServiceTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/service/InboundCartonLabelPrintServiceTest.java @@ -146,6 +146,26 @@ class InboundCartonLabelPrintServiceTest { assertThat(request.getValue().documents().get(1).skuRows()).hasSize(1); } + @Test + void printsPalletDocumentWhenCustomerNicknameIsMissing() { + Pallet pallet = dropshipPallet("OPEN"); + stubPalletFacts(90001L); + when(customerSnapshots.customerNicknameForPrint(10001L)).thenReturn("—"); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_PDF); + when(print.generateDropshipPalletA4Documents(org.mockito.ArgumentMatchers.anyString(), + org.mockito.ArgumentMatchers.eq("request-missing-nickname"), org.mockito.ArgumentMatchers.any())) + .thenReturn(new ResponseEntity<>(new byte[] {1}, headers, org.springframework.http.HttpStatus.OK)); + + service.generateDropshipPallet(pallet, "PCHK2608040174", "request-missing-nickname"); + + ArgumentCaptor request = + ArgumentCaptor.forClass(PrintPdfClient.DropshipPalletA4PdfRequest.class); + verify(print).generateDropshipPalletA4Documents(org.mockito.ArgumentMatchers.anyString(), + org.mockito.ArgumentMatchers.eq("request-missing-nickname"), request.capture()); + assertThat(request.getValue().documents().get(0).inboundRows().get(0).customerNickname()).isEqualTo("—"); + } + @Test void forwardsStableLabelsWithoutSkuAndOnlySafePdfHeaders() throws Exception { when(labels.list(10001L, 70001L, List.of(1))).thenReturn(batch());