交班小票实现

This commit is contained in:
张松 2025-03-12 18:21:47 +08:00
parent 70b451fcb9
commit 03c757f38f
8 changed files with 299 additions and 104 deletions

View File

@ -7,11 +7,13 @@ import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.enums.YesNoEnum;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -29,6 +31,8 @@ import java.util.List;
@RequestMapping("/admin/handoverRecord")
public class HandoverRecordController {
private final HandoverRecordService handoverRecordService;
@Resource
private RabbitPublisher rabbitPublisher;
/**
* 交班记录-分页
@ -96,7 +100,9 @@ public class HandoverRecordController {
//@SaAdminCheckPermission("handoverRecord:handover")
public CzgResult<Long> handover(@RequestParam Integer isPrint) {
Long id = handoverRecordService.handover();
if (isPrint == 1){
rabbitPublisher.sendHandoverPrintMsg(id.toString());
}
return CzgResult.success(id);
}

View File

@ -52,11 +52,7 @@ public class PrintMqListener {
log.error("订单信息不存在, {}", orderId);
throw new RuntimeException("订单信息不存在");
}
getPrintMachine(orderInfo.getShopId(), "cash", "all", "").forEach(machine -> {
printerHandler.handleRequest(machine, orderInfo, null);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
printerHandler.handler(orderId, PrinterHandler.PrintTypeEnum.ORDER);
} catch (Exception e) {
log.error("订单打印失败", e);
@ -67,6 +63,26 @@ public class PrintMqListener {
}
}
/**
* 交班打印
*/
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) {
long startTime = DateUtil.date().getTime();
log.info("接收到交班打印消息:{}", id);
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE).setMsg(id).setType("handoverPrint").setPlat("java.order").setCreateTime(DateUtil.date().toLocalDateTime());
try {
printerHandler.handler(id, PrinterHandler.PrintTypeEnum.HANDOVER);
} catch (Exception e) {
log.error("交班打印失败", e);
mqLog.setErrInfo(JSONObject.toJSONString(e));
mqLog.setDuration(DateUtil.date().getTime() - startTime);
mqLog.setFailTime(DateUtil.date().toLocalDateTime());
mqLogService.save(mqLog);
}
}
/**
* 获取可用打印机
*
@ -103,6 +119,5 @@ public class PrintMqListener {
log.info("打印机列表: {}", list);
return list;
}
}

View File

@ -40,6 +40,11 @@ public class RabbitConfig {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue handoverPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue orderCancelQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE, true);
@ -72,6 +77,11 @@ public class RabbitConfig {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE);
}
@Bean
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
}
@Bean
public Binding bindingOrderMachinePrintExchange(Queue orderMachinePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderMachinePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE);

View File

@ -125,20 +125,4 @@ public class HandoverRecordDTO implements Serializable {
* 商品数据
*/
List<HandoverProductListVo> productDatalist;
public Object getCategoryData() {
return JSON.parseObject(Convert.toStr(categoryData, "{}"));
}
public Object getProductData() {
return JSON.parseObject(Convert.toStr(productData, "{}"));
}
public List<HandoverCategoryListVo> getCategoryDataList() {
return JSON.parseArray(StrUtil.blankToDefault(categoryData, "[]"), HandoverCategoryListVo.class);
}
public List<HandoverProductListVo> getProductDatalist() {
return JSON.parseArray(StrUtil.blankToDefault(productData, "[]"), HandoverProductListVo.class);
}
}
}

View File

