店铺管理-店铺配置:打印机设置相关接口

This commit is contained in:
谭凯凯
2024-10-18 13:32:18 +08:00
committed by Tankaikai
parent 66763774ab
commit 82aba51c36
5 changed files with 33 additions and 18 deletions

View File

@@ -255,7 +255,7 @@ public class PrintMechineConsumer {
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType()); String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}"; 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)); log.error("打印数据2>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType, printerNum);
} }
} }

View File

@@ -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()); "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "退款单"; String printType = "退款单";
log.error("打印数据3>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); 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]); 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()); "0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount() == null ? null : orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio() == null ? null : orderInfo.getDiscountRatio().toPlainString());
String printType = "结算单"; String printType = "结算单";
log.error("打印数据1>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); 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]); shopPrintLogService.save(machine, "结算单", resp[0], resp[1]);
} }
@@ -130,7 +139,7 @@ public class FeiPrinter extends PrinterHandler {
po.setTakeTime(queue.getCreateTime()); po.setTakeTime(queue.getCreateTime());
po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum())); po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum()));
String data = FeieyunPrintUtil.getCallNumPrintData(po); 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); shopPrintLogService.save(machine, "叫号单", data, resp);
} }
} }

View File

@@ -72,6 +72,9 @@ public abstract class PrinterHandler {
if (!CollUtil.contains(optionList, "queue")) { if (!CollUtil.contains(optionList, "queue")) {
return; return;
} }
if (printDTO == null) {
return;
}
callNumPrint(machine, printDTO); callNumPrint(machine, printDTO);
} }
@@ -92,7 +95,10 @@ public abstract class PrinterHandler {
log.error("商品不存在, id: {}", item.getProductSkuId()); log.error("商品不存在, id: {}", item.getProductSkuId());
return; return;
} }
if (StrUtil.isEmpty(machine.getClassifyPrint())) {
log.error("分类打印是空, classifyPrint: {}", machine.getClassifyPrint());
return;
}
long count = categoryInfos.stream().filter(c -> long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();

View File

@@ -484,7 +484,7 @@ public class CloudPrinterService {
} }
log.error("打印数据4>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO)); log.error("打印数据4>>>>>>>>>>>>>>>>>>>>>>>>: {}", JSON.toJSONString(detailPO));
FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType, printerNum);
} }
} }

View File

@@ -255,7 +255,7 @@ public class FeieyunPrintUtil {
return data.toString(); 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); String content = buildPrintContent(detailPO, type, orderType);
//通过POST请求发送打印信息到服务器 //通过POST请求发送打印信息到服务器
@@ -277,7 +277,7 @@ public class FeieyunPrintUtil {
nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改 nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改
nvps.add(new BasicNameValuePair("sn", sn)); nvps.add(new BasicNameValuePair("sn", sn));
nvps.add(new BasicNameValuePair("content", content)); nvps.add(new BasicNameValuePair("content", content));
nvps.add(new BasicNameValuePair("times", "1"));//打印联数 nvps.add(new BasicNameValuePair("times", printerNum));//打印联数
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String result = 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请求发送打印信息到服务器 // 通过POST请求发送打印信息到服务器
RequestConfig requestConfig = RequestConfig.custom() RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(30000)// 读取超时 .setSocketTimeout(30000)// 读取超时
@@ -334,7 +334,7 @@ public class FeieyunPrintUtil {
nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改
nvps.add(new BasicNameValuePair("sn", sn)); nvps.add(new BasicNameValuePair("sn", sn));
nvps.add(new BasicNameValuePair("content", content)); nvps.add(new BasicNameValuePair("content", content));
nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 nvps.add(new BasicNameValuePair("times", printerNum));// 打印联数
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String result = null; String result = null;