额外打印 店铺名称

This commit is contained in:
2026-04-15 18:27:29 +08:00
parent 45fbdd514e
commit ce2136b3cb
4 changed files with 58 additions and 51 deletions

View File

@@ -11,6 +11,7 @@ import com.czg.order.entity.OrderInfo;
import com.czg.print.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -29,6 +30,7 @@ import java.util.Map;
*/
@Component
@Slf4j
@Qualifier("feiPrinter")
public class FeiPrinter extends PrinterHandler implements PrinterImpl {
// API 地址
@@ -143,7 +145,7 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void stockPrint(PrintMachine machine, StockPrintDTO record) {
protected void stockPrint(PrintMachine machine, String shopName, StockPrintDTO record) {
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildStockData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -151,7 +153,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void dayReportPrint(PrintMachine machine, DayReportPrintDTO record) {
protected void dayReportPrint(PrintMachine machine, String shopName, DayReportPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildDayReportData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -159,7 +162,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void productReportPrint(PrintMachine machine, ProductReportPrintDTO record) {
protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildProductReportData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -167,7 +171,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void rechargePrint(PrintMachine machine, RechargePrintDTO record) {
protected void rechargePrint(PrintMachine machine, String shopName, RechargePrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildRechargeData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -175,7 +180,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record) {
protected void stockCheckPrint(PrintMachine machine, String shopName, StockCheckPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildStockCheckData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -183,7 +189,8 @@ public class FeiPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
protected void handoverPrint(PrintMachine machine, String shopName, HandoverRecordDTO record) {
record.setShopName(shopName);
String string = buildHandoverData(record);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
sendPrintRequest(machine.getAddress(), string, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());

View File

@@ -9,23 +9,21 @@ import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.dto.PrintOrderDetailDTO;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.exception.CzgException;
import com.czg.print.*;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderDetailService;
import com.czg.order.service.PrintMachineLogService;
import com.czg.print.*;
import com.czg.product.entity.ProdSku;
import com.czg.product.entity.Product;
import com.czg.product.service.ProdSkuService;
import com.czg.product.service.ProductService;
import com.czg.resp.CzgResult;
import com.czg.service.RedisService;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SysParamsService;
import com.czg.utils.FunUtils;
import com.mybatisflex.core.query.QueryWrapper;
@@ -211,36 +209,37 @@ public abstract class PrinterHandler {
log.info("otherHandler 打印数据为空, shopId: {}, data: {}", shopId, data);
return;
}
ShopInfo shopInfo = shopInfoService.getById(shopId);
switch (printTypeEnum) {
case PrintTypeEnum.STOCK:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockPrint(machine, (StockPrintDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockPrint(machine, shopInfo.getShopName(), (StockPrintDTO) data));
break;
case PrintTypeEnum.DAY_REPORT:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).dayReportPrint(machine, (DayReportPrintDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).dayReportPrint(machine, shopInfo.getShopName(), (DayReportPrintDTO) data));
break;
case PrintTypeEnum.PRODUCT_REPORT:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).productReportPrint(machine, (ProductReportPrintDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).productReportPrint(machine, shopInfo.getShopName(), (ProductReportPrintDTO) data));
break;
case PrintTypeEnum.RECHARGE:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).rechargePrint(machine, (RechargePrintDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).rechargePrint(machine, shopInfo.getShopName(), (RechargePrintDTO) data));
break;
case PrintTypeEnum.STOCK_CHECK:
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockCheckPrint(machine, (StockCheckPrintDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).stockCheckPrint(machine, shopInfo.getShopName(), (StockCheckPrintDTO) data));
break;
case PrintTypeEnum.HANDOVER:
log.info("准备开始打印交班");
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).handoverPrint(machine, (HandoverRecordDTO) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).handoverPrint(machine, shopInfo.getShopName(), (HandoverRecordDTO) data));
break;
case PrintTypeEnum.CALL:
log.info("准备开始打印叫号单");
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).callNumPrintBefore(machine, (CallQueue) data));
.forEach(machine -> printConfig.getPrinter(machine.getBrand()).callNumPrintBefore(machine, shopInfo.getShopName(), (CallQueue) data));
break;
default:
throw new CzgException("otherHandler 未知打印类型");
@@ -339,11 +338,11 @@ public abstract class PrinterHandler {
}
List<Long> productIds = tbOrderDetailList.stream().map(OrderDetail::getProductId).collect(Collectors.toList());
canPrintProSet = productService.list(new QueryWrapper()
.in(Product::getCategoryId, categoryIds)
.in(Product::getId, productIds))
.stream()
.map(Product::getId)
.collect(Collectors.toSet());
.in(Product::getCategoryId, categoryIds)
.in(Product::getId, productIds))
.stream()
.map(Product::getId)
.collect(Collectors.toSet());
}
ArrayList<OrderDetail> orderDetails = new ArrayList<>();
for (OrderDetail item : tbOrderDetailList) {
@@ -465,26 +464,20 @@ public abstract class PrinterHandler {
/**
* 打印排队小票
*/
private void callNumPrintBefore(PrintMachine machine, CallQueue queue) {
private void callNumPrintBefore(PrintMachine machine, String shopName, CallQueue queue) {
if (queue == null) {
log.warn("叫号记录不存在");
return;
}
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode(ParamCodeCst.System.CALL_PAGE_URL);
SysParamsDTO params = paramsByCode.getData();
String callUrl = null;
if (params != null && StrUtil.isNotBlank(params.getParamValue())) {
callUrl = params.getParamValue();
}
String callUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.CALL_PAGE_URL);
CallTable tbCallTable = callTableService.getById(queue.getCallTableId());
ShopInfo shopInfo = shopInfoService.getById(queue.getShopId());
callNumPrint(machine, queue.getCallNum(), shopInfo.getShopName(), tbCallTable.getName(), tbCallTable.getNote(), String.valueOf(callQueueService.count(new QueryWrapper()
.eq(CallQueue::getShopId, queue.getShopId())
.eq(CallQueue::getCallTableId, queue.getCallTableId())
.lt(CallQueue::getId, queue.getId())
.in(CallQueue::getState, 0, 1))), callUrl == null ? "未配置页面" : StrUtil.format(callUrl, queue.getShopId(), queue.getId()), queue.getCreateTime(),
long count = callQueueService.count(new QueryWrapper()
.eq(CallQueue::getShopId, queue.getShopId())
.eq(CallQueue::getCallTableId, queue.getCallTableId())
.lt(CallQueue::getId, queue.getId())
.in(CallQueue::getState, 0, 1));
callNumPrint(machine, queue.getCallNum(), shopName, tbCallTable.getName(), tbCallTable.getNote(), String.valueOf(count),
StrUtil.isEmpty(callUrl) ? "未配置页面" : StrUtil.format(callUrl, queue.getShopId(), queue.getId()), queue.getCreateTime(),
StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum()));
}
@@ -621,33 +614,33 @@ public abstract class PrinterHandler {
/**
* 出入库打印单
*/
protected abstract void stockPrint(PrintMachine machine, StockPrintDTO record);
protected abstract void stockPrint(PrintMachine machine, String shopName, StockPrintDTO record);
/**
* 经营日报打印
*/
protected abstract void dayReportPrint(PrintMachine machine, DayReportPrintDTO record);
protected abstract void dayReportPrint(PrintMachine machine, String shopName, DayReportPrintDTO record);
/**
* 商品报表打印
*/
protected abstract void productReportPrint(PrintMachine machine, ProductReportPrintDTO record);
protected abstract void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record);
/**
* 储值单打印
*/
protected abstract void rechargePrint(PrintMachine machine, RechargePrintDTO record);
protected abstract void rechargePrint(PrintMachine machine, String shopName, RechargePrintDTO record);
/**
* 库存盘点打印
*/
protected abstract void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record);
protected abstract void stockCheckPrint(PrintMachine machine, String shopName, StockCheckPrintDTO record);
/**
* 交班打印
*/
protected abstract void handoverPrint(PrintMachine machine, HandoverRecordDTO record);
protected abstract void handoverPrint(PrintMachine machine, String shopName, HandoverRecordDTO record);
private OrderPrintDTO getPrintInfoDTO(OrderInfo orderInfo, String printTitle) {

View File

@@ -799,7 +799,7 @@ public interface PrinterImpl {
* @param callNum 号码
* @param preNum 前面还有几桌
* @param codeUrl 二维码地址
* @param shopNote 店铺备注
* @param shopNote 店铺备注 过号顺延{}桌 {}桌后需重新排号 谢谢理解!
* @param takeTime 取号时间
* @return 元数据
*/
@@ -817,7 +817,7 @@ public interface PrinterImpl {
getFormatLabel(codeUrl, signLabelInfo.center, signLabelInfo.qr) +
signLabelInfo.br +
"--------------------------------" + signLabelInfo.br +
getFormatLabel("听到叫号请到前台过号可顺延1桌", signLabelInfo.s) +
getFormatLabel(shopNote, signLabelInfo.s) +
getFormatLabel(StrUtil.format("取号时间: {}", DateUtil.format(takeTime, "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
signLabelInfo.br +
signLabelInfo.cut;

View File

@@ -8,6 +8,7 @@ import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.print.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -26,6 +27,7 @@ import java.util.*;
*/
@Slf4j
@Component
@Qualifier("yxyPrinter")
public class YxyPrinter extends PrinterHandler implements PrinterImpl {
//请求地址
@@ -141,7 +143,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
@Override
protected void stockPrint(PrintMachine machine, StockPrintDTO record) {
protected void stockPrint(PrintMachine machine, String shopName, StockPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildStockData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -149,7 +152,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void dayReportPrint(PrintMachine machine, DayReportPrintDTO record) {
protected void dayReportPrint(PrintMachine machine, String shopName, DayReportPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildDayReportData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -157,7 +161,8 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void productReportPrint(PrintMachine machine, ProductReportPrintDTO record) {
protected void productReportPrint(PrintMachine machine, String shopName, ProductReportPrintDTO record) {
record.setShopName(shopName);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
String data = buildProductReportData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
@@ -165,16 +170,18 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
}
@Override
protected void rechargePrint(PrintMachine machine, RechargePrintDTO record) {
protected void rechargePrint(PrintMachine machine, String shopName, RechargePrintDTO record) {
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
record.setShopName(shopName);
String data = buildRechargeData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
printMachineLogService.save(machine, "储值单", data, resp);
}
@Override
protected void stockCheckPrint(PrintMachine machine, StockCheckPrintDTO record) {
protected void stockCheckPrint(PrintMachine machine, String shopName, StockCheckPrintDTO record) {
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
record.setShopName(shopName);
String data = buildStockCheckData(record);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
printMachineLogService.save(machine, "盘点单", data, resp);
@@ -185,7 +192,7 @@ public class YxyPrinter extends PrinterHandler implements PrinterImpl {
* 交班单打印
*/
@Override
protected void handoverPrint(PrintMachine machine, HandoverRecordDTO record) {
protected void handoverPrint(PrintMachine machine, String shopName, HandoverRecordDTO record) {
String string = buildHandoverData(record);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
sendPrintRequest(machine.getAddress(), string, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());