打印机问题

打印设备shopId问题
This commit is contained in:
2026-04-16 09:45:05 +08:00
parent ce2136b3cb
commit 2b3b76f6ef
9 changed files with 370 additions and 316 deletions

View File

@@ -7,11 +7,11 @@ import com.czg.config.RedisCst;
import com.czg.order.entity.MqLog;
import com.czg.order.service.MqLogService;
import com.czg.service.RedisService;
import com.czg.service.order.print.PrintConfig;
import com.czg.service.order.print.PrinterHandler;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.function.Consumer;
@@ -28,9 +28,8 @@ public class PrintMqListener {
private MqLogService mqLogService;
@Resource
private RedisService redisService;
@Lazy
@Resource
private PrinterHandler printerHandler;
private PrintConfig printConfig;
private <T> void invokeFun(String queue, String type, String plat, T data, Consumer<T> consumer) {
long startTime = DateUtil.date().getTime();
@@ -61,11 +60,11 @@ public class PrintMqListener {
Boolean printOrder = jsonObject.getBoolean("printOrder");
redisService.runFunAndCheckKey(() -> {
if (printOrder) {
printerHandler.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ORDER, null);
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ORDER, null);
}
//菜品打印 全是后端
printerHandler.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
printerHandler.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
return null;
}, RedisCst.getLockKey("orderPrint", orderId));
});
@@ -75,6 +74,6 @@ public class PrintMqListener {
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE})
public void otherPrint(Long shopId, Object o, String printTypeEnum) {
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
printerHandler.otherHandler(shopId, o, typeEnum);
printConfig.otherHandler(shopId, o, typeEnum);
}
}