Erwin Jacimino пре 8 месеци
родитељ
комит
0f38b791da
3 измењених фајлова са 14 додато и 8 уклоњено
  1. 10 0
      check_printer.sh
  2. 3 7
      routes/orders.py
  3. 1 1
      services/print_service.py

+ 10 - 0
check_printer.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+PORTS=(6010 6012 6014 6016)
+AUTH="Authorization: Bearer PRINTER123cerveza@"
+
+for PORT in "${PORTS[@]}"; do
+    echo "Checking printer on port $PORT..."
+    RESPONSE=$(curl -s "http://localhost:$PORT/status" -H "$AUTH")
+    echo "Port $PORT response: $RESPONSE"
+done

+ 3 - 7
routes/orders.py

@@ -242,6 +242,7 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
             logger.info(f"Order pizza printed successfully for table {table}")
         if burger_items:
             ps.print_order(Order(table=table, items=burger_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.BURGUER)
+            logger.info(f"Order burger printed successfully for table {table}")
         if bar_items:
             ps.print_order(Order(table=table, items=bar_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.BAR)
             logger.info(f"Order bar printed successfully for table {table}")
@@ -256,16 +257,11 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
     except Exception as e:
         error_msg = f"Error printing order for table {table}: {e}"
         logger.error(error_msg)
+        return JSONResponse(status_code=500, content={"message": "Error interno del servidor"})
         # Don't fail the order for print issues, just log it
 
-    # Log order
-    try:
-        logger.info(f"Logging order for table {table} with sale ID {sale}, products= {[(product.name, item.quantity) for product, item in zip(products, items)]}")
+    logger.info(f"Logging order for table {table} with sale ID {sale}, products= {[(product.name, item.quantity) for product, item in zip(products, items)]}")
         
-    except Exception as e:
-        logger.error(f"Error in legacy order logging: {e}")
-        # Don't fail the order for logging issues
-
     logger.info(f"Order processing completed successfully for table {table}, sale ID: {sale}")
     return JSONResponse({"message": SuccessResponse.ORDER_SUCCESS, "new_progress": new_progress})
 

+ 1 - 1
services/print_service.py

@@ -44,7 +44,7 @@ def print_order(order: Order, location:Locations ):
             "orderDate": order.orderDate
         }
         
-        logger.info(f"Order data prepared for printing: table={order.table}, items={len(order.items)}, total={order.totalAmount}")
+        logger.info(f"Order data prepared for printing: table={order.table}, items={order.items}, total={order.totalAmount}")
         
 
         # Send the order data to the printer service