交班小票实现

This commit is contained in:
张松
2025-03-12 18:21:47 +08:00
parent 70b451fcb9
commit 03c757f38f
8 changed files with 299 additions and 104 deletions

View File

@@ -52,11 +52,7 @@ public class PrintMqListener {
log.error("订单信息不存在, {}", orderId);
throw new RuntimeException("订单信息不存在");
}
getPrintMachine(orderInfo.getShopId(), "cash", "all", "").forEach(machine -> {
printerHandler.handleRequest(machine, orderInfo, null);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
printerHandler.handler(orderId, PrinterHandler.PrintTypeEnum.ORDER);
} catch (Exception e) {
log.error("订单打印失败", e);
@@ -67,6 +63,26 @@ public class PrintMqListener {
}
}
/**
* 交班打印
*/
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) {
long startTime = DateUtil.date().getTime();
log.info("接收到交班打印消息:{}", id);
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE).setMsg(id).setType("handoverPrint").setPlat("java.order").setCreateTime(DateUtil.date().toLocalDateTime());
try {
printerHandler.handler(id, PrinterHandler.PrintTypeEnum.HANDOVER);
} catch (Exception e) {
log.error("交班打印失败", e);
mqLog.setErrInfo(JSONObject.toJSONString(e));
mqLog.setDuration(DateUtil.date().getTime() - startTime);
mqLog.setFailTime(DateUtil.date().toLocalDateTime());
mqLogService.save(mqLog);
}
}
/**
* 获取可用打印机
*
@@ -103,6 +119,5 @@ public class PrintMqListener {
log.info("打印机列表: {}", list);
return list;
}
}