交班小票实现

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

@@ -7,11 +7,13 @@ import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.enums.YesNoEnum;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -29,6 +31,8 @@ import java.util.List;
@RequestMapping("/admin/handoverRecord")
public class HandoverRecordController {
private final HandoverRecordService handoverRecordService;
@Resource
private RabbitPublisher rabbitPublisher;
/**
* 交班记录-分页
@@ -96,7 +100,9 @@ public class HandoverRecordController {
//@SaAdminCheckPermission("handoverRecord:handover")
public CzgResult<Long> handover(@RequestParam Integer isPrint) {
Long id = handoverRecordService.handover();
if (isPrint == 1){
rabbitPublisher.sendHandoverPrintMsg(id.toString());
}
return CzgResult.success(id);
}

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;
}
}