assign machine
This commit is contained in:
@@ -53,14 +53,39 @@ export class EquipoService {
|
||||
.createQueryBuilder('equipo')
|
||||
.innerJoinAndSelect('equipo.plataforma', 'plataforma')
|
||||
.innerJoin('plataforma.alumnos_inscritos', 'ai')
|
||||
.innerJoin('ai.alumno', 'alumno')
|
||||
.innerJoin('ai.periodo', 'periodo')
|
||||
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
||||
.andWhere("periodo.activo = b'1'")
|
||||
.andWhere("equipo.activo = b'1'")
|
||||
.innerJoin('equipo.areaUbicacion', 'area')
|
||||
.where('ai.id_cuenta = :id_cuenta', { id_cuenta })
|
||||
.andWhere('periodo.activo = true')
|
||||
|
||||
.andWhere('equipo.activo = true')
|
||||
|
||||
.andWhere('ai.tiempo_disponible > 0')
|
||||
|
||||
.andWhere('area.extra = 0')
|
||||
|
||||
.andWhere((qb) => {
|
||||
const subQuery = qb
|
||||
.subQuery()
|
||||
.select('bitacora.id_equipo')
|
||||
.from('bitacora', 'bitacora')
|
||||
.where(
|
||||
`TIMESTAMPDIFF(
|
||||
SECOND,
|
||||
NOW(),
|
||||
DATE_ADD(bitacora.tiempo_entrada, INTERVAL bitacora.tiempo_asignado MINUTE)
|
||||
) > 0`,
|
||||
)
|
||||
.getQuery();
|
||||
|
||||
return `equipo.id_equipo NOT IN ${subQuery}`;
|
||||
})
|
||||
|
||||
.orderBy('equipo.ubicacion', 'ASC')
|
||||
|
||||
.getMany();
|
||||
|
||||
if (equipos.length === 0) {
|
||||
if (!equipos.length) {
|
||||
throw new NotFoundException('No usable equipment found');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user