carieri label
This commit is contained in:
parent
046b9fd712
commit
afdee1335e
28
config/label_templates/203/LabelCARRIERI.prn
Normal file
28
config/label_templates/203/LabelCARRIERI.prn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
CT~~CD,~CC^~CT~
|
||||
^XA
|
||||
~TA000
|
||||
~JSN
|
||||
^LT0
|
||||
^MNW
|
||||
^MTT
|
||||
^PON
|
||||
^PMN
|
||||
^LH0,0
|
||||
^JMA
|
||||
^PR2,2
|
||||
~SD20
|
||||
^JUS
|
||||
^LRN
|
||||
^CI27
|
||||
^PA0,1,1,0
|
||||
^XZ
|
||||
^XA
|
||||
^MMT
|
||||
^PW240
|
||||
^LL128
|
||||
^LS0
|
||||
^FT75,107^BQN,2,2
|
||||
^FH\^FDLA,<CN>HOSE<PN>5803647057|<RV>000|<BL>0000|<SC>B1|<AC>YES|<PC>YES|<TN>Errecinque srl|<SN>00001|<OCG>OCG36006208|<DT>16-16-2026|<LT>000000PART|<LV>000^FS
|
||||
^FT20,124^A0N,17,25^FH\^CI28^FD{PART}_C1^FS^CI27
|
||||
^PQ1,0,1,Y
|
||||
^XZ
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import csv
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -7,38 +7,87 @@ from PyQt5.QtWidgets import QApplication
|
|||
from src.components.os_label_printer import *
|
||||
from src.lib.helpers import ConfigReader
|
||||
|
||||
SYSTEM_ID = "test-linux"
|
||||
CSV_PATH="tmp/promatec.csv"
|
||||
TEMPLATE="ferrari_flag_qr_only.prn"
|
||||
#TEMPLATE="ferrari_30x16_203.prn"
|
||||
# --- Product Data ---
|
||||
PRODUCTS = {
|
||||
"5803647057": {"CN": "pressure-hose_SG", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803647058": {"CN": "Return-hose-SG", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803647061": {"CN": "pressure-hose-fn4", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803648415": {"CN": "NVH-HOSE", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803688601": {"CN": "NVH-HOSE-xc13-fn4", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803610921": {"CN": "NVH-HOSE-ESRA", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803610922": {"CN": "NVH-HOSE-ESRA", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
"5803610923": {"CN": "NVH-HOSE-ESRA", "RV": "000", "BL": "00001", "SC": "B1", "AC": "YES", "PC": "NO", "LT": "000000PART", "LV": "000"},
|
||||
}
|
||||
|
||||
config = ConfigReader(system_id=SYSTEM_ID)
|
||||
printer=Os_Label_Printer(config=config,name="label_printer")
|
||||
def generate_qr_code(product_pn, product_data, ocg, supplier_name, date_obj, serial_number):
|
||||
# Format date as day/week_number/year, e.g., 09/15/2026
|
||||
date_str = date_obj.strftime("%d/%W/%Y")
|
||||
|
||||
qr_string = (
|
||||
f"<CN>{product_data['CN']}|<PN>{product_pn}|<RV>{product_data['RV']}|"
|
||||
f"<BL>{product_data['BL']}|<SC>{product_data['SC']}|<AC>{product_data['AC']}|"
|
||||
f"<PC>{product_data['PC']}|<TN>{supplier_name}|<SN>{serial_number:05d}|"
|
||||
f"<OCG>{ocg}|<DT>{date_str}|<LT>{product_data['LT']}|<LV>{product_data['LV']}"
|
||||
)
|
||||
return qr_string
|
||||
|
||||
# timenow = datetime.now()
|
||||
app = QApplication(sys.argv)
|
||||
def main():
|
||||
SYSTEM_ID = "st-ten-7"
|
||||
TEMPLATE = "LabelCARRIERI.prn"
|
||||
FIXED_OCG = "OCG36006208"
|
||||
|
||||
config = ConfigReader(system_id=SYSTEM_ID)
|
||||
printer = Os_Label_Printer(config=config, name="label_printer")
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
with open(CSV_PATH, "r", encoding="utf-8-sig") as f:
|
||||
reader = csv.DictReader(f)
|
||||
for row in reader:
|
||||
START_SN = 1
|
||||
STOP_SN = int(row["quantity"])
|
||||
PN = row["part_number"]
|
||||
print(f"PART NUMBER # {PN}")
|
||||
while True:
|
||||
print("\n--- New Label Printing Session ---")
|
||||
print("Available Part Numbers:")
|
||||
for pn in PRODUCTS.keys():
|
||||
print(f"- {pn}")
|
||||
|
||||
selected_pn = ""
|
||||
while selected_pn not in PRODUCTS:
|
||||
selected_pn = input("Enter the Part Number to print: ")
|
||||
if selected_pn not in PRODUCTS:
|
||||
print("Invalid Part Number. Please choose from the list above.")
|
||||
|
||||
product_info = PRODUCTS[selected_pn]
|
||||
|
||||
supplier_name = input("Enter the supplier name: ")
|
||||
|
||||
while True:
|
||||
try:
|
||||
quantity_str = input("Enter the number of labels to print [15]: ")
|
||||
if not quantity_str:
|
||||
quantity = 15
|
||||
break
|
||||
quantity = int(quantity_str)
|
||||
if quantity > 0:
|
||||
break
|
||||
else:
|
||||
print("Please enter a positive number.")
|
||||
except ValueError:
|
||||
print("Invalid number.")
|
||||
|
||||
print(f"Printing {quantity} labels for PART NUMBER # {selected_pn}")
|
||||
input("Press Enter to continue...")
|
||||
for sn in range(START_SN,STOP_SN+2):
|
||||
|
||||
last_label_context = None
|
||||
for sn in range(1, quantity + 1):
|
||||
timenow = datetime.now()
|
||||
print(f"PRINTING LABEL # {sn}")
|
||||
|
||||
# Pass the incrementing serial number 'sn' to the QR code generator
|
||||
qr_code = generate_qr_code(selected_pn, product_info, FIXED_OCG, supplier_name, timenow, sn)
|
||||
|
||||
# The context now contains the full QR_CODE string with the correct SN,
|
||||
# and a separate SN for any human-readable fields on the label.
|
||||
context = {
|
||||
# RECIPE DATA
|
||||
"PART": PN,
|
||||
# SERIAL DEFINITION
|
||||
"SN": str(sn),
|
||||
"SN4": f"{sn:0>4}",
|
||||
"SN5": f"{sn:0>5}",
|
||||
"SN6": f"{sn:0>6}",
|
||||
# TIME DEFINITION
|
||||
"QR_CODE": qr_code,
|
||||
"PART": selected_pn,
|
||||
"SN": f"{sn:05d}",
|
||||
"DATETIME": timenow.strftime("%d/%m/%Y %H:%M:%S"),
|
||||
"DATE": timenow.strftime("%d/%m/%Y"),
|
||||
"TIME": timenow.strftime("%H:%M:%S"),
|
||||
|
|
@ -51,6 +100,29 @@ with open(CSV_PATH, "r", encoding="utf-8-sig") as f:
|
|||
"SS": timenow.strftime("%S"),
|
||||
"JJJ": timenow.strftime("%j"),
|
||||
}
|
||||
printer.print_label(TEMPLATE,context)
|
||||
printer.print_label(TEMPLATE, context)
|
||||
last_label_context = context
|
||||
time.sleep(0.5)
|
||||
|
||||
time.sleep(.5)
|
||||
while True:
|
||||
action = input("\nReprint last label (r), print another product (a), or exit (e)? ").lower()
|
||||
if action == 'r':
|
||||
if last_label_context:
|
||||
print("Reprinting last label...")
|
||||
printer.print_label(TEMPLATE, last_label_context)
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
print("No label has been printed in this session to reprint.")
|
||||
elif action == 'a':
|
||||
break
|
||||
elif action == 'e':
|
||||
print("Exiting.")
|
||||
return
|
||||
else:
|
||||
print("Invalid option. Please enter 'r', 'a', or 'e'.")
|
||||
|
||||
if action == 'a':
|
||||
continue
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user