CARGA masiva corregida
This commit is contained in:
parent
03e9f1a145
commit
df04dcb4d9
@ -71,6 +71,8 @@ import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Usuario } from './usuario/entity/usuario.entity';
|
||||
|
||||
import { InformacionEquipoView } from './equipo/entity/views/informacion-equipo.view';
|
||||
import { InformacionEquipoProgramaView } from './equipo-programa/entity/views/informacion-equipo-programa.view';
|
||||
import { InformacionEquipoTipoEntradaView } from './equipo-tipo-entrada/entity/views/informacion-equipo-tipo-entrada.view';
|
||||
import { InformacionOperadorView } from './operador/entity/views/informacion-operador.view';
|
||||
import { InformacionUsuarioView } from './usuario/entity/views/informacion-usuario.view';
|
||||
|
||||
@ -133,6 +135,8 @@ import { InformacionUsuarioView } from './usuario/entity/views/informacion-usuar
|
||||
TipoUsuario,
|
||||
Usuario,
|
||||
InformacionEquipoView,
|
||||
InformacionEquipoProgramaView,
|
||||
InformacionEquipoTipoEntradaView,
|
||||
InformacionOperadorView,
|
||||
InformacionUsuarioView,
|
||||
],
|
||||
|
@ -58,17 +58,19 @@ export class AuthService {
|
||||
}
|
||||
|
||||
loginUsuario(usuario: string, password: string) {
|
||||
return this.usuarioService.informacionUsuario(usuario).then((data) => {
|
||||
if (!data.password)
|
||||
throw new BadRequestException('Este usuario no ha sido registrado.');
|
||||
if (
|
||||
!data.usuario ||
|
||||
!this.bcryptService.comparar(password, data.password)
|
||||
)
|
||||
throw new BadRequestException(
|
||||
'Usuario y/o password incorrectos, ingresa unas credenciales válidas.',
|
||||
);
|
||||
return { token: this.jwtService.sign(data.usuario) };
|
||||
});
|
||||
return this.usuarioService
|
||||
.informacionUsuarioByUsuario(usuario)
|
||||
.then((data) => {
|
||||
if (!data.password)
|
||||
throw new BadRequestException('Este usuario no ha sido registrado.');
|
||||
if (
|
||||
!data.usuario ||
|
||||
!this.bcryptService.comparar(password, data.password)
|
||||
)
|
||||
throw new BadRequestException(
|
||||
'Usuario y/o password incorrectos, ingresa unas credenciales válidas.',
|
||||
);
|
||||
return { token: this.jwtService.sign(data.usuario) };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
import { DataSource, ViewEntity, ViewColumn } from 'typeorm';
|
||||
import { EquipoPrograma } from '../equipo-programa.entity';
|
||||
|
||||
@ViewEntity({
|
||||
expression: (dataSource: DataSource) =>
|
||||
dataSource
|
||||
.createQueryBuilder()
|
||||
.select('ep.id_equipo_programa', 'id_equipo_programa')
|
||||
.addSelect('ep.id_equipo', 'id_equipo')
|
||||
.addSelect('ep.id_programa', 'id_programa')
|
||||
.from(EquipoPrograma, 'ep'),
|
||||
})
|
||||
export class InformacionEquipoProgramaView {
|
||||
@ViewColumn()
|
||||
id_equipo_programa: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_equipo: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_programa: number;
|
||||
}
|
@ -4,6 +4,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { EquipoProgramaController } from './equipo-programa.controller';
|
||||
import { EquipoProgramaService } from './equipo-programa.service';
|
||||
import { EquipoPrograma } from '../equipo-programa/entity/equipo-programa.entity';
|
||||
import { InformacionEquipoProgramaView } from './entity/views/informacion-equipo-programa.view';
|
||||
import { EquipoModule } from '../equipo/equipo.module';
|
||||
import { InstitucionProgramaModule } from '../institucion-programa/institucion-programa.module';
|
||||
|
||||
@ -12,7 +13,7 @@ import { InstitucionProgramaModule } from '../institucion-programa/institucion-p
|
||||
forwardRef(() => EquipoModule),
|
||||
InstitucionProgramaModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
TypeOrmModule.forFeature([EquipoPrograma]),
|
||||
TypeOrmModule.forFeature([EquipoPrograma, InformacionEquipoProgramaView]),
|
||||
],
|
||||
controllers: [EquipoProgramaController],
|
||||
providers: [EquipoProgramaService],
|
||||
|
@ -10,6 +10,7 @@ import { Repository } from 'typeorm';
|
||||
import { Equipo } from '../equipo/entity/equipo.entity';
|
||||
import { EquipoPrograma } from './entity/equipo-programa.entity';
|
||||
import { Programa } from '../institucion-programa/entity/programa.entity';
|
||||
import { InformacionEquipoProgramaView } from './entity/views/informacion-equipo-programa.view';
|
||||
import { EquipoService } from '../equipo/equipo.service';
|
||||
import { InstitucionProgramaService } from '../institucion-programa/institucion-programa.service';
|
||||
import { Operador } from '../operador/entity/operador.entity';
|
||||
@ -19,6 +20,8 @@ export class EquipoProgramaService {
|
||||
constructor(
|
||||
@InjectRepository(EquipoPrograma)
|
||||
private repository: Repository<EquipoPrograma>,
|
||||
@InjectRepository(InformacionEquipoProgramaView)
|
||||
private informacionEquipoProgramaView: Repository<InformacionEquipoProgramaView>,
|
||||
@Inject(forwardRef(() => EquipoService))
|
||||
private equipoService: EquipoService,
|
||||
private institucionProgramaService: InstitucionProgramaService,
|
||||
@ -29,9 +32,6 @@ export class EquipoProgramaService {
|
||||
id_equipo: number | Equipo,
|
||||
id_programa: number | Programa,
|
||||
) {
|
||||
const sinPrograma = await this.institucionProgramaService.findProgramaById(
|
||||
1,
|
||||
);
|
||||
const equipo =
|
||||
typeof id_equipo === 'number'
|
||||
? await this.equipoService.findById(id_equipo)
|
||||
@ -41,13 +41,39 @@ export class EquipoProgramaService {
|
||||
? await this.institucionProgramaService.findProgramaById(id_programa)
|
||||
: id_programa;
|
||||
|
||||
return this.findEquipoProgramaByEquipoPrograma(equipo, programa)
|
||||
.then((_) =>
|
||||
this.findEquipoProgramaByEquipoPrograma(equipo, sinPrograma, false),
|
||||
)
|
||||
return this.informacionEquipoPrograma(
|
||||
equipo.id_equipo,
|
||||
programa.id_programa,
|
||||
)
|
||||
.then((existeEquipoPrograma) => {
|
||||
if (existeEquipoPrograma)
|
||||
throw new ConflictException(
|
||||
'Este software ya fue asignado a este equipo.',
|
||||
);
|
||||
return this.informacionEquipoPrograma(equipo.id_equipo, 1);
|
||||
})
|
||||
.then(async (existeEquipoSinPrograma) => {
|
||||
if (existeEquipoSinPrograma)
|
||||
await this.repository.remove(existeEquipoSinPrograma);
|
||||
await this.repository.delete({
|
||||
id_equipo_programa: existeEquipoSinPrograma.id_equipo_programa,
|
||||
});
|
||||
return this.repository.save(
|
||||
this.repository.create({ equipo, programa }),
|
||||
);
|
||||
})
|
||||
.then((equipoPrograma) => ({
|
||||
message: `Se asignó el software: ${equipoPrograma.programa.programa}, al equipo con número de inventario: ${equipo.numero_inventario}.`,
|
||||
equipoPrograma,
|
||||
}));
|
||||
}
|
||||
|
||||
async createCargaMasiva(equipo: Equipo, programa: Programa) {
|
||||
return this.informacionEquipoPrograma(equipo.id_equipo, 1)
|
||||
.then(async (existeEquipoSinPrograma) => {
|
||||
if (existeEquipoSinPrograma)
|
||||
await this.repository.delete({
|
||||
id_equipo_programa: existeEquipoSinPrograma.id_equipo_programa,
|
||||
});
|
||||
return this.repository.save(
|
||||
this.repository.create({ equipo, programa }),
|
||||
);
|
||||
@ -120,4 +146,10 @@ export class EquipoProgramaService {
|
||||
return equipoPrograma;
|
||||
});
|
||||
}
|
||||
|
||||
informacionEquipoPrograma(id_equipo: number, id_programa: number) {
|
||||
return this.informacionEquipoProgramaView.findOne({
|
||||
where: { id_equipo, id_programa },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
import { DataSource, ViewEntity, ViewColumn } from 'typeorm';
|
||||
import { EquipoTipoEntrada } from '../equipo-tipo-entrada.entity';
|
||||
|
||||
@ViewEntity({
|
||||
expression: (dataSource: DataSource) =>
|
||||
dataSource
|
||||
.createQueryBuilder()
|
||||
.select('ete.id_equipo_tipo_entrada', 'id_equipo_tipo_entrada')
|
||||
.addSelect('ete.id_equipo', 'id_equipo')
|
||||
.addSelect('ete.id_tipo_entrada', 'id_tipo_entrada')
|
||||
.from(EquipoTipoEntrada, 'ete'),
|
||||
})
|
||||
export class InformacionEquipoTipoEntradaView {
|
||||
@ViewColumn()
|
||||
id_equipo_tipo_entrada: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_equipo: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_tipo_entrada: number;
|
||||
}
|
@ -4,6 +4,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { EquipoTipoEntradaController } from './equipo-tipo-entrada.controller';
|
||||
import { EquipoTipoEntradaService } from './equipo-tipo-entrada.service';
|
||||
import { EquipoTipoEntrada } from '../equipo-tipo-entrada/entity/equipo-tipo-entrada.entity';
|
||||
import { InformacionEquipoTipoEntradaView } from './entity/views/informacion-equipo-tipo-entrada.view';
|
||||
import { EquipoModule } from '../equipo/equipo.module';
|
||||
import { InstitucionTipoEntradaModule } from '../institucion-tipo-entrada/institucion-tipo-entrada.module';
|
||||
|
||||
@ -12,7 +13,10 @@ import { InstitucionTipoEntradaModule } from '../institucion-tipo-entrada/instit
|
||||
EquipoModule,
|
||||
InstitucionTipoEntradaModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
TypeOrmModule.forFeature([EquipoTipoEntrada]),
|
||||
TypeOrmModule.forFeature([
|
||||
EquipoTipoEntrada,
|
||||
InformacionEquipoTipoEntradaView,
|
||||
]),
|
||||
],
|
||||
controllers: [EquipoTipoEntradaController],
|
||||
providers: [EquipoTipoEntradaService],
|
||||
|
@ -4,6 +4,7 @@ import { Repository } from 'typeorm';
|
||||
import { Equipo } from '../equipo/entity/equipo.entity';
|
||||
import { EquipoTipoEntrada } from './entity/equipo-tipo-entrada.entity';
|
||||
import { TipoEntrada } from '../institucion-tipo-entrada/entity/tipo-entrada.entity';
|
||||
import { InformacionEquipoTipoEntradaView } from './entity/views/informacion-equipo-tipo-entrada.view';
|
||||
import { EquipoService } from '../equipo/equipo.service';
|
||||
import { InstitucionTipoEntradaService } from '../institucion-tipo-entrada/institucion-tipo-entrada.service';
|
||||
|
||||
@ -12,6 +13,8 @@ export class EquipoTipoEntradaService {
|
||||
constructor(
|
||||
@InjectRepository(EquipoTipoEntrada)
|
||||
private repository: Repository<EquipoTipoEntrada>,
|
||||
@InjectRepository(InformacionEquipoTipoEntradaView)
|
||||
private informacionEquipoTipoEntradaView: Repository<InformacionEquipoTipoEntradaView>,
|
||||
private equipoService: EquipoService,
|
||||
private institucionTipoEntradaService: InstitucionTipoEntradaService,
|
||||
) {}
|
||||
@ -31,10 +34,28 @@ export class EquipoTipoEntradaService {
|
||||
)
|
||||
: id_tipo_entrada;
|
||||
|
||||
return this.findEquipoTipoEntradaByEquipoTipoEntrada(equipo, tipoEntrada)
|
||||
.then((_) =>
|
||||
this.repository.save(this.repository.create({ equipo, tipoEntrada })),
|
||||
)
|
||||
return this.informacionEquipoTipoEntrada(
|
||||
equipo.id_equipo,
|
||||
tipoEntrada.id_tipo_entrada,
|
||||
)
|
||||
.then((existeEquipoTipoEntrada) => {
|
||||
if (existeEquipoTipoEntrada)
|
||||
throw new ConflictException(
|
||||
'Este tipo de entrada ya fue asignado a este equipo.',
|
||||
);
|
||||
return this.repository.save(
|
||||
this.repository.create({ equipo, tipoEntrada }),
|
||||
);
|
||||
})
|
||||
.then((equipoTipoEntrada) => ({
|
||||
message: `Se asignó el tipo de entrada: ${tipoEntrada.tipo_entrada}, al equipo con número de inventario: ${equipo.numero_inventario}.`,
|
||||
equipoTipoEntrada,
|
||||
}));
|
||||
}
|
||||
|
||||
async createCargaMasiva(equipo: Equipo, tipoEntrada: TipoEntrada) {
|
||||
return this.repository
|
||||
.save(this.repository.create({ equipo, tipoEntrada }))
|
||||
.then((equipoTipoEntrada) => ({
|
||||
message: `Se asignó el tipo de entrada: ${tipoEntrada.tipo_entrada}, al equipo con número de inventario: ${equipo.numero_inventario}.`,
|
||||
equipoTipoEntrada,
|
||||
@ -59,19 +80,9 @@ export class EquipoTipoEntradaService {
|
||||
});
|
||||
}
|
||||
|
||||
findEquipoTipoEntradaByEquipoTipoEntrada(
|
||||
equipo: Equipo,
|
||||
tipoEntrada: TipoEntrada,
|
||||
validarExistencia = true,
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({ where: { equipo, tipoEntrada } })
|
||||
.then((equipoTipoEntrada) => {
|
||||
if (validarExistencia && equipoTipoEntrada)
|
||||
throw new ConflictException(
|
||||
'Este tipo de entrada ya fue asignado a este equipo.',
|
||||
);
|
||||
return equipoTipoEntrada;
|
||||
});
|
||||
informacionEquipoTipoEntrada(id_equipo: number, id_tipo_entrada: number) {
|
||||
return this.informacionEquipoTipoEntradaView.findOne({
|
||||
where: { id_equipo, id_tipo_entrada },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -43,10 +43,19 @@ export class InformacionEquipoView {
|
||||
id_equipo: number;
|
||||
|
||||
@ViewColumn()
|
||||
equipo: string;
|
||||
activo_carrito: boolean;
|
||||
|
||||
@ViewColumn()
|
||||
prestado: boolean;
|
||||
activo_institucion: boolean;
|
||||
|
||||
@ViewColumn()
|
||||
activo_modulo: boolean;
|
||||
|
||||
@ViewColumn()
|
||||
carrito: string;
|
||||
|
||||
@ViewColumn()
|
||||
equipo: string;
|
||||
|
||||
@ViewColumn()
|
||||
id_modulo: number;
|
||||
@ -57,6 +66,15 @@ export class InformacionEquipoView {
|
||||
@ViewColumn()
|
||||
id_institucion: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_tipo_carrito: number;
|
||||
|
||||
@ViewColumn()
|
||||
id_status: number;
|
||||
|
||||
@ViewColumn()
|
||||
numero_inventario: string;
|
||||
|
||||
@ViewColumn()
|
||||
prestado: boolean;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Carrito } from '../carrito/entity/carrito.entity';
|
||||
import { Equipo } from './entity/equipo.entity';
|
||||
import { InformacionEquipoView } from './entity/views/informacion-equipo.view';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { Marca } from '../marca/entity/marca.entity';
|
||||
import { Modelo } from '../modelo/entity/modelo.entity';
|
||||
@ -19,6 +18,7 @@ import { Operador } from '../operador/entity/operador.entity';
|
||||
import { Programa } from '../institucion-programa/entity/programa.entity';
|
||||
import { TipoCarrito } from '../institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
import { TipoEntrada } from '../institucion-tipo-entrada/entity/tipo-entrada.entity';
|
||||
import { InformacionEquipoView } from './entity/views/informacion-equipo.view';
|
||||
import { CarritoService } from '../carrito/carrito.service';
|
||||
import { EquipoProgramaService } from '../equipo-programa/equipo-programa.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
@ -253,6 +253,25 @@ export class EquipoService {
|
||||
});
|
||||
}
|
||||
|
||||
async findEquipoByEquipo(
|
||||
id_carrito: number | Carrito,
|
||||
equipo: string,
|
||||
validarNoExiste = true,
|
||||
) {
|
||||
const carrito =
|
||||
typeof id_carrito === 'number'
|
||||
? await this.carritoService.findById(id_carrito)
|
||||
: id_carrito;
|
||||
|
||||
return this.repository
|
||||
.findOne({ where: { carrito, equipo } })
|
||||
.then((equipo) => {
|
||||
if (validarNoExiste && !equipo)
|
||||
throw new NotFoundException('No existe este equipo.');
|
||||
return equipo;
|
||||
});
|
||||
}
|
||||
|
||||
async findEquipo(
|
||||
modulo: Modulo,
|
||||
tipoCarrito: TipoCarrito,
|
||||
@ -333,6 +352,18 @@ export class EquipoService {
|
||||
});
|
||||
}
|
||||
|
||||
informacionEquipoByEquipo(id_carrito: number, equipo: string) {
|
||||
return this.informacionEquipoView.findOne({
|
||||
where: { equipo, id_carrito },
|
||||
});
|
||||
}
|
||||
|
||||
informacionEquipoNumeroInventario(id_institucion: number, equipo: string) {
|
||||
return this.informacionEquipoView.findOne({
|
||||
where: { equipo, id_institucion },
|
||||
});
|
||||
}
|
||||
|
||||
reseteoTotal() {
|
||||
return this.repository
|
||||
.createQueryBuilder()
|
||||
@ -341,25 +372,6 @@ export class EquipoService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
async findEquipoByEquipo(
|
||||
id_carrito: number | Carrito,
|
||||
equipo: string,
|
||||
validarNoExiste = true,
|
||||
) {
|
||||
const carrito =
|
||||
typeof id_carrito === 'number'
|
||||
? await this.carritoService.findById(id_carrito)
|
||||
: id_carrito;
|
||||
|
||||
return this.repository
|
||||
.findOne({ where: { carrito, equipo } })
|
||||
.then((equipo) => {
|
||||
if (validarNoExiste && !equipo)
|
||||
throw new NotFoundException('No existe este equipo.');
|
||||
return equipo;
|
||||
});
|
||||
}
|
||||
|
||||
async update(
|
||||
// operador: Operador,
|
||||
attrs: Partial<Equipo>,
|
||||
|
@ -211,11 +211,17 @@ export class UploadFileService {
|
||||
false,
|
||||
)
|
||||
: null;
|
||||
// let equipo = carrito
|
||||
// ? await this.equipoService.findEquipoByEquipo(
|
||||
// carrito,
|
||||
// dataEquipo.equipo,
|
||||
// false,
|
||||
// )
|
||||
// : null;
|
||||
let equipo = carrito
|
||||
? await this.equipoService.findEquipoByEquipo(
|
||||
carrito,
|
||||
? await this.equipoService.informacionEquipoByEquipo(
|
||||
carrito.id_carrito,
|
||||
dataEquipo.equipo,
|
||||
false,
|
||||
)
|
||||
: null;
|
||||
|
||||
@ -243,116 +249,120 @@ export class UploadFileService {
|
||||
|
||||
if (equipo) {
|
||||
errores.push(
|
||||
`${error} ya existe un equipo de cómputo con el sobrenombre: ${equipo.equipo} en el carrito: ${equipo.carrito.carrito}.`,
|
||||
`${error} ya existe un equipo de cómputo con el sobrenombre: ${equipo.equipo} en el carrito: ${equipo.carrito}.`,
|
||||
// `${error} ya existe un equipo de cómputo con el sobrenombre: ${equipo.equipo} en el carrito: ${equipo.carrito.carrito}.`,
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
equipo = await this.equipoService.findByNumeroInventario(
|
||||
institucion,
|
||||
// equipo = await this.equipoService.findByNumeroInventario(
|
||||
// institucion,
|
||||
// dataEquipo.numero_inventario,
|
||||
// false,
|
||||
// );
|
||||
equipo = await this.equipoService.informacionEquipoNumeroInventario(
|
||||
institucion.id_institucion,
|
||||
dataEquipo.numero_inventario,
|
||||
false,
|
||||
);
|
||||
console.log('hola');
|
||||
|
||||
if (equipo) {
|
||||
errores.push(
|
||||
`${error} ya existe un equipo con ese número de inventario en esta institución.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
equipo = await this.equipoService.create(
|
||||
carrito,
|
||||
dataEquipo.equipo,
|
||||
dataEquipo.numero_inventario,
|
||||
dataEquipo.numero_serie,
|
||||
marca,
|
||||
modelo,
|
||||
);
|
||||
console.log('adios');
|
||||
await this.equipoService
|
||||
.create(
|
||||
carrito,
|
||||
dataEquipo.equipo,
|
||||
dataEquipo.numero_inventario,
|
||||
dataEquipo.numero_serie,
|
||||
marca,
|
||||
modelo,
|
||||
)
|
||||
.then(async (equipo) => {
|
||||
const entradas = dataEquipo.entradas.split(',');
|
||||
const programas = dataEquipo.programas
|
||||
? dataEquipo.programas.split(',')
|
||||
: [];
|
||||
|
||||
const entradas = dataEquipo.entradas.split(',');
|
||||
const programas = dataEquipo.programas
|
||||
? dataEquipo.programas.split(',')
|
||||
: [];
|
||||
equipo.programas = [];
|
||||
equipo.tiposEntradas = [];
|
||||
for (let j = 0; j < entradas.length; j++) {
|
||||
const tipoEntrada =
|
||||
await this.institucionTipoEntradaService.findTipoEntradaByTipoEntrada(
|
||||
entradas[j].trim(),
|
||||
false,
|
||||
);
|
||||
const existeEquipoTipoEntrada = tipoEntrada
|
||||
? await this.equipoTipoEntradaService.informacionEquipoTipoEntrada(
|
||||
equipo.id_equipo,
|
||||
tipoEntrada.id_tipo_entrada,
|
||||
)
|
||||
: null;
|
||||
|
||||
equipo.programas = [];
|
||||
equipo.tiposEntradas = [];
|
||||
for (let j = 0; j < entradas.length; j++) {
|
||||
const tipoEntrada =
|
||||
await this.institucionTipoEntradaService.findTipoEntradaByTipoEntrada(
|
||||
entradas[j].trim(),
|
||||
false,
|
||||
);
|
||||
const existeEquipoTipoEntrada = tipoEntrada
|
||||
? await this.equipoTipoEntradaService.findEquipoTipoEntradaByEquipoTipoEntrada(
|
||||
equipo,
|
||||
tipoEntrada,
|
||||
false,
|
||||
)
|
||||
: null;
|
||||
if (!tipoEntrada || existeEquipoTipoEntrada) {
|
||||
if (!tipoEntrada)
|
||||
errores.push(
|
||||
`No se asignó el conector: ${
|
||||
entradas[j]
|
||||
}, al equipo de la linea ${
|
||||
index + 2
|
||||
} porque no existe este conector.`,
|
||||
);
|
||||
if (existeEquipoTipoEntrada)
|
||||
errores.push(
|
||||
`El conector: ${
|
||||
entradas[j]
|
||||
}, ya fue asignado al equipo de la linea ${index + 2}.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
await this.equipoTipoEntradaService
|
||||
.createCargaMasiva(equipo, tipoEntrada)
|
||||
.then((res) => {
|
||||
equipo.tiposEntradas.push(res.equipoTipoEntrada);
|
||||
mensajes.push(res.message);
|
||||
});
|
||||
}
|
||||
for (let j = 0; j < programas.length; j++) {
|
||||
const programa =
|
||||
await this.institucionProgramaService.findProgramaByPrograma(
|
||||
programas[j].trim(),
|
||||
false,
|
||||
);
|
||||
const existeEquipoPrograma = programa
|
||||
? await this.equipoProgramaService.informacionEquipoPrograma(
|
||||
equipo.id_equipo,
|
||||
programa.id_programa,
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!tipoEntrada || existeEquipoTipoEntrada) {
|
||||
if (!tipoEntrada)
|
||||
errores.push(
|
||||
`No se asignó el conector: ${
|
||||
entradas[j]
|
||||
}, al equipo de la linea ${
|
||||
index + 2
|
||||
} porque no existe este conector.`,
|
||||
);
|
||||
if (existeEquipoTipoEntrada)
|
||||
errores.push(
|
||||
`El conector: ${
|
||||
entradas[j]
|
||||
}, ya fue asignado al equipo de la linea ${index + 2}.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
await this.equipoTipoEntradaService
|
||||
.create(equipo, tipoEntrada)
|
||||
.then((res) => {
|
||||
equipo.tiposEntradas.push(res.equipoTipoEntrada);
|
||||
mensajes.push(res.message);
|
||||
});
|
||||
}
|
||||
for (let j = 0; j < programas.length; j++) {
|
||||
const programa =
|
||||
await this.institucionProgramaService.findProgramaByPrograma(
|
||||
programas[j].trim(),
|
||||
false,
|
||||
);
|
||||
const existeEquipoPrograma = programa
|
||||
? await this.equipoProgramaService.findEquipoProgramaByEquipoPrograma(
|
||||
equipo,
|
||||
programa,
|
||||
false,
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!programa || existeEquipoPrograma) {
|
||||
if (!programa)
|
||||
errores.push(
|
||||
`No se asignó el software: ${
|
||||
programas[j]
|
||||
}, al equipo de la linea ${
|
||||
index + 2
|
||||
} porque no existe este software.`,
|
||||
);
|
||||
if (existeEquipoPrograma)
|
||||
errores.push(
|
||||
`El programa: ${
|
||||
programas[j]
|
||||
}, ya lo tiene asignado el equipo de la linea ${index + 2}.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
await this.equipoProgramaService
|
||||
.create(equipo, programa)
|
||||
.then((res) => {
|
||||
equipo.programas.push(res.equipoPrograma);
|
||||
mensajes.push(res.message);
|
||||
});
|
||||
}
|
||||
equiposNuevos.push(equipo);
|
||||
if (!programa || existeEquipoPrograma) {
|
||||
if (!programa)
|
||||
errores.push(
|
||||
`No se asignó el software: ${
|
||||
programas[j]
|
||||
}, al equipo de la linea ${
|
||||
index + 2
|
||||
} porque no existe este software.`,
|
||||
);
|
||||
if (existeEquipoPrograma)
|
||||
errores.push(
|
||||
`El programa: ${
|
||||
programas[j]
|
||||
}, ya lo tiene asignado el equipo de la linea ${index + 2}.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
await this.equipoProgramaService
|
||||
.createCargaMasiva(equipo, programa)
|
||||
.then((res) => {
|
||||
equipo.programas.push(res.equipoPrograma);
|
||||
mensajes.push(res.message);
|
||||
});
|
||||
}
|
||||
equiposNuevos.push(equipo);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ export class UsuarioService {
|
||||
});
|
||||
}
|
||||
|
||||
informacionUsuario(usuario: string) {
|
||||
informacionUsuarioByUsuario(usuario: string) {
|
||||
return this.informacionUsuarioView
|
||||
.find({ where: { usuario } })
|
||||
.then((data) => {
|
||||
|
Loading…
Reference in New Issue
Block a user