Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
2024-10-12 11:28:53 +08:00
4 changed files with 151 additions and 94 deletions

View File

@@ -35,6 +35,14 @@ public class TbPrintMachine implements Serializable {
private String productId; private String productId;
private String receiptSize;
private String classifyPrint;
private String tablePrint;
private String printQty;
private String printMethod;
private String printType;
private String printReceipt;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Integer getId() {
@@ -164,4 +172,60 @@ public class TbPrintMachine implements Serializable {
public void setProductId(String productId) { public void setProductId(String productId) {
this.productId = productId == null ? null : productId.trim(); this.productId = productId == null ? null : productId.trim();
} }
public String getReceiptSize() {
return receiptSize;
}
public void setReceiptSize(String receiptSize) {
this.receiptSize = receiptSize;
}
public String getClassifyPrint() {
return classifyPrint;
}
public void setClassifyPrint(String classifyPrint) {
this.classifyPrint = classifyPrint;
}
public String getTablePrint() {
return tablePrint;
}
public void setTablePrint(String tablePrint) {
this.tablePrint = tablePrint;
}
public String getPrintQty() {
return printQty;
}
public void setPrintQty(String printQty) {
this.printQty = printQty;
}
public String getPrintMethod() {
return printMethod;
}
public void setPrintMethod(String printMethod) {
this.printMethod = printMethod;
}
public String getPrintType() {
return printType;
}
public void setPrintType(String printType) {
this.printType = printType;
}
public String getPrintReceipt() {
return printReceipt;
}
public void setPrintReceipt(String printReceipt) {
this.printReceipt = printReceipt;
}
} }

View File

@@ -3,7 +3,6 @@ package com.chaozhanggui.system.cashierservice.rabbit;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo; import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
@@ -22,7 +21,10 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -87,57 +89,53 @@ public class PrintMechineConsumer {
log.info("打印机列表,{}", ArrayUtil.toString(list)); log.info("打印机列表,{}", ArrayUtil.toString(list));
log.info("待打印订单信息, {}", orderInfo); log.info("待打印订单信息, {}", orderInfo);
list.forEach(tbPrintMachineWithBLOBs->{ list.forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) { if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
log.error("非网络打印机:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getConnectionType()); log.error("非网络打印机:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getConnectionType());
return; return;
} }
if (!"1".equals(tbPrintMachineWithBLOBs.getStatus().toString())) { if (!"1".equals(tbPrintMachineWithBLOBs.getStatus().toString())) {
log.error("打印机状态异常:{},{}",tbPrintMachineWithBLOBs.getAddress(),tbPrintMachineWithBLOBs.getStatus()); log.error("打印机状态异常:{},{}", tbPrintMachineWithBLOBs.getAddress(), tbPrintMachineWithBLOBs.getStatus());
return; return;
} }
JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig()); String model = tbPrintMachineWithBLOBs.getPrintMethod();
String model = config.getString("model");
String printerNum = config.getString("printerNum"); String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
String feet = config.getString("feet"); List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
String autoCut = config.getString("autoCut"); switch (tbPrintMachineWithBLOBs.getContentType()) {
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class);
switch (tbPrintMachineWithBLOBs.getContentType()){
case "yxyPrinter": case "yxyPrinter":
yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
case "fePrinter": case "fePrinter":
fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
} }
}); });
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* 博时结云打印机 * 博时结云打印机
*
* @param tbPrintMachineWithBLOBs * @param tbPrintMachineWithBLOBs
* @param model * @param model
* @param orderInfo * @param orderInfo
* @param shopInfo * @param shopInfo
* @param printerNum * @param printerNum
*/ */
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId=orderInfo.getId().toString(); String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
@@ -146,23 +144,23 @@ public class PrintMechineConsumer {
case "cash": //小票打印机 case "cash": //小票打印机
switch (model) { switch (model) {
case "normal": //普通出单 case "normal": //普通出单
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -182,11 +180,11 @@ public class PrintMechineConsumer {
balance = user.getAmount().toPlainString(); balance = user.getAmount().toPlainString();
} }
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ 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()); 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()); detailPO.setOutNumber(orderInfo.getOutNumber());
String data= PrinterUtils.getCashPrintData(detailPO,"结算单"); String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
@@ -194,7 +192,7 @@ public class PrintMechineConsumer {
break; break;
case "one": //一菜一品 case "one": //一菜一品
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
log.info("一菜一品打印,待打印信息:{}", cashierCarts); log.info("一菜一品打印,待打印信息:{}", cashierCarts);
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
@@ -210,18 +208,18 @@ public class PrintMechineConsumer {
log.info("--------------------非代客下单 打印一菜一品"); log.info("--------------------非代客下单 打印一菜一品");
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -285,7 +283,7 @@ public class PrintMechineConsumer {
if (info != null) { if (info != null) {
isReturn = it.getNum() - Integer.parseInt(info) < 0; isReturn = it.getNum() - Integer.parseInt(info) < 0;
printerNum = it.getNum() - Integer.parseInt(info); printerNum = it.getNum() - Integer.parseInt(info);
}else { } else {
printerNum = it.getNum(); printerNum = it.getNum();
} }
@@ -353,37 +351,35 @@ public class PrintMechineConsumer {
} }
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机 case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it->{ cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0) { if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
for(int i=0;i<it.getNumber();i++){ for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark); FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
} }
@@ -524,7 +520,7 @@ public class PrintMechineConsumer {
}); });
} }
} }
break; break;
case "kitchen": //出品打印机 case "kitchen": //出品打印机
break; break;
} }

