排队小票问题

This commit is contained in:
2026-04-17 10:21:05 +08:00
parent b854c9bc0f
commit 021fd32228
8 changed files with 91 additions and 63 deletions

View File

@@ -57,7 +57,7 @@ public interface RedisCst {
//后厨总单
public static final String ALL = "print:kitchen:all";
//菜品单
public static final String NORMAL = "print:kitchen:normal";
public static final String ONLY = "print:kitchen:only";
//退菜单
public static final String REFUND_ALL = "print:kitchen:refundAll";
}
@@ -91,8 +91,8 @@ public interface RedisCst {
*
* @param machineId 打印机设备id
*/
static String kitchenNormal(Long orderId, Long machineId, Long detailId) {
return kitchen.NORMAL + orderId + ":" + machineId + ":" + detailId;
static String kitchenOnly(Long orderId, Long machineId, Long detailId) {
return kitchen.ONLY + orderId + ":" + machineId + ":" + detailId;
}
/**

View File

@@ -0,0 +1,27 @@
package com.czg.print;
import com.czg.account.entity.CallQueue;
import com.czg.account.entity.CallTable;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* @author ww
*/
@Data
public class CallTablePrintDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private CallQueue callQueue;
private CallTable callTable;
//二维码地址
private String callUrl;
private Long preNum;
}

View File

@@ -13,6 +13,7 @@ import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.print.CallTablePrintDTO;
import com.czg.resp.CzgResult;
import com.czg.service.RedisService;
import com.czg.service.account.mapper.CallQueueMapper;
@@ -220,6 +221,21 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
callQueueService.save(callQueue);
CallTablePrintDTO callTablePrintDTO = new CallTablePrintDTO();
callTablePrintDTO.setCallQueue(callQueue);
callTablePrintDTO.setCallTable(callTable);
String callUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.CALL_PAGE_URL);
if (StrUtil.isNotBlank(callUrl)) {
callTablePrintDTO.setCallUrl(StrUtil.format(callUrl, callQueue.getShopId(), callQueue.getId()));
} else {
callTablePrintDTO.setCallUrl("未配置页面");
}
long count = callQueueService.count(new QueryWrapper()
.eq(CallQueue::getShopId, callQueue.getShopId())
.eq(CallQueue::getCallTableId, callQueue.getCallTableId())
.lt(CallQueue::getId, callQueue.getId())
.in(CallQueue::getState, 0, 1));
callTablePrintDTO.setPreNum(count);
// 打印排号票信息
rabbitPublisher.sendOtherPrintMsg(callQueue.getShopId(), callQueue, "CALL");

View File

