From 732a4718f6d49851f8e263a9fe1bd62de032e2f2 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Thu, 14 May 2026 13:52:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E4=BD=93?=
=?UTF-8?q?=E5=A4=A7=E5=B0=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/czg/order/dto/OrderInfoPrintDTO.java | 4 +
.../czg/service/order/print/FeiPrinter.java | 6 +-
.../czg/service/order/print/PrinterImpl.java | 169 ++++++++++--------
.../czg/service/order/print/YxyPrinter.java | 6 +-
4 files changed, 102 insertions(+), 83 deletions(-)
diff --git a/cash-common/cash-common-service/src/main/java/com/czg/order/dto/OrderInfoPrintDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/order/dto/OrderInfoPrintDTO.java
index a4bdeca2f..67b84382c 100644
--- a/cash-common/cash-common-service/src/main/java/com/czg/order/dto/OrderInfoPrintDTO.java
+++ b/cash-common/cash-common-service/src/main/java/com/czg/order/dto/OrderInfoPrintDTO.java
@@ -19,6 +19,10 @@ public class OrderInfoPrintDTO implements Serializable {
*/
@NotNull(message = "id不为空")
private Long id;
+ /**
+ * 店铺id
+ */
+ private Long shopId;
/**
* 1 预结算单
* 2 结算单
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java b/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java
index 788a93bf1..3a0151ff6 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/print/FeiPrinter.java
@@ -41,7 +41,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
super("飞鹅");
}
- private final PrintSignLabel printSignLabel = new PrintSignLabel()
+ private final PrintLabel printLabel = new PrintLabel()
.setBr("
")
.setCut("")
.setOut("OUT")
@@ -55,8 +55,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
.setBold(new String[]{"", ""});
@Override
- public PrintSignLabel getSignLabelInfo() {
- return printSignLabel;
+ public PrintLabel getSignLabelInfo() {
+ return printLabel;
}
@Override
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/print/PrinterImpl.java b/cash-service/order-service/src/main/java/com/czg/service/order/print/PrinterImpl.java
index 3e4e8521b..f603ad66d 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/print/PrinterImpl.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/print/PrinterImpl.java
@@ -30,7 +30,7 @@ import java.util.Objects;
public interface PrinterImpl {
@Data
@Accessors(chain = true)
- class PrintSignLabel {
+ class PrintLabel {
/**
*
:换行符
* :切刀指令/自动走纸(主动切纸,仅限切刀打印机使用才有效果/手动撕纸设备使用该指令时为自动走纸)
@@ -61,7 +61,7 @@ public interface PrinterImpl {
private String[] centerBold;
private String[] bold;
private String br;
- //f 的行数字符为 30
+ //s 的行数字符为 30
private String[] s;
//f 的行数字符为 14
private String[] f;
@@ -71,11 +71,18 @@ public interface PrinterImpl {
private String out;
private String rs;
- public String getOut(int num) {
- if (out != null) {
- return StrUtil.format("<{}:{}>", out, num);
- }
- return "";
+ public String out() {
+ return StrUtil.format("<{}:{}>", out, 180);
+ }
+
+ /**
+ * 设置可变字体大小
+ * :设置可变字体大小(x:16,24,32,48,64,72,96都可支持,如x=96则为96*96字体)
+ *
+ * @param num 字号
+ */
+ public String[] cs(int num) {
+ return new String[]{StrUtil.format("", num), ""};
}
}
@@ -96,7 +103,7 @@ public interface PrinterImpl {
*
* @return 标签信息
*/
- PrintSignLabel getSignLabelInfo();
+ PrintLabel getSignLabelInfo();
/**
* 获取分割线
@@ -129,7 +136,7 @@ public interface PrinterImpl {
* 构建交班 打印元数据
*/
default String buildHandoverData(HandoverRecordDTO handoverRecord) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder()
.append(formatLabel(handoverRecord.getShopName(), signLabelInfo.center)).append(signLabelInfo.br)
.append(formatLabel("交班小票", signLabelInfo.center)).append(signLabelInfo.br)
@@ -161,19 +168,19 @@ public interface PrinterImpl {
if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) {
builder.append(formatLabel("----------- 销售数据 -----------", signLabelInfo.s)).append(signLabelInfo.br)
- .append(formatLabel(key3("商品分类", "数量", "总计", 14, 8), signLabelInfo.s))
+ .append(formatLabel(key3("商品分类", "数量", "总计", 14, 8,32), signLabelInfo.s))
.append(signLabelInfo.br);
JSONArray.parseArray(handoverRecord.getCategoryData()).forEach(item -> {
JSONObject info = (JSONObject) item;
String categoryName = info.getString("categoryName");
Integer quantity = info.getInteger("quantity");
BigDecimal amount = info.getBigDecimal("amount");
- builder.append(formatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8), signLabelInfo.s)).append(signLabelInfo.br);
+ builder.append(formatLabel(key3(categoryName, quantity.toString(), bdToStr(amount), 14, 8,32), signLabelInfo.s)).append(signLabelInfo.br);
});
}
builder.append(getDividingLine()).append(signLabelInfo.br)
.append(formatLabel("打印时间: " + DateUtil.format(DateUtil.date(), "yyyy/MM/dd HH:mm:ss"), signLabelInfo.s)).append(signLabelInfo.br)
- .append(signLabelInfo.getOut(180))
+ .append(signLabelInfo.out())
.append(signLabelInfo.cut);
return builder.toString();
}
@@ -186,18 +193,18 @@ public interface PrinterImpl {
* @return 订单打印元数据
*/
default String buildOrderPrintData(OrderPrintDTO orderPrintDTO, List detailList) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabel = getSignLabelInfo();
StringBuilder data = new StringBuilder();
- data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
- data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
- data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabelInfo.f)).append(signLabelInfo.br);
+ data.append(formatLabel(orderPrintDTO.getShopName(), signLabel.center)).append(signLabel.br);
+ data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabel.center)).append(signLabel.br);
+ data.append(formatLabel(orderPrintDTO.getPickupNum(), signLabel.f)).append(signLabel.br);
data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "人" : "", 32))
- , signLabelInfo.s)).append(signLabelInfo.br);
+ , signLabel.s)).append(signLabel.br);
if (StrUtil.isNotBlank(orderPrintDTO.getTradeDate())) {
- data.append(formatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(StrUtil.format("结账时间:{}", orderPrintDTO.getTradeDate()), signLabel.s)).append(signLabel.br);
}
- data.append(getDividingLine()).append(signLabelInfo.br);
- data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(getDividingLine()).append(signLabel.br);
+ data.append(formatLabel(key3("品名", "单价", "数量", 18, 9,32), signLabel.s)).append(signLabel.br);
for (OrderDetail detail : detailList) {
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
@@ -206,11 +213,12 @@ public interface PrinterImpl {
}
String number = subtract.stripTrailingZeros().toPlainString();
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
- data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7,32), signLabel.s)).append(signLabel.br);
+// data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 13, 4,24), signLabel.cs(32))).append(signLabel.br);
if (StrUtil.isNotBlank(detail.getSkuName())) {
- data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
- .append(signLabelInfo.br);
+ data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabel.s))
+ .append(signLabel.br);
}
String proGroupInfo = detail.getProGroupInfo();
if (StrUtil.isBlank(proGroupInfo)) {
@@ -225,41 +233,41 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number");
- data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9,32), signLabel.s)).append(signLabel.br);
});
}
}
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
- data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9,32), signLabel.s)).append(signLabel.br);
}
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
- data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9,32), signLabel.s)).append(signLabel.br);
}
data.append(getDividingLine())
- .append(signLabelInfo.br);
- data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
+ .append(signLabel.br);
+ data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabel.s)).append(signLabel.br);
if (ObjectUtil.isNotNull(orderPrintDTO.getDiscountAmount())) {
- data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(LRAlign("优惠:", "-" + orderPrintDTO.getDiscountAmount(), 32), signLabel.s)).append(signLabel.br);
}
if (StrUtil.isNotBlank(orderPrintDTO.getRemark())) {
- data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(StrUtil.format("备注:{}", orderPrintDTO.getRemark()), signLabel.s)).append(signLabel.br);
}
- data.append(getDividingLine()).append(signLabelInfo.br);
- data.append(formatLabel(LRAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
+ data.append(getDividingLine()).append(signLabel.br);
+ data.append(formatLabel(LRAlign("应付:", orderPrintDTO.getPayAmount(), 16), signLabel.f)).append(signLabel.br);
if ("结算单".equals(orderPrintDTO.getPrintTitle())) {
- data.append(getDividingLine()).append(signLabelInfo.br);
- data.append(formatLabel(LRAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabelInfo.f)).append(signLabelInfo.br);
- data.append(formatLabel(LRAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(getDividingLine()).append(signLabel.br);
+ data.append(formatLabel(LRAlign("已付:", orderPrintDTO.getPayAmount(), 16), signLabel.f)).append(signLabel.br);
+ data.append(formatLabel(LRAlign("支付方式:", orderPrintDTO.getPayType(), 32), signLabel.s)).append(signLabel.br);
}
- data.append(getDividingLine()).append(signLabelInfo.br);
- data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(signLabelInfo.getOut(180));
- data.append(signLabelInfo.cut);
+ data.append(getDividingLine()).append(signLabel.br);
+ data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabel.s)).append(signLabel.br);
+ data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabel.s)).append(signLabel.br);
+ data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabel.s)).append(signLabel.br);
+ data.append(signLabel.out());
+ data.append(signLabel.cut);
return data.toString();
}
@@ -271,7 +279,7 @@ public interface PrinterImpl {
* @return 订单打印元数据
*/
default String buildGuestOrderPrintData(OrderPrintDTO orderPrintDTO, List detailList) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder();
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(formatLabel("客看单", signLabelInfo.center)).append(signLabelInfo.br);
@@ -281,7 +289,7 @@ public interface PrinterImpl {
data.append(formatLabel(formatLabel(LRAlign(orderPrintDTO.getPrintType(), StrUtil.isNotBlank(orderPrintDTO.getSeatNum()) ? orderPrintDTO.getSeatNum() + "人" : "", 32))
, signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
- data.append(formatLabel(key3("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("品名", "单价", "数量", 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) {
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
@@ -290,7 +298,7 @@ public interface PrinterImpl {
}
String number = subtract.stripTrailingZeros().toPlainString();
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
- data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(detail.getProductName(), unitPrice, number, 18, 7,32), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
@@ -309,15 +317,15 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number");
- data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
});
}
}
if (StrUtil.isNotBlank(orderPrintDTO.getSeatAmount())) {
- data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("餐位费", orderPrintDTO.getSeatAmount(), orderPrintDTO.getSeatNum(), 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
}
if (StrUtil.isNotBlank(orderPrintDTO.getPackFee())) {
- data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("打包费", toPlainStr(orderPrintDTO.getPackFee()), "", 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
}
data.append(getDividingLine()).append(signLabelInfo.br);
data.append(formatLabel(LRAlign("原价:", orderPrintDTO.getOriginalAmount(), 32), signLabelInfo.s)).append(signLabelInfo.br);
@@ -331,7 +339,7 @@ public interface PrinterImpl {
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(signLabelInfo.getOut(180));
+ data.append(signLabelInfo.out());
data.append(signLabelInfo.cut);
return data.toString();
}
@@ -344,7 +352,7 @@ public interface PrinterImpl {
* @return 订单打印元数据
*/
default String buildRefundOrderPrintData(OrderPrintDTO orderPrintDTO, List detailList) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder();
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
@@ -353,7 +361,7 @@ public interface PrinterImpl {
, signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
if (CollUtil.isNotEmpty(detailList)) {
- data.append(formatLabel(key3("退款明细", "数量", "小计", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3("退款明细", "数量", "小计", 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
for (OrderDetail detail : detailList) {
String number = detail.getNum().stripTrailingZeros().toPlainString();
@@ -361,7 +369,7 @@ public interface PrinterImpl {
if ("退款单".equals(orderPrintDTO.getPrintTitle())) {
amount = detail.getReturnAmount().stripTrailingZeros().toPlainString();
}
- data.append(formatLabel(key3(detail.getProductName(), number, amount, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(detail.getProductName(), number, amount, 18, 7,32), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getSkuName())) {
data.append(formatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
.append(signLabelInfo.br);
@@ -379,7 +387,7 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number");
- data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
});
}
}
@@ -401,7 +409,7 @@ public interface PrinterImpl {
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(signLabelInfo.getOut(180));
+ data.append(signLabelInfo.out());
data.append(signLabelInfo.cut);
return data.toString();
}
@@ -413,7 +421,7 @@ public interface PrinterImpl {
* @return 元数据
*/
default String buildAllKitchenPrintData(OrderPrintDTO orderPrintDTO, List detailList) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder data = new StringBuilder();
data.append(formatLabel(orderPrintDTO.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
data.append(formatLabel(orderPrintDTO.getPrintTitle(), signLabelInfo.center)).append(signLabelInfo.br);
@@ -438,7 +446,7 @@ public interface PrinterImpl {
jsonObject.getJSONArray("goods").forEach(item -> {
String proName = ((JSONObject) item).getString("proName");
String qty = ((JSONObject) item).getString("number");
- data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
+ data.append(formatLabel(key3(" - " + proName, "", qty, 18, 9,32), signLabelInfo.s)).append(signLabelInfo.br);
});
}
}
@@ -457,7 +465,7 @@ public interface PrinterImpl {
data.append(formatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(formatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
- data.append(signLabelInfo.getOut(180));
+ data.append(signLabelInfo.out());
data.append(signLabelInfo.cut);
return data.toString();
}
@@ -469,7 +477,7 @@ public interface PrinterImpl {
* @return 元数据
*/
default String buildOnlyKitchenPrintData(String pickupNumber, OrderDetail orderDetail) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
builder.append(formatLabel(pickupNumber, signLabelInfo.centerBold))
.append(signLabelInfo.br);
@@ -528,7 +536,7 @@ public interface PrinterImpl {
.append(signLabelInfo.br);
}
builder.append(signLabelInfo.br)
- .append(signLabelInfo.getOut(150))
+ .append(signLabelInfo.out())
.append(signLabelInfo.cut);
return builder.toString();
}
@@ -537,7 +545,7 @@ public interface PrinterImpl {
* 出入库打印单
*/
default String buildStockData(StockPrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:入库 + 店铺名称 + 入库单
@@ -577,7 +585,7 @@ public interface PrinterImpl {
builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(record.getPrintTime(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和充值单保持一致)
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -585,7 +593,7 @@ public interface PrinterImpl {
* 经营日报打印单
*/
default String buildDayReportData(DayReportPrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一)
@@ -643,7 +651,7 @@ public interface PrinterImpl {
builder.append(formatLabel(LRAlign(" 订单改价", bdToStr(disSta.getOrderDiscount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和充值/入库单完全一致)
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -651,7 +659,7 @@ public interface PrinterImpl {
* 日结单
*/
default String buildDaySettleData(DaySettlePrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
@@ -701,11 +709,11 @@ public interface PrinterImpl {
builder.append(formatLabel("敏感操作记录", signLabelInfo.bold)).append(signLabelInfo.br);
for (DaySettlePrintDTO.OperationRecord operation : operationRecords) {
builder.append(formatLabel(
- key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + bdToStr(operation.getAmount()), 8, 14)
+ key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + bdToStr(operation.getAmount()), 8, 14,32)
, signLabelInfo.s)).append(signLabelInfo.br);
}
}
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -713,7 +721,7 @@ public interface PrinterImpl {
* 商品报表打印单
*/
default String buildProductReportData(ProductReportPrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 商品报表(居中,和之前的报表风格统一)
@@ -760,7 +768,7 @@ public interface PrinterImpl {
}
}
// 结尾空行 + 切纸(和之前所有打印单完全一致)
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -769,7 +777,7 @@ public interface PrinterImpl {
* 充值打印单
*/
default String buildRechargeData(RechargePrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 充值凭证
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
@@ -802,7 +810,7 @@ public interface PrinterImpl {
builder.append(formatLabel(StrUtil.format("充值编号: {}", record.getRechargeId()), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -810,7 +818,7 @@ public interface PrinterImpl {
* 库存盘点打印单
*/
default String buildStockCheckData(StockCheckPrintDTO record) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder();
// 标题:店铺名称 + 盘点单(居中,和之前所有打印单风格统一)
@@ -849,7 +857,7 @@ public interface PrinterImpl {
builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
// 结尾空行 + 切纸(和之前所有打印单完全一致)
- builder.append(signLabelInfo.getOut(150)).append(signLabelInfo.cut);
+ builder.append(signLabelInfo.out()).append(signLabelInfo.cut);
return builder.toString();
}
@@ -861,7 +869,7 @@ public interface PrinterImpl {
* @return 元数据
*/
default String buildCallTicketData(String shopName, CallTablePrintDTO printDTO) {
- PrintSignLabel signLabelInfo = getSignLabelInfo();
+ PrintLabel signLabelInfo = getSignLabelInfo();
CallTable callTable = printDTO.getCallTable();
CallQueue callQueue = printDTO.getCallQueue();
String str = formatLabel(shopName, signLabelInfo.center) +
@@ -881,7 +889,7 @@ public interface PrinterImpl {
}
str = str + formatLabel(StrUtil.format("取号时间: {}", DateUtil.format(callQueue.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
signLabelInfo.br +
- signLabelInfo.getOut(150) + signLabelInfo.cut;
+ signLabelInfo.out() + signLabelInfo.cut;
return str;
}
@@ -933,11 +941,11 @@ public interface PrinterImpl {
/**
* 通用三列对齐方法(严格总长度)
* 规则:key1=左对齐,key2=左对齐,key3=右对齐
- * 整行总长度 = totalWidth,绝不超界
+ * 24的字体 最大宽度32
+ * 32的字体 最大宽度24
*/
default String key3(String key1, String key2, String key3,
- int key1Width,
- int key2Width) {
+ int key1Width, int key2Width, int allWidth) {
// 1. 空值安全处理
key1 = Objects.toString(key1, "");
key2 = Objects.toString(key2, "");
@@ -955,7 +963,7 @@ public interface PrinterImpl {
// 6. 最终按总显示宽度截断(100%不超界)
int usedWidth = key1Width + key2Width + w3;
- int space3 = Math.max(32 - usedWidth, 0);
+ int space3 = Math.max(allWidth - usedWidth, 0);
// 5. 拼接:左1 + 空格 + 左2 + 空格 + (靠右空格) + 右3
return key1 + " ".repeat(space1)
@@ -964,6 +972,13 @@ public interface PrinterImpl {
+ key3;
}
+ /**
+ * 通用四列对齐方法(严格总长度)
+ * 规则:key1=左对齐,key2=左对齐,key3=左对齐,key4=右对齐
+ * 24的字体 最大宽度32
+ * 32的字体 最大宽度24
+ * 目前写死了最大宽度32
+ */
default String key4(String key1, String key2, String key3, String key4,
int key1Width, int key2Width, int key3Width) {
// 1. 空值安全处理
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java b/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java
index 6d21db602..48195705b 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/print/YxyPrinter.java
@@ -40,7 +40,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
super("云想印");
}
- private final PrintSignLabel printSignLabel = new PrintSignLabel()
+ private final PrintLabel printLabel = new PrintLabel()
.setBr("
")
.setCut("")
.setOut("OUT")
@@ -217,8 +217,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
- public PrintSignLabel getSignLabelInfo() {
- return printSignLabel;
+ public PrintLabel getSignLabelInfo() {
+ return printLabel;
}
@Override