fix(print): remove SKU from carton labels while retaining dropship A4 details

This commit is contained in:
2026-09-20 11:22:29 +08:00
parent 78a36d1a39
commit bbf000a38a
11 changed files with 16 additions and 29 deletions
@@ -26,12 +26,7 @@ public final class InboundMarkPdfDtos {
String warehouseText,
String cartonText,
String routeText,
String qrContent,
String skuCode
String qrContent
) {
public Label(String topCode, String warehouseText, String cartonText,
String routeText, String qrContent) {
this(topCode, warehouseText, cartonText, routeText, qrContent, null);
}
}
}
@@ -41,9 +41,6 @@ public class InboundMarkV1Renderer {
drawCenteredText(stream, units, font, label.warehouseText(), 36, 26);
drawCenteredText(stream, units, font, label.cartonText(), 22, 37);
drawCenteredText(stream, units, font, label.routeText(), 21, 47);
if (label.skuCode() != null) {
drawCenteredText(stream, units, font, "SKU: " + label.skuCode(), 14, 55);
}
qrRenderer.draw(stream, qrMatrix, QR_LEFT_PT, QR_BOTTOM_PT, QR_SIZE_PT);
drawCenteredText(stream, units, font, label.qrContent(), 12, 85.5);
drawCenteredText(stream, units, font, "MADE IN CHINA", 14, 92);
@@ -110,8 +110,7 @@ public class InboundMarkPdfService {
normalizeRequired(label.warehouseText(), field(index, "warehouseText")),
normalizeRequired(label.cartonText(), field(index, "cartonText")),
normalizeRequired(label.routeText(), field(index, "routeText")),
normalizeQr(label.qrContent(), field(index, "qrContent")),
normalizeOptional(label.skuCode(), field(index, "skuCode"))));
normalizeQr(label.qrContent(), field(index, "qrContent"))));
}
return new NormalizedRequest(normalizeFileName(request.downloadFileName()), List.copyOf(labels));
}
@@ -166,14 +165,6 @@ public class InboundMarkPdfService {
return normalized;
}
private String normalizeOptional(String value, String field) {
if (value == null || value.isBlank()) return null;
String normalized = Normalizer.normalize(value.trim(), Normalizer.Form.NFC);
if (normalized.codePointCount(0, normalized.length()) > 64) invalid(field + " must not exceed 64 characters");
normalized.codePoints().forEach(codePoint -> { if (isForbiddenControl(codePoint)) invalid(field + " contains a control character"); });
return normalized;
}
private boolean isForbiddenControl(int codePoint) {
int type = Character.getType(codePoint);
return Character.isISOControl(codePoint)
@@ -229,6 +229,7 @@ components:
enum: [100]
InboundMarkLabel:
type: object
description: 箱唛仅展示入仓码、仓库、箱序、线路、稳定箱码二维码及产地,不包含 SKU;SKU 明细由一件代发 A4 托盘信息单展示。
required: [topCode, warehouseText, cartonText, routeText, qrContent]
properties:
topCode:
@@ -244,11 +245,6 @@ components:
minLength: 1
maxLength: 34
pattern: '^[\\x20-\\x7E]+$'
skuCode:
type: string
maxLength: 64
nullable: true
description: 一件代发箱唛显示的 SKU;二维码仍只使用 qrContent 稳定箱码
FreightA4PdfRequest:
type: object
required: [templateCode, pageSpec, documents]
@@ -50,7 +50,8 @@ class InboundMarkPdfServiceGenerationTest {
stripper.setEndPage(1);
assertThat(stripper.getText(document))
.contains("PCHK2608040174", "MCC1", "CTNS:2-1", "洛杉矶普船海卡",
"PCHK2608040174#2-1", "MADE IN CHINA");
"PCHK2608040174#2-1", "MADE IN CHINA")
.doesNotContain("SKU");
stripper.setStartPage(2);
stripper.setEndPage(2);
assertThat(stripper.getText(document)).contains("CTNS:2-2", "PCHK2608040174#2-2");