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

@@ -2,7 +2,7 @@ package com.chaozhanggui.system.cashierservice.service;
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.entity.*;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
@@ -46,9 +46,7 @@ public class CloudPrinterService {
private TbOrderDetailMapper tbOrderDetailMapper;
public Result printReceipt(String type,String orderId,Boolean ispre){
public Result printReceipt(String type, String orderId, Boolean ispre) {
try {
@@ -71,7 +69,7 @@ public class CloudPrinterService {
return Result.fail("此店铺没有对应的打印机设备");
}
list.parallelStream().forEach(tbPrintMachineWithBLOBs->{
list.parallelStream().forEach(tbPrintMachineWithBLOBs -> {
if (!"network".equals(tbPrintMachineWithBLOBs.getConnectionType())) {
log.error("非网络打印机");
return;
@@ -82,29 +80,25 @@ public class CloudPrinterService {
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":
yxyPrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos);
yxyPrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
case "fePrinter":
fePrinter(tbPrintMachineWithBLOBs,model,orderInfo,shopInfo,printerNum,categoryInfos);
fePrinter(tbPrintMachineWithBLOBs, model, orderInfo, shopInfo, printerNum, categoryInfos);
break;
}
});
return Result.success(CodeEnum.SUCCESS);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@@ -113,18 +107,17 @@ public class CloudPrinterService {
}
/**
* 博时结云打印机
* 博时结云打印机
*
* @param tbPrintMachineWithBLOBs
* @param model
* @param orderInfo
* @param shopInfo
* @param printerNum
*/
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs,String model,TbOrderInfo orderInfo,TbShopInfo shopInfo,String printerNum, List<CategoryInfo> categoryInfos){
String orderId=orderInfo.getId().toString();
private void yxyPrinter(TbPrintMachineWithBLOBs tbPrintMachineWithBLOBs, String model, TbOrderInfo orderInfo, TbShopInfo shopInfo, String printerNum, List<CategoryInfo> categoryInfos) {
String orderId = orderInfo.getId().toString();
switch (tbPrintMachineWithBLOBs.getSubType()) {
@@ -133,23 +126,23 @@ public class CloudPrinterService {
case "cash": //小票打印机
switch (model) {
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) {
List<OrderDetailPO.Detail> detailList = new ArrayList<>();
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if(count>0){
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
@@ -169,10 +162,10 @@ public class CloudPrinterService {
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());
String data= PrinterUtils.getCashPrintData(detailPO,"结算单");
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);
}
@@ -180,24 +173,24 @@ public class CloudPrinterService {
break;
case "one": //一菜一品
cashierCarts = tbCashierCartMapper.selectByOrderId(orderId,"final");
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();
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if(count>0){
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
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()) {
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) {
cashierCarts.parallelStream().forEach(it->{
cashierCarts.parallelStream().forEach(it -> {
String categoryId;
if(ObjectUtil.isEmpty(it.getCategoryId())){
categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
if (ObjectUtil.isEmpty(it.getCategoryId())) {
categoryId = tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
} else {
categoryId = it.getCategoryId();
}
Long count= categoryInfos.stream().filter(c->
Long count = categoryInfos.stream().filter(c ->
c.getId().toString().equals(categoryId)
).count();
if(count>0) {
if (count > 0) {
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getSkuId()));
String remark = "";
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(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);
}
@@ -398,6 +389,4 @@ public class CloudPrinterService {
}
}