This commit is contained in:
2026-09-14 15:33:45 +08:00
parent cdac78e4f7
commit 059757507a
@@ -16,10 +16,9 @@ import org.springframework.stereotype.Component;
/** 每个托盘一页 A4:托盘码、目的仓、入仓码汇总和 SKU 汇总。 */ /** 每个托盘一页 A4:托盘码、目的仓、入仓码汇总和 SKU 汇总。 */
@Component @Component
public class DropshipPalletA4Renderer { public class DropshipPalletA4Renderer {
private static final Color BLUE = new Color(20, 89, 156); private static final Color INK = Color.BLACK;
private static final Color LIGHT_BLUE = new Color(225, 239, 251); private static final Color LIGHT_GRAY = new Color(242, 242, 242);
private static final Color TABLE_HEADER = new Color(238, 242, 247); private static final Color TABLE_HEADER = new Color(232, 232, 232);
private static final Color RED = new Color(180, 43, 36);
private static final float[] INBOUND_COLS = {18, 27, 79, 146, 169, 192}; private static final float[] INBOUND_COLS = {18, 27, 79, 146, 169, 192};
private static final String[] INBOUND_HEADERS = {"#", "入仓码", "客户", "箱数", "件数"}; private static final String[] INBOUND_HEADERS = {"#", "入仓码", "客户", "箱数", "件数"};
private static final float[] SKU_COLS = {18, 132, 154, 176, 192}; private static final float[] SKU_COLS = {18, 132, 154, 176, 192};
@@ -35,7 +34,7 @@ public class DropshipPalletA4Renderer {
try (PDPageContentStream stream = new PDPageContentStream(pdf, page)) { try (PDPageContentStream stream = new PDPageContentStream(pdf, page)) {
stream.setLineWidth(PdfUnits.mmToPt(.25)); stream.setLineWidth(PdfUnits.mmToPt(.25));
border(stream, units); border(stream, units);
colorText(stream, units, font, "一件代发备货托", 14, 18, 22, BLUE); colorText(stream, units, font, "一件代发备货托", 14, 18, 22, INK);
rightText(stream, units, font, rightText(stream, units, font,
"第 " + data.palletSequence() + " 托 / 共 " + data.totalPallets() + " 托", "第 " + data.palletSequence() + " 托 / 共 " + data.totalPallets() + " 托",
10, 192, 22, new Color(75, 75, 75)); 10, 192, 22, new Color(75, 75, 75));
@@ -44,9 +43,9 @@ public class DropshipPalletA4Renderer {
PdfUnits.mmToPt(80), PdfUnits.mmToPt(22)); PdfUnits.mmToPt(80), PdfUnits.mmToPt(22));
fittedText(stream, units, font, data.palletNo(), 25, 105, 44, 87, Color.BLACK); fittedText(stream, units, font, data.palletNo(), 25, 105, 44, 87, Color.BLACK);
fill(stream, units, LIGHT_BLUE, 10, 57, 200, 82); fill(stream, units, LIGHT_GRAY, 10, 57, 200, 82);
colorText(stream, units, font, "目的仓", 7.5f, 18, 66, BLUE); colorText(stream, units, font, "目的仓", 7.5f, 18, 66, INK);
fittedText(stream, units, font, data.destinationWarehouse(), 20, 18, 77, 174, BLUE); fittedText(stream, units, font, data.destinationWarehouse(), 20, 18, 77, 174, INK);
int rowCount = data.inboundRows().size() + 1 + Math.max(1, data.skuRows().size()); int rowCount = data.inboundRows().size() + 1 + Math.max(1, data.skuRows().size());
double rowHeight = rowCount > 36 ? 2.9 : rowCount > 24 ? 3.6 : 6.0; double rowHeight = rowCount > 36 ? 2.9 : rowCount > 24 ? 3.6 : 6.0;
@@ -56,7 +55,7 @@ public class DropshipPalletA4Renderer {
int inboundItems = data.inboundRows().stream().mapToInt(DropshipPalletA4PdfDtos.InboundRow::itemQuantity).sum(); int inboundItems = data.inboundRows().stream().mapToInt(DropshipPalletA4PdfDtos.InboundRow::itemQuantity).sum();
colorText(stream, units, font, colorText(stream, units, font,
"入仓码信息 · 共 " + data.inboundRows().size() + " 票", "入仓码信息 · 共 " + data.inboundRows().size() + " 票",
9, 18, 92, BLUE); 9, 18, 92, INK);
double inboundBottom = inboundTable(stream, units, font, data.inboundRows(), double inboundBottom = inboundTable(stream, units, font, data.inboundRows(),
inboundCartons, inboundItems, 97, rowHeight, rowFont); inboundCartons, inboundItems, 97, rowHeight, rowFont);
@@ -65,7 +64,7 @@ public class DropshipPalletA4Renderer {
skuTable(stream, units, font, data.skuRows(), skuTitleY + 5, rowHeight, rowFont); skuTable(stream, units, font, data.skuRows(), skuTitleY + 5, rowHeight, rowFont);
line(stream, units, 10, 280, 200, 280); line(stream, units, 10, 280, 200, 280);
colorText(stream, units, font, "拆托 / 合托后此标作废,须重打", 8.5f, 18, 288, RED); colorText(stream, units, font, "拆托 / 合托后此标作废,须重打", 8.5f, 18, 288, INK);
} }
} }
@@ -142,7 +141,7 @@ public class DropshipPalletA4Renderer {
} }
private void border(PDPageContentStream s, PdfUnits u) throws IOException { private void border(PDPageContentStream s, PdfUnits u) throws IOException {
s.setStrokingColor(BLUE); s.setStrokingColor(INK);
s.setLineWidth(PdfUnits.mmToPt(.55)); s.setLineWidth(PdfUnits.mmToPt(.55));
s.addRect(PdfUnits.mmToPt(10), u.topDownMmToPdfY(290), PdfUnits.mmToPt(190), PdfUnits.mmToPt(280)); s.addRect(PdfUnits.mmToPt(10), u.topDownMmToPdfY(290), PdfUnits.mmToPt(190), PdfUnits.mmToPt(280));
s.stroke(); s.stroke();