订单 打印票

This commit is contained in:
wangw 2025-02-26 17:51:21 +08:00
parent c82895d1e3
commit 92d9af40d5
3 changed files with 3 additions and 73 deletions

View File

@ -1,29 +0,0 @@
package com.czg.mq;
import com.czg.config.RabbitPublisher;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author GYJoker
*/
@RestController
public class RabbitMqController {
@Resource
private RabbitPublisher rabbitPublisher;
@GetMapping("/sendOrderPrintMsg")
public String sendOrderPrintMsg(String msg) {
rabbitPublisher.sendOrderPrintMsg(msg);
return "success";
}
@GetMapping("/sendOrderStockMsg")
public String sendOrderStockPrintMsg(String msg) {
rabbitPublisher.sendOrderStockMsg(msg);
return "success";
}
}

View File

@ -1,44 +0,0 @@
//package com.czg.mq;
//
//import com.czg.config.RabbitConstants;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.*;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//
///**
// * @author GYJoker
// */
//@Slf4j
//@Component
//public class RabbitmqReceiver {
//
// /**
// * 消费者监听绑定队列
// * Queue RabbitConfig类的 orderPrintQueue
// */
// @RabbitListener(
// bindings = @QueueBinding(value = @Queue(value = "#{orderPrintQueue.name}", durable = "true",
// arguments = {@Argument(name = "x-message-ttl", value = "180000", type = "java.lang.Long")}),
// exchange = @Exchange(value = RabbitConstants.Exchange.CASH_EXCHANGE)),
// concurrency = "10"
// )
// @RabbitHandler
// public void receiveOrderPrintQueue(Channel channel, String orderId, Message message) throws IOException {
// try {
// log.info("订单监听 消息体:{},消息内容:{}", message, orderId);
// // 手动确认消息multiple 参数表示是否批量确认
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// // 判断是否需要重新入队
// boolean requeue = false;
// // 拒绝消息requeue true 表示将消息重新放回队列
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, requeue);
// }
//
// }
//}

View File

@ -39,6 +39,9 @@ public class RabbitPublisher {
* @param orderId 订单id * @param orderId 订单id
*/ */
public void sendOrderPrintMsg(String orderId) { public void sendOrderPrintMsg(String orderId) {
//厨房票
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, orderId);
//前台票
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId); sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
} }