@ -3,6 +3,8 @@ package com.czg.service.order.print;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.entity.PrintMachine;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService;
@ -56,6 +58,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
.setQr(new String[]{"<QR>", "</QR>"})
.setCenter(new String[]{"<CB>", "</CB>"})
.setBold(new String[]{"<BOLD>", "</BOLD>"});
@Override
public PrintSignLabel getSignLabelInfo() {
return printSignLabel;
@ -66,7 +69,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
String remark = orderDetail.getRemark();
String content = buildDishPrintData(false, getPickupNum(orderInfo), orderInfo.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
orderDetail.getProductName(), orderDetail.getSkuName(), orderDetail.getNum(), remark, orderDetail.getProGroupInfo());
sendPrintRequest(machine.getAddress(), content, null,"1");
sendPrintRequest(machine.getAddress(), content, null, "1");
// printMachineLogService.save(machine, "新订单", , );
}
@ -75,7 +78,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
String remark = orderDetail.getRemark();
String content = buildDishPrintData(true, getPickupNum(orderInfo), orderInfo.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
orderDetail.getProductName(), orderDetail.getSkuName(), orderDetail.getReturnNum(), remark, orderDetail.getProGroupInfo());
sendPrintRequest(machine.getAddress(), content, null,"1");
sendPrintRequest(machine.getAddress(), content, null, "1");
}
@Override
@ -120,11 +123,18 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
@Override
protected void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum, String codeUrl, LocalDateTime takeTime, String shopNote) {
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl,shopNote, takeTime);
String resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
sendPrintRequest(machine.getAddress(), resp, voiceJson, "1");
// shopPrintLogService.save(machine, "叫号单", data, resp);
}
@Override
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
String string = buildHandoverData(record);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
sendPrintRequest(machine.getAddress(), string, voiceJson, "1");
}
/**
* 生成签名
*/

View File

@ -6,12 +6,10 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.dto.PrintOrderDetailDTO;
import com.czg.account.entity.*;
import com.czg.account.service.CallQueueService;
import com.czg.account.service.CallTableService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.account.service.*;
import com.czg.config.RedisCst;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
@ -30,6 +28,7 @@ import com.czg.system.service.SysParamsService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
@ -38,10 +37,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -77,6 +73,23 @@ public abstract class PrinterHandler {
protected ProductService productService;
@DubboReference
protected ProdSkuService prodSkuService;
@DubboReference
private PrintMachineService printMachineService;
@DubboReference
private HandoverRecordRpcService handoverRecordService;
@Getter
public enum PrintTypeEnum {
HANDOVER("交班", "handover"),
ORDER("订单", "order"), ONE("菜品", "one"), CALL("叫号", "call");
private final String name;
private final String code;
PrintTypeEnum(String name, String code) {
this.name = name;
this.code = code;
}
}
@Data
@Accessors(chain = true)
@ -112,29 +125,101 @@ public abstract class PrinterHandler {
// 是否退款单
private boolean isReturn;
@Data
@Accessors(chain = true)
public static class DetailInfo {
private String num;
private String productName;
private String amount;
private String skuName;
private String prodGroupInfo;
}
}
public PrinterHandler(String printerBrand) {
this.printerBrand = printerBrand;
}
public void handleRequest(PrintMachine machine, OrderInfo orderInfo, Long callQueueId) {
/**
* 获取可用打印机
*
* @param shopId 店铺id
* @param subType 打印类型分类label标签 cash小票 kitchen出品
* @param printMethod 打印方式 all-全部打印 normal-仅打印结账单前台one-仅打印制作单厨房
* @param printType 打印类型JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
* @return 打印机列表
*/
private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType) {
QueryWrapper wrapper = new QueryWrapper()
.eq(PrintMachine::getStatus, 1)
.eq(PrintMachine::getShopId, shopId)
.eq(PrintMachine::getSubType, subType)
.eq(PrintMachine::getConnectionType, "网络");
if (StrUtil.isNotEmpty(printMethod)) {
wrapper.in(PrintMachine::getPrintMethod, Arrays.asList(printMethod, "all"));
}
if ("callTicket".equals(printType)) {
printType = "queue";
}
if (StrUtil.isNotEmpty(printType)) {
wrapper.like(PrintMachine::getPrintType, printType);
}
List<PrintMachine> list = printMachineService.list(wrapper);
for (PrintMachine item : list) {
//实际打印以传递的参数为准
item.setPrintMethod(printMethod);
}
if (list.isEmpty()) {
log.error("店铺未配置打印机店铺id: {}", shopId);
return list;
}
log.info("打印机列表: {}", list);
return list;
}
/**
* 处理打印
* @param data 传递的数据
* @param printTypeEnum order returnOrder preOrder one call handover
*/
public void handler(String data, PrintTypeEnum printTypeEnum) {
Long shopId = null;
String printMethod = "";
String printType = "";
Object obj = null;
switch (printTypeEnum) {
case PrintTypeEnum.HANDOVER:
HandoverRecordDTO record = handoverRecordService.getHandoverRecordById(Long.parseLong(data));
if (record == null) {
throw new RuntimeException("交班票打印失败,交班记录不存在");
}
obj = record;
shopId = record.getShopId();
printType = "handover";
break;
case PrintTypeEnum.ORDER:
OrderInfo orderInfo = orderInfoService.getById(data);
if (orderInfo == null) {
throw new RuntimeException("订单打印失败,订单不存在");
}
obj = orderInfo;
shopId = orderInfo.getShopId();
printMethod = "order";
printType = "order";
break;
}
if (shopId == null) {
throw new RuntimeException("店铺不存在, id:" + shopId);
}
Object finalObj = obj;
getPrintMachine(shopId, "cash", printMethod, printType).forEach(machine -> {
handleRequest(machine, finalObj, printTypeEnum);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
}
private void handleRequest(PrintMachine machine, Object data, PrintTypeEnum printTypeEnum) {
if (canHandleRequest(machine.getContentType(), machine.getConnectionType())) {
log.info("打印机: {}, 订单信息: {}", machine.getName(), orderInfo);
print(machine, orderInfo, callQueueId);
log.info("打印机: {}, 传递信息: {}", machine.getName(), data);
print(machine, data, printTypeEnum);
} else if (nextPrinter != null) {
log.info("当前打印机无法处理: {},将请求传递给下一个打印机:{}...", this.printerBrand, nextPrinter.printerBrand);
nextPrinter.handleRequest(machine, orderInfo, callQueueId);
nextPrinter.handleRequest(machine, data, printTypeEnum);
} else {
log.warn("未找到匹配打印机");
}
@ -186,50 +271,33 @@ public abstract class PrinterHandler {
return orderDetails;
}
protected void print(PrintMachine machine, OrderInfo orderInfo, Long callQueueId) {
String printMethod = machine.getPrintMethod();
if (StrUtil.isBlank(printMethod) && StrUtil.isBlank(machine.getPrintType())) {
throw new RuntimeException("打印机配置为空");
}
// 订单打印
if (StrUtil.isNotBlank(printMethod) && !"queue".equals(printMethod)) {
log.info("准备开始打印订单或菜品单");
// 查询订单详情
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
//仅打印后厨一菜一品
switch (printMethod) {
case "one" -> onlyKitchen(machine, orderInfo, orderDetailList);
case "normal" ->
//仅打印前台
onlyFrontDesk(machine, orderInfo, orderDetailList);
case "all" -> {
//全部打印 前台+后厨
protected void print(PrintMachine machine, Object data, PrintTypeEnum printTypeEnum) {
switch (printTypeEnum) {
case PrintTypeEnum.HANDOVER:
log.info("准备开始打印交班");
if (data instanceof HandoverRecordDTO record) {
handoverPrint(machine, record);
}
break;
case PrintTypeEnum.ORDER:
log.info("准备开始打印订单");
if (data instanceof OrderInfo orderInfo) {
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
onlyFrontDesk(machine, orderInfo, orderDetailList);
}
break;
case PrintTypeEnum.ONE:
log.info("准备开始打印菜品单");
if (data instanceof OrderInfo orderInfo) {
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
onlyKitchen(machine, orderInfo, orderDetailList);
}
default -> log.warn("未知打印类型: {}", printMethod);
}
} else {
log.info("准备开始打印叫号单");
if (StrUtil.isBlank(machine.getPrintType())) {
return;
}
break;
case PrintTypeEnum.CALL:
log.info("准备开始打印叫号单");
onlyCallNumPrint(machine, null);
JSONArray options = JSONArray.parseArray(machine.getPrintType());
if (options == null || options.isEmpty()) {
log.warn("打印机: {}, 未配置: print_type", machine.getId());
return;
}
//是否包含排队取号
if (!options.contains("queue")) {
log.warn("打印机: {}, 此打印机不包含排队叫号打印", machine.getId());
return;
}
// if (printDTO == null) {
// return;
// }
onlyCallNumPrint(machine, callQueueId);
}
}
@ -428,4 +496,6 @@ public abstract class PrinterHandler {
protected abstract void callNumPrint(PrintMachine machine, String callNum, String shopName, String tableName, String tableNote, String preNum,
String codeUrl, LocalDateTime takeTime, String shopNote);
protected abstract void handoverPrint(PrintMachine machine, HandoverRecordDTO record);
}

View File

@ -8,6 +8,8 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.order.entity.OrderDetail;
import lombok.Data;
import lombok.experimental.Accessors;
@ -38,6 +40,7 @@ public interface PrinterImpl {
private String[] qr;
private String cut;
private String out;
private String rs;
public String getOut(int num) {
if (out != null) {
@ -45,9 +48,19 @@ public interface PrinterImpl {
}
return "";
}
}
/**
* @param num 最小1最大127不设置则为默认
*/
public String getRs(int num) {
if (StrUtil.isNotBlank(rs)) {
return StrUtil.format("<{}:{}>", rs, num);
}
return "";
}
}
/**
* 发送打印请求
@ -89,7 +102,7 @@ public interface PrinterImpl {
price = addSpace(price, b2);
num = addSpace(num, b3);
total = addSpace(total, b4);
String otherStr = " %s%s%s".formatted(price, num, total);
String otherStr = "%s%s%s".formatted(price, num, total);
int titleByteLen = StrUtil.bytes(title, CharsetUtil.CHARSET_GBK).length;
StringBuilder sb = new StringBuilder();
@ -109,16 +122,25 @@ public interface PrinterImpl {
// 第一行拼接其它字段
String firstLine = titleAddSpace(lines.getFirst(), b1);
sb.append(getFormatLabel(firstLine + otherStr, signLabelInfo.s)).append(signLabelInfo.br);
// sb.append(startSplitSign).append(firstLine).append(otherStr).append(endSplitSign).append("<BR>");
sb.append(getFormatLabel(firstLine + otherStr, signLabelInfo.s));
sb.append(signLabelInfo.br);
// 剩余的行单独换行输出
for (int i = 1; i < lines.size(); i++) {
sb.append(getFormatLabel(lines.get(i), signLabelInfo.s)).append(signLabelInfo.br);
if (i+1 != lines.size()) {
// sb.append(signLabelInfo.getRs(1));
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
sb.append(signLabelInfo.br);
}else {
sb.append(getFormatLabel(titleAddSpace(lines.get(i), b1), signLabelInfo.s));
}
// sb.append(startSplitSign).append(lines.get(i)).append(endSplitSign).append("BR>");
}
}
sb.append("<BR>");
sb.append(signLabelInfo.br);
return sb.toString();
}
@ -135,6 +157,73 @@ public interface PrinterImpl {
return str.toString();
}
default String buildHandoverData(HandoverRecordDTO handoverRecord) {
PrintSignLabel signLabelInfo = getSignLabelInfo();
StringBuilder builder = new StringBuilder()
.append(getFormatLabel(handoverRecord.getShopName(), signLabelInfo.center, signLabelInfo.f)).append(signLabelInfo.br)
.append(getFormatLabel("交班小票", signLabelInfo.l,signLabelInfo.center)).append(signLabelInfo.br)
.append("交班时间: ").append(handoverRecord.getHandoverTime()).append(signLabelInfo.br)
.append("收银员: ").append(handoverRecord.getStaffName()).append(signLabelInfo.br)
.append("当班总收入: ").append(handoverRecord.getHandAmount()).append(signLabelInfo.br)
.append("现金收入: ").append(handoverRecord.getCashAmount()).append(signLabelInfo.br)
.append("微信收入: ").append(handoverRecord.getWechatAmount()).append(signLabelInfo.br)
.append("支付宝收入: ").append(handoverRecord.getAlipayAmount()).append(signLabelInfo.br)
.append("会员支付: ").append(handoverRecord.getVipPay()).append(signLabelInfo.br)
.append("会员充值: ").append(handoverRecord.getVipRecharge()).append(signLabelInfo.br)
.append(signLabelInfo.br)
.append(signLabelInfo.br)
.append("分类数据").append(signLabelInfo.br).append(signLabelInfo.br)
.append(getFormatLabel("名称 数量 总计 ", signLabelInfo.s))
.append(signLabelInfo.br)
.append(signLabelInfo.br);
if (StrUtil.isNotBlank(handoverRecord.getCategoryData())) {
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(getRow(categoryName, "", quantity.toString(), amount.toPlainString(), 20, 0, 6, 6)).append(signLabelInfo.br);
});
}
builder.append(signLabelInfo.br);
builder.append(signLabelInfo.br);
builder.append("商品数据")
.append(signLabelInfo.br)
.append(signLabelInfo.br);
builder.append(getFormatLabel("名称 总计 ", signLabelInfo.s))
.append(signLabelInfo.br)
.append(signLabelInfo.br);
if (StrUtil.isNotBlank(handoverRecord.getProductData())) {
JSONArray.parseArray(handoverRecord.getProductData()).forEach(item -> {
JSONObject info = (JSONObject) item;
String productName = info.getString("productName");
String skuName = info.getString("skuName");
if (StrUtil.isNotBlank(skuName)) {
productName = productName + "-" + skuName;
}
BigDecimal num = info.getBigDecimal("num");
// builder.append(signLabelInfo.getRs(5));
builder.append(getRow(productName, "", "", num.toPlainString(), 25, 0, 1, 6)).append(signLabelInfo.br);
});
}
builder
.append(signLabelInfo.br)
.append(signLabelInfo.br)
.append("快捷收款金额: ").append(handoverRecord.getQuickInAmount()).append(signLabelInfo.br)
.append("退款金额: ").append(handoverRecord.getRefundAmount()).append(signLabelInfo.br)
.append("总收入: ").append(handoverRecord.getHandAmount()).append(signLabelInfo.br)
.append("挂账金额: ").append(handoverRecord.getCreditAmount()).append(signLabelInfo.br)
.append("总订单数: ").append(handoverRecord.getOrderCount()).append(signLabelInfo.br)
.append("打印时间: ").append(DateUtil.date()).append(signLabelInfo.br)
.append(signLabelInfo.getOut(180))
.append(signLabelInfo.cut)
;
return builder.toString();
}
/**
* 构建订单打印元数据
*
@ -347,13 +436,14 @@ public interface PrinterImpl {
/**
* 构建叫号元数据
* @param shopName 店铺名称
*
* @param shopName 店铺名称
* @param tableName 表名
* @param callNum 号码
* @param preNum 前面还有几桌
* @param codeUrl 二维码地址
* @param shopNote 店铺备注
* @param takeTime 取号时间
* @param callNum 号码
* @param preNum 前面还有几桌
* @param codeUrl 二维码地址
* @param shopNote 店铺备注
* @param takeTime 取号时间
* @return 元数据
*/
default String buildCallTicketData(String shopName, String tableName, String callNum, String preNum, String codeUrl, String shopNote, LocalDateTime takeTime) {
@ -452,7 +542,7 @@ public interface PrinterImpl {
public static void main(String[] args) {
System.out.println("水煮肉片".length());
System.out.println( StrUtil.repeat(' ', 8));
System.out.println(StrUtil.repeat(' ', 8));
System.out.println(StrUtil.fillAfter("水煮肉片", ' ', 21));
}

View File

@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.HandoverRecord;
import com.czg.account.entity.PrintMachine;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService;
@ -59,6 +61,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
.setS(new String[]{"<S>", "</S>"})
.setQr(new String[]{"<QR>", "</QR>"})
.setCenter(new String[]{"<C>", "</C>"})
.setRs("RS")
.setBold(new String[]{"<B>", "</B>"});
@Override
@ -134,8 +137,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
.setRemark(orderInfo.getRemark()).setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
String data = buildOrderPrintData(printInfoDTO, detailList);
String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
// String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String printerNum = "1";
if (StrUtil.isNotBlank(machine.getPrintQty())) {
printerNum = machine.getPrintQty().split("\\^")[1];
@ -154,8 +157,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
.setRemark(orderInfo.getRemark()).setDiscountAmount(orderInfo.getOriginAmount().subtract(orderInfo.getPayAmount()).toPlainString());
String data = buildOrderPrintData(printInfoDTO, detailList);
String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
// String voiceJson = "{\"PbizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String printerNum = "1";
if (StrUtil.isNotBlank(machine.getPrintQty())) {
printerNum = machine.getPrintQty().split("\\^")[1];
@ -170,6 +173,13 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
sendPrintRequest(machine.getAddress(), resp, null, "1");
}
@Override
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
String string = buildHandoverData(record);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
sendPrintRequest(machine.getAddress(), string, voiceJson, "1");
}
/**
* 获取TOKEN值
*