assign machine
This commit is contained in:
@@ -7,8 +7,8 @@ export class BitacoraController {
|
|||||||
constructor(private readonly bitacoraService: BitacoraService) {}
|
constructor(private readonly bitacoraService: BitacoraService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
create(@Body() createBitacoraDto: CreateBitacoraDto) {
|
assignment(@Body() createBitacoraDto: CreateBitacoraDto) {
|
||||||
return this.bitacoraService.create(createBitacoraDto);
|
return this.bitacoraService.assignment(createBitacoraDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/cuenta/:id')
|
@Get('/cuenta/:id')
|
||||||
@@ -28,9 +28,9 @@ export class BitacoraController {
|
|||||||
) {
|
) {
|
||||||
return this.bitacoraService.cancelation(id, tiempo_asignado);
|
return this.bitacoraService.cancelation(id, tiempo_asignado);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get()
|
||||||
findAll(@Param('id') id: string) {
|
findAll() {
|
||||||
return this.bitacoraService.findAll();
|
return this.bitacoraService.findAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||||
import { CreateBitacoraDto } from './dto/create-bitacora.dto';
|
import { CreateBitacoraDto } from './dto/create-bitacora.dto';
|
||||||
import { UpdateBitacoraDto } from './dto/update-bitacora.dto';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Bitacora } from './entities/bitacora.entity';
|
import { Bitacora } from './entities/bitacora.entity';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
@@ -11,12 +10,25 @@ export class BitacoraService {
|
|||||||
@InjectRepository(Bitacora)
|
@InjectRepository(Bitacora)
|
||||||
private readonly bitacoraRepository: Repository<Bitacora>,
|
private readonly bitacoraRepository: Repository<Bitacora>,
|
||||||
) {}
|
) {}
|
||||||
create(createBitacoraDto: CreateBitacoraDto) {
|
|
||||||
return 'This action adds a new bitacora';
|
assignment(dto: CreateBitacoraDto) {
|
||||||
|
const bitacora = this.bitacoraRepository.create({
|
||||||
|
tiempo_entrada: new Date(),
|
||||||
|
tiempo_asignado: dto.tiempo_asignado,
|
||||||
|
ubicacion: dto.ubicacion,
|
||||||
|
equipo: { id_equipo: dto.id_equipo },
|
||||||
|
alumno_inscrito: { id_alumno_inscrito: dto.id_alumno_inscrito },
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.bitacoraRepository.save(bitacora);
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return `This action returns all bitacora`;
|
return this.bitacoraRepository.find({
|
||||||
|
take: 100,
|
||||||
|
order: { tiempo_entrada: 'DESC' },
|
||||||
|
relations: ['alumno_inscrito', 'equipo'],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneByAcount(id_cuenta: number) {
|
async findOneByAcount(id_cuenta: number) {
|
||||||
@@ -35,7 +47,7 @@ export class BitacoraService {
|
|||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (!student) {
|
if (!student) {
|
||||||
throw new NotFoundException('Alumno sin equipo asignado');
|
throw new NotFoundException('No cuenta con tiempo asignado');
|
||||||
}
|
}
|
||||||
|
|
||||||
return student;
|
return student;
|
||||||
|
|||||||
@@ -1 +1,16 @@
|
|||||||
export class CreateBitacoraDto {}
|
import { IsInt, IsOptional, IsString } from "class-validator";
|
||||||
|
|
||||||
|
export class CreateBitacoraDto {
|
||||||
|
@IsInt()
|
||||||
|
tiempo_asignado: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
ubicacion?: string;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
id_equipo: number;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
id_alumno_inscrito: number;
|
||||||
|
}
|
||||||
@@ -19,8 +19,8 @@ export class Bitacora {
|
|||||||
@Column({ name: 'tiempo_asignado', type: 'int' })
|
@Column({ name: 'tiempo_asignado', type: 'int' })
|
||||||
tiempo_asignado: number;
|
tiempo_asignado: number;
|
||||||
|
|
||||||
@Column({ name: 'ubicacion', type: 'smallint', nullable: true })
|
@Column({ name: 'ubicacion', nullable: true })
|
||||||
ubicacion: number;
|
ubicacion: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
name: 'fecha_actualizacion',
|
name: 'fecha_actualizacion',
|
||||||
@@ -42,7 +42,7 @@ export class Bitacora {
|
|||||||
{
|
{
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE',
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: 'id_alumno_inscrito' })
|
@JoinColumn({ name: 'id_alumno_inscrito' })
|
||||||
alumno_inscrito: AlumnoInscrito;
|
alumno_inscrito: AlumnoInscrito;
|
||||||
|
|||||||
@@ -53,14 +53,39 @@ export class EquipoService {
|
|||||||
.createQueryBuilder('equipo')
|
.createQueryBuilder('equipo')
|
||||||
.innerJoinAndSelect('equipo.plataforma', 'plataforma')
|
.innerJoinAndSelect('equipo.plataforma', 'plataforma')
|
||||||
.innerJoin('plataforma.alumnos_inscritos', 'ai')
|
.innerJoin('plataforma.alumnos_inscritos', 'ai')
|
||||||
.innerJoin('ai.alumno', 'alumno')
|
|
||||||
.innerJoin('ai.periodo', 'periodo')
|
.innerJoin('ai.periodo', 'periodo')
|
||||||
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
.innerJoin('equipo.areaUbicacion', 'area')
|
||||||
.andWhere("periodo.activo = b'1'")
|
.where('ai.id_cuenta = :id_cuenta', { id_cuenta })
|
||||||
.andWhere("equipo.activo = b'1'")
|
.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();
|
.getMany();
|
||||||
|
|
||||||
if (equipos.length === 0) {
|
if (!equipos.length) {
|
||||||
throw new NotFoundException('No usable equipment found');
|
throw new NotFoundException('No usable equipment found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user