View File

@@ -2,7 +2,7 @@ package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import cn.hutool.core.util.StrUtil;
import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo; import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
@@ -46,9 +46,7 @@ public class CloudPrinterService {
private TbOrderDetailMapper tbOrderDetailMapper; private TbOrderDetailMapper tbOrderDetailMapper;
public Result printReceipt(String type, String orderId, Boolean ispre) {
public Result printReceipt(String type,String orderId,Boolean ispre){
try { try {
@@ -71,7 +69,7 @@ public class CloudPrinterService {
return Result.fail("此店铺没有对应的打印机设备"); return Result.fail("此店铺没有对应的打印机设备");
} }
list.parallelStream().forEach(tbPrintMachineWithBLOBs->{ list.parallelStream().forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) { if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
log.error("非网络打印机"); log.error("非网络打印机");
return; return;
@@ -82,29 +80,25 @@ public class CloudPrinterService {
return; return;
} }
JSONObject config = JSONObject.parseObject(tbPrintMachineWithBLOBs.getConfig());
String model = config.getString("model");
String printerNum = config.getString("printerNum"); String model = tbPrintMachineWithBLOBs.getPrintMethod();
String feet = config.getString("feet"); String printerNum = StrUtil.isEmpty(tbPrintMachineWithBLOBs.getPrintQty()) ? "1" : tbPrintMachineWithBLOBs.getPrintQty().split("^")[1];
String autoCut = config.getString("autoCut"); List<CategoryInfo> categoryInfos = JSONUtil.parseJSONStr2TList(StrUtil.emptyToDefault(tbPrintMachineWithBLOBs.getCategoryList(), "[]"), CategoryInfo.class);
List<CategoryInfo> categoryInfos=JSONUtil.parseJSONStr2TList(config.getJSONArray("categoryList").toString(),CategoryInfo.class); switch (tbPrintMachineWithBLOBs.getContentType()) {
switch (tbPrintMachineWithBLOBs.getContentType()){
case "yxyPrinter": case "yxyPrinter":
yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
case "fePrinter": case "fePrinter":
fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos); fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break; break;
} }
}); });
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -113,18 +107,17 @@ public class CloudPrinterService {
} }
/** /**
* 博时结云打印机 * 博时结云打印机
*
* @param tbPrintMachineWithBLOBs * @param tbPrintMachineWithBLOBs
* @param model * @param model
* @param orderInfo * @param orderInfo
* @param shopInfo * @param shopInfo
* @param printerNum * @param printerNum
*/ */
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){ private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId=orderInfo.getId().toString(); String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
@@ -133,23 +126,23 @@ public class CloudPrinterService {
case "cash": //小票打印机 case "cash": //小票打印机
switch (model) { switch (model) {
case "normal": //普通出单 case "normal": //普通出单
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>(); List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -169,10 +162,10 @@ public class CloudPrinterService {
balance = user.getAmount().toPlainString(); balance = user.getAmount().toPlainString();
} }
} }
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){ 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()); 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,"结算单"); String data = PrinterUtils.getCashPrintData(detailPO, "结算单");
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data); PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
} }
@@ -180,24 +173,24 @@ public class CloudPrinterService {
break; break;
case "one": //一菜一品 case "one": //一菜一品
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final"); cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it -> { cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0){ if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -220,37 +213,35 @@ public class CloudPrinterService {
} }
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
private void fePrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) { switch (tbPrintMachineWithBLOBs.getSubType()) {
case "label": //标签打印机 case "label": //标签打印机
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(),"final"); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderInfo.getId().toString(), "final");
if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) { if (ObjectUtil.isNotEmpty(cashierCarts) && cashierCarts.size() > 0) {
cashierCarts.parallelStream().forEach(it->{ cashierCarts.parallelStream().forEach(it -> {
String categoryId; String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){ if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId(); categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else { } else {
categoryId = it.getCategoryId(); categoryId = it.getCategoryId();
} }
Long count= categoryInfos.stream().filter(c-> Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId) c.getId().toString().equals(categoryId)
).count(); ).count();
if(count>0) { if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId())); TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = ""; String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) { if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
remark = tbProductSkuWithBLOBs.getSpecSnap(); remark = tbProductSkuWithBLOBs.getSpecSnap();
} }
for(int i=0;i<it.getNumber();i++){ for (int i = 0; i < it.getNumber(); i++) {
FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark); FeieyunPrintUtil.printLabelMsg(tbPrintMachineWithBLOBs.getAddress(), orderInfo.getTableName(), it.getName(), 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), it.getSalePrice().toPlainString(), remark);
} }
@@ -398,6 +389,4 @@ public class CloudPrinterService {
} }
} }

