Se agragaron cambios para los envios de correos
This commit is contained in:
@@ -38,34 +38,27 @@ export class ExcelController {
|
||||
console.log('Alta de usuario:', alta);
|
||||
await this.movimientoService.updateStatus(alta.movId, 'SUCCESS')
|
||||
|
||||
await this.mailService.sendMail({
|
||||
to: req.user.email, // Asegúrate de que el usuario tenga un email
|
||||
subject: 'Carga de datos exitosa',
|
||||
text: "La carga de datos se ha realizado con éxito.",
|
||||
html: `<p>La carga de datos se ha realizado con éxito ${alta} </p>`,
|
||||
});
|
||||
|
||||
|
||||
await this.excelService.enviarInforme("LOAD","Carga Individual de datos en Servicios PCpuma",
|
||||
`Se ha hecho una carga individual en el sistema por el usuario ${req.user.email}`)
|
||||
if(alta.at){
|
||||
await this.excelService.enviarInforme('AT',"Carga Individual de datos en Servicios PCpuma",
|
||||
`Se ha hecho una carga individual en el sistema`)
|
||||
`Se ha hecho una carga individual en el sistema de ${usuario.tipo_usuario}`)
|
||||
}
|
||||
if(alta.red){
|
||||
await this.excelService.enviarInforme('RED',"Carga Individual de datos en Servicios PCpuma",
|
||||
`Se ha hecho una carga individual en el sistema`)
|
||||
`Se ha hecho una carga individual en el sistema de ${usuario.tipo_usuario}`)
|
||||
}
|
||||
|
||||
|
||||
if(alta.solicita){
|
||||
await this.excelService.enviarInforme('SOLICITA',"Carga Individual de datos en Servicios PCpuma",
|
||||
`Se ha hecho una carga individual en el sistema` )
|
||||
`Se ha hecho una carga individual en el sistema de ${usuario.tipo_usuario}` )
|
||||
}
|
||||
|
||||
if(alta.correo){
|
||||
await this.excelService.enviarInforme('CORREO',"Carga Individual de datos en Servicios PCpuma",
|
||||
`Se ha hecho una carga individual en el sistema`)
|
||||
`Se ha hecho una carga individual en el sistema de ${usuario.tipo_usuario}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +131,13 @@ export class ExcelController {
|
||||
to: req.user.email, // Asegúrate de que el usuario tenga un email
|
||||
subject: 'Carga de datos exitosa',
|
||||
text: "La carga de datos se ha realizado con éxito.",
|
||||
html: `<p>La carga de datos se ha realizado con éxito. Se han insertado ${result.inserted} registros.</p>
|
||||
<p>Errores encontrados:</p>
|
||||
<ul>${result.errors.map(error => `<li>${error}</li>`).join('')}</ul>`,
|
||||
html:
|
||||
`<p>La carga de datos se ha realizado con éxito. Se han insertado ${result.inserted} registros.</p>
|
||||
<p>Usuarios At: ${result.conteoTiposAt}</p>
|
||||
<p>Usuarios Red: ${result.conteoTiposRed}</p>
|
||||
<p>Usuarios Solicita: ${result.conteoTiposSolicita}</p>
|
||||
<p>Usuarios Correo: ${result.conteoTiposCorreo}</p>
|
||||
<ul>${result.errors.map(error => `<li>${error}</li>`).join('')}</ul>`,
|
||||
});
|
||||
|
||||
// await this.excelService.enviarCargaMasiva();
|
||||
|
||||
@@ -831,18 +831,23 @@ export class ExcelService {
|
||||
|
||||
|
||||
async enviarInforme(origen:string, subject:string ,text:string, html:string = "" ):Promise<void>{
|
||||
const user = await this.usuariosDelSistemaRepo.find({where:{origen:{origen}}})
|
||||
|
||||
user.forEach(async(u)=>{
|
||||
|
||||
try{
|
||||
const user = await this.usuariosDelSistemaRepo.find({where:{origen:{origen}}})
|
||||
user.forEach(async(u)=>{
|
||||
await this.mailService.sendMail({
|
||||
to: u.correo ?? '',
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
}catch(error){
|
||||
throw new BadRequestException('No se encontraron usuarios para enviar correo o no se pudo enviar el correo');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user