feat: complete Phases 2 to 5 inclusive - Access Core, Web Cockpit, Hardware enqueuing, Optical Scanner and QA (v0.5.0-beta)

This commit is contained in:
Carlos Tello
2026-10-13 15:47:43 -03:00
parent 78c1a306de
commit 1ba74f7929
53 changed files with 4000 additions and 279 deletions
@@ -0,0 +1,51 @@
# ==============================================================================
# Repositorio de Workstations y Carriles en SQL Server (videoman)
# ==============================================================================
from typing import Optional, List, Dict, Any
from app.core.database import db_session
class WorkstationRepository:
@staticmethod
def obtener_workstation_por_nombre(name: str) -> Optional[Dict[str, Any]]:
"""Busca una estación de trabajo por nombre en la tabla `wks`."""
query = """
SELECT WorkstationID, Nombre, SystemParameter
FROM wks
WHERE LOWER(Nombre) = LOWER(%s)
"""
with db_session() as conn:
cursor = conn.cursor(as_dict=True)
cursor.execute(query, (name.strip(),))
return cursor.fetchone()
@staticmethod
def listar_modulos_por_workstation(workstation_id: int) -> List[Dict[str, Any]]:
"""Obtiene la lista de módulos de hardware / carriles vinculados a la estación."""
query = """
SELECT
m.ModuloID,
m.Nombre,
m.Address,
m.GrupoModulos,
m.ModuloEntradaID,
m.ModuloSalidaID,
m.duracion_pulso
FROM wksmdl wm
JOIN mdl m ON wm.ModuloID = m.ModuloID
WHERE wm.WorkstationID = %s
ORDER BY m.ModuloID
"""
with db_session() as conn:
cursor = conn.cursor(as_dict=True)
cursor.execute(query, (workstation_id,))
return cursor.fetchall()
@staticmethod
def listar_todas() -> List[Dict[str, Any]]:
"""Retorna todas las estaciones de trabajo registradas."""
query = "SELECT WorkstationID, Nombre FROM wks ORDER BY Nombre"
with db_session() as conn:
cursor = conn.cursor(as_dict=True)
cursor.execute(query)
return cursor.fetchall()