View File

@@ -18,6 +18,14 @@
<result column="sort" jdbcType="INTEGER" property="sort" /> <result column="sort" jdbcType="INTEGER" property="sort" />
<result column="vendor_id" jdbcType="VARCHAR" property="vendorId" /> <result column="vendor_id" jdbcType="VARCHAR" property="vendorId" />
<result column="product_id" jdbcType="VARCHAR" property="productId" /> <result column="product_id" jdbcType="VARCHAR" property="productId" />
<result column="receipt_size" jdbcType="VARCHAR" property="receiptSize" />
<result column="classify_print" jdbcType="VARCHAR" property="classifyPrint" />
<result column="table_print" jdbcType="VARCHAR" property="tablePrint" />
<result column="print_qty" jdbcType="VARCHAR" property="printQty" />
<result column="print_method" jdbcType="VARCHAR" property="printMethod" />
<result column="print_type" jdbcType="VARCHAR" property="printType" />
<result column="print_receipt" jdbcType="VARCHAR" property="printReceipt" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs">
<result column="config" jdbcType="LONGVARCHAR" property="config" /> <result column="config" jdbcType="LONGVARCHAR" property="config" />
@@ -25,7 +33,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids,
content_type, created_at, updated_at, sort, vendor_id, product_id content_type, created_at, updated_at, sort, vendor_id, product_id, receipt_size, classify_print, table_print, print_qty, print_method, print_type, print_receipt
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
config, category_list config, category_list