小票打印完善
This commit is contained in:
@@ -81,7 +81,7 @@ public abstract class PrinterHandler {
|
||||
@Getter
|
||||
public enum PrintTypeEnum {
|
||||
HANDOVER("交班", "handover"),
|
||||
ORDER("订单", "order"), ONE("菜品", "one"), CALL("叫号", "call");
|
||||
ORDER("订单", "order"), ONE("菜品", "one"), CALL("叫号", "call"), ONE_AND_ORDER("菜品和结算单同时打印", "oneAndOrder");
|
||||
private final String name;
|
||||
private final String code;
|
||||
|
||||
@@ -178,7 +178,8 @@ public abstract class PrinterHandler {
|
||||
Long shopId = null;
|
||||
String printMethod = "";
|
||||
String printType = "";
|
||||
Object obj = null;
|
||||
Object obj;
|
||||
OrderInfo orderInfo;
|
||||
switch (printTypeEnum) {
|
||||
case PrintTypeEnum.HANDOVER:
|
||||
HandoverRecordDTO record = handoverRecordService.getHandoverRecordById(Long.parseLong(data));
|
||||
@@ -190,7 +191,7 @@ public abstract class PrinterHandler {
|
||||
printType = "handover";
|
||||
break;
|
||||
case PrintTypeEnum.ORDER:
|
||||
OrderInfo orderInfo = orderInfoService.getById(data);
|
||||
orderInfo = orderInfoService.getById(data);
|
||||
if (orderInfo == null) {
|
||||
throw new RuntimeException("订单打印失败,订单不存在");
|
||||
}
|
||||
@@ -199,6 +200,25 @@ public abstract class PrinterHandler {
|
||||
printMethod = "order";
|
||||
printType = "order";
|
||||
break;
|
||||
case PrintTypeEnum.ONE:
|
||||
orderInfo = orderInfoService.getById(data);
|
||||
if (orderInfo == null) {
|
||||
throw new RuntimeException("订单打印失败,订单不存在");
|
||||
}
|
||||
obj = orderInfo;
|
||||
printMethod = "one";
|
||||
break;
|
||||
case PrintTypeEnum.ONE_AND_ORDER:
|
||||
orderInfo = orderInfoService.getById(data);
|
||||
if (orderInfo == null) {
|
||||
throw new RuntimeException("订单打印失败,订单不存在");
|
||||
}
|
||||
obj = orderInfo;
|
||||
printMethod = "all";
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("未知打印类型");
|
||||
|
||||
}
|
||||
if (shopId == null) {
|
||||
@@ -278,6 +298,8 @@ public abstract class PrinterHandler {
|
||||
log.info("准备开始打印交班");
|
||||
if (data instanceof HandoverRecordDTO record) {
|
||||
handoverPrint(machine, record);
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ORDER:
|
||||
@@ -285,6 +307,8 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, orderInfo, orderDetailList);
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ONE:
|
||||
@@ -292,11 +316,27 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.CALL:
|
||||
log.info("准备开始打印叫号单");
|
||||
onlyCallNumPrint(machine, null);
|
||||
if (data instanceof Long id) {
|
||||
onlyCallNumPrint(machine, id);
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
case PrintTypeEnum.ONE_AND_ORDER:
|
||||
log.info("准备开始打印菜品以及结算单");
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, orderInfo, orderDetailList);
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
}else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user