feat(access): paridad funcional de verificacion peaton vs conductor y pulsos a barrera/molinete segun desktop pct_view
This commit is contained in:
@@ -42,6 +42,77 @@ class HardwareService:
|
||||
cursor.execute(query, (modulo_id,))
|
||||
return cursor.fetchone()
|
||||
|
||||
@classmethod
|
||||
def obtener_tipo_acceso(cls, modulo_id: int) -> int:
|
||||
"""
|
||||
Obtiene el tipo_acceso_id (CategoriaID = 15 de MdlCatVal) resolviendo si
|
||||
es un módulo virtual hacia su módulo físico asociado (ModuloEntradaID o ModuloSalidaID).
|
||||
Valores estándar de CatVal (Cat 15):
|
||||
1: Puerta
|
||||
2: Molinete
|
||||
7: Molinete Club
|
||||
3: Barrera de Estado
|
||||
4: Controlado
|
||||
5: Barrera Pulso
|
||||
6: Barrera Doble Pulso
|
||||
"""
|
||||
if not modulo_id:
|
||||
return 0
|
||||
|
||||
mdl = cls.obtener_info_modulo(modulo_id)
|
||||
if not mdl:
|
||||
return 0
|
||||
|
||||
cat_map = {}
|
||||
try:
|
||||
with db_session() as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"SELECT CategoriaID, ValorID FROM MdlCatVal WHERE ModuloID = %s",
|
||||
(modulo_id,),
|
||||
)
|
||||
cat_map = {row[0]: row[1] for row in cursor.fetchall()}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
tipo_modulo_id = cat_map.get(2, 0)
|
||||
sentido_id = cat_map.get(4, 0)
|
||||
nombre_upper = (mdl.get("Nombre") or "").upper()
|
||||
|
||||
target_id = modulo_id
|
||||
if tipo_modulo_id == 6 or mdl.get("Address", 0) >= 90:
|
||||
if (sentido_id == 1 or "ENTRADA" in nombre_upper or "INGRESO" in nombre_upper) and mdl.get("ModuloEntradaID"):
|
||||
target_id = mdl["ModuloEntradaID"]
|
||||
elif (sentido_id == 2 or "SALIDA" in nombre_upper or "EGRESO" in nombre_upper) and mdl.get("ModuloSalidaID"):
|
||||
target_id = mdl["ModuloSalidaID"]
|
||||
|
||||
target_cat_map = {}
|
||||
if target_id != modulo_id:
|
||||
try:
|
||||
with db_session() as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"SELECT CategoriaID, ValorID FROM MdlCatVal WHERE ModuloID = %s",
|
||||
(target_id,),
|
||||
)
|
||||
target_cat_map = {row[0]: row[1] for row in cursor.fetchall()}
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
target_cat_map = cat_map
|
||||
|
||||
tipo_acceso = target_cat_map.get(15) or cat_map.get(15, 3)
|
||||
return int(tipo_acceso)
|
||||
|
||||
@classmethod
|
||||
def es_acceso_peatonal(cls, modulo_id: int) -> bool:
|
||||
"""
|
||||
Devuelve True si el acceso está configurado como Puerta (1), Molinete (2) o Molinete Club (7).
|
||||
Idéntico a pct_view.py:2862 (`tipo_acc_mod in (1, 2, 7)`).
|
||||
"""
|
||||
tipo_acceso = cls.obtener_tipo_acceso(modulo_id)
|
||||
return tipo_acceso in (1, 2, 7)
|
||||
|
||||
@classmethod
|
||||
def encolar_apertura(
|
||||
cls, modulo_id: int, ticket_id: int = 0, sin_ticket: bool = False
|
||||
|
||||
Reference in New Issue
Block a user