fix: 修复标签打印功能中'打印份数'参数未生效的问题

This commit is contained in:
DXC
2026-03-10 17:27:14 +08:00
parent ea28ee1c86
commit bc866e7670

View File

@ -275,6 +275,11 @@ class LabelPrintService:
ip = config['ip'] ip = config['ip']
port = config['port'] port = config['port']
# 获取打印份数,默认为 1
copies = data.get('copies', 1)
if copies < 1:
copies = 1
try: try:
# 1. 获取 RGB 图像 # 1. 获取 RGB 图像
img_rgb = LabelPrintService._create_image_object(data) img_rgb = LabelPrintService._create_image_object(data)
@ -301,7 +306,7 @@ class LabelPrintService:
# 位图指令 # 位图指令
bitmap_cmd = f"BITMAP 0,0,{width_bytes},{height_dots},0,".encode('gbk') bitmap_cmd = f"BITMAP 0,0,{width_bytes},{height_dots},0,".encode('gbk')
footer = b"\r\nPRINT 1,1\r\n" footer = f"\r\nPRINT 1,{copies}\r\n".encode('gbk')
# 5. 发送 socket # 5. 发送 socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)