carga masiva con mas mensajes
This commit is contained in:
@@ -11,6 +11,7 @@ const cargaMasiva = async (file) => {
|
||||
const path = `server/uploads/${file}`;
|
||||
const equiposNuevos = [];
|
||||
const errores = [];
|
||||
const avisos = [];
|
||||
|
||||
await csv()
|
||||
.fromFile(path)
|
||||
@@ -67,6 +68,9 @@ const cargaMasiva = async (file) => {
|
||||
idModulo: existeModulo.idModulo,
|
||||
})
|
||||
);
|
||||
avisos.push(
|
||||
`Se creo el carrito ${existeCarrito.sobrenombre} que pretenece al modulo ${existeModulo.idModulo}`
|
||||
);
|
||||
}
|
||||
existeEquipo = await Equipo.findAll({
|
||||
where: { idCarrito: existeCarrito.idCarrito },
|
||||
@@ -81,6 +85,21 @@ const cargaMasiva = async (file) => {
|
||||
: null,
|
||||
})
|
||||
);
|
||||
existeEquipo = await Equipo.findOne({
|
||||
where: { idEquipo: existeEquipo.idEquipo },
|
||||
include: [
|
||||
{ model: Programa },
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
],
|
||||
});
|
||||
delete existeEquipo.dataValues.idStatus;
|
||||
delete existeEquipo.dataValues.idCarrito;
|
||||
delete existeEquipo.dataValues.idPrograma;
|
||||
delete existeEquipo.dataValues.Carrito.dataValues.idModulo;
|
||||
delete existeEquipo.dataValues.Carrito.dataValues.idTipoCarrito;
|
||||
equiposNuevos.push(existeEquipo);
|
||||
}
|
||||
fs.unlinkSync(path);
|
||||
@@ -89,6 +108,7 @@ const cargaMasiva = async (file) => {
|
||||
message: 'Se subio correctamente el archivo csv.',
|
||||
equiposNuevos,
|
||||
errores,
|
||||
avisos,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
numeroSerie,numeroInventario,programa,carritoSobrenombre,tipo,modulo
|
||||
abc1,1,Autodesk,L01,Laptop,1
|
||||
abc2,2,Autodesk,L01,Laptop,1
|
||||
abc3,3,Autodesk,L01,Laptop,1
|
||||
abc4,4,Autodesk,L01,Laptop,1
|
||||
abc5,5,Adobe,L01,Laptop,1
|
||||
abc6,6,Adobe,L01,Laptop,1
|
||||
abc7,7,Adobe,L01,Laptop,1
|
||||
abc8,8,Adobe,L01,Laptop,1
|
||||
abc9,9,Programación,L01,Laptop,1
|
||||
abc10,10,Programación,L01,Laptop,1
|
||||
abc11,11,,P01,iPad,1
|
||||
abc12,12,,P01,iPad,1
|
||||
abc13,13,,P01,iPad,1
|
||||
abc14,14,,P01,iPad,1
|
||||
abc15,15,,P01,iPad,1
|
||||
abc16,16,,P01,iPad,1
|
||||
abc17,17,,P01,iPad,1
|
||||
abc18,18,,P01,iPad,1
|
||||
abc19,19,,P01,iPad,1
|
||||
abc20,20,,P01,iPad,1
|
||||
abc21,21,,C01,Chromebook,1
|
||||
abc22,22,,C01,Chromebook,1
|
||||
abc23,23,,C01,Chromebook,1
|
||||
abc24,24,,C01,Chromebook,1
|
||||
abc25,25,,C01,Chromebook,1
|
||||
abc26,26,,C01,Chromebook,1
|
||||
abc27,27,,C01,Chromebook,1
|
||||
abc28,28,,C01,Chromebook,1
|
||||
abc29,29,,C01,Chromebook,1
|
||||
abc30,30,,C01,Chromebook,1
|
||||
abc31,31,,P02,iPad,2
|
||||
abc32,32,,P02,iPad,2
|
||||
abc33,33,,P02,iPad,2
|
||||
abc34,34,,P02,iPad,2
|
||||
abc35,35,,P02,iPad,2
|
||||
abc36,36,,P02,iPad,2
|
||||
abc37,37,,P02,iPad,2
|
||||
abc38,38,,P02,iPad,2
|
||||
abc39,39,,P02,iPad,2
|
||||
abc40,40,,P02,iPad,2
|
||||
abc41,41,,C02,Chromebook,2
|
||||
abc42,42,,C02,Chromebook,2
|
||||
abc43,43,,C02,Chromebook,2
|
||||
abc44,44,,C02,Chromebook,2
|
||||
abc45,45,,C02,Chromebook,2
|
||||
abc46,46,,C02,Chromebook,2
|
||||
abc47,47,,C02,Chromebook,2
|
||||
abc48,48,,C02,Chromebook,2
|
||||
abc49,49,,C02,Chromebook,2
|
||||
abc50,50,,C02,Chromebook,2
|
||||
abc51,51,,L02,Laptop,2
|
||||
abc52,52,,L02,Laptop,2
|
||||
abc53,53,,L02,Laptop,2
|
||||
abc54,54,,L02,Laptop,2
|
||||
abc55,55,,L02,Laptop,2
|
||||
abc56,56,,L02,Laptop,2
|
||||
abc57,57,,L02,Laptop,2
|
||||
abc58,58,,L02,Laptop,2
|
||||
abc59,59,,L02,Laptop,2
|
||||
abc60,60,,L02,Laptop,2
|
||||
Reference in New Issue
Block a user