se agregaron reportes por estado
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -25,6 +25,11 @@ export class AuthController {
|
||||
return this.authService.registro(registroDto);
|
||||
}
|
||||
|
||||
@Post('registro/Masivo')
|
||||
registroMasivo(@Body() registroDto: CreateUsuarioDto[]) {
|
||||
return this.authService.registroMasivo(registroDto);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('buscar')
|
||||
search() {
|
||||
@@ -39,8 +44,8 @@ export class AuthController {
|
||||
if (!id_usuario) {
|
||||
throw new NotFoundException('token sin id_usuario');
|
||||
}
|
||||
|
||||
return this.authService.update(registroDto,id_usuario);
|
||||
|
||||
return this.authService.update(registroDto, id_usuario);
|
||||
}
|
||||
|
||||
@Post('login')
|
||||
|
||||
+18
-10
@@ -18,16 +18,13 @@ export class AuthService {
|
||||
private readonly jwtService: JwtService,
|
||||
) {}
|
||||
|
||||
async update(registroDto: UpdateUsuarioDto, id_User:number) {
|
||||
const update_data = await this.usuarioService.actualizarUsuario(
|
||||
id_User,
|
||||
{
|
||||
nombre: registroDto.nombre,
|
||||
contraseñaN: registroDto.contraseñaN,
|
||||
id_tipo_usuario: registroDto.tipoUsuario,
|
||||
contraseñaV: registroDto.contraseñaV,
|
||||
},
|
||||
);
|
||||
async update(registroDto: UpdateUsuarioDto, id_User: number) {
|
||||
const update_data = await this.usuarioService.actualizarUsuario(id_User, {
|
||||
nombre: registroDto.nombre,
|
||||
contraseñaN: registroDto.contraseñaN,
|
||||
id_tipo_usuario: registroDto.tipoUsuario,
|
||||
contraseñaV: registroDto.contraseñaV,
|
||||
});
|
||||
return update_data;
|
||||
}
|
||||
|
||||
@@ -59,6 +56,17 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
async registroMasivo(usuarios: CreateUsuarioDto[]) {
|
||||
let resultados: string[] = [];
|
||||
|
||||
for (const usuario of usuarios) {
|
||||
const creado = await this.registro(usuario);
|
||||
resultados.push(creado.message);
|
||||
}
|
||||
|
||||
return resultados;
|
||||
}
|
||||
|
||||
async login({ nombre, contraseña }: LoginDto) {
|
||||
const usuario = await this.usuarioService.findOneByName(nombre);
|
||||
if (!usuario) {
|
||||
|
||||
@@ -146,21 +146,20 @@ export class EquipoController {
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte')
|
||||
async reporte() {
|
||||
@Post('reporte')
|
||||
async reporte(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.generar_reporte();
|
||||
return await this.equipoService.generar_reporte(estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException('Error al generar el reporte:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/tipoEquipos_tipoUso')
|
||||
async reportetipoEquipos_tipoUso() {
|
||||
@Post('reporte/tipoEquipos_tipoUso')
|
||||
async reportetipoEquipos_tipoUso(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.contar_tipoEquipos_tipoUso();
|
||||
return await this.equipoService.contar_tipoEquipos_tipoUso(estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte tipoEquipos_tipoUso:',
|
||||
@@ -170,19 +169,30 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/tipoEquipos_sistemasOperativos')
|
||||
async reportetipoEquipos_sistemasOperativos() {
|
||||
@Post('reporte/tipoEquipos_sistemasOperativos')
|
||||
async reportetipoEquipos_sistemasOperativos(@Body() estado: string[]) {
|
||||
try {
|
||||
return await Promise.all([
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(equpos_pc),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos([
|
||||
estritorio_mac,
|
||||
]),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(portatiles),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos([
|
||||
portatiles_mac,
|
||||
]),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos([servidor]),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(
|
||||
equpos_pc,
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(
|
||||
[estritorio_mac],
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(
|
||||
portatiles,
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(
|
||||
[portatiles_mac],
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_sistemasOperativos(
|
||||
[servidor],
|
||||
estado,
|
||||
),
|
||||
]);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
@@ -193,15 +203,21 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/tipoEquipos_procesador')
|
||||
async reportetipoEquipos_procesador() {
|
||||
@Post('reporte/tipoEquipos_procesador')
|
||||
async reportetipoEquipos_procesador(@Body() estado: string[]) {
|
||||
try {
|
||||
return await Promise.all([
|
||||
this.equipoService.contar_tipoEquipos_procesador(equpos_pc),
|
||||
this.equipoService.contar_tipoEquipos_procesador([estritorio_mac]),
|
||||
this.equipoService.contar_tipoEquipos_procesador(portatiles),
|
||||
this.equipoService.contar_tipoEquipos_procesador([portatiles_mac]),
|
||||
this.equipoService.contar_tipoEquipos_procesador([servidor]),
|
||||
this.equipoService.contar_tipoEquipos_procesador(equpos_pc, estado),
|
||||
this.equipoService.contar_tipoEquipos_procesador(
|
||||
[estritorio_mac],
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_procesador(portatiles, estado),
|
||||
this.equipoService.contar_tipoEquipos_procesador(
|
||||
[portatiles_mac],
|
||||
estado,
|
||||
),
|
||||
this.equipoService.contar_tipoEquipos_procesador([servidor], estado),
|
||||
]);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
@@ -212,10 +228,10 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/tipoEquipos_antiguedad')
|
||||
async reportetipoEquipos_antiguedad() {
|
||||
@Post('reporte/tipoEquipos_antiguedad')
|
||||
async reportetipoEquipos_antiguedad(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.contar_tipoEquipos_antiguedad();
|
||||
return await this.equipoService.contar_tipoEquipos_antiguedad(estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte contar_tipoEquipos_antiguedad:',
|
||||
@@ -225,13 +241,13 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/garantia')
|
||||
async reportegarantia() {
|
||||
@Post('reporte/garantia')
|
||||
async reportegarantia(@Body() estado: string[]) {
|
||||
try {
|
||||
return await Promise.all([
|
||||
this.equipoService.garantia(escritorio),
|
||||
this.equipoService.garantia(portatil),
|
||||
this.equipoService.garantia([servidor]),
|
||||
this.equipoService.garantia(escritorio, estado),
|
||||
this.equipoService.garantia(portatil, estado),
|
||||
this.equipoService.garantia([servidor], estado),
|
||||
]);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
@@ -242,10 +258,13 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/equipos_impesion_group/impresoras')
|
||||
async reporteequipos_impesion_group() {
|
||||
@Post('reporte/equipos_impesion_group/impresoras')
|
||||
async reporteequipos_impesion_group(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.equipos_impesion_group(impresoras);
|
||||
return await this.equipoService.equipos_impesion_group(
|
||||
impresoras,
|
||||
estado,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte impesion_group impresoras:',
|
||||
@@ -255,10 +274,10 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/equipos_impesion_group/dijitales')
|
||||
async reporteequipos_impesion_group_dijitales() {
|
||||
@Post('reporte/equipos_impesion_group/dijitales')
|
||||
async reporteequipos_impesion_group_dijitales(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.equipos_impesion_group(dijitales);
|
||||
return await this.equipoService.equipos_impesion_group(dijitales, estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte impesion_group dijitales:',
|
||||
@@ -268,10 +287,13 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_periferico_tipoUso/impresoras')
|
||||
async reporte_contar_periferico_tipoUso_impresoras() {
|
||||
@Post('reporte/contar_periferico_tipoUso/impresoras')
|
||||
async reporte_contar_periferico_tipoUso_impresoras(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.contar_periferico_tipoUso(impresoras);
|
||||
return await this.equipoService.contar_periferico_tipoUso(
|
||||
impresoras,
|
||||
estado,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte periferico_tipoUso impresoras:',
|
||||
@@ -281,10 +303,13 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_periferico_tipoUso/dijtales')
|
||||
async reporte_contar_periferico_tipoUso_dijtales() {
|
||||
@Post('reporte/contar_periferico_tipoUso/dijtales')
|
||||
async reporte_contar_periferico_tipoUso_dijtales(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.contar_periferico_tipoUso(dijitales);
|
||||
return await this.equipoService.contar_periferico_tipoUso(
|
||||
dijitales,
|
||||
estado,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte periferico_tipoUso dijtales:',
|
||||
@@ -294,12 +319,13 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_perifericos_antiguedad')
|
||||
async reporte_contar_perifericos_antiguedad() {
|
||||
@Post('reporte/contar_perifericos_antiguedad')
|
||||
async reporte_contar_perifericos_antiguedad(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.contar_perifericos_antiguedad(
|
||||
impresoras,
|
||||
dijitales,
|
||||
estado,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
@@ -310,10 +336,10 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_laboratorio')
|
||||
async reporte_contar_laboratorio() {
|
||||
@Post('reporte/contar_laboratorio')
|
||||
async reporte_contar_laboratorio(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.laboratorio_equipos();
|
||||
return await this.equipoService.laboratorio_equipos(estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte perifericos_antiguedad:',
|
||||
@@ -323,10 +349,10 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_proyecto')
|
||||
async reporte_contar_proyecto() {
|
||||
@Post('reporte/contar_proyecto')
|
||||
async reporte_contar_proyecto(@Body() estado: string[]) {
|
||||
try {
|
||||
return await this.equipoService.proyecto_equipos();
|
||||
return await this.equipoService.proyecto_equipos(estado);
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte perifericos_antiguedad:',
|
||||
|
||||
@@ -436,14 +436,16 @@ export class EquipoService {
|
||||
return objectParse;
|
||||
}
|
||||
|
||||
async contar_tipoEquipos_tipoUso(): Promise<any> {
|
||||
async contar_tipoEquipos_tipoUso(estado: string[]): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't') // une la tabla usuario
|
||||
.innerJoin('e.tipoUso', 'u') // une la tabla categoria
|
||||
.innerJoin('e.estado', 'es')
|
||||
.select(['u.tipo_uso AS uso', 't.tipo_equipo AS categoria'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.groupBy('t.id_tipo_de_equipo')
|
||||
.addGroupBy('u.id_uso')
|
||||
.getRawMany();
|
||||
@@ -457,13 +459,16 @@ export class EquipoService {
|
||||
|
||||
async contar_tipoEquipos_sistemasOperativos(
|
||||
tipo_equipo: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.sistemaOperativo', 's')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', { tipo_equipo })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['s.sistema_operativo AS sistema_operativo'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('s.sistema_operativo')
|
||||
@@ -476,14 +481,19 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async contar_tipoEquipos_procesador(tipo_equipo: string[]): Promise<any> {
|
||||
async contar_tipoEquipos_procesador(
|
||||
tipo_equipo: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.procesador', 'p')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.tipoUso', 'u')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', { tipo_equipo })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['p.procesador AS procesador', 'u.tipo_uso AS uso'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('p.procesador')
|
||||
@@ -497,12 +507,17 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async contar_tipoEquipos(tipo_equipo: string[]): Promise<any> {
|
||||
async contar_tipoEquipos(
|
||||
tipo_equipo: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', { tipo_equipo })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select('COUNT(*) AS total')
|
||||
.getRawOne();
|
||||
|
||||
@@ -513,27 +528,34 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async contar_tipoEquipos_antiguedad(): Promise<any> {
|
||||
const totalEscrtitorio = await this.contar_tipoEquipos(escritorio);
|
||||
const totalPortatiles = await this.contar_tipoEquipos(portatil);
|
||||
const totalAltoRendimiento = await this.contar_tipoEquipos(['SERVIDOR']);
|
||||
async contar_tipoEquipos_antiguedad(estado: string[]): Promise<any> {
|
||||
const totalEscrtitorio = await this.contar_tipoEquipos(escritorio, estado);
|
||||
const totalPortatiles = await this.contar_tipoEquipos(portatil, estado);
|
||||
const totalAltoRendimiento = await this.contar_tipoEquipos(
|
||||
['SERVIDOR'],
|
||||
estado,
|
||||
);
|
||||
try {
|
||||
const countEscritorios = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', {
|
||||
tipo_equipo: escritorio,
|
||||
})
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('e.antiguedad')
|
||||
.getRawMany();
|
||||
const countPortatiles = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', {
|
||||
tipo_equipo: portatil,
|
||||
})
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('e.antiguedad')
|
||||
@@ -541,9 +563,11 @@ export class EquipoService {
|
||||
const countAltoRendimiento = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', {
|
||||
tipo_equipo: ['SERVIDOR'],
|
||||
})
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('e.antiguedad')
|
||||
@@ -574,13 +598,15 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async garantia(tipo_equipo: string[]): Promise<any> {
|
||||
async garantia(tipo_equipo: string[], estado: string[]): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('e.fechaFactura >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR)')
|
||||
.andWhere('t.tipo_equipo IN (:...tipo_equipo)', { tipo_equipo })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.getCount();
|
||||
|
||||
return count;
|
||||
@@ -590,13 +616,18 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async equipos_impesion(perifericos: string[]): Promise<any> {
|
||||
async equipos_impesion(
|
||||
perifericos: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.select(['p.periferico AS periferico'])
|
||||
.where('p.periferico IN (:...perifericos)', { perifericos })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.getCount();
|
||||
|
||||
return count;
|
||||
@@ -606,12 +637,17 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async equipos_impesion_group(perifericos: string[]): Promise<any> {
|
||||
async equipos_impesion_group(
|
||||
perifericos: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('p.periferico IN (:...perifericos)', { perifericos })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select('p.periferico AS periferico')
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('p.periferico')
|
||||
@@ -624,13 +660,18 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async contar_periferico_tipoUso(perifericos: string[]): Promise<any> {
|
||||
async contar_periferico_tipoUso(
|
||||
perifericos: string[],
|
||||
estado: string[],
|
||||
): Promise<any> {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoUso', 't')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('p.periferico IN (:...perifericos)', { perifericos })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['t.tipo_uso AS uso'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('t.tipo_uso')
|
||||
@@ -646,6 +687,7 @@ export class EquipoService {
|
||||
async contar_perifericos_antiguedad(
|
||||
impresion: string[],
|
||||
digitalizacion: string[],
|
||||
estado: string[],
|
||||
): Promise<{
|
||||
impresion: { antiguedad: any; total: number; porcentaje: string }[];
|
||||
digitalizacion: { antiguedad: any; total: number; porcentaje: string }[];
|
||||
@@ -657,7 +699,9 @@ export class EquipoService {
|
||||
return this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('p.periferico IN (:...tipos)', { tipos })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select('COUNT(*) AS total')
|
||||
.getRawOne();
|
||||
};
|
||||
@@ -677,7 +721,9 @@ export class EquipoService {
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('p.periferico IN (:...periferico)', { periferico: impresion })
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(e.id_equipo) AS total')
|
||||
.groupBy('e.antiguedad')
|
||||
@@ -688,9 +734,11 @@ export class EquipoService {
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.periferico', 'p')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.where('p.periferico IN (:...periferico)', {
|
||||
periferico: digitalizacion,
|
||||
})
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(e.id_equipo) AS total')
|
||||
.groupBy('e.antiguedad')
|
||||
@@ -748,12 +796,14 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async proyecto_equipos() {
|
||||
async proyecto_equipos(estado: string[]) {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.proyecto', 'p')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.select(['p.proyecto AS proyecto'])
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('p.proyecto')
|
||||
.getRawMany();
|
||||
@@ -765,12 +815,14 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async laboratorio_equipos() {
|
||||
async laboratorio_equipos(estado: string[]) {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.laboratorio', 'l')
|
||||
.innerJoin('e.estado', 'es')
|
||||
.select(['l.laboratorio AS laboratorio'])
|
||||
.andWhere('es.estado IN (:...estado)', { estado })
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('l.laboratorio')
|
||||
.getRawMany();
|
||||
@@ -782,7 +834,7 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async generar_reporte() {
|
||||
async generar_reporte(estado: string[] = estado_excluidos) {
|
||||
const [
|
||||
contar_equipos_de_tipo_uso,
|
||||
sisitema_operativo_pc,
|
||||
@@ -807,28 +859,28 @@ export class EquipoService {
|
||||
cotar_laboratorios,
|
||||
contar_proyectos,
|
||||
] = await Promise.all([
|
||||
this.contar_tipoEquipos_tipoUso(),
|
||||
this.contar_tipoEquipos_sistemasOperativos(equpos_pc),
|
||||
this.contar_tipoEquipos_sistemasOperativos([estritorio_mac]),
|
||||
this.contar_tipoEquipos_sistemasOperativos(portatiles),
|
||||
this.contar_tipoEquipos_sistemasOperativos([portatiles_mac]),
|
||||
this.contar_tipoEquipos_sistemasOperativos([servidor]),
|
||||
this.contar_tipoEquipos_procesador(equpos_pc),
|
||||
this.contar_tipoEquipos_procesador([estritorio_mac]),
|
||||
this.contar_tipoEquipos_procesador(portatiles),
|
||||
this.contar_tipoEquipos_procesador([portatiles_mac]),
|
||||
this.contar_tipoEquipos_procesador([servidor]),
|
||||
this.contar_tipoEquipos_antiguedad(),
|
||||
this.garantia(escritorio),
|
||||
this.garantia(portatil),
|
||||
this.garantia([servidor]),
|
||||
this.equipos_impesion_group(impresoras),
|
||||
this.contar_periferico_tipoUso(impresoras),
|
||||
this.equipos_impesion_group(dijitales),
|
||||
this.contar_periferico_tipoUso(dijitales),
|
||||
this.contar_perifericos_antiguedad(impresoras, dijitales),
|
||||
this.proyecto_equipos(),
|
||||
this.laboratorio_equipos(),
|
||||
this.contar_tipoEquipos_tipoUso(estado),
|
||||
this.contar_tipoEquipos_sistemasOperativos(equpos_pc, estado),
|
||||
this.contar_tipoEquipos_sistemasOperativos([estritorio_mac], estado),
|
||||
this.contar_tipoEquipos_sistemasOperativos(portatiles, estado),
|
||||
this.contar_tipoEquipos_sistemasOperativos([portatiles_mac], estado),
|
||||
this.contar_tipoEquipos_sistemasOperativos([servidor], estado),
|
||||
this.contar_tipoEquipos_procesador(equpos_pc, estado),
|
||||
this.contar_tipoEquipos_procesador([estritorio_mac], estado),
|
||||
this.contar_tipoEquipos_procesador(portatiles, estado),
|
||||
this.contar_tipoEquipos_procesador([portatiles_mac], estado),
|
||||
this.contar_tipoEquipos_procesador([servidor], estado),
|
||||
this.contar_tipoEquipos_antiguedad(estado),
|
||||
this.garantia(escritorio, estado),
|
||||
this.garantia(portatil, estado),
|
||||
this.garantia([servidor], estado),
|
||||
this.equipos_impesion_group(impresoras, estado),
|
||||
this.contar_periferico_tipoUso(impresoras, estado),
|
||||
this.equipos_impesion_group(dijitales, estado),
|
||||
this.contar_periferico_tipoUso(dijitales, estado),
|
||||
this.contar_perifericos_antiguedad(impresoras, dijitales, estado),
|
||||
this.proyecto_equipos(estado),
|
||||
this.laboratorio_equipos(estado),
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -920,6 +972,9 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
let estado_excluidos = ['DE BAJA'];
|
||||
let estado_inclyuidos = ['EN DESUSO', 'EN USO'];
|
||||
|
||||
let escritorio = ['ESCRITORIO PC', 'ESCRITORIO MAC OS ', 'ESCRITORIO LINUX'];
|
||||
let portatil = [
|
||||
'PORTÁTILES WINDOWS',
|
||||
|
||||
Reference in New Issue
Block a user