|
|
|
@@ -167,6 +167,8 @@ def generate_zpl_dataflex( |
|
|
|
batch_no: str, |
|
|
|
item_code: str, |
|
|
|
item_name: str, |
|
|
|
item_id: Optional[int] = None, |
|
|
|
stock_in_line_id: Optional[int] = None, |
|
|
|
lot_no: Optional[str] = None, |
|
|
|
font_regular: str = "E:STXihei.ttf", |
|
|
|
font_bold: str = "E:STXihei.ttf", |
|
|
|
@@ -180,14 +182,18 @@ def generate_zpl_dataflex( |
|
|
|
code = _zpl_escape((item_code or "—").strip()) |
|
|
|
label_line = (lot_no or batch_no or "").strip() |
|
|
|
label_esc = _zpl_escape(label_line) |
|
|
|
qr_value = label_line if label_line else batch_no.strip() |
|
|
|
# QR payload: prefer JSON {"itemId":..., "stockInLineId":...} when both present; else fall back to lot/batch text |
|
|
|
if item_id is not None and stock_in_line_id is not None: |
|
|
|
qr_value = _zpl_escape(json.dumps({"itemId": item_id, "stockInLineId": stock_in_line_id})) |
|
|
|
else: |
|
|
|
qr_value = _zpl_escape(label_line if label_line else batch_no.strip()) |
|
|
|
return f"""^XA |
|
|
|
^CI28 |
|
|
|
^PW700 |
|
|
|
^LL500 |
|
|
|
^PO N |
|
|
|
^FO10,20 |
|
|
|
^BQR,4,7^FDQA,{qr_value}^FS |
|
|
|
^BQR,4,7^FD{qr_value}^FS |
|
|
|
^FO170,20 |
|
|
|
^A@R,72,72,{font_regular}^FD{desc}^FS |
|
|
|
^FO0,290 |
|
|
|
@@ -717,8 +723,17 @@ def main() -> None: |
|
|
|
if count is not None: |
|
|
|
item_code = j.get("itemCode") or "—" |
|
|
|
item_name = j.get("itemName") or "—" |
|
|
|
item_id = j.get("itemId") |
|
|
|
stock_in_line_id = j.get("stockInLineId") |
|
|
|
lot_no = j.get("lotNo") |
|
|
|
zpl = generate_zpl_dataflex(b, item_code, item_name, lot_no=lot_no) |
|
|
|
zpl = generate_zpl_dataflex( |
|
|
|
b, |
|
|
|
item_code, |
|
|
|
item_name, |
|
|
|
item_id=item_id, |
|
|
|
stock_in_line_id=stock_in_line_id, |
|
|
|
lot_no=lot_no, |
|
|
|
) |
|
|
|
n = 100 if count == -1 else count |
|
|
|
label_text = (lot_no or b).strip() |
|
|
|
try: |
|
|
|
|