打印尝试2
This commit is contained in:
@@ -54,8 +54,9 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
|
|||||||
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
||||||
.setF(new String[]{"<F>", "</F>"})
|
.setF(new String[]{"<F>", "</F>"})
|
||||||
.setL(new String[]{"<L>", "</L>"})
|
.setL(new String[]{"<L>", "</L>"})
|
||||||
.setS(new String[]{"", ""})
|
.setS(new String[]{"<s>", "</s>"})
|
||||||
.setF(new String[]{"<B>", "</B>"})
|
.setS(new String[]{"<s>", "</s>"})
|
||||||
|
.setRight(new String[]{"<RIGHT>", "</RIGHT>"})
|
||||||
.setQr(new String[]{"<QR>", "</QR>"})
|
.setQr(new String[]{"<QR>", "</QR>"})
|
||||||
.setCenter(new String[]{"<C>", "</C>"})
|
.setCenter(new String[]{"<C>", "</C>"})
|
||||||
.setBold(new String[]{"<BOLD>", "</BOLD>"});
|
.setBold(new String[]{"<BOLD>", "</BOLD>"});
|
||||||
|
|||||||
@@ -28,6 +28,32 @@ public interface PrinterImpl {
|
|||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
class PrintSignLabel {
|
class PrintSignLabel {
|
||||||
|
/**
|
||||||
|
* <BR> :换行符
|
||||||
|
* <CUT> :切刀指令/自动走纸(主动切纸,仅限切刀打印机使用才有效果/手动撕纸设备使用该指令时为自动走纸)
|
||||||
|
* <LOGO> :打印LOGO指令(有该指令则会打印LOGO,设备首次使用需上传LOGO图片)
|
||||||
|
* <PLUGIN> :预留
|
||||||
|
* <S></S>:缩小字体对应24*24字体(注:默认字体大小为32*32)
|
||||||
|
* <F></F>:放大字体对应48*48字体
|
||||||
|
* <CB></CB>:设置字体64*64且居中
|
||||||
|
* <B></B>:放大一倍对应64*64字体
|
||||||
|
* <C></C>:居中
|
||||||
|
* <L></L>:字体变高一倍
|
||||||
|
* <W></W>:字体变宽一倍
|
||||||
|
* <QR></QR>:二维码(单个订单,最多只能打印一个二维码)
|
||||||
|
* <BC128_A></BC128_A>:数字字母混合条形码
|
||||||
|
* <RIGHT></RIGHT>:右对齐
|
||||||
|
* <BOLD></BOLD>:字体加粗
|
||||||
|
* <UDL></UDL>: 设置下划线打印
|
||||||
|
* <HL></HL>: 反白打印
|
||||||
|
* <RT:?></RT>: 字符旋转(“?”代表旋转角度)
|
||||||
|
* <RS:?>: 此行到下行的行间距“?”该值可自己设置(最小1,最大127,不设置则为默认)
|
||||||
|
* <WS:?>: 每行中文字的间距“?”该值可自己设置(最小1,最大48,不设置则为默认)
|
||||||
|
* <CS:x>:设置可变字体大小</CS>(x:16,24,32,48,64,72,96都可支持,如x=96则为96*96字体)
|
||||||
|
* <OUT:113>:走纸113点
|
||||||
|
* <PLUGIN>:切刀全切指令(只适用带切刀型设备)
|
||||||
|
* <PCUT>:切刀半切指令(只适用带切刀型设备)
|
||||||
|
*/
|
||||||
private String[] center;
|
private String[] center;
|
||||||
private String[] centerBold;
|
private String[] centerBold;
|
||||||
private String[] bold;
|
private String[] bold;
|
||||||
@@ -36,6 +62,7 @@ public interface PrinterImpl {
|
|||||||
private String[] f;
|
private String[] f;
|
||||||
private String[] l;
|
private String[] l;
|
||||||
private String[] qr;
|
private String[] qr;
|
||||||
|
private String[] Right;
|
||||||
private String cut;
|
private String cut;
|
||||||
private String out;
|
private String out;
|
||||||
private String rs;
|
private String rs;
|
||||||
@@ -108,7 +135,6 @@ public interface PrinterImpl {
|
|||||||
// 品名可以在一行显示,直接补足空格
|
// 品名可以在一行显示,直接补足空格
|
||||||
title = titleAddSpace(title, b1);
|
title = titleAddSpace(title, b1);
|
||||||
sb.append(getFormatLabel(title + otherStr, signLabelInfo.s));
|
sb.append(getFormatLabel(title + otherStr, signLabelInfo.s));
|
||||||
// sb.append(startSplitSign).append(title).append(otherStr).append(endSplitSign);
|
|
||||||
} else {
|
} else {
|
||||||
// 品名超出一行,进行拆分
|
// 品名超出一行,进行拆分
|
||||||
List<String> lines = isEn(title)
|
List<String> lines = isEn(title)
|
||||||
@@ -119,22 +145,16 @@ public interface PrinterImpl {
|
|||||||
|
|
||||||
// 第一行拼接其它字段
|
// 第一行拼接其它字段
|
||||||
String firstLine = titleAddSpace(lines.getFirst(), b1);
|
String firstLine = titleAddSpace(lines.getFirst(), b1);
|
||||||
// sb.append(startSplitSign).append(firstLine).append(otherStr).append(endSplitSign).append("<BR>");
|
|
||||||
|
|
||||||
sb.append(getFormatLabel(firstLine + otherStr, signLabelInfo.s));
|
sb.append(getFormatLabel(firstLine + otherStr, signLabelInfo.s));
|
||||||
|
|
||||||
sb.append(signLabelInfo.br);
|
sb.append(signLabelInfo.br);
|
||||||
|
|
||||||
// 剩余的行单独换行输出
|
// 剩余的行单独换行输出
|
||||||
for (int i = 1; i < lines.size(); i++) {
|
for (int i = 1; i < lines.size(); i++) {
|
||||||
if (i + 1 != lines.size()) {
|
if (i + 1 != lines.size()) {
|
||||||
// sb.append(signLabelInfo.getRs(1));
|
|
||||||
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
|
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
|
||||||
sb.append(signLabelInfo.br);
|
sb.append(signLabelInfo.br);
|
||||||
} else {
|
} else {
|
||||||
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
|
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
|
||||||
}
|
}
|
||||||
// sb.append(startSplitSign).append(lines.get(i)).append(endSplitSign).append("BR>");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.append(signLabelInfo.br);
|
sb.append(signLabelInfo.br);
|
||||||
@@ -243,8 +263,8 @@ public interface PrinterImpl {
|
|||||||
|
|
||||||
for (OrderDetail detail : detailList) {
|
for (OrderDetail detail : detailList) {
|
||||||
String number = detail.getNum().stripTrailingZeros().toPlainString();
|
String number = detail.getNum().stripTrailingZeros().toPlainString();
|
||||||
String row = getRow(detail.getProductName(), toPlainStr(detail.getUnitPrice().toPlainString()), number, toPlainStr(detail.getPayAmount().toPlainString())
|
String row = getRow(detail.getProductName(), toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString()), number, toPlainStr(detail.getPayAmount().toPlainString())
|
||||||
, 18, 0, 5, 6);
|
, 18, 0, 5, 5);
|
||||||
data.append(row);
|
data.append(row);
|
||||||
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
if (StrUtil.isNotBlank(detail.getSkuName())) {
|
||||||
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
|
data.append(getFormatLabel(StrUtil.format("规格:{}", detail.getSkuName()), signLabelInfo.s))
|
||||||
@@ -280,14 +300,16 @@ public interface PrinterImpl {
|
|||||||
}
|
}
|
||||||
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
|
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
|
||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
data.append(getFormatLabel(StrUtil.format("原价: {}", toPlainStr(printInfoDTO.getOriginalAmount())), signLabelInfo.s))
|
data.append(getFormatLabel("原价:", signLabelInfo.s));
|
||||||
.append(signLabelInfo.br);
|
data.append(getFormatLabel(toPlainStr(printInfoDTO.getOriginalAmount()), signLabelInfo.Right, signLabelInfo.s));
|
||||||
|
|
||||||
|
data.append(signLabelInfo.br);
|
||||||
if (ObjectUtil.isNotNull(printInfoDTO.getDiscountAmount())) {
|
if (ObjectUtil.isNotNull(printInfoDTO.getDiscountAmount())) {
|
||||||
data.append(getFormatLabel(StrUtil.format("优惠金额: -{}", toPlainStr(printInfoDTO.getDiscountAmount())), signLabelInfo.s))
|
data.append(getFormatLabel(StrUtil.format("优惠金额: -{}", toPlainStr(printInfoDTO.getDiscountAmount())), signLabelInfo.s))
|
||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(printInfoDTO.getRemark())) {
|
if (StrUtil.isNotBlank(printInfoDTO.getRemark())) {
|
||||||
data.append(getFormatLabel(StrUtil.format("备注:{}", printInfoDTO.getRemark()), signLabelInfo.l, signLabelInfo.bold)).append(signLabelInfo.br);
|
data.append(getFormatLabel(StrUtil.format("备注:{}", printInfoDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
}
|
}
|
||||||
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
|
data.append(getFormatLabel("--------------------------------", signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
data.append(getFormatLabel(StrUtil.format("应付金额: {}", printInfoDTO.getPayAmount()), signLabelInfo.s, signLabelInfo.bold)).append(signLabelInfo.br);
|
data.append(getFormatLabel(StrUtil.format("应付金额: {}", printInfoDTO.getPayAmount()), signLabelInfo.s, signLabelInfo.bold)).append(signLabelInfo.br);
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
|
|||||||
.setQr(new String[]{"<QR>", "</QR>"})
|
.setQr(new String[]{"<QR>", "</QR>"})
|
||||||
.setCenter(new String[]{"<C>", "</C>"})
|
.setCenter(new String[]{"<C>", "</C>"})
|
||||||
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
.setCenterBold(new String[]{"<CB>", "</CB>"})
|
||||||
|
|
||||||
|
.setRight(new String[]{"<RIGHT>", "</RIGHT>"})
|
||||||
.setRs("RS")
|
.setRs("RS")
|
||||||
|
.setBr("<BR>")
|
||||||
|
.setCut("")
|
||||||
.setBold(new String[]{"<B>", "</B>"});
|
.setBold(new String[]{"<B>", "</B>"});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user