se cambiò el tamaño del campo serie y se agregò nuevos reportes
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -29,7 +29,7 @@ export class Equipo {
|
||||
@Column({ type: 'varchar', length: 10, nullable: true })
|
||||
inventario: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 15, nullable: true })
|
||||
@Column({ type: 'varchar', length: 30, nullable: true })
|
||||
serie: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 200, nullable: true })
|
||||
|
||||
@@ -303,6 +303,32 @@ export class EquipoController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_laboratorio')
|
||||
async reporte_contar_laboratorio() {
|
||||
try {
|
||||
return await this.equipoService.laboratorio_equipos();
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte perifericos_antiguedad:',
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('reporte/contar_proyecto')
|
||||
async reporte_contar_proyecto() {
|
||||
try {
|
||||
return await this.equipoService.proyecto_equipos();
|
||||
} catch (error) {
|
||||
throw new BadRequestException(
|
||||
'Error al generar el reporte perifericos_antiguedad:',
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let escritorio = ['ESCRITORIO PC', 'ESCRITORIO MAC OS ', 'ESCRITORIO LINUX'];
|
||||
|
||||
@@ -454,27 +454,15 @@ export class EquipoService {
|
||||
}
|
||||
|
||||
async contar_tipoEquipos_antiguedad(): Promise<any> {
|
||||
const totalEscrtitorio = this.contar_tipoEquipos([
|
||||
'ESCRITORIO PC',
|
||||
'ESCRITORIO MAC OS',
|
||||
'ESCRITORIO LINUX',
|
||||
]);
|
||||
const totalPortatiles = this.contar_tipoEquipos([
|
||||
'PORTÁTILES WINDOWS',
|
||||
'PORTÁTILES CHROMEBOOK',
|
||||
'PORTÁTILES MAC OS',
|
||||
]);
|
||||
const totalAltoRendimiento = this.contar_tipoEquipos(['SERVIDOR']);
|
||||
const totalEscrtitorio = await this.contar_tipoEquipos(escritorio);
|
||||
const totalPortatiles = await this.contar_tipoEquipos(portatil);
|
||||
const totalAltoRendimiento = await this.contar_tipoEquipos(['SERVIDOR']);
|
||||
try {
|
||||
const countEscritorios = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', {
|
||||
tipo_equipo: [
|
||||
'ESCRITORIO PC',
|
||||
'ESCRITORIO MAC OS',
|
||||
'ESCRITORIO LINUX',
|
||||
],
|
||||
tipo_equipo: escritorio,
|
||||
})
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
@@ -484,11 +472,7 @@ export class EquipoService {
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.tipoEquipo', 't')
|
||||
.where('t.tipo_equipo IN (:...tipo_equipo)', {
|
||||
tipo_equipo: [
|
||||
'PORTÁTILES WINDOWS',
|
||||
'PORTÁTILES CHROMEBOOK',
|
||||
'PORTÁTILES MAC OS',
|
||||
],
|
||||
tipo_equipo: portatil,
|
||||
})
|
||||
.select(['e.antiguedad AS antiguedad'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
@@ -511,43 +495,22 @@ export class EquipoService {
|
||||
porcentaje: string;
|
||||
}
|
||||
|
||||
let porcentajesEscritorios: Porcentaje[] = [];
|
||||
let porcentajesPortatiles: Porcentaje[] = [];
|
||||
let porcentajesAltoRendimiento: Porcentaje[] = [];
|
||||
|
||||
countEscritorios.forEach(async (item) => {
|
||||
porcentajesEscritorios.push({
|
||||
antiguedad: item.antiguedad,
|
||||
total: item.total,
|
||||
porcentaje: ((item.total / (await totalEscrtitorio)) * 100).toFixed(
|
||||
2,
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
countPortatiles.forEach(async (item) => {
|
||||
porcentajesPortatiles.push({
|
||||
antiguedad: item.antiguedad,
|
||||
total: item.total,
|
||||
porcentaje: ((item.total / (await totalPortatiles)) * 100).toFixed(2),
|
||||
});
|
||||
});
|
||||
|
||||
countAltoRendimiento.forEach(async (item) => {
|
||||
porcentajesAltoRendimiento.push({
|
||||
antiguedad: item.antiguedad,
|
||||
total: item.total,
|
||||
porcentaje: (
|
||||
(item.total / (await totalAltoRendimiento)) *
|
||||
100
|
||||
).toFixed(2),
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
escritorios: porcentajesEscritorios,
|
||||
portatiles: porcentajesPortatiles,
|
||||
altoRendimiento: porcentajesAltoRendimiento,
|
||||
escritorios: countEscritorios.map((i) => ({
|
||||
antiguedad: i.antiguedad,
|
||||
total: i.total,
|
||||
porcentaje: ((i.total / totalEscrtitorio) * 100).toFixed(2),
|
||||
})),
|
||||
portatiles: countPortatiles.map((i) => ({
|
||||
antiguedad: i.antiguedad,
|
||||
total: i.total,
|
||||
porcentaje: ((i.total / totalPortatiles) * 100).toFixed(2),
|
||||
})),
|
||||
altoRendimiento: countAltoRendimiento.map((i) => ({
|
||||
antiguedad: i.antiguedad,
|
||||
total: i.total,
|
||||
porcentaje: ((i.total / totalAltoRendimiento) * 100).toFixed(2),
|
||||
})),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error al contar equipos por tipo y uso:', error);
|
||||
@@ -724,6 +687,40 @@ export class EquipoService {
|
||||
}
|
||||
}
|
||||
|
||||
async proyecto_equipos() {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.proyecto', 'p')
|
||||
.select(['p.proyecto AS proyecto'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('p.proyecto')
|
||||
.getRawMany();
|
||||
|
||||
return count;
|
||||
} catch (error) {
|
||||
console.error('Error al contar equipos proyectos:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async laboratorio_equipos() {
|
||||
try {
|
||||
const count = await this.equipoRepository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoin('e.laboratorio', 'l')
|
||||
.select(['l.laboratorio AS laboratorio'])
|
||||
.addSelect('COUNT(*) AS total')
|
||||
.groupBy('l.laboratorio')
|
||||
.getRawMany();
|
||||
|
||||
return count;
|
||||
} catch (error) {
|
||||
console.error('Error al contar equipos proyectos:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async generar_reporte() {
|
||||
const [
|
||||
contar_equipos_de_tipo_uso,
|
||||
@@ -746,6 +743,8 @@ export class EquipoService {
|
||||
contar_digitalizacion,
|
||||
contar_contar_digitalizacion_u,
|
||||
contar_perifericos_antiguedad,
|
||||
cotar_laboratorios,
|
||||
contar_proyectos,
|
||||
] = await Promise.all([
|
||||
this.contar_tipoEquipos_tipoUso(),
|
||||
this.contar_tipoEquipos_sistemasOperativos(equpos_pc),
|
||||
@@ -767,6 +766,8 @@ export class EquipoService {
|
||||
this.equipos_impesion_group(dijitales),
|
||||
this.contar_periferico_tipoUso(dijitales),
|
||||
this.contar_perifericos_antiguedad(impresoras, dijitales),
|
||||
this.proyecto_equipos(),
|
||||
this.laboratorio_equipos(),
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -790,6 +791,8 @@ export class EquipoService {
|
||||
contar_digitalizacion,
|
||||
contar_contar_digitalizacion_u,
|
||||
contar_perifericos_antiguedad,
|
||||
cotar_laboratorios,
|
||||
contar_proyectos,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -876,15 +879,20 @@ let tabletas = ['TABLETA ANDROID', 'TABLETA iPAD OS'];
|
||||
let impresoras = [
|
||||
'INYECCIÓN TINTA',
|
||||
'LÁSER DE ALTO VOLUMEN B/N',
|
||||
'LÁSER DE ALTO VOLUMEN COLOR',
|
||||
'LÁSER PEQUEÑA B/N',
|
||||
'LÁSER PEQUEÑA COLOR',
|
||||
'MATRIZ DE PUNTOS',
|
||||
'MULTIFUNCIONALES',
|
||||
'IMPRESORA TÉRMICA',
|
||||
'IMPRESORA CREDENCIALES',
|
||||
'PLOTTER',
|
||||
];
|
||||
|
||||
let dijitales = [
|
||||
'3D',
|
||||
'DIGITALIZADOR DE CAMA PLANA PARA OFICINA',
|
||||
'DIGITALIZADOR DE GRAN VOLUMEN',
|
||||
'DIGITALIZADOR CON ALIMENTADOR DE HOJAS PARA OFICINA',
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user