diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java index fdaca12..c1cebdf 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/PrintMechineConsumer.java @@ -103,7 +103,7 @@ public class PrintMechineConsumer { String model = tbPrintMachineWithBLOBs.getPrintMethod(); - String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1]; + String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1]; List categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class); @@ -125,6 +125,101 @@ public class PrintMechineConsumer { } + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, TbOrderInfo orderInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + log.info("一菜一品打印,待打印信息:{}", cashierCarts); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + + cashierCarts.parallelStream().forEach(it -> { + + // 取餐号不为空为代客下单 + if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) { + log.info("--------------------代客下单 打印一菜一品"); + printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo); + return; + } + log.info("--------------------非代客下单 打印一菜一品"); + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + }); + } + } + + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForYxy(String orderId, TbOrderInfo orderInfo, String printerNum, TbShopInfo shopInfo, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + detailPO.setOutNumber(orderInfo.getOutNumber()); + String data = PrinterUtils.getCashPrintData(detailPO, "结算单"); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + + } + } + /** * 博时结云打印机 * @@ -136,105 +231,18 @@ public class PrintMechineConsumer { */ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { String orderId = orderInfo.getId().toString(); - - switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - detailPO.setOutNumber(orderInfo.getOutNumber()); - String data = PrinterUtils.getCashPrintData(detailPO, "结算单"); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - - } - - break; - case "one": //一菜一品 - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - log.info("一菜一品打印,待打印信息:{}", cashierCarts); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - - cashierCarts.parallelStream().forEach(it -> { - - // 取餐号不为空为代客下单 - if ("postPay".equals(orderInfo.getUseType()) && StrUtil.isNotBlank(it.getMasterId())) { - log.info("--------------------代客下单 打印一菜一品"); - printTicket(Integer.valueOf(orderId), categoryInfos, tbPrintMachineWithBLOBs, orderInfo); - return; - } - log.info("--------------------非代客下单 打印一菜一品"); - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - }); - } - break; - case "category": //分类出单 - break; + if ("normal".equals(model)) { + onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForYxy(orderId, orderInfo, printerNum, shopInfo, tbPrintMachineWithBLOBs, categoryInfos); + onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, orderInfo, printerNum, categoryInfos); } - break; case "kitchen": //出品打印机 break; @@ -350,6 +358,141 @@ public class PrintMechineConsumer { } } + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + if ("return".equals(orderInfo.getOrderType())) { + List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); + if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { + List detailList = new ArrayList<>(); + tbOrderDetails.parallelStream().forEach(it -> { + String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + log.info("获取当前类别是否未打印类别:{}", count); + + + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); + detailList.add(detail); + + }); + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + + + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { +// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + + String printType = "退款单"; + + String data = PrinterUtils.getCashPrintData(detailPO, printType); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + } + + + } else { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); + String printType = "结算单"; + + if ("return".equals(orderInfo.getOrderType())) { + printType = "退款单"; + } + + + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + } + + } + } + } + + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + } + }); + } + } + private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { String orderId = orderInfo.getId().toString(); @@ -389,136 +532,13 @@ public class PrintMechineConsumer { break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - - if ("return".equals(orderInfo.getOrderType())) { - List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); - if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { - List detailList = new ArrayList<>(); - tbOrderDetails.parallelStream().forEach(it -> { - String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - log.info("获取当前类别是否未打印类别:{}", count); - - - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); - detailList.add(detail); - - }); - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - - - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { -// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - - String printType = "退款单"; - - String data = PrinterUtils.getCashPrintData(detailPO, printType); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - } - - - } else { - cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); - String printType = "结算单"; - - if ("return".equals(orderInfo.getOrderType())) { - printType = "退款单"; - } - - - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); - } - - } - } - - break; - case "one": //一菜一品 - - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - cashierCarts.parallelStream().forEach(it -> { - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - } - }); - } + if ("normal".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); } break; case "kitchen": //出品打印机 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java index ce38b17..e6f2f83 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CloudPrinterService.java @@ -83,7 +83,7 @@ public class CloudPrinterService { String model = tbPrintMachineWithBLOBs.getPrintMethod(); - String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1]; + String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("\\^")[1]; List categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class); @@ -106,6 +106,90 @@ public class CloudPrinterService { } + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + String data = PrinterUtils.getCashPrintData(detailPO, "结算单"); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + + } + } + + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForYxy(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + }); + } + } + /** * 博时结云打印机 @@ -118,100 +202,159 @@ public class CloudPrinterService { */ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { String orderId = orderInfo.getId().toString(); - - switch (tbPrintMachineWithBLOBs.getSubType()) { case "label": //标签打印机 break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getTableName(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - String data = PrinterUtils.getCashPrintData(detailPO, "结算单"); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - - } - - break; - case "one": //一菜一品 - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - cashierCarts.parallelStream().forEach(it -> { - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - String data = PrinterUtils.getPrintData(orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - }); - } - break; - case "category": //分类出单 - break; + if ("normal".equals(model)) { + onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + onlyKitchenForYxy(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); } - break; case "kitchen": //出品打印机 break; } } + /** + * 仅打印结算单「前台」 + */ + private void onlyFrontDeskForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + if ("return".equals(orderInfo.getOrderType())) { + List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); + if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { + List detailList = new ArrayList<>(); + tbOrderDetails.parallelStream().forEach(it -> { + String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + log.info("获取当前类别是否未打印类别:{}", count); + + + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); + detailList.add(detail); + + }); + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + + + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { +// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); + + String printType = "退款单"; + + String data = PrinterUtils.getCashPrintData(detailPO, printType); + PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); + } + } + + + } else { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); + + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + List detailList = new ArrayList<>(); + cashierCarts.parallelStream().forEach(it -> { + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); + detailList.add(detail); + } + + }); + + String balance = "0"; + + if ("deposit".equals(orderInfo.getPayType())) { + TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); + if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { + balance = user.getAmount().toPlainString(); + } + } + if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { + OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); + String printType = "结算单"; + + if ("return".equals(orderInfo.getOrderType())) { + printType = "退款单"; + } + + + FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); + } + + } + } + } + + /** + * 仅打印制作单「厨房」 + */ + private void onlyKitchenForFe(String orderId, TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); + if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { + + cashierCarts.parallelStream().forEach(it -> { + + String categoryId; + if (ObjectUtil.isEmpty(it.getCategoryId())) { + categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); + } else { + categoryId = it.getCategoryId(); + } + + + Long count = categoryInfos.stream().filter(c -> + c.getId().toString().equals(categoryId) + ).count(); + + if (count > 0) { + TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); + String remark = ""; + if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { + remark = tbProductSkuWithBLOBs.getSpecSnap(); + } + FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); + } + }); + } + } + private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List categoryInfos) { String orderId = orderInfo.getId().toString(); @@ -251,136 +394,13 @@ public class CloudPrinterService { break; case "cash": //小票打印机 - switch (model) { - case "normal": //普通出单 - - if ("return".equals(orderInfo.getOrderType())) { - List tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId)); - if (ObjectUtil.isNotEmpty(tbOrderDetails) && tbOrderDetails.size() > 0) { - List detailList = new ArrayList<>(); - tbOrderDetails.parallelStream().forEach(it -> { - String categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - log.info("获取当前类别是否未打印类别:{}", count); - - - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), it.getPriceAmount().toPlainString(), remark); - detailList.add(detail); - - }); - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - - - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { -// OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList); - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0", detailList, orderInfo.getRemark()); - - String printType = "退款单"; - - String data = PrinterUtils.getCashPrintData(detailPO, printType); - PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); - } - } - - - } else { - cashierCarts = cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final"); - - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - List detailList = new ArrayList<>(); - cashierCarts.parallelStream().forEach(it -> { - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), it.getTotalAmount().toPlainString(), remark); - detailList.add(detail); - } - - }); - - String balance = "0"; - - if ("deposit".equals(orderInfo.getPayType())) { - TbShopUser user = tbShopUserMapper.selectByPrimaryKey(orderInfo.getMemberId()); - if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getAmount())) { - balance = user.getAmount().toPlainString(); - } - } - if (ObjectUtil.isNotEmpty(detailList) && detailList.size() > 0) { - OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp") ? orderInfo.getTableName() : orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), "0", detailList, orderInfo.getRemark()); - String printType = "结算单"; - - if ("return".equals(orderInfo.getOrderType())) { - printType = "退款单"; - } - - - FeieyunPrintUtil.getCashPrintData(detailPO, tbPrintMachineWithBLOBs.getAddress(), printType, printType); - } - - } - } - - break; - case "one": //一菜一品 - - cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final"); - if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { - - cashierCarts.parallelStream().forEach(it -> { - - String categoryId; - if (ObjectUtil.isEmpty(it.getCategoryId())) { - categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); - } else { - categoryId = it.getCategoryId(); - } - - - Long count = categoryInfos.stream().filter(c -> - c.getId().toString().equals(categoryId) - ).count(); - - if (count > 0) { - TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); - String remark = ""; - if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { - remark = tbProductSkuWithBLOBs.getSpecSnap(); - } - FeieyunPrintUtil.getPrintData(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark); - } - }); - } + if ("normal".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("one".equals(model)) { + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + } else if ("all".equals(model)) { + onlyFrontDeskForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); + onlyKitchenForFe(orderId, tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos); } break; case "kitchen": //出品打印机