订单打印日志完善

This commit is contained in:
张松
2025-03-18 11:25:49 +08:00
parent 78c51266b9
commit 966b925c4b
2 changed files with 13 additions and 7 deletions

View File

@@ -49,6 +49,9 @@ public abstract class PrinterHandler {
@Setter
protected PrinterHandler nextPrinter;
protected String printerBrand;
// 创建 ThreadLocal 变量
private static final ThreadLocal<String> ERR_MSG = ThreadLocal.withInitial(() -> "");
@Resource
protected OrderDetailService orderDetailService;
@@ -175,7 +178,7 @@ public abstract class PrinterHandler {
* @param printTypeEnum order returnOrder preOrder one call handover
*/
public void handler(String data, PrintTypeEnum printTypeEnum) {
Long shopId = null;
Long shopId;
String printMethod = "";
String printType = "";
Object obj;
@@ -280,11 +283,11 @@ public abstract class PrinterHandler {
item.setReturnNum(item.getReturnNum() == null ? BigDecimal.ZERO : item.getReturnNum());
PrintDetailInfo printDetailInfo = o != null ? JSONObject.parseObject((String) o, PrintDetailInfo.class) : null;
if (printDetailInfo != null) {
if (item.getNum().compareTo(printDetailInfo.getPrintNum()) <= 0) {
if (item.getNum().compareTo(BigDecimal.ZERO) != 0 && item.getNum().compareTo(printDetailInfo.getPrintNum()) <= 0) {
log.info("此菜品已打印, {} {} {}", item.getProductName(), item.getSkuName(), printDetailInfo);
}
if (item.getReturnNum().compareTo(printDetailInfo.getPrintReturnNum()) <= 0) {
if (item.getReturnNum().compareTo(BigDecimal.ZERO) != 0 && item.getReturnNum().compareTo(printDetailInfo.getPrintReturnNum()) <= 0) {
log.info("此退菜菜品已打印, {} {} {}", item.getProductName(), item.getSkuName(), printDetailInfo);
}
item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum()));
@@ -383,6 +386,9 @@ public abstract class PrinterHandler {
Map<Long, OrderDetail> detailMap = tbOrderDetailList.stream().map(item -> BeanUtil.copyProperties(item, OrderDetail.class)).collect(Collectors.toMap(OrderDetail::getId, i -> i));
tbOrderDetailList = getCanPrintOrderDetails("1".equals(machine.getClassifyPrint()), orderInfo.getId(), tbOrderDetailList, categoryIds);
tbOrderDetailList.parallelStream().filter(o -> ObjectUtil.defaultIfNull(o.getIsPrint(), 0) == 1).forEach(item -> {
if (item.getNum().compareTo(BigDecimal.ZERO) <= 0 && item.getReturnNum().compareTo(BigDecimal.ZERO) <= 0) {
return;
}
log.info("开始打印菜品,商品名:{}", item.getProductName());
Integer isWaitCall = ObjectUtil.defaultIfNull(item.getIsWaitCall(), 0);
if (isWaitCall == 1) {

View File

@@ -182,7 +182,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
Map<Integer, String> yxxStatusMap = MapUtil.builder(0, "离线(设备上线后自动补打)").put(1, "在线").put(2, "获取失败").put(3, "未激活").put(4, "设备已禁用").build();
// 云想印
if ("yxyPrinter".equals(config.getContentType())) {
if ("云享印".equals(config.getContentType())) {
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
int code = resp.getInt("code");
cn.hutool.json.JSONObject data = resp.getJSONObject("data").getJSONObject("data");
@@ -203,7 +203,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
entity.setTaskId(taskId);
}
// 飞鹅云打印机暂时没有适配先return不做打印记录
} else if ("fePrinter".equals(config.getContentType())) {
} else if ("飞鹅".equals(config.getContentType())) {
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
int ret = resp.getInt("ret");
if (ret != 0) {
@@ -235,7 +235,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
super.save(entity);
// 云想印
if ("yxyPrinter".equals(config.getContentType())) {
if ("云享印".equals(config.getContentType())) {
// 延迟3ms复查打印状态 (用户可以根据设备信息查询到当前设备的在线情况该接口只能提供参考设备的离线状态是在设备离线3分钟后才会生效)
ThreadUtil.safeSleep(1000 * 5);
String jsonStr = checkPrintStatus(config.getAddress(), entity.getTaskId());
@@ -269,7 +269,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
super.updateById(entity);
}
// 飞鹅云打印机
} else if ("fePrinter".equals(config.getContentType())) {
} else if ("飞鹅".equals(config.getContentType())) {
ThreadUtil.safeSleep(1000 * 5);
Boolean success = checkFPrintStatus(entity.getTaskId());
if (success == null) {