From df87cb3c58afcc2e73f3837201f18d945f65cca9 Mon Sep 17 00:00:00 2001 From: Emilio Date: Fri, 21 Nov 2025 10:21:29 -0600 Subject: [PATCH] =?UTF-8?q?se=20cambi=C3=B2=20el=20tama=C3=B1o=20del=20cam?= =?UTF-8?q?po=20serie=20y=20se=20agreg=C3=B2=20nuevos=20reportes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mariadb/aria_log.00000001 | Bin 5144576 -> 5152768 bytes mariadb/aria_log_control | Bin 52 -> 52 bytes src/equipo/entities/equipo.entity.ts | 2 +- src/equipo/equipo.controller.ts | 26 ++++++ src/equipo/equipo.service.ts | 122 ++++++++++++++------------- 5 files changed, 92 insertions(+), 58 deletions(-) diff --git a/mariadb/aria_log.00000001 b/mariadb/aria_log.00000001 index c6f62a48a5da79214bd7fd5fccfea1c74abc9c7f..42acfcdeaabe9e01218971d375b21653425340eb 100644 GIT binary patch delta 5588 zcmYkieU&7ox9in?tk~cd;S0Sc|ZHzzoKGi_ln&o?&ucXBQZ{i z9?>(BqF3~eK9L-K=+eUF*?S?IguUb#@HAaIdNW$kMkopCd9|=<94GKZSOK&Or9hXk63D)Ssw;to!c{<}PzG!lt_BVYtAL~xjIRcAg>s-+r~s;kH9(WF z7HAVHfs|6J0>~HE0ZWASK&?;(Gz-@N?ZUM{+DfXf0}6#|V3}||P%mr%T7->2hfo7# zTuId?V6LzkC>3r1wh6Vse&I&oxNsAYbrn@xfCWMwP%hjIGzzx>2ZURJ#4^U~fgIsB zV3BY;P$k>}>=3pBhlD$U7oSwh3kt+c|BDJfjr@3V6pHCP$PT_>=F(EM}*IS)GDeD0|mn8z*3b_6T1B zM}@C|^lPX(0u%{f10}*Yz*gZ~V6V^)bPC@Anb%VFJuqMR0VorW0u913pjG%0=n{Sc zvah4616U~h3{(og0NaIMfrCOPkW|h1Z$Pf_J5VhA0aOdefhOTkpiTG-NV%S>zkz(A z3s@o~)E%Dm|DRs1&<$u7x&!S(B9OL$s#AbMp$D)`=n2#dNkEIx3+NDf0~s5s>I2Lb zl7Uj8FR)EG71%HI1C9$RKvoS^{ecC-0H9nr4QLcnfdj(nK;kCG2Ld_5AYhS@22=@y zfgQpS;E*sBNZw3UI*=y}0~QOzfg0fqV3&{q91+e0Qg5JY1W+KH1uPXZfjVI%utzu> zI4X<+(rc;80*ZvuK#4F0*eaX@>=m+sPT^c2^G2%10`rA&K$(yOGzjMbt-^SqOE@3M zzKN<_V4*Mps1zmw+l32&gF+sVw1x3WK&~(uC>Evw)j~edBwPrz2~&ZTI;t)L@`VCm zi7*YQ6{Z8t!o@(lPza>mOw|maP?!lU6J`PRLJ`m+Tmp0mvrodYf?oX}oA!3ke*k{) BmfipW delta 176 zcmWN=SyF)k007{Llv1KiQkKxZYg0m@O?4R;_#eJIIER^@JUNoLrZ;^vUoaYmg5bX? zAz{-ZX3UD3GcRVrqPQgqNy}EOTC*-?L)xZ{E!(nk@(Okom6Yw;v+uy6BgamhI&<#A urHU)pZrr+4b?-sVqq>HsC(l~iI$peb^X@~}r>~#y-(G**h$aTjzt{vFHa+J6 diff --git a/mariadb/aria_log_control b/mariadb/aria_log_control index 401f3dacf03cf14f6196ff3148b22d69c2ec90f7..a7a34fbfa216c4ade96c508584d5dcf9ddb1618a 100644 GIT binary patch delta 27 gcmXppnII>ovE`BpF delta 27 gcmXppnII>2V%M%%Mh1q{#eNJxilI;pNH8z}0Bv^#+W-In diff --git a/src/equipo/entities/equipo.entity.ts b/src/equipo/entities/equipo.entity.ts index e23b5ab..cbb6c51 100644 --- a/src/equipo/entities/equipo.entity.ts +++ b/src/equipo/entities/equipo.entity.ts @@ -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 }) diff --git a/src/equipo/equipo.controller.ts b/src/equipo/equipo.controller.ts index 3290117..cc856e5 100644 --- a/src/equipo/equipo.controller.ts +++ b/src/equipo/equipo.controller.ts @@ -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']; diff --git a/src/equipo/equipo.service.ts b/src/equipo/equipo.service.ts index 59a75c9..39eb02a 100644 --- a/src/equipo/equipo.service.ts +++ b/src/equipo/equipo.service.ts @@ -454,27 +454,15 @@ export class EquipoService { } async contar_tipoEquipos_antiguedad(): Promise { - 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', ];