From 7138271279c6513b650d33c469ce71605915cad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=87=AF=E5=87=AF?= Date: Tue, 15 Oct 2024 09:59:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=A0=B7=E5=BC=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/rabbit/PrintConsumer.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintConsumer.java index 6e41090..2ac9a4e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintConsumer.java @@ -21,8 +21,8 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; @Slf4j @Component @@ -68,7 +68,7 @@ public class PrintConsumer { } // 菜品票 - getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one").forEach(machine -> { + getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one", null).forEach(machine -> { log.info("打印机信息: {}", machine); machine.setCurrentUserId(currentUserId); machine.setCurrentUserName(currentUserName); @@ -77,7 +77,7 @@ public class PrintConsumer { }); // 标签打印 - getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "label", "one").forEach(machine -> { + getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "label", "one", null).forEach(machine -> { log.info("打印机信息: {}", machine); machine.setCurrentUserId(currentUserId); machine.setCurrentUserName(currentUserName); @@ -104,7 +104,7 @@ public class PrintConsumer { TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId())); Utils.checkValueUnReturn(shopInfo, "店铺信息不存在"); - getPrintMachine(shopInfo.getId(), "cash", "normal").forEach(machine -> { + getPrintMachine(shopInfo.getId(), "cash", "normal", null).forEach(machine -> { List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId()); printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails, null); // printPlaceTicket(isReturn, machine, orderInfo, shopInfo); @@ -121,7 +121,7 @@ public class PrintConsumer { log.info("打印消息mq 接收到打印取号小票消息,消息内容: {}", msg); CallNumPrintDTO printDTO = JSONObject.parseObject(msg, CallNumPrintDTO.class); - getPrintMachine(printDTO.getShopId(), "cash", "callTicket").forEach(machine -> { + getPrintMachine(printDTO.getShopId(), "cash", null, "callTicket").forEach(machine -> { machine.setCurrentUserId(printDTO.getCurrentUserId()); machine.setCurrentUserName(printDTO.getCurrentUserName()); machine.setCurrentUserNickName(printDTO.getCurrentUserNickName()); @@ -134,19 +134,27 @@ public class PrintConsumer { } - private List getPrintMachine(Integer shopId, String subType, String printMethod) { + private List getPrintMachine(Integer shopId, String subType, String printMethod, String printType) { TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId); if (ObjectUtil.isEmpty(shopInfo)) { log.error("店铺信息不存在"); return new ArrayList<>(); } - - List list = mpPrintMachineMapper.selectList(new LambdaQueryWrapper() + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .eq(TbPrintMachine::getStatus, 1) .eq(TbPrintMachine::getShopId, shopId) .eq(TbPrintMachine::getSubType, subType) - .eq(TbPrintMachine::getPrintMethod, printMethod) - .eq(TbPrintMachine::getConnectionType, "network")); + .eq(TbPrintMachine::getConnectionType, "network"); + if (StrUtil.isNotEmpty(printMethod)) { + wrapper.in(TbPrintMachine::getPrintMethod, Arrays.asList(printMethod, "all")); + } + if ("callTicket".equals(printType)) { + printType = "queue"; + } + if (StrUtil.isNotEmpty(printType)) { + wrapper.like(TbPrintMachine::getPrintType, printType); + } + List list = mpPrintMachineMapper.selectList(wrapper); if (list.isEmpty()) { log.error("店铺未配置打印机,店铺id: {}", shopId); return list;