@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -132,12 +131,12 @@ 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) {
protected void callNumPrint(PrintMachine machine, String shopName, CallTablePrintDTO queue) {
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
if (1 == machine.getVolumeSwitch()) {
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
}
String data = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
String data = buildCallTicketData(shopName, queue);
String resp = sendPrintRequest(machine.getAddress(), data, voiceJson, machine.getPrintNum() == null ? "1" : machine.getPrintNum().toString());
printMachineLogService.save(machine, "叫号单", data, resp);
}

View File

@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.entity.CallQueue;
import com.czg.account.entity.PrintMachine;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.PrintMachineService;
@@ -109,9 +108,9 @@ public class PrintConfig implements ApplicationRunner {
orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
default -> orderDetailList;
};
redisService.set("order:print:" + orderInfo.getId(), "", 180);
for (PrintMachine machine : getPrintMachine(orderInfo.getShopId(), printTypeEnum)) {
PrinterHandler printer = getPrinter(machine.getBrand());
redisService.set("order:print:" + orderInfo.getId(), "", 180);
switch (printTypeEnum) {
case PrinterHandler.PrintTypeEnum.GUEST_ORDER:
log.info("准备开始打印客看订单");
@@ -139,20 +138,20 @@ public class PrintConfig implements ApplicationRunner {
log.info("准备开始打印菜品单");
//后厨单菜品
tbOrderDetailList.forEach(item -> {
Boolean b = redisService.hasKey(RedisCst.kitchenNormal(orderInfo.getId(), machine.getId(), item.getId()));
if (!b) {
// Boolean b = redisService.hasKey(RedisCst.kitchenOnly(orderInfo.getId(), machine.getId(), item.getId()));
// if (!b) {
FunUtils.safeRunVoid(() -> printer.onlyKitchenPrint(orderInfo, item, machine),
"订单id:{} ,后厨分单打印失败", orderInfo.getId());
// 保存已打印信息
redisService.set(RedisCst.kitchenNormal(orderInfo.getId(), machine.getId(), item.getId()), "", 180);
}
// redisService.set(RedisCst.kitchenOnly(orderInfo.getId(), machine.getId(), item.getId()), "", 180);
// }
});
break;
case PrinterHandler.PrintTypeEnum.ALL_KITCHEN:
Boolean exit = redisService.hasKey(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()));
if (exit) {
break;
}
// Boolean exit = redisService.hasKey(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()));
// if (exit) {
// break;
// }
// 判断订单是否是先付费或者已结算
if (!"after-pay".equals(orderInfo.getPayMode()) && (OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus()) || OrderStatusEnums.CANCELLED.getCode().equals(orderInfo.getStatus()))) {
log.warn("此订单未支付, 订单信息: {}", orderInfo.getId());
@@ -164,7 +163,7 @@ public class PrintConfig implements ApplicationRunner {
}
log.info("准备开始打印后厨整单");
printer.allKitchenPrint(orderInfo, allOrderDetailList, machine);
redisService.set(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()), "", 180);
// redisService.set(RedisCst.kitchenAll(orderInfo.getId(), machine.getId()), "", 180);
break;
}
}
@@ -217,7 +216,7 @@ public class PrintConfig implements ApplicationRunner {
log.info("准备开始打印叫号单");
getPrintMachine(shopId, printTypeEnum)
.forEach(machine -> getPrinter(machine.getBrand())
.callNumPrintBefore(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), CallQueue.class)));
.callNumPrintBefore(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), CallTablePrintDTO.class)));
break;
default:
throw new CzgException("otherHandler 未知打印类型");
@@ -287,10 +286,6 @@ public class PrintConfig implements ApplicationRunner {
if (item.getNum().compareTo(BigDecimal.ZERO) <= 0 || item.getProductId().equals(-999L)) {
continue;
}
Boolean isPrint = redisService.hasKey(RedisCst.kitchenNormal(orderId, machine.getId(), item.getId()));
if (isPrint) {
continue;
}
if (item.getIsPrint() != null && item.getIsPrint() == 1 && (!partPrint || canPrintProSet.contains(item.getProductId()))) {
orderDetails.add(item);
} else {

View File

@@ -5,9 +5,10 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.HandoverRecordDTO;
import com.czg.account.dto.PrintOrderDetailDTO;
import com.czg.account.entity.*;
import com.czg.account.entity.PrintMachine;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopStaff;
import com.czg.account.service.*;
import com.czg.constants.ParamCodeCst;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
@@ -29,7 +30,6 @@ import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -206,21 +206,12 @@ public abstract class PrinterHandler {
/**
* 打印排队小票
*/
public void callNumPrintBefore(PrintMachine machine, String shopName, CallQueue queue) {
if (queue == null) {
public void callNumPrintBefore(PrintMachine machine, String shopName, CallTablePrintDTO queue) {
if (queue == null || queue.getCallQueue() == null || queue.getCallTable() == null) {
log.warn("叫号记录不存在");
return;
}
String callUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.CALL_PAGE_URL);
CallTable tbCallTable = callTableService.getById(queue.getCallTableId());
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()));
callNumPrint(machine, shopName, queue);
}
/**
@@ -360,8 +351,7 @@ 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 callNumPrint(PrintMachine machine, String shopName, CallTablePrintDTO queue);
/**
* 出入库打印单 √

View File

@@ -9,6 +9,8 @@ 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.CallQueue;
import com.czg.account.entity.CallTable;
import com.czg.order.entity.OrderDetail;
import com.czg.print.*;
import lombok.Data;
@@ -450,14 +452,18 @@ public interface PrinterImpl {
});
}
}
data.append(getFormatLabel(StrUtil.format(" 备注:{}", detail.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
if (StrUtil.isNotBlank(detail.getRemark()) && "null".equals(detail.getRemark())) {
data.append(getFormatLabel(StrUtil.format(" 备注:{}", detail.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
}
}
data.append(getDividingLine())
.append(signLabelInfo.br);
}
data.append(getFormatLabel(StrUtil.format("备注: {}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine())
.append(signLabelInfo.br);
if (StrUtil.isNotBlank(orderPrintDTO.getRemark()) && "null".equals(orderPrintDTO.getRemark())) {
data.append(getFormatLabel(StrUtil.format("备注: {}", orderPrintDTO.getRemark()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getDividingLine()).append(signLabelInfo.br);
}
data.append(getFormatLabel(StrUtil.format("操作员:{}", orderPrintDTO.getOperator()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("打印时间:{}", DateUtil.date().toString()), signLabelInfo.s)).append(signLabelInfo.br);
data.append(getFormatLabel(StrUtil.format("订单号:{}", orderPrintDTO.getOrderNo()), signLabelInfo.s)).append(signLabelInfo.br);
@@ -477,7 +483,7 @@ public interface PrinterImpl {
StringBuilder builder = new StringBuilder();
builder.append(getFormatLabel(pickupNumber, signLabelInfo.centerBold))
.append(signLabelInfo.br);
builder.append(getFormatLabel(StrUtil.format("时间:{}", DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.f, signLabelInfo.center))
builder.append(getFormatLabel(StrUtil.format("时间:{}", DateUtil.format(orderDetail.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s, signLabelInfo.center))
.append(signLabelInfo.br);
Integer isWaitCall = ObjectUtil.defaultIfNull(orderDetail.getIsWaitCall(), 0);
if (isWaitCall == 1) {
@@ -800,32 +806,28 @@ public interface PrinterImpl {
/**
* 构建叫号元数据
*
* @param shopName 店铺名称
* @param tableName 表名
* @param callNum 号码
* @param preNum 前面还有几桌
* @param codeUrl 二维码地址
* @param shopNote 店铺备注 过号顺延{}桌 {}桌后需重新排号 谢谢理解!
* @param takeTime 取号时间
* @param shopName 店铺名称
* @return 元数据
*/
default String buildCallTicketData(String shopName, String tableName, String callNum, String preNum, String codeUrl, String shopNote, LocalDateTime takeTime) {
default String buildCallTicketData(String shopName, CallTablePrintDTO printDTO) {
PrintSignLabel signLabelInfo = getSignLabelInfo();
return getFormatLabel(shopName, signLabelInfo.center, signLabelInfo.bold) +
CallTable callTable = printDTO.getCallTable();
CallQueue callQueue = printDTO.getCallQueue();
return getFormatLabel(shopName, signLabelInfo.center) +
signLabelInfo.br +
signLabelInfo.br +
getFormatLabel(StrUtil.format("{} {}", tableName, callNum), signLabelInfo.center, signLabelInfo.bold) +
getFormatLabel(StrUtil.format("{} {}", callTable.getName(), callQueue.getCallNum()), signLabelInfo.center, signLabelInfo.bold) +
signLabelInfo.br +
getFormatLabel(StrUtil.format("前面有{}桌", preNum), signLabelInfo.center) +
getFormatLabel(StrUtil.format("前面有{}桌", printDTO.getPreNum()), signLabelInfo.center) +
signLabelInfo.br +
getFormatLabel("怕过号,扫一扫", signLabelInfo.center, signLabelInfo.bold) +
getFormatLabel("怕过号,扫一扫", signLabelInfo.center, signLabelInfo.f) +
signLabelInfo.br +
getFormatLabel(codeUrl, signLabelInfo.center, signLabelInfo.qr) +
getFormatLabel(printDTO.getCallUrl(), signLabelInfo.center, signLabelInfo.qr) +
signLabelInfo.br + getDividingLine() + signLabelInfo.br +
getFormatLabel(shopNote, signLabelInfo.s) +
getFormatLabel(StrUtil.format("取号时间: {}", DateUtil.format(takeTime, "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
getFormatLabel(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", callTable.getPostponeNum(), callTable.getPostponeNum()), signLabelInfo.s) +
getFormatLabel(StrUtil.format("取号时间: {}", DateUtil.format(callQueue.getCreateTime(), "yyyy-MM-dd HH:mm:ss")), signLabelInfo.s) +
signLabelInfo.br +
signLabelInfo.cut;
signLabelInfo.getOut(150) + signLabelInfo.cut;
}

View File

@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.time.LocalDateTime;
import java.util.*;
/**
@@ -130,8 +129,8 @@ public class YxyPrinter 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 resp = buildCallTicketData(shopName, tableName, callNum, preNum, codeUrl, shopNote, takeTime);
protected void callNumPrint(PrintMachine machine, String shopName, CallTablePrintDTO printDTO) {
String resp = buildCallTicketData(shopName, printDTO);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
if (1 == machine.getVolumeSwitch()) {
voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";