打印 调整

This commit is contained in:
2026-04-15 18:17:41 +08:00
parent 44f896168f
commit 45fbdd514e
33 changed files with 1887 additions and 1155 deletions

View File

@@ -70,26 +70,16 @@ public class RabbitConfig {
return BindingBuilder.bind(orderMachinePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE);
}
//------------------------------------------------------交班打票
//------------------------------------------------------其它打印消息打票
@Bean
public Queue handoverPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
public Queue otherPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE, true, false, false);
}
@Bean
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
}
//------------------------------------------------------叫号 打票
@Bean
public Queue callTablePrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_QUEUE, true, false, false);
}
@Bean
public Binding bindingCallTablePrintExchange(Queue callTablePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_QUEUE);
public Binding bindingOtherPrintExchange(Queue otherPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(otherPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE);
}
//------------------------------------------------------订单取消

View File

@@ -14,10 +14,11 @@ public interface RabbitConstants {
public static final String ORDER_STOCK_QUEUE = "order.stock.queue";
public static final String ORDER_REFUND_QUEUE = "order.refund.queue";
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
public static final String CALL_TABLE_QUEUE = "call.table.print.queue";
public static final String OTHER_PRINT_QUEUE = "other.print.queue";
public static final String PRODUCT_INFO_CHANGE_QUEUE = "product.info.change.queue";
public static final String CONS_INFO_CHANGE_QUEUE = "cons.info.change.queue";

View File

@@ -7,6 +7,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
@@ -62,37 +63,19 @@ public class RabbitPublisher {
sendMsg(RabbitConstants.Queue.ORDER_PRINT_QUEUE, orderId);
}
}
/**
* 订单打印消息
* 厨房票打印消息
*
* @param orderId 订单id
* @param printOrder 是否打印结算单
*/
public void sendKitchenOrderPrintMsg(String orderId, boolean printOrder, String source) {
log.info("厨房打印消息, orderId: {}, printOrder: {}, source: {}", orderId, printOrder, source);
log.info("厨房菜品单打印消息, orderId: {}, printOrder: {}, source: {}", orderId, printOrder, source);
//厨房票
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, new JSONObject().fluentPut("orderId", orderId).fluentPut("printOrder", printOrder).toString());
}
/**
* 退款订单打印消息
*
* @param orderId 订单id
*/
public void sendOrderReturnPrintMsg(String orderId) {
//厨房票
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, new JSONObject().fluentPut("orderId", orderId).fluentPut("printOrder", true).toString());
}
/**
* 交班小票打印消息
*
* @param handoverRecordId 交班记录id
*/
public void sendHandoverPrintMsg(String handoverRecordId) {
sendMsg(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, handoverRecordId);
}
/**
* 商品信息变动消息
*
@@ -111,15 +94,6 @@ public class RabbitPublisher {
sendMsg(RabbitConstants.Queue.CONS_INFO_CHANGE_QUEUE, shopId);
}
/**
* 排队叫号小票打印
*
* @param id 叫号队列id
*/
public void printCallNumTicket(Long id) {
sendMsg(RabbitConstants.Queue.CALL_TABLE_QUEUE, id.toString());
}
/**
* 1,2,applySmsTemp 模版审核 shop_id,sms_shop_template.id,applySmsTemp
* 1,2,sendMarkSms 发送营销短信 shop_id,sms_push_event.id,sendMarkSms
@@ -172,4 +146,25 @@ public class RabbitPublisher {
rabbitTemplate.convertAndSend(activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE, activeProfile + "-" + queue, msg);
}
/**
* 其它类型 打印消息
* STOCK 出入库
* DAY_REPORT 经营日报
* PRODUCT_REPORT 商品报表
* RECHARGE 储值单
* STOCK_CHECK 库存盘点
* HANDOVER 交班单
* CALL 排队取号
* @param printType {@link com.czg.service.order.print.PrinterHandler.PrintTypeEnum}
*/
public void sendOtherPrintMsg(Long shopId, Object data, String printType) {
String exchange = activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE;
String queueName = activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE;
Map<String, Object> msg = new HashMap<>();
msg.put("shopId", shopId);
msg.put("data", data);
msg.put("printTypeEnum", printType);
rabbitTemplate.convertAndSend(exchange, queueName, msg);
}
}

View File

@@ -3,6 +3,7 @@ package com.czg.config;
/**
*
* key常量
*
* @author Administrator
*/
public interface RedisCst {
@@ -12,7 +13,6 @@ public interface RedisCst {
String SYS_LOG_KEY = "sys:log:";
/**
* key过期监听
*/
@@ -50,11 +50,18 @@ public interface RedisCst {
// 排队取号全局号码
String TABLE_CALL_NUMBER = "table:call:number:";
String PRINT_ORDER_DETAIL = "print:order:detail:";
// 点歌地址url
String SONG_URL = "song:";
class kitchen {
//后厨总单
public static final String ALL = "print:kitchen:all";
//菜品单
public static final String NORMAL = "print:kitchen:normal";
//退菜单
public static final String REFUND_ALL = "print:kitchen:refundAll";
}
static String getLockKey(String sign, Object... args) {
StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":");
@@ -70,9 +77,31 @@ public interface RedisCst {
return TABLE_CALL_NUMBER + shopId + ":" + callTableId;
}
/**
* 后厨总单
*
* @param machineId 打印机设备id
*/
static String kitchenAll(Long orderId, Long machineId) {
return kitchen.ALL + orderId + ":" + machineId;
}
static String getPrintOrderDetailKey(Long orderId, Long detailId) {
return PRINT_ORDER_DETAIL + orderId + ":" + detailId;
/**
* 后厨单个菜品单
*
* @param machineId 打印机设备id
*/
static String kitchenNormal(Long orderId, Long machineId, Long detailId) {
return kitchen.NORMAL + orderId + ":" + machineId + ":" + detailId;
}
/**
* 后厨总单
*
* @param machineId 打印机设备id
*/
static String kitchenRefundAll(Long orderId, Long machineId) {
return kitchen.REFUND_ALL + orderId + ":" + machineId;
}
static String getSongUrlKey(Long shopId) {

View File

@@ -4,16 +4,15 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 打印机设备 实体类。
*
@@ -21,7 +20,7 @@ import lombok.NoArgsConstructor;
* @since 2025-02-20
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_print_machine")
@@ -30,8 +29,16 @@ public class PrintMachine implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id(keyType = KeyType.Auto)
private Integer id;
private Long id;
/**
* 店铺Id
*/
private Long shopId;
/**
* 设备名称
@@ -39,12 +46,22 @@ public class PrintMachine implements Serializable {
private String name;
/**
* 现在打印机支持USB 和 网络、蓝牙
* 连接方式 USB、云打印、局域网
*/
private String connectionType;
/**
* ip地址
* 打印类型 label标签 cash小票
*/
private String printType;
/**
* 打印机品牌 飞鹅/云想印
*/
private String brand;
/**
* ip地址/MAC地址
*/
private String address;
@@ -53,46 +70,6 @@ public class PrintMachine implements Serializable {
*/
private String port;
/**
* 打印类型分类label标签cash小票kitchen出品
*/
private String subType;
/**
* 状态 online
*/
private Integer status;
/**
* 店铺Id
*/
private Long shopId;
/**
* 分类Id
*/
private String categoryIds;
/**
* 现在打印机支持USB 和 网络两种
*/
private String contentType;
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
/**
* 分类
*/
private List<Object> categoryList;
/**
* 排序
*/
private Integer sort;
/**
* 小票尺寸 58mm 80mm
@@ -100,31 +77,58 @@ public class PrintMachine implements Serializable {
private String receiptSize;
/**
* 分类打印 0-所有 1-部分分类 2-部分商品
* 打印数量
*/
private Integer printNum;
/**
* 打印内容 数组
* GUEST_ORDER("客看单"),PRE_ORDER("预结算单"),ORDER("订单结算单"),RETURN_ORDER("退菜单"),REFUND_ORDER("退款单"),
* ALL_KITCHEN("后厨整单"),ONLY_KITCHEN("后厨分单"),REFUND_KITCHEN("后厨退菜单"),
* HANDOVER("交班单"),CALL("排队取号"),RECHARGE("储值单"),STOCK("出入库单"),STOCK_CHECK("盘点单"),
* PRODUCT_REPORT("商品报表"),DAY_REPORT("经营日报"),DAY_ORDER("日结单")
*/
private String printContentType;
/**
* 打印模式(厨房打印菜品) all整单 /only单个
*/
private String kitchenPrintMode;
/**
* 分类打印 0-所有 1-部分分类
*/
private String classifyPrint;
/**
* 打印数量 c1m1^2=顾客+商家[2张] m1^1=商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
* 分类Id
*/
private String printQty;
private String categoryIds;
/**
* 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」
* 0 禁用 1启用
*/
private String printMethod;
private Integer status;
/**
* 打印类型JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
*/
private String printType;
/**
* 媒体音开关 0-关 1-开
* 媒体声音开关 0关1开
*/
private Integer volumeSwitch;
/**
* 交班打印机开关 0-关 1-开
*/
private Integer handoverSwitch;
}
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(onUpdateValue = "now()")
private LocalDateTime updateTime;
/**
* 排序
*/
private Integer sort;
}

View File

@@ -51,14 +51,14 @@ public interface HandoverRecordService extends IService<HandoverRecord> {
*
* @return 交班记录ID
*/
Long handover();
HandoverRecord handover();
/**
* 交班打印小票
*
* @param handoverRecordId 交班记录id
* @param isPrint 是否打印 1-是 0-否
* @param record 交班记录
* @param isPrint 是否打印 1-是 0-否
*/
void printHandoverReceipt(Long handoverRecordId, Integer isPrint);
void printHandoverReceipt(HandoverRecord record, Integer isPrint);
}

View File

@@ -1,11 +1,7 @@
package com.czg.account.service;
import com.czg.account.dto.print.PrinterAddDTO;
import com.czg.account.dto.print.PrinterEditDTO;
import com.czg.account.dto.print.PrinterOrderDTO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.account.entity.PrintMachine;
import com.mybatisflex.core.service.IService;
/**
* 打印机设备 服务层。
@@ -15,9 +11,9 @@ import com.czg.account.entity.PrintMachine;
*/
public interface PrintMachineService extends IService<PrintMachine> {
boolean add(Long shopId, PrinterAddDTO printerAddDTO);
boolean add(Long shopId, PrintMachine printMachine);
Boolean edit(Long shopId, PrinterEditDTO printerEditDTO);
Boolean edit(Long shopId, PrintMachine printMachine);
}

View File

@@ -20,11 +20,8 @@ public class OrderInfoPrintDTO implements Serializable {
@NotNull(message = "id不为空")
private Long id;
/**
* 0 菜品和结算单同时打印
* 1 预结算单
* 2 结算单
* 3 退菜/退款
* 4 交班
*/
@NotNull(message = "打印类型不为空")
private Integer type;

View File

@@ -40,9 +40,9 @@ public interface OrderInfoRpcService {
/**
* 订单交班回调 发送答应交班小票消息至MQ
*
* @param handoverRecordId 交班记录id
* @param record 交班记录id
*/
void sendHandoverReceiptPrintMsgToMq(Long handoverRecordId);
void sendHandoverReceiptPrintMsgToMq(Long shopId, HandoverRecord record);
/**
* 交班售出商品明细

View File

@@ -0,0 +1,158 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 经营日报
* @author Administrator
*/
@Data
@Accessors(chain = true)
public class DayReportPrintDTO {
/**
* 店铺名称
*/
private String shopName;
/**
* 操作人
*/
private String operator;
/**
* 统计时间
*/
private String statisticsTime;
/**
* 退款金额
*/
private BigDecimal refundAmount;
/**
* 退菜数量
*/
private Long returnDishCount;
/**
* 营业额
*/
private TurnoverSts turnover;
/**
* 订单
*/
private OrderSts order;
/**
* 数据统计
*/
private Sts sts;
/**
* 营业额 类
*/
@Data
@Accessors(chain = true)
public static class TurnoverSts {
/**
* 营业额
*/
private BigDecimal turnover;
/**
* 微信支付金额
*/
private BigDecimal wechat;
/**
* 支付宝支付金额
*/
private BigDecimal alipay;
/**
* 二维码收款
*/
private BigDecimal selfScan;
/**
* 扫码收款
*/
private BigDecimal barScan;
/**
* 现金收款
*/
private BigDecimal cash;
/**
* 充值
*/
private BigDecimal recharge;
/**
* 挂账
*/
private BigDecimal owed;
/**
* 余额支付
*/
private BigDecimal balance;
}
/**
* 订单 类
*/
@Data
@Accessors(chain = true)
public static class OrderSts {
/**
* 订单金额
*/
private BigDecimal orderAmount;
/**
* 订单总数
*/
private Long orderCount;
}
/**
* 数据统计 类
*/
@Data
@Accessors(chain = true)
public static class Sts {
/**
* 就餐人数
*/
private Long customerCount;
/**
* 客单价
* 实付金额(包含现金支付 包含会员支付 包含挂账)/就餐人数
* 没有具体人数时默认一桌按照1人计算
*/
private BigDecimal avgPayAmount;
/**
* 翻台率
* (订单数-桌台数)/桌台数*100%
*/
private BigDecimal turnoverRate;
/**
* 商品成本
*/
private BigDecimal productCostAmount;
/**
* 毛利率(订单实付金额-商品成本)/订单实付金额*100%
*/
private BigDecimal profitRate;
}
}

View File

@@ -0,0 +1,44 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单打印实体
* @author ww
*/
@Data
@Accessors(chain = true)
public class OrderPrintDTO {
// 打印标题 结算单/客看单/预结算单 退菜单/退款单
private String printTitle;
private String shopName;
//打印类型 收银-堂食
private String printType;
//台桌区域-台桌号
private String pickupNum;
private String orderNo;
//结账时间
private String tradeDate;
//操作人名称
private String operator;
private String payAmount;
private String originalAmount;
private String payType;
private String remark;
//取餐码
private String outNumber;
private String discountAmount;
private String seatNum;
private String seatAmount;
private String packFee;
// 是否退款单
private boolean isReturn;
//退款单用
private String refundAmount;
//退款方式 现金退款/原路退回
private String refundType;
//退款原因
private String refundReason;
}

View File

@@ -0,0 +1,94 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 商品报表打印实体
*
* @author ww
*/
@Data
@Accessors(chain = true)
public class ProductReportPrintDTO {
/**
* 店铺名称
*/
private String shopName;
/**
* 打印时间
*/
private String printTime;
/**
* 操作人
*/
private String operator;
/**
* 统计时间
*/
private String statisticsTime;
/**
* 总计商品数量
*/
private BigDecimal totalProductCount;
/**
* 总计实收金额
*/
private BigDecimal totalActualAmount;
/**
* 商品明细列表
* 分类名称,商品集合
*/
private Map<String, List<ProductItem>> items;
public ProductItem createProductItem(String productName, BigDecimal number, BigDecimal actualAmount, BigDecimal salesAmount) {
ProductItem item = new ProductItem();
item.setProductName(productName);
item.setNumber(number);
item.setActualAmount(actualAmount);
item.setSalesAmount(salesAmount);
return item;
}
/**
* 商品明细项
*
* @author ww
*/
@Data
@Accessors(chain = true)
public static class ProductItem {
/**
* 商品名称(第二列商品名称)
*/
private String productName;
/**
* 数量(第三列数量)
*/
private BigDecimal number;
/**
* 实收(第四列)
*/
private BigDecimal actualAmount;
/**
* 销售额(第五列)
*/
private BigDecimal salesAmount;
}
}

View File

@@ -0,0 +1,44 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 储值单
* @author ww
*/
@Data
@Accessors(chain = true)
public class RechargePrintDTO {
//店铺名称
private String shopName;
private String userId;
private String userName;
private String userPhone;
//支付时间
private LocalDateTime payTime;
//充值金额
private BigDecimal rechargeAmount;
//赠送金额
private BigDecimal giftAmount;
//赠送积分
private BigDecimal giftPoints;
//赠送优惠券 张
private Integer giftCoupon;
//充值后余额
private BigDecimal balance;
//已付金额
private BigDecimal payAmount;
//支付方式
private String payType;
//操作员
private String operator;
//充值编号
private String rechargeId;
}

View File

@@ -0,0 +1,87 @@
package com.czg.print;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.List;
/**
* 盘点单打印实体
* @author ww
*/
@Data
@Accessors(chain = true)
public class StockCheckPrintDTO {
/**
* 店铺名称
*/
private String shopName;
/**
* 耗材明细列表
*/
private List<StockCheckItem> items;
/**
* 账存数量
*/
private Integer winLossNumberCount;
/**
* 盈亏金额
*/
private BigDecimal winLossAmount;
/**
* 备注
*/
private String remark;
/**
* 操作员
*/
private String operator;
public StockCheckItem createStockCheckItem(String consName, BigDecimal price, String unit, BigDecimal actualNumber, BigDecimal winLossNumber) {
return new StockCheckItem(consName, price, unit, actualNumber, winLossNumber);
}
/**
* 入库耗材明细
*
* @author ww
*/
@Data
@Accessors(chain = true)
@AllArgsConstructor
public static class StockCheckItem {
/**
* 耗材名称
*/
private String consName;
/**
* 单价
*/
private BigDecimal price;
/**
* 单位
*/
private String unit;
/**
* 实际数
*/
private BigDecimal actualNumber;
/**
* 盈亏数
*/
private BigDecimal winLossNumber;
}
}

View File

@@ -0,0 +1,101 @@
package com.czg.print;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 入库打印单
*
* @author ww
*/
@Data
@Accessors(chain = true)
public class StockPrintDTO {
//IN OUT
private String type;
/**
* 店铺名称
*/
private String shopName;
/**
* 出入库时间
*/
private LocalDateTime inStockTime;
/**
* 出入库耗材明细列表
*/
private List<InStockItem> items;
/**
* 耗材总种类数
*/
private Integer consCount;
/**
* 出入库总数量
*/
private BigDecimal stockNumberCount;
/**
* 总金额
*/
private BigDecimal amountCount;
/**
* 操作员
*/
private String operator;
/**
* 打印时间
*/
private LocalDateTime printTime;
public InStockItem createInStockItem(String consName, String unit, BigDecimal stockNumber, BigDecimal amount) {
InStockItem item = new InStockItem();
item.setConsName(consName);
item.setUnit(unit);
item.setStockNumber(stockNumber);
item.setAmount(amount);
return item;
}
/**
* 入库耗材明细
*
* @author ww
*/
@Data
@Accessors(chain = true)
public static class InStockItem {
/**
* 耗材名称
*/
private String consName;
/**
* 库存单位
*/
private String unit;
/**
* 出入数量
*/
private BigDecimal stockNumber;
/**
* 金额
*/
private BigDecimal amount;
}
}

View File

@@ -31,6 +31,9 @@ public class ConsCheckStockParam implements Serializable {
*/
@NotBlank(message = "耗材名称不能为空", groups = DefaultGroup.class)
private String conName;
@NotBlank(message = "操作员不能为空", groups = DefaultGroup.class)
private String operator;
/**
* 账存数量
*/

View File

@@ -69,4 +69,9 @@ public class ConsInOutStockHeadParam implements Serializable {
* 未入库信息
*/
private List<SaleOrderDTO.Item> unInCons;
/**
* 操作员
*/
private String operator;
}