打印逻辑修改
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQUtils {
|
||||
@@ -20,6 +24,12 @@ public class MQUtils {
|
||||
log.info("开始发送{}mq消息, exchange: {}, routingKey: {}, data: {}", note, exchange, routingKey, data);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data));
|
||||
}
|
||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", note, correlationId.getId(), exchange, routingKey, data);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
|
||||
}
|
||||
|
||||
|
||||
public <T> void sendStockSaleMsg(T data) {
|
||||
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
|
||||
@@ -31,4 +41,20 @@ public class MQUtils {
|
||||
printDTO.setShopId(shopId);
|
||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印");
|
||||
}
|
||||
|
||||
public void printDishesTicket(Integer orderId, boolean isReturn, TbOrderDetail... detailOrderIds) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", orderId);
|
||||
jsonObject.put("orderDetailIds", detailOrderIds);
|
||||
jsonObject.put("isReturn", isReturn);
|
||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_DISHES, jsonObject, "菜品打印", true);
|
||||
}
|
||||
|
||||
public void printPlaceTicket(Integer id, boolean isReturn) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", id);
|
||||
jsonObject.put("isReturn", isReturn);
|
||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_PLACE, jsonObject, "订单打印", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user