Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3dc49766cc | |||
| 36cf0d217b | |||
| 970a6acc0b | |||
| cd5f2efc54 | |||
| b76c98b7fc | |||
| a3eea6bf2e | |||
| d2910bbdd7 |
Generated
+122
-37
@@ -28,7 +28,8 @@
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"typeor": "^1.2.0",
|
||||
"typeorm": "^0.3.27"
|
||||
"typeorm": "^0.3.27",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
@@ -720,9 +721,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@borewit/text-codec": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.1.1.tgz",
|
||||
"integrity": "sha512-5L/uBxmjaCIX5h8Z+uu+kA9BQLkc/Wl06UGR5ajNRxu+/XjonB5i8JpgFMrPj3LXTCPA0pv8yxUvbUi+QthGGA==",
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.2.tgz",
|
||||
"integrity": "sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
@@ -2139,14 +2140,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/common": {
|
||||
"version": "11.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.6.tgz",
|
||||
"integrity": "sha512-krKwLLcFmeuKDqngG2N/RuZHCs2ycsKcxWIDgcm7i1lf3sQ0iG03ci+DsP/r3FcT/eJDFsIHnKtNta2LIi7PzQ==",
|
||||
"version": "11.1.17",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.17.tgz",
|
||||
"integrity": "sha512-hLODw5Abp8OQgA+mUO4tHou4krKgDtUcM9j5Ihxncst9XeyxYBTt2bwZm4e4EQr5E352S4Fyy6V3iFx9ggxKAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"file-type": "21.0.0",
|
||||
"file-type": "21.3.2",
|
||||
"iterare": "1.2.1",
|
||||
"load-esm": "1.0.2",
|
||||
"load-esm": "1.0.3",
|
||||
"tslib": "2.8.1",
|
||||
"uid": "2.0.2"
|
||||
},
|
||||
@@ -2599,14 +2600,13 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tokenizer/inflate": {
|
||||
"version": "0.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.2.7.tgz",
|
||||
"integrity": "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg==",
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.4.1.tgz",
|
||||
"integrity": "sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.4.0",
|
||||
"fflate": "^0.8.2",
|
||||
"token-types": "^6.0.0"
|
||||
"debug": "^4.4.3",
|
||||
"token-types": "^6.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
@@ -3798,6 +3798,15 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/adler-32": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz",
|
||||
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz",
|
||||
@@ -4603,6 +4612,19 @@
|
||||
],
|
||||
"license": "CC-BY-4.0"
|
||||
},
|
||||
"node_modules/cfb": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
|
||||
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"adler-32": "~1.3.0",
|
||||
"crc-32": "~1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/chainsaw": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz",
|
||||
@@ -4840,6 +4862,15 @@
|
||||
"node": ">= 0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/codepage": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz",
|
||||
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/collect-v8-coverage": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.3.tgz",
|
||||
@@ -5998,12 +6029,6 @@
|
||||
"bser": "2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
|
||||
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||
@@ -6018,14 +6043,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/file-type": {
|
||||
"version": "21.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-21.0.0.tgz",
|
||||
"integrity": "sha512-ek5xNX2YBYlXhiUXui3D/BXa3LdqPmoLJ7rqEx2bKJ7EAUEfmXgW0Das7Dc6Nr9MvqaOnIqiPV0mZk/r/UpNAg==",
|
||||
"version": "21.3.2",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-21.3.2.tgz",
|
||||
"integrity": "sha512-DLkUvGwep3poOV2wpzbHCOnSKGk1LzyXTv+aHFgN2VFl96wnp8YA9YjO2qPzg5PuL8q/SW9Pdi6WTkYOIh995w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tokenizer/inflate": "^0.2.7",
|
||||
"strtok3": "^10.2.2",
|
||||
"token-types": "^6.0.0",
|
||||
"@tokenizer/inflate": "^0.4.1",
|
||||
"strtok3": "^10.3.4",
|
||||
"token-types": "^6.1.1",
|
||||
"uint8array-extras": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -6101,9 +6126,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/flatted": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz",
|
||||
"integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==",
|
||||
"version": "3.4.2",
|
||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
|
||||
"integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
@@ -6250,6 +6275,15 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/frac": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz",
|
||||
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/fresh": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
|
||||
@@ -7916,9 +7950,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/load-esm": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.2.tgz",
|
||||
"integrity": "sha512-nVAvWk/jeyrWyXEAs84mpQCYccxRqgKY4OznLuJhJCa0XsPSfdOIr2zvBZEj3IHEHbX97jjscKRRV539bW0Gpw==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.3.tgz",
|
||||
"integrity": "sha512-v5xlu8eHD1+6r8EHTg6hfmO97LN8ugKtiXcy5e6oN72iD2r6u0RPfLl6fxM+7Wnh2ZRq15o0russMst44WauPA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -9801,6 +9835,18 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ssf": {
|
||||
"version": "0.11.2",
|
||||
"resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz",
|
||||
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"frac": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/stack-utils": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz",
|
||||
@@ -10404,12 +10450,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/token-types": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/token-types/-/token-types-6.1.1.tgz",
|
||||
"integrity": "sha512-kh9LVIWH5CnL63Ipf0jhlBIy0UsrMj/NJDfpsy1SqOXlLKEVyXXYrnFxFT1yOOYVGBSApeVnjPw/sBz5BfEjAQ==",
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/token-types/-/token-types-6.1.2.tgz",
|
||||
"integrity": "sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@borewit/text-codec": "^0.1.0",
|
||||
"@borewit/text-codec": "^0.2.1",
|
||||
"@tokenizer/token": "^0.3.0",
|
||||
"ieee754": "^1.2.1"
|
||||
},
|
||||
@@ -11392,6 +11438,24 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/wmf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz",
|
||||
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/word": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz",
|
||||
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/word-wrap": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
|
||||
@@ -11506,6 +11570,27 @@
|
||||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/xlsx": {
|
||||
"version": "0.18.5",
|
||||
"resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz",
|
||||
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"adler-32": "~1.3.0",
|
||||
"cfb": "~1.2.1",
|
||||
"codepage": "~1.15.0",
|
||||
"crc-32": "~1.2.1",
|
||||
"ssf": "~0.11.2",
|
||||
"wmf": "~1.0.1",
|
||||
"word": "~0.3.0"
|
||||
},
|
||||
"bin": {
|
||||
"xlsx": "bin/xlsx.njs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/xmlchars": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"typeor": "^1.2.0",
|
||||
"typeorm": "^0.3.27"
|
||||
"typeorm": "^0.3.27",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
|
||||
+6
-2
@@ -24,7 +24,11 @@ import { AppController } from './app.controller';
|
||||
autoLoadEntities: process.env.AUTOLOAD === 'true',
|
||||
synchronize: process.env.SINCRONIZAR === 'true',
|
||||
logger: 'advanced-console',
|
||||
logging: 'all',
|
||||
logging: ['error', 'warn','log'],
|
||||
|
||||
extra: {
|
||||
connectionLimit: 10,
|
||||
},
|
||||
}),
|
||||
UsuariosModule,
|
||||
MovimientoModule,
|
||||
@@ -34,4 +38,4 @@ import { AppController } from './app.controller';
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule { }
|
||||
|
||||
@@ -27,4 +27,32 @@ export class FiltrosGraficaDto {
|
||||
@IsString({ each: true })
|
||||
antiguedad?: string[]
|
||||
|
||||
}
|
||||
|
||||
export class FiltrosTablaDto {
|
||||
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
adscripciones?: string[]
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
procesadores?: string[]
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
sistemas?: string[]
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
usos?: string[]
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
antiguedad?: string[]
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import { UpdateEquipoDto } from './dto/update-equipo.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import type { Response } from 'express';
|
||||
import { FiltrosGraficaDto } from './dto/grafica.dto';
|
||||
import { FiltrosGraficaDto, FiltrosTablaDto } from './dto/grafica.dto';
|
||||
|
||||
@Controller('equipos')
|
||||
export class EquipoController {
|
||||
@@ -35,13 +35,67 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@Post('grafica/:tipo')
|
||||
async graficaProcesador(
|
||||
async grafica(
|
||||
@Param("tipo") tipo: 'antiguedad' | 'uso' | 'so' | 'procesador',
|
||||
@Body() filtros: FiltrosGraficaDto
|
||||
) {
|
||||
return this.equipoService.grafica(tipo, filtros);
|
||||
}
|
||||
|
||||
@Post('graficaPerifericos/:tipo')
|
||||
async graficaPerifericos(
|
||||
@Param("tipo") tipo: 'antiguedad' | 'uso' | 'so' | 'procesador',
|
||||
@Body() filtros: FiltrosGraficaDto
|
||||
) {
|
||||
return this.equipoService.graficaPerifericos(tipo, filtros);
|
||||
}
|
||||
|
||||
@Post('tabla')
|
||||
async tabla(
|
||||
@Body() filtros: FiltrosTablaDto
|
||||
) {
|
||||
return this.equipoService.tabla(filtros);
|
||||
}
|
||||
|
||||
@Post('tabla/count')
|
||||
async tablacount(
|
||||
@Body() filtros: FiltrosTablaDto
|
||||
) {
|
||||
return this.equipoService.tablaCount(filtros);
|
||||
}
|
||||
|
||||
@Post('excel/tabla')
|
||||
async exceltabla(
|
||||
@Res() res: Response,
|
||||
@Body() filtros: FiltrosTablaDto
|
||||
) {
|
||||
const buffer = await this.equipoService.tablaExcel(filtros);
|
||||
|
||||
res.set({
|
||||
'Content-Type':
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'Content-Disposition': 'attachment; filename=tabla.xlsx',
|
||||
});
|
||||
|
||||
res.send(buffer);
|
||||
}
|
||||
|
||||
@Post('excel/tabla/count')
|
||||
async exceltablacount(
|
||||
@Res() res: Response,
|
||||
@Body() filtros: FiltrosGraficaDto
|
||||
) {
|
||||
const buffer = await this.equipoService.tablaCountExcel(filtros);
|
||||
|
||||
res.set({
|
||||
'Content-Type':
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'Content-Disposition': 'attachment; filename=tabla.xlsx',
|
||||
});
|
||||
|
||||
res.send(buffer);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('buscar/:inv')
|
||||
async serch(@Param('inv') inv: string) {
|
||||
@@ -101,7 +155,7 @@ export class EquipoController {
|
||||
findTiposEquipo() {
|
||||
return this.equipoService.findAllTiposEquipo();
|
||||
}
|
||||
|
||||
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@Get('sistemas-operativos')
|
||||
findSistemasOperativos() {
|
||||
|
||||
+584
-52
@@ -10,6 +10,7 @@ import { UpdateEquipoDto } from './dto/update-equipo.dto';
|
||||
import axios from 'axios';
|
||||
import e, { Response } from 'express';
|
||||
import * as ExcelJS from 'exceljs';
|
||||
|
||||
import {
|
||||
Adscripcion,
|
||||
Estado,
|
||||
@@ -27,7 +28,7 @@ import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
|
||||
import { MovimientoService } from 'src/movimiento/movimiento.service';
|
||||
import { Cron } from '@nestjs/schedule';
|
||||
import { FiltrosGraficaDto } from './dto/grafica.dto';
|
||||
import { FiltrosGraficaDto, FiltrosTablaDto } from './dto/grafica.dto';
|
||||
|
||||
@Injectable()
|
||||
export class EquipoService {
|
||||
@@ -1131,8 +1132,400 @@ export class EquipoService {
|
||||
.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo')
|
||||
.leftJoin('equipo.tipoUso', 'tipoUso')
|
||||
|
||||
// filtros
|
||||
// filtros
|
||||
.andWhere('equipo.id_periferico IS NULL')
|
||||
if (filtros?.adscripciones?.length) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
})
|
||||
.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
.groupBy('equipo.adscripcion')
|
||||
|
||||
}
|
||||
|
||||
if (filtros?.procesadores?.length) {
|
||||
qb.andWhere('procesador.id_procesador IN (:...procesadores)', {
|
||||
procesadores: filtros.procesadores
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.sistemas?.length) {
|
||||
qb.andWhere('sistemaOperativo.id_sistema_operativo IN (:...sistemas)', {
|
||||
sistemas: filtros.sistemas
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.usos?.length) {
|
||||
qb.andWhere('tipoUso.id_uso IN (:...usos)', {
|
||||
usos: filtros.usos
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.antiguedad?.length && !filtros.antiguedad.includes("Todos")) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
})
|
||||
}
|
||||
|
||||
// selector dinámico
|
||||
|
||||
switch (tipo) {
|
||||
|
||||
case 'antiguedad':
|
||||
|
||||
qb.select('equipo.antiguedad', 'antiguedad')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('equipo.antiguedad')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('equipo.antiguedad')
|
||||
|
||||
}
|
||||
|
||||
qb.orderBy(`
|
||||
CASE
|
||||
WHEN equipo.antiguedad = 'Menor a 2 años' THEN 1
|
||||
WHEN equipo.antiguedad = 'Entre 2 y 3 años' THEN 2
|
||||
WHEN equipo.antiguedad = 'Entre 4 y 5 años' THEN 3
|
||||
WHEN equipo.antiguedad = 'Mayor a 6 años' THEN 4
|
||||
END
|
||||
`)
|
||||
|
||||
break
|
||||
|
||||
case 'uso':
|
||||
|
||||
qb.select('tipoUso.tipo_uso', 'uso')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('tipoUso.tipo_uso')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('tipoUso.tipo_uso')
|
||||
|
||||
}
|
||||
|
||||
qb.orderBy(`
|
||||
CASE
|
||||
WHEN tipoUso.tipo_uso = 'ALUMNO' THEN 1
|
||||
WHEN tipoUso.tipo_uso = 'PROFESOR' THEN 2
|
||||
WHEN tipoUso.tipo_uso = 'ADMINISTRATIVO' THEN 3
|
||||
WHEN tipoUso.tipo_uso = 'TÉCNICO ACADEMICO' THEN 4
|
||||
END`)
|
||||
|
||||
break
|
||||
|
||||
case 'so':
|
||||
|
||||
qb.select('sistemaOperativo.sistema_operativo', 'so')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('sistemaOperativo.sistema_operativo')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('sistemaOperativo.sistema_operativo')
|
||||
|
||||
}
|
||||
qb.orderBy(`equipo.adscripcion`, "ASC")
|
||||
|
||||
break
|
||||
|
||||
case 'procesador':
|
||||
|
||||
qb.select('procesador.procesador', 'procesador')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('procesador.procesador')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('procesador.procesador')
|
||||
|
||||
}
|
||||
qb.orderBy(`equipo.adscripcion`, "ASC")
|
||||
|
||||
break
|
||||
|
||||
}
|
||||
return qb.getRawMany()
|
||||
|
||||
}
|
||||
|
||||
async graficaPerifericos(
|
||||
tipo: 'antiguedad' | 'uso' | 'so' | 'procesador',
|
||||
filtros?: FiltrosGraficaDto
|
||||
) {
|
||||
|
||||
const qb = this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.leftJoin('equipo.adscripcion', 'adscripcion')
|
||||
.leftJoin('equipo.procesador', 'procesador')
|
||||
.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo')
|
||||
.leftJoin('equipo.tipoUso', 'tipoUso')
|
||||
|
||||
// filtros
|
||||
.andWhere('equipo.id_periferico IS NOT NULL')
|
||||
if (filtros?.adscripciones?.length) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
})
|
||||
.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
.groupBy('equipo.adscripcion')
|
||||
|
||||
}
|
||||
|
||||
if (filtros?.procesadores?.length) {
|
||||
qb.andWhere('procesador.id_procesador IN (:...procesadores)', {
|
||||
procesadores: filtros.procesadores
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.sistemas?.length) {
|
||||
qb.andWhere('sistemaOperativo.id_sistema_operativo IN (:...sistemas)', {
|
||||
sistemas: filtros.sistemas
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.usos?.length) {
|
||||
qb.andWhere('tipoUso.id_uso IN (:...usos)', {
|
||||
usos: filtros.usos
|
||||
})
|
||||
}
|
||||
|
||||
if (filtros?.antiguedad?.length && !filtros.antiguedad.includes("Todos")) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
})
|
||||
}
|
||||
|
||||
// selector dinámico
|
||||
|
||||
switch (tipo) {
|
||||
|
||||
case 'antiguedad':
|
||||
|
||||
qb.select('equipo.antiguedad', 'antiguedad')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('equipo.antiguedad')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('equipo.antiguedad')
|
||||
|
||||
}
|
||||
|
||||
qb.orderBy(`
|
||||
CASE
|
||||
WHEN equipo.antiguedad = 'Menor a 2 años' THEN 1
|
||||
WHEN equipo.antiguedad = 'Entre 2 y 3 años' THEN 2
|
||||
WHEN equipo.antiguedad = 'Entre 4 y 5 años' THEN 3
|
||||
WHEN equipo.antiguedad = 'Mayor a 6 años' THEN 4
|
||||
END
|
||||
`)
|
||||
|
||||
break
|
||||
|
||||
case 'uso':
|
||||
|
||||
qb.select('tipoUso.tipo_uso', 'uso')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('tipoUso.tipo_uso')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('tipoUso.tipo_uso')
|
||||
|
||||
}
|
||||
|
||||
qb.orderBy(`
|
||||
CASE
|
||||
WHEN tipoUso.tipo_uso = 'ALUMNO' THEN 1
|
||||
WHEN tipoUso.tipo_uso = 'PROFESOR' THEN 2
|
||||
WHEN tipoUso.tipo_uso = 'ADMINISTRATIVO' THEN 3
|
||||
WHEN tipoUso.tipo_uso = 'TÉCNICO ACADEMICO' THEN 4
|
||||
END`)
|
||||
|
||||
break
|
||||
|
||||
case 'so':
|
||||
|
||||
qb.select('sistemaOperativo.sistema_operativo', 'so')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('sistemaOperativo.sistema_operativo')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('sistemaOperativo.sistema_operativo')
|
||||
|
||||
}
|
||||
qb.orderBy(`equipo.adscripcion`, "ASC")
|
||||
|
||||
break
|
||||
|
||||
case 'procesador':
|
||||
|
||||
qb.select('procesador.procesador', 'procesador')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
qb.groupBy('procesador.procesador')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
|
||||
} else {
|
||||
|
||||
qb.groupBy('procesador.procesador')
|
||||
|
||||
}
|
||||
qb.orderBy(`equipo.adscripcion`, "ASC")
|
||||
|
||||
break
|
||||
|
||||
}
|
||||
return qb.getRawMany()
|
||||
|
||||
}
|
||||
|
||||
|
||||
async tabla(filtros?: FiltrosTablaDto) {
|
||||
const qb = this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.select([])
|
||||
|
||||
qb.leftJoin('equipo.adscripcion', 'adscripcion')
|
||||
qb.leftJoin('equipo.procesador', 'procesador')
|
||||
qb.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo')
|
||||
qb.leftJoin('equipo.tipoUso', 'tipoUso')
|
||||
|
||||
qb.addSelect('equipo.inventario', 'inventario')
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
qb.addSelect('equipo.lugar', 'ubicacion')
|
||||
|
||||
const tieneFiltroReal = (arr?: string[]) => arr?.length && !arr.includes("0") && !arr.includes("Todos")
|
||||
qb.andWhere('equipo.id_periferico IS NULL')
|
||||
|
||||
// ADSCRIPCIONES
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
// siempre selecciona
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
|
||||
if (tieneFiltroReal(filtros.adscripciones)) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// PROCESADOR
|
||||
if (filtros?.procesadores?.length) {
|
||||
|
||||
qb.addSelect('procesador.procesador', 'procesador')
|
||||
|
||||
if (tieneFiltroReal(filtros.procesadores)) {
|
||||
qb.andWhere('procesador.id_procesador IN (:...procesadores)', {
|
||||
procesadores: filtros.procesadores
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// SISTEMA OPERATIVO
|
||||
if (filtros?.sistemas?.length) {
|
||||
|
||||
qb.addSelect('sistemaOperativo.sistema_operativo', 'so')
|
||||
|
||||
if (tieneFiltroReal(filtros.sistemas)) {
|
||||
qb.andWhere('sistemaOperativo.id_sistema_operativo IN (:...sistemas)', {
|
||||
sistemas: filtros.sistemas
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// USO
|
||||
if (filtros?.usos?.length) {
|
||||
|
||||
qb.addSelect('tipoUso.tipo_uso', 'uso')
|
||||
|
||||
if (tieneFiltroReal(filtros.usos)) {
|
||||
qb.andWhere('tipoUso.id_uso IN (:...usos)', {
|
||||
usos: filtros.usos
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ANTIGÜEDAD
|
||||
if (filtros?.antiguedad?.length) {
|
||||
|
||||
qb.addSelect('equipo.antiguedad', 'antiguedad')
|
||||
|
||||
if (tieneFiltroReal(filtros.antiguedad)) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return qb
|
||||
.orderBy(`equipo.adscripcion`, "DESC")
|
||||
.getRawMany()
|
||||
}
|
||||
|
||||
async tablaCount(filtros?: FiltrosTablaDto) {
|
||||
const qb = this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.select([])
|
||||
|
||||
qb.leftJoin('equipo.adscripcion', 'adscripcion')
|
||||
qb.leftJoin('equipo.procesador', 'procesador')
|
||||
qb.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo')
|
||||
qb.leftJoin('equipo.tipoUso', 'tipoUso')
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion')
|
||||
qb.andWhere('equipo.id_periferico IS NULL')
|
||||
if (filtros?.adscripciones?.length) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
@@ -1157,61 +1550,200 @@ export class EquipoService {
|
||||
})
|
||||
}
|
||||
|
||||
if(filtros?.antiguedad?.length){
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)',{
|
||||
antiguedad:filtros.antiguedad
|
||||
if (filtros?.antiguedad?.length && !filtros.antiguedad.includes("Todos")) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
})
|
||||
}
|
||||
|
||||
// selector dinámico
|
||||
|
||||
switch (tipo) {
|
||||
|
||||
case 'antiguedad':
|
||||
|
||||
qb.select('equipo.antiguedad', 'antiguedad')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.groupBy('equipo.antiguedad')
|
||||
.orderBy(`
|
||||
CASE
|
||||
WHEN equipo.antiguedad = 'Menor a 2 años' THEN 1
|
||||
WHEN equipo.antiguedad = 'Entre 2 y 3 años' THEN 2
|
||||
WHEN equipo.antiguedad = 'Entre 4 y 5 años' THEN 3
|
||||
WHEN equipo.antiguedad = 'Mayor a 6 años' THEN 4
|
||||
END
|
||||
`)
|
||||
|
||||
break
|
||||
|
||||
case 'uso':
|
||||
|
||||
qb.select('tipoUso.tipo_uso', 'uso')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.groupBy('tipoUso.tipo_uso')
|
||||
|
||||
break
|
||||
|
||||
case 'so':
|
||||
|
||||
qb.select('sistemaOperativo.sistema_operativo', 'so')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.groupBy('sistemaOperativo.sistema_operativo')
|
||||
|
||||
break
|
||||
|
||||
case 'procesador':
|
||||
|
||||
qb.select('procesador.procesador', 'procesador')
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.groupBy('procesador.procesador')
|
||||
|
||||
break
|
||||
|
||||
}
|
||||
return qb.getRawMany()
|
||||
|
||||
return qb
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
.orderBy(`equipo.adscripcion`, "DESC")
|
||||
.getRawMany()
|
||||
}
|
||||
|
||||
async tablaExcel(filtros?: FiltrosTablaDto) {
|
||||
const qb = this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.select([]);
|
||||
|
||||
qb.leftJoin('equipo.adscripcion', 'adscripcion');
|
||||
qb.leftJoin('equipo.procesador', 'procesador');
|
||||
qb.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo');
|
||||
qb.leftJoin('equipo.tipoUso', 'tipoUso');
|
||||
|
||||
qb.addSelect('equipo.inventario', 'inventario');
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion');
|
||||
qb.addSelect('equipo.lugar', 'ubicacion');
|
||||
|
||||
const tieneFiltroReal = (arr?: string[]) => arr?.length && !arr.includes("0") && !arr.includes("Todos");
|
||||
|
||||
qb.andWhere('equipo.id_periferico IS NULL')
|
||||
// ADSCRIPCIONES
|
||||
if (filtros?.adscripciones?.length) {
|
||||
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion');
|
||||
|
||||
if (tieneFiltroReal(filtros.adscripciones)) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// PROCESADOR
|
||||
if (filtros?.procesadores?.length) {
|
||||
|
||||
qb.addSelect('procesador.procesador', 'procesador');
|
||||
|
||||
if (tieneFiltroReal(filtros.procesadores)) {
|
||||
qb.andWhere('procesador.id_procesador IN (:...procesadores)', {
|
||||
procesadores: filtros.procesadores
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// SISTEMA OPERATIVO
|
||||
if (filtros?.sistemas?.length) {
|
||||
|
||||
qb.addSelect('sistemaOperativo.sistema_operativo', 'so');
|
||||
|
||||
if (tieneFiltroReal(filtros.sistemas)) {
|
||||
qb.andWhere('sistemaOperativo.id_sistema_operativo IN (:...sistemas)', {
|
||||
sistemas: filtros.sistemas
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// USO
|
||||
if (filtros?.usos?.length) {
|
||||
|
||||
qb.addSelect('tipoUso.tipo_uso', 'uso');
|
||||
|
||||
if (tieneFiltroReal(filtros.usos)) {
|
||||
qb.andWhere('tipoUso.id_uso IN (:...usos)', {
|
||||
usos: filtros.usos
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ANTIGÜEDAD
|
||||
if (filtros?.antiguedad?.length) {
|
||||
|
||||
qb.addSelect('equipo.antiguedad', 'antiguedad');
|
||||
|
||||
if (tieneFiltroReal(filtros.antiguedad)) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const data = await qb
|
||||
.orderBy(`equipo.adscripcion`, "DESC")
|
||||
.getRawMany();
|
||||
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const sheet = workbook.addWorksheet('Equipos');
|
||||
|
||||
const columns = [
|
||||
{ header: 'Inventario', key: 'inventario', width: 20 },
|
||||
{ header: 'Ubicación', key: 'ubicacion', width: 40 },
|
||||
{ header: 'Adscripción', key: 'adscripcion', width: 40 },
|
||||
];
|
||||
|
||||
if (data[0]?.procesador !== undefined) {
|
||||
columns.push({ header: 'Procesador', key: 'procesador', width: 25 });
|
||||
}
|
||||
|
||||
if (data[0]?.so !== undefined) {
|
||||
columns.push({ header: 'Sistema Operativo', key: 'so', width: 25 });
|
||||
}
|
||||
|
||||
if (data[0]?.uso !== undefined) {
|
||||
columns.push({ header: 'Uso', key: 'uso', width: 20 });
|
||||
}
|
||||
|
||||
if (data[0]?.antiguedad !== undefined) {
|
||||
columns.push({ header: 'Antigüedad', key: 'antiguedad', width: 15 });
|
||||
}
|
||||
|
||||
sheet.columns = columns;
|
||||
|
||||
data.forEach(row => {
|
||||
sheet.addRow(row);
|
||||
});
|
||||
|
||||
sheet.getRow(1).font = { bold: true };
|
||||
|
||||
return await workbook.xlsx.writeBuffer();
|
||||
}
|
||||
|
||||
async tablaCountExcel(filtros?: FiltrosGraficaDto) {
|
||||
const qb = this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.select([]);
|
||||
|
||||
qb.leftJoin('equipo.adscripcion', 'adscripcion');
|
||||
qb.leftJoin('equipo.procesador', 'procesador');
|
||||
qb.leftJoin('equipo.sistemaOperativo', 'sistemaOperativo');
|
||||
qb.leftJoin('equipo.tipoUso', 'tipoUso');
|
||||
qb.addSelect('adscripcion.adscripcion', 'adscripcion');
|
||||
|
||||
qb.andWhere('equipo.id_periferico IS NULL')
|
||||
if (filtros?.adscripciones?.length) {
|
||||
qb.andWhere('adscripcion.id_adscripcion IN (:...adscripciones)', {
|
||||
adscripciones: filtros.adscripciones
|
||||
});
|
||||
}
|
||||
|
||||
if (filtros?.procesadores?.length) {
|
||||
qb.andWhere('procesador.id_procesador IN (:...procesadores)', {
|
||||
procesadores: filtros.procesadores
|
||||
});
|
||||
}
|
||||
|
||||
if (filtros?.sistemas?.length) {
|
||||
qb.andWhere('sistemaOperativo.id_sistema_operativo IN (:...sistemas)', {
|
||||
sistemas: filtros.sistemas
|
||||
});
|
||||
}
|
||||
|
||||
if (filtros?.usos?.length) {
|
||||
qb.andWhere('tipoUso.id_uso IN (:...usos)', {
|
||||
usos: filtros.usos
|
||||
});
|
||||
}
|
||||
|
||||
if (filtros?.antiguedad?.length && !filtros.antiguedad.includes("Todos")) {
|
||||
qb.andWhere('equipo.antiguedad IN (:...antiguedad)', {
|
||||
antiguedad: filtros.antiguedad
|
||||
});
|
||||
}
|
||||
|
||||
const data = await qb
|
||||
.addSelect('COUNT(*)', 'total')
|
||||
.addGroupBy('adscripcion.adscripcion')
|
||||
.orderBy(`equipo.adscripcion`, "DESC")
|
||||
.getRawMany();
|
||||
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const sheet = workbook.addWorksheet('Resumen');
|
||||
|
||||
sheet.columns = [
|
||||
{ header: 'Adscripción', key: 'adscripcion', width: 30 },
|
||||
{ header: 'Total', key: 'total', width: 15 },
|
||||
];
|
||||
|
||||
data.forEach(row => {
|
||||
sheet.addRow(row);
|
||||
});
|
||||
|
||||
sheet.getRow(1).font = { bold: true };
|
||||
|
||||
return await workbook.xlsx.writeBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
let estado_excluidos = ['DE BAJA'];
|
||||
|
||||
Reference in New Issue
Block a user