添加退单打印
This commit is contained in:
@@ -180,7 +180,8 @@ public class PrintMechineConsumer {
|
||||
String printType="退款单";
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +231,8 @@ public class PrintMechineConsumer {
|
||||
String printType="结算单";
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,orderInfo.getOrderType());
|
||||
PrinterUtils.printTickets(3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -239,38 +241,61 @@ public class PrintMechineConsumer {
|
||||
case "one": //一菜一品
|
||||
|
||||
if("return".equals(orderInfo.getOrderType())){
|
||||
log.error("退款但不打印出品小票");
|
||||
return;
|
||||
}
|
||||
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();
|
||||
}
|
||||
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if(ObjectUtil.isNotEmpty(details)&&details.size()>0){
|
||||
details.parallelStream().forEach(it->{
|
||||
|
||||
|
||||
Long count= categoryInfos.stream().filter(c->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
Long count= categoryInfos.stream().filter(c->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
log.info("获取当前类别是否未打印类别:{}",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();
|
||||
if(count>0){
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData("return",orderInfo.getPayType().equals("wx_lite")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return;
|
||||
}else {
|
||||
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();
|
||||
|
||||
log.info("获取当前类别是否未打印类别:{}",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.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "category": //分类出单
|
||||
@@ -366,7 +391,8 @@ public class PrintMechineConsumer {
|
||||
String printType="退款单";
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
// PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,9 @@ public class CloudPrinterService {
|
||||
String printType="退款单";
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +255,8 @@ public class CloudPrinterService {
|
||||
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,orderInfo.getOrderType());
|
||||
PrinterUtils.printTickets(3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -267,34 +270,71 @@ public class CloudPrinterService {
|
||||
if(ispre){
|
||||
return Result.fail("预结算单不打印菜单");
|
||||
}
|
||||
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();
|
||||
if("return".equals(orderInfo.getOrderType())){
|
||||
List<TbOrderDetail> details= tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(orderId));
|
||||
if(ObjectUtil.isNotEmpty(details)&&details.size()>0){
|
||||
details.parallelStream().forEach(it->{
|
||||
|
||||
|
||||
String categoryId= tbProductMapper.selectByPrimaryKey(Integer.valueOf(it.getProductId())).getCategoryId();
|
||||
Long count= categoryInfos.stream().filter(c->
|
||||
c.getId().toString().equals(categoryId)
|
||||
).count();
|
||||
|
||||
if(count>0){
|
||||
TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(it.getProductSkuId()));
|
||||
String remark = "";
|
||||
if (ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs) && ObjectUtil.isNotEmpty(tbProductSkuWithBLOBs.getSpecSnap())) {
|
||||
remark = tbProductSkuWithBLOBs.getSpecSnap();
|
||||
}
|
||||
String data = PrinterUtils.getPrintData("return",orderInfo.getPayType().equals("wx_lite")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getProductName(), it.getNum(), remark);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
String data = PrinterUtils.getPrintData(orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
PrinterUtils.printTickets(3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}else {
|
||||
|
||||
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.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), it.getName(), it.getNumber(), remark);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
|
||||
PrinterUtils.printTickets(voiceJson,3, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "category": //分类出单
|
||||
if(!"category".equals(type)){
|
||||
@@ -394,7 +434,7 @@ public class CloudPrinterService {
|
||||
String printType="退款单";
|
||||
|
||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
||||
PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
// PrinterUtils.printTickets(1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,8 +640,8 @@ public class CloudPrinterService {
|
||||
shopUserDuty.getOrderNum().toString(),
|
||||
productCategories
|
||||
);
|
||||
|
||||
PrinterUtils.printTickets(1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo));
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo));
|
||||
|
||||
});
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
|
||||
@@ -66,10 +66,15 @@ public class PrinterUtils {
|
||||
* @param remark
|
||||
* @return
|
||||
*/
|
||||
public static String getPrintData(String pickupNumber,String date,String productName,Integer number,String remark) {
|
||||
public static String getPrintData(String type,String pickupNumber,String date,String productName,Integer number,String remark) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if("return".equals(type)){
|
||||
builder.append("<C><B>"+pickupNumber+"【退】</B></C><BR><BR>");
|
||||
}else {
|
||||
builder.append("<C><B>"+pickupNumber+"</B></C><BR><BR>");
|
||||
}
|
||||
|
||||
|
||||
builder.append("<C><B>"+pickupNumber+"</B></C><BR><BR>");
|
||||
builder.append("<S><L>时间: "+date+" </L></S><BR><BR><BR>");
|
||||
|
||||
if(productName.length()>4||remark.length()>4){
|
||||
@@ -211,7 +216,7 @@ public class PrinterUtils {
|
||||
* 打印票据
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void printTickets(Integer actWay ,Integer cn,String devName,String data) {
|
||||
public static void printTickets(String voiceJson,Integer actWay ,Integer cn,String devName,String data) {
|
||||
//设备名称
|
||||
//行为方式 1:只打印数据 2:只播放信息 3:打印数据并播放信息
|
||||
// actWay = 3;
|
||||
@@ -219,8 +224,6 @@ public class PrinterUtils {
|
||||
// int cn = 1;
|
||||
//打印内容
|
||||
//播报语音数据体,字段参考文档IOT_XY_API11001
|
||||
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String time = String.valueOf(System.currentTimeMillis());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
@@ -299,8 +302,8 @@ public class PrinterUtils {
|
||||
detailList.add(detail4);
|
||||
OrderDetailPO detailPO=new OrderDetailPO("牛叉闪闪","普通打印","#365","DD20240306134718468","2024-03-06 15:00:00","【POS-1】001","79000.80","5049758.96","deposit","0",detailList,"变态辣");
|
||||
|
||||
|
||||
printTickets(1,1,"ZF544PG03W00002",getCashPrintData(detailPO,"结算单",""));
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
printTickets(voiceJson,1,1,"ZF544PG03W00002",getCashPrintData(detailPO,"结算单",""));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user