From 82aba51c3695d9bbee9e6e4c187f862da47b5791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Fri, 18 Oct 2024 13:32:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=AE=A1=E7=90=86-=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E9=85=8D=E7=BD=AE=EF=BC=9A=E6=89=93=E5=8D=B0=E6=9C=BA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rabbit/PrintMechineConsumer.java | 4 ++-- .../cashierservice/rabbit/print/FeiPrinter.java | 15 ++++++++++++--- .../rabbit/print/PrinterHandler.java | 10 ++++++++-- .../service/CloudPrinterService.java | 8 ++++---- .../cashierservice/util/FeieyunPrintUtil.java | 14 +++++++------- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index 8bf4e99..871ac38 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -255,7 +255,7 @@ public class PrintMechineConsumer { String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType()); String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; - PrinterUtils.printTickets(voiceJson, 3, 1, tbPrintMachineWithBLOBs.getAddress(), data); + PrinterUtils.printTickets(voiceJson, 3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); } } } @@ -630,7 +630,7 @@ public class PrintMechineConsumer { } log.error("打印数据2>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType, printerNum); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java index 50564d0..8949c77 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/FeiPrinter.java @@ -85,7 +85,12 @@ public class FeiPrinter extends PrinterHandler { "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString()); String printType = "退款单"; log.error("打印数据3>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); - String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType); + String printerNum = "1"; + if (StrUtil.isNotBlank(machine.getPrintQty())) { + printerNum = machine.getPrintQty().split("\\^")[1]; + } + StrUtil.blankToDefault(machine.getPrintQty(), ""); + String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType, printerNum); shopPrintLogService.save(machine, "退款单", resp[0], resp[1]); } @@ -100,7 +105,11 @@ public class FeiPrinter extends PrinterHandler { "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString()); String printType = "结算单"; log.error("打印数据1>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); - String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType); + String printerNum = "1"; + if (StrUtil.isNotBlank(machine.getPrintQty())) { + printerNum = machine.getPrintQty().split("\\^")[1]; + } + String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType, printerNum); shopPrintLogService.save(machine, "结算单", resp[0], resp[1]); } @@ -130,7 +139,7 @@ public class FeiPrinter extends PrinterHandler { po.setTakeTime(queue.getCreateTime()); po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum())); String data = FeieyunPrintUtil.getCallNumPrintData(po); - String resp = FeieyunPrintUtil.print(data, machine.getAddress()); + String resp = FeieyunPrintUtil.print(data, machine.getAddress(), "1"); shopPrintLogService.save(machine, "叫号单", data, resp); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java index a926ca7..ae05b44 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/print/PrinterHandler.java @@ -44,7 +44,7 @@ public abstract class PrinterHandler { if (StrUtil.isBlank(printMethod) && StrUtil.isBlank(machine.getPrintType())) { throw new MsgException("打印机配置为空"); } - if(StrUtil.isNotBlank(printMethod)){ + if (StrUtil.isNotBlank(printMethod)) { List categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(machine.getCategoryList(), "[]"), CategoryInfo.class); //仅打印后厨-一菜一品 if ("one".equals(printMethod)) { @@ -72,6 +72,9 @@ public abstract class PrinterHandler { if (!CollUtil.contains(optionList, "queue")) { return; } + if (printDTO == null) { + return; + } callNumPrint(machine, printDTO); } @@ -92,7 +95,10 @@ public abstract class PrinterHandler { log.error("商品不存在, id: {}", item.getProductSkuId()); return; } - + if (StrUtil.isEmpty(machine.getClassifyPrint())) { + log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint()); + return; + } long count = categoryInfos.stream().filter(c -> c.getId().toString().equals(categoryId) ).count(); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java index f93a649..9604aee 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -281,7 +281,7 @@ public class CloudPrinterService { ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", - detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString()); + detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString()); detailPO.setOutNumber(orderInfo.getOutNumber()); String printType = "退款单"; @@ -373,7 +373,7 @@ public class CloudPrinterService { /** * 仅打印结算单「前台」 */ - private Result onlyFrontDeskForFe(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos, String type, Boolean ispre,String orderId) { + private Result onlyFrontDeskForFe(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos, String type, Boolean ispre, String orderId) { if (!"normal".equals(type)) { return Result.fail("非小票打印"); } @@ -473,7 +473,7 @@ public class CloudPrinterService { orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), - "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString()); + "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString()); String printType = "结算单"; if (ispre) { printType = "预结算单"; @@ -484,7 +484,7 @@ public class CloudPrinterService { } log.error("打印数据4>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType, printerNum); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java index bd91de5..40c3758 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/FeieyunPrintUtil.java @@ -255,7 +255,7 @@ public class FeieyunPrintUtil { return data.toString(); } - public static String[] getCashPrintData(OrderDetailPO detailPO, String sn, String type, String orderType) { + public static String[] getCashPrintData(OrderDetailPO detailPO, String sn, String type, String orderType, String printerNum) { String content = buildPrintContent(detailPO, type, orderType); //通过POST请求,发送打印信息到服务器 @@ -277,7 +277,7 @@ public class FeieyunPrintUtil { nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改 nvps.add(new BasicNameValuePair("sn", sn)); nvps.add(new BasicNameValuePair("content", content)); - nvps.add(new BasicNameValuePair("times", "1"));//打印联数 + nvps.add(new BasicNameValuePair("times", printerNum));//打印联数 CloseableHttpResponse response = null; String result = null; @@ -317,7 +317,7 @@ public class FeieyunPrintUtil { } - public static String print(String content, String sn){ + public static String print(String content, String sn, String printerNum) { // 通过POST请求,发送打印信息到服务器 RequestConfig requestConfig = RequestConfig.custom() .setSocketTimeout(30000)// 读取超时 @@ -334,7 +334,7 @@ public class FeieyunPrintUtil { nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 nvps.add(new BasicNameValuePair("sn", sn)); nvps.add(new BasicNameValuePair("content", content)); - nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 + nvps.add(new BasicNameValuePair("times", printerNum));// 打印联数 CloseableHttpResponse response = null; String result = null; @@ -402,12 +402,12 @@ public class FeieyunPrintUtil { StringBuilder sb = new StringBuilder(); sb.append(StrUtil.format("{}
", po.getShopName())); sb.append("--------------------------------
"); - sb.append(StrUtil.format("{} {}
",po.getTableName(),po.getCallNum())); - sb.append(StrUtil.format("前面有{}桌
",po.getPreNum())); + sb.append(StrUtil.format("{} {}
", po.getTableName(), po.getCallNum())); + sb.append(StrUtil.format("前面有{}桌
", po.getPreNum())); sb.append(StrUtil.format("{}
", po.getCodeUrl())); sb.append("怕过号扫一扫
"); sb.append("--------------------------------
"); - sb.append(po.getShopNote()+"
"); + sb.append(po.getShopNote() + "
"); sb.append("--------------------------------
"); sb.append(StrUtil.format("取号时间:{}
", DateUtils.getTime(po.getTakeTime()))); sb.append(StrUtil.format("打印时间:{}
", DateUtils.getTime(new Date())));