|
|
|
@ -11,6 +11,180 @@ import java.util.Date; |
|
|
|
|
*/ |
|
|
|
|
public class ZkcPrinterTemplate { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加油站 |
|
|
|
|
* @param gasName 油站名称 |
|
|
|
|
* @param orderNo 订单号 |
|
|
|
|
* @param payTime 支付时间 |
|
|
|
|
* @param source 来源 |
|
|
|
|
* @param gunNo 抢号 |
|
|
|
|
* @param oilNo 油号 |
|
|
|
|
* @param oilLiters 升数 |
|
|
|
|
* @param orderPrice 加油金额 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static byte[] oilTemp(String gasName, |
|
|
|
|
String orderNo, |
|
|
|
|
String payTime, |
|
|
|
|
String phone, |
|
|
|
|
String source, |
|
|
|
|
String gunNo, |
|
|
|
|
String oilNo, |
|
|
|
|
String oilLiters, |
|
|
|
|
String orderPrice) throws Exception { |
|
|
|
|
ByteArrayOutputStream stream = new ByteArrayOutputStream(); |
|
|
|
|
// 居中
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x01); |
|
|
|
|
|
|
|
|
|
stream.write(gasName.getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write("(收银员存根)".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
// 左对齐
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x00); |
|
|
|
|
|
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(("流水号:" + orderNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("打印时间:" + DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("支付时间:" + payTime).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("电话:" + phone.substring(0, 3) + "****" + phone.substring(7)).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("来源:嗨森逛".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("油枪:" + gunNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("油品:" + oilNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("升数:" + oilLiters + "升").getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("实际加油升数以加油机为准!".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x0E); |
|
|
|
|
|
|
|
|
|
stream.write("加油金额".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(("¥" + orderPrice).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x21); |
|
|
|
|
stream.write(0x00); |
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x01); |
|
|
|
|
stream.write("开心又省钱;来“ 嗨森逛 ”".getBytes("UTF-8")); |
|
|
|
|
|
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 居中
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x01); |
|
|
|
|
|
|
|
|
|
stream.write(gasName.getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write("(客户存根)".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
// 左对齐
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x00); |
|
|
|
|
|
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(("流水号:" + orderNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("打印时间:" + DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("支付时间:" + payTime).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("电话:" + phone.substring(0, 3) + "****" + phone.substring(7)).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("来源:嗨森逛".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("油枪:" + gunNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("油品:" + oilNo).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("升数:" + oilLiters + "升").getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("实际加油升数以加油机为准!".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x0E); |
|
|
|
|
|
|
|
|
|
stream.write("加油金额".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(("¥" + orderPrice).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x21); |
|
|
|
|
stream.write(0x00); |
|
|
|
|
stream.write("--------------------------------".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(0x1B); |
|
|
|
|
stream.write(0x61); |
|
|
|
|
stream.write(0x01); |
|
|
|
|
stream.write("开心又省钱;来“ 嗨森逛 ”".getBytes("UTF-8")); |
|
|
|
|
|
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
return getPrinterBytes(stream.toByteArray(), 1, "UTF-8"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加油站收银员存根模板 |
|
|
|
|
* @param gasName 油站名称 |
|
|
|
@ -26,6 +200,7 @@ public class ZkcPrinterTemplate { |
|
|
|
|
public static byte[] oilCashierStubTemp(String gasName, |
|
|
|
|
String orderNo, |
|
|
|
|
String payTime, |
|
|
|
|
String phone, |
|
|
|
|
String source, |
|
|
|
|
String gunNo, |
|
|
|
|
String oilNo, |
|
|
|
@ -60,6 +235,9 @@ public class ZkcPrinterTemplate { |
|
|
|
|
stream.write(("支付时间:" + payTime).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("电话:" + phone.substring(0, 3) + "****" + phone.substring(7)).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("来源:嗨森逛".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
@ -119,6 +297,7 @@ public class ZkcPrinterTemplate { |
|
|
|
|
public static byte[] oilClientStubTemp(String gasName, |
|
|
|
|
String orderNo, |
|
|
|
|
String payTime, |
|
|
|
|
String phone, |
|
|
|
|
String source, |
|
|
|
|
String gunNo, |
|
|
|
|
String oilNo, |
|
|
|
@ -154,6 +333,9 @@ public class ZkcPrinterTemplate { |
|
|
|
|
stream.write(("支付时间:" + payTime).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write(("电话:" + phone.substring(0, 3) + "****" + phone.substring(7)).getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|
stream.write("来源:嗨森逛".getBytes("UTF-8")); |
|
|
|
|
stream.write(0x0A); |
|
|
|
|
|
|
|
|
|