打印完善
This commit is contained in:
parent
0d3b9abd2e
commit
0674936901
|
|
@ -6,6 +6,7 @@ import com.czg.account.service.PermissionService;
|
||||||
import com.czg.account.vo.LoginVO;
|
import com.czg.account.vo.LoginVO;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.annotation.SaStaffCheckPermission;
|
import com.czg.annotation.SaStaffCheckPermission;
|
||||||
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.mq.PrintMqListener;
|
import com.czg.mq.PrintMqListener;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
|
|
@ -54,9 +55,12 @@ public class AuthorizationController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
PrintMqListener printMqListener;
|
PrintMqListener printMqListener;
|
||||||
|
@Resource
|
||||||
|
RabbitPublisher rabbitPublisher;
|
||||||
@GetMapping("test")
|
@GetMapping("test")
|
||||||
public CzgResult<?> login() {
|
public CzgResult<?> login() {
|
||||||
printMqListener.orderPrint("1");
|
rabbitPublisher.sendOrderPrintMsg("1");
|
||||||
|
// printMqListener.orderPrint("1");
|
||||||
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
|
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
@ -40,7 +42,7 @@ public class PrintMqListener {
|
||||||
@Resource
|
@Resource
|
||||||
private PrinterHandler printerHandler;
|
private PrinterHandler printerHandler;
|
||||||
|
|
||||||
// @RabbitListener(queues = {RabbitConstants.Queue.ORDER_PRINT_QUEUE})
|
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE})
|
||||||
public void orderPrint(String orderId) {
|
public void orderPrint(String orderId) {
|
||||||
long startTime = DateUtil.date().getTime();
|
long startTime = DateUtil.date().getTime();
|
||||||
log.info("接收到订单打印消息:{}", orderId);
|
log.info("接收到订单打印消息:{}", orderId);
|
||||||
|
|
@ -52,18 +54,17 @@ public class PrintMqListener {
|
||||||
throw new RuntimeException("订单信息不存在");
|
throw new RuntimeException("订单信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrintMachine(1L, "cash", "one", "order").forEach(machine -> {
|
getPrintMachine(orderInfo.getShopId(), "cash", "all", "order").forEach(machine -> {
|
||||||
printerHandler.handleRequest(machine, orderInfo, null);
|
printerHandler.handleRequest(machine, orderInfo, null);
|
||||||
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
log.error("订单打印失败", e);
|
log.error("订单打印失败", e);
|
||||||
mqLog.setErrInfo(JSONObject.toJSONString(e));
|
mqLog.setErrInfo(JSONObject.toJSONString(e));
|
||||||
mqLog.setDuration(DateUtil.date().getTime() - startTime);
|
mqLog.setDuration(DateUtil.date().getTime() - startTime);
|
||||||
mqLog.setFailTime(DateUtil.date().toLocalDateTime());
|
mqLog.setFailTime(DateUtil.date().toLocalDateTime());
|
||||||
// mqLogService.save(mqLog);
|
mqLogService.save(mqLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue