fix: Se añade Tipo Usb
This commit is contained in:
parent
a974acc623
commit
b17a2b83e9
20
api.py
20
api.py
@ -15,16 +15,23 @@ app = FastAPI(
|
||||
|
||||
class Info(BaseModel):
|
||||
content: str
|
||||
printer_type: str
|
||||
ip_printer: str
|
||||
idVendor: str
|
||||
idProduct: str
|
||||
user_name: str
|
||||
|
||||
|
||||
def print_bill(data, address, waiter):
|
||||
def print_bill(data, address=None, idVendor=None idProduct=None, waiter):
|
||||
d = data
|
||||
# Crea una instancia de la impresora ficticia
|
||||
# printer = Network(str(address))
|
||||
# printer.open()
|
||||
printer = Dummy()
|
||||
if address:
|
||||
printer = Network(str(address))
|
||||
elif idVendor and idProduct:
|
||||
printer = Usb(int(idVendor), int(idProduct), 0)
|
||||
else:
|
||||
printer = Dummy()
|
||||
|
||||
# Imprime el encabezado
|
||||
printer.set(align='center', bold=False, height=1, width=1)
|
||||
printer.text(d["shop_name"]+'\n')
|
||||
@ -94,9 +101,9 @@ def print_bill(data, address, waiter):
|
||||
printer.cut()
|
||||
printer.close()
|
||||
# Obtiene el contenido del ticket de prueba
|
||||
ticket_contenido = printer.output
|
||||
# ticket_contenido = printer.output
|
||||
# Imprime el contenido en la consola
|
||||
sys.stdout.write(ticket_contenido.decode('utf-8'))
|
||||
# sys.stdout.write(ticket_contenido.decode('utf-8'))
|
||||
|
||||
|
||||
def print_customer_order(data, address, waiter):
|
||||
@ -170,6 +177,7 @@ def print_ticket_bill(info: Info):
|
||||
info = dict(info)
|
||||
data = info["content"]
|
||||
address = info["ip_printer"]
|
||||
|
||||
waiter = info["user_name"]
|
||||
data = json.loads(data.replace("'", "\""))
|
||||
print_bill(data, address, waiter)
|
||||
|
Loading…
Reference in New Issue
Block a user