645 lines
29 KiB
JavaScript
645 lines
29 KiB
JavaScript
const connection = require('../conf/connection')
|
|
const sql = require('mssql')
|
|
const fs = require("fs")
|
|
const getProfesores = require('./queryBaseProfesores/index.js')
|
|
async function traer() {
|
|
// try {
|
|
// let pass = "67NHA*Y";
|
|
// // make sure that any items are correctly URL encoded in the connection string
|
|
// await sql.connect(`mssql://USR_REDINVESTIGACION:${pass}@132.248.180.228/DB_ARES`)
|
|
// const result = await sql.query `EXEC DB_ARES.dbo.SPD_CONSULTA_DATOS_PROFESORES_RED_INVESTIGACION;`
|
|
|
|
// //console.log(result);
|
|
// let aux = [];
|
|
// await result.recordsets[0].forEach(element => {
|
|
// let r = aux.find(item => item.Rfc == element.Rfc);
|
|
// //console.log(element + ' ' + r);
|
|
// if (r == undefined)
|
|
// aux.push(element);
|
|
|
|
// });
|
|
// return aux;
|
|
// } catch (err) {
|
|
// //console.log(err);
|
|
// }
|
|
}
|
|
|
|
function twoDigits(d) {
|
|
if (0 <= d && d < 10) return "0" + d.toString();
|
|
if (-10 < d && d < 0) return "-0" + (-1 * d).toString();
|
|
return d.toString();
|
|
}
|
|
|
|
function dataJsToMysql(dat) {
|
|
// console.log("data de la fecha mysql ", dat);
|
|
|
|
//console.log(dat.getFullYear());
|
|
let ne = dat.getFullYear() + "-" + twoDigits(1 + dat.getUTCMonth()) + "-" + twoDigits(dat.getUTCDate()) + " " + twoDigits(dat.getUTCHours()) + ":" + twoDigits(dat.getUTCMinutes()) + ":" + twoDigits(dat.getUTCSeconds());
|
|
// console.log("ne ", ne);
|
|
//let ne = "88";
|
|
return ne;
|
|
}
|
|
|
|
function query(consulta) {
|
|
return new Promise(function(resolve, reject) {
|
|
connection.query(`${consulta}`, (error, results, files) => {
|
|
if (error) reject(error);
|
|
resolve(results);
|
|
});
|
|
})
|
|
}
|
|
|
|
async function llenar() {
|
|
|
|
let data = JSON.parse(fs.readFileSync("../data_base/csvjson.json"))
|
|
|
|
//console.log(data[0])
|
|
let pon = await getProfesores();
|
|
console.log(pon);
|
|
let si = [];
|
|
let no = [];
|
|
let maxi = {};
|
|
let maximo_disc = 0;
|
|
|
|
for (i in data) {
|
|
let element = data[i];
|
|
// if (maxi.Nombre_completo == undefined)
|
|
// maxi.Nombre_completo = element.Nombre_completo.length;
|
|
// else
|
|
// if (maxi.Nombre_completo < element.Nombre_completo.length)
|
|
// maxi.Nombre_completo = element.Nombre_completo.length;
|
|
|
|
// if (maxi.nombre_proyecto_investigacion == undefined)
|
|
// maxi.nombre_proyecto_investigacion = element.nombre_proyecto_investigacion.length;
|
|
// else
|
|
// if (maxi.nombre_proyecto_investigacion < element.nombre_proyecto_investigacion.length)
|
|
// maxi.nombre_proyecto_investigacion = element.nombre_proyecto_investigacion.length;
|
|
|
|
|
|
// if (maxi.objetivo_particular_1 == undefined)
|
|
// maxi.objetivo_particular_1 = element.objetivo_particular_1.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_1 < element.objetivo_particular_1.length)
|
|
// maxi.objetivo_particular_1 = element.objetivo_particular_1.length;
|
|
|
|
// if (maxi.objetivo_particular_2 == undefined)
|
|
// maxi.objetivo_particular_2 = element.objetivo_particular_2.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_2 < element.objetivo_particular_2.length)
|
|
// maxi.objetivo_particular_2 = element.objetivo_particular_2.length;
|
|
|
|
// if (maxi.objetivo_particular_3 == undefined)
|
|
// maxi.objetivo_particular_3 = element.objetivo_particular_3.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_3 < element.objetivo_particular_3.length)
|
|
// maxi.objetivo_particular_3 = element.objetivo_particular_3.length;
|
|
|
|
// if (maxi.objetivo_particular_4 == undefined)
|
|
// maxi.objetivo_particular_4 = element.objetivo_particular_4.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_4 < element.objetivo_particular_4.length)
|
|
// maxi.objetivo_particular_4 = element.objetivo_particular_4.length;
|
|
|
|
// if (maxi.objetivo_particular_5 == undefined)
|
|
// maxi.objetivo_particular_5 = element.objetivo_particular_5.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_5 < element.objetivo_particular_5.length)
|
|
// maxi.objetivo_particular_5 = element.objetivo_particular_5.length;
|
|
// if (maxi.objetivo_particular_6 == undefined)
|
|
// maxi.objetivo_particular_6 = element.objetivo_particular_6.length;
|
|
// else
|
|
// if (maxi.objetivo_particular_6 < element.objetivo_particular_6.length)
|
|
// maxi.objetivo_particular_6 = element.objetivo_particular_6.length;
|
|
|
|
// if (maxi.objetivo_general == undefined)
|
|
// maxi.objetivo_general = element.objetivo_general.length;
|
|
// else
|
|
// if (maxi.objetivo_general < element.objetivo_general.length)
|
|
// maxi.objetivo_general = element.objetivo_general.length;
|
|
|
|
|
|
// if (maxi.Hipotesis_original == undefined)
|
|
// maxi.Hipotesis_original = element.Hipotesis_original.length;
|
|
// else
|
|
// if (maxi.Hipotesis_original < element.Hipotesis_original.length)
|
|
// maxi.Hipotesis_original = element.Hipotesis_original.length;
|
|
|
|
// if (maxi.resumen_original == undefined)
|
|
// maxi.resumen_original = element.resumen_original.length;
|
|
// else
|
|
// if (maxi.resumen_original < element.resumen_original.length)
|
|
// maxi.resumen_original = element.resumen_original.length;
|
|
let com = '"';
|
|
let sim = "'";
|
|
let dig = '/';
|
|
|
|
element.objetivo_particular_1 = element.objetivo_particular_1.toString();
|
|
element.objetivo_particular_2 = element.objetivo_particular_2.toString();
|
|
element.objetivo_particular_3 = element.objetivo_particular_3.toString();
|
|
element.objetivo_particular_4 = element.objetivo_particular_4.toString();
|
|
element.objetivo_particular_5 = element.objetivo_particular_5.toString();
|
|
element.objetivo_particular_6 = element.objetivo_particular_6.toString();
|
|
|
|
|
|
element.Nombre_completo = element.Nombre_completo.replace(/"/g, ' ');
|
|
element.Nombre_completo = element.Nombre_completo.replace(/'/g, ' ');
|
|
element.Nombre_completo = element.Nombre_completo.replace(dig, ' ');
|
|
|
|
element.nombre_proyecto_investigacion = element.nombre_proyecto_investigacion.replace(/"/g, ' ');
|
|
element.nombre_proyecto_investigacion = element.nombre_proyecto_investigacion.replace(/'/g, ' ');
|
|
element.nombre_proyecto_investigacion = element.nombre_proyecto_investigacion.replace(dig, ' ');
|
|
|
|
|
|
element.Campo_de_conocimiento = element.Campo_de_conocimiento.replace(/"/g, ' ');
|
|
element.Campo_de_conocimiento = element.Campo_de_conocimiento.replace(/'/g, ' ');
|
|
element.Campo_de_conocimiento = element.Campo_de_conocimiento.replace(dig, ' ');
|
|
|
|
|
|
|
|
|
|
element.Disciplina = element.Disciplina.replace(/"/g, ' ');
|
|
element.Disciplina = element.Disciplina.replace(/'/g, ' ');
|
|
element.Disciplina = element.Disciplina.replace(dig, ' ');
|
|
|
|
|
|
|
|
|
|
element.objetivo_general = element.objetivo_general.replace(/"/g, ' ');
|
|
element.objetivo_general = element.objetivo_general.replace(/'/g, ' ');
|
|
element.objetivo_general = element.objetivo_general.replace(dig, ' ');
|
|
|
|
|
|
element.objetivo_particular_1 = element.objetivo_particular_1.replace(/"/g, ' ');
|
|
element.objetivo_particular_1 = element.objetivo_particular_1.replace(/'/g, ' ');
|
|
element.objetivo_particular_1 = element.objetivo_particular_1.replace(dig, ' ');
|
|
|
|
|
|
element.objetivo_particular_2 = element.objetivo_particular_2.replace(/"/g, ' ');
|
|
element.objetivo_particular_2 = element.objetivo_particular_2.replace(/'/g, ' ');
|
|
element.objetivo_particular_2 = element.objetivo_particular_2.replace(dig, ' ');
|
|
|
|
|
|
element.objetivo_particular_3 = element.objetivo_particular_3.replace(/"/g, ' ');
|
|
element.objetivo_particular_3 = element.objetivo_particular_3.replace(/'/g, ' ');
|
|
element.objetivo_particular_3 = element.objetivo_particular_3.replace(dig, ' ');
|
|
|
|
|
|
element.objetivo_particular_4 = element.objetivo_particular_4.replace(/"/g, ' ');
|
|
element.objetivo_particular_4 = element.objetivo_particular_4.replace(/'/g, ' ');
|
|
element.objetivo_particular_4 = element.objetivo_particular_4.replace(dig, ' ');
|
|
|
|
|
|
element.objetivo_particular_5 = element.objetivo_particular_5.replace(/"/g, ' ');
|
|
element.objetivo_particular_5 = element.objetivo_particular_5.replace(/'/g, ' ');
|
|
element.objetivo_particular_5 = element.objetivo_particular_5.replace(dig, ' ');
|
|
|
|
|
|
|
|
element.objetivo_particular_6 = element.objetivo_particular_6.replace(/"/g, ' ');
|
|
element.objetivo_particular_6 = element.objetivo_particular_6.replace(/'/g, ' ');
|
|
element.objetivo_particular_6 = element.objetivo_particular_6.replace(dig, ' ');
|
|
|
|
|
|
element.Hipotesis_original = element.Hipotesis_original.replace(/"/g, ' ');
|
|
element.Hipotesis_original = element.Hipotesis_original.replace(/'/g, ' ');
|
|
element.Hipotesis_original = element.Hipotesis_original.replace(dig, ' ');
|
|
|
|
|
|
element.resumen_original = element.resumen_original.replace(/"/g, ' ');
|
|
element.resumen_original = element.resumen_original.replace(/'/g, ' ');
|
|
element.resumen_original = element.resumen_original.replace(dig, ' ');
|
|
|
|
|
|
if (element.fecha_inicio == "")
|
|
element.fecha_inicio = "01/01/1980";
|
|
|
|
if (element.fecha_termino == "")
|
|
element.fecha_inicio = "01/01/1980";
|
|
|
|
element.avance = element.avance.replace("%", ' ');
|
|
|
|
element.presupuesto = element.presupuesto.replace("$", ' ');
|
|
|
|
|
|
let rfc = null;
|
|
let nombre = null
|
|
let ban = 0;
|
|
if (element.linea_investigacion.length > maximo_disc)
|
|
maximo_disc = element.linea_investigacion.length;
|
|
|
|
for (let i = 0; i < element.avance.length; i++)
|
|
if (element.avance[i] != ' ' && (element.avance[i] < '0' || element.avance[i] > '9'))
|
|
ban = 1;
|
|
if (element.avance == '' || ban == 1)
|
|
element.avance = '0';
|
|
let porciento = parseInt(element.avance);
|
|
if (porciento === NaN) {
|
|
porciento = 0;
|
|
element.avance = 0;
|
|
}
|
|
|
|
let presupuesto = element.presupuesto;
|
|
let f_c = new Date();
|
|
f_c = dataJsToMysql(f_c);
|
|
if (presupuesto.length > 0)
|
|
presupuesto[0] = '0';
|
|
let antes = presupuesto;
|
|
presupuesto = Number(presupuesto.replace(/[^0-9.-]+/g, ""));
|
|
|
|
if (presupuesto == NaN) {
|
|
console.log("error nan", antes);
|
|
presupuesto = 0.0;
|
|
}
|
|
let b = pon.find(e => e.Nombre + ' ' + e.ApellidoPaterno + ' ' + e.ApellidoMaterno === `${element.Nombre_completo}`);
|
|
if (b != undefined) {
|
|
|
|
|
|
|
|
let fecha_inicio = element.fecha_inicio;
|
|
let fecha_termino = element.fecha_termino;
|
|
|
|
let dateParts = fecha_inicio.split("/");
|
|
|
|
// month is 0-based, that's why we need dataParts[1] - 1
|
|
fecha_inicio = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]);
|
|
|
|
dateParts = fecha_termino.split("/");
|
|
|
|
// month is 0-based, that's why we need dataParts[1] - 1
|
|
fecha_termino = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]);
|
|
|
|
|
|
let antes = fecha_inicio;
|
|
let des = fecha_termino;
|
|
if (element.fecha_inicio != "" && fecha_inicio != "Invalid Date")
|
|
fecha_inicio = dataJsToMysql(fecha_inicio);
|
|
else
|
|
fecha_inicio = null
|
|
if (element.fecha_termino != "" && fecha_termino != "Invalid Date")
|
|
fecha_termino = dataJsToMysql(fecha_termino);
|
|
else
|
|
fecha_termino = null
|
|
|
|
// console.log("fecha inicio ", new Date(`"${fecha_inicio}"`), " ", fecha_inicio, " ", element.fecha_inicio, " ", antes);
|
|
// console.log("fecha fin ", new Date(`"${fecha_termino}"`), " ", fecha_termino, " ", element.fecha_termino, " ", des);
|
|
|
|
|
|
|
|
rfc = b.Rfc;
|
|
nombre = element.Nombre_completo;
|
|
|
|
// console.log("element.nombre_proyecto_investigacion");
|
|
// console.log(element.nombre_proyecto_investigacion);
|
|
// console.log("rfc");
|
|
// console.log(rfc);
|
|
// console.log("nombre");
|
|
// console.log(nombre);
|
|
// console.log("element.Disciplina");
|
|
// console.log(element.Disciplina);
|
|
// console.log("element.objetivo_general");
|
|
// console.log(element.objetivo_general);
|
|
// console.log("element.Hipotesis_original");
|
|
// console.log(element.Hipotesis_original);
|
|
// console.log("element.resumen_original");
|
|
// console.log(element.resumen_original);
|
|
// console.log("element.fecha_inicio");
|
|
// console.log(fecha_inicio);
|
|
// console.log("element.fecha_termino");
|
|
// console.log(fecha_termino);
|
|
// console.log("element.estatus");
|
|
// console.log(element.estatus);
|
|
// console.log("porciento");
|
|
// console.log(porciento);
|
|
// console.log("element.duracion");
|
|
// console.log(element.duracion);
|
|
// console.log("element.financiamiento");
|
|
// console.log(element.financiamiento);
|
|
// console.log("element.numero_registro");
|
|
// console.log(element.numero_registro);
|
|
|
|
// console.log("presupuesto");
|
|
// console.log(presupuesto);
|
|
// console.log("c_f");
|
|
// console.log(f_c)
|
|
let resultado;
|
|
if (fecha_inicio == null && fecha_termino == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", ${fecha_inicio}, ${fecha_termino}, "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else {
|
|
if (fecha_inicio == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}', "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", ${fecha_inicio}, "${fecha_termino}", "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else
|
|
if (fecha_termino == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", "${fecha_inicio}", ${fecha_termino}, "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", "${fecha_inicio}", "${fecha_termino}", "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
let c = `select id_proyecto from proyecto where nombre_proyecto="${element.nombre_proyecto_investigacion}";`;
|
|
respuesta_id_proyecto = await query(c);
|
|
console.log(respuesta_id_proyecto);
|
|
|
|
let id = respuesta_id_proyecto[0].id_proyecto;
|
|
c = `select id_campo from campo_conocimiento where nombre="${element.Campo_de_conocimiento}";`
|
|
let respuesta = await query(c);
|
|
// respuesta.catch(error => {
|
|
// console.log(error);
|
|
// console.log(element);
|
|
// return;
|
|
// })
|
|
|
|
// console.log("Esta es la respuesta de campo: ", respuesta, " ", element.Campo_de_conocimiento);
|
|
if (respuesta.length != 0) {
|
|
let id_campo = respuesta[0].id_campo;
|
|
c = `insert into proyecto_campo values (null, ${id}, ${id_campo})`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
if (element.objetivo_particular_1 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_1}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
if (element.objetivo_particular_2 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_2}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
if (element.objetivo_particular_3 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_3}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
if (element.objetivo_particular_4 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_4}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
});
|
|
}
|
|
|
|
if (element.objetivo_particular_5 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_5}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
no.push([element.num, element.nombre_proyecto_investigacion]);
|
|
|
|
|
|
let fecha_inicio = element.fecha_inicio;
|
|
let fecha_termino = element.fecha_termino;
|
|
|
|
let dateParts = fecha_inicio.split("/");
|
|
|
|
// month is 0-based, that's why we need dataParts[1] - 1
|
|
fecha_inicio = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]);
|
|
|
|
dateParts = fecha_termino.split("/");
|
|
|
|
// month is 0-based, that's why we need dataParts[1] - 1
|
|
fecha_termino = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]);
|
|
|
|
|
|
let antes = fecha_inicio;
|
|
let des = fecha_termino;
|
|
if (element.fecha_inicio != "" && fecha_inicio != "Invalid Date")
|
|
fecha_inicio = dataJsToMysql(fecha_inicio);
|
|
else
|
|
fecha_inicio = null
|
|
if (element.fecha_termino != "" && fecha_termino != "Invalid Date")
|
|
fecha_termino = dataJsToMysql(fecha_termino);
|
|
else
|
|
fecha_termino = null
|
|
|
|
// console.log("fecha inicio ", new Date(`"${fecha_inicio}"`), " ", fecha_inicio, " ", element.fecha_inicio, " ", antes);
|
|
// console.log("fecha fin ", new Date(`"${fecha_termino}"`), " ", fecha_termino, " ", element.fecha_termino, " ", des);
|
|
|
|
|
|
|
|
|
|
|
|
// console.log("element.nombre_proyecto_investigacion");
|
|
// console.log(element.nombre_proyecto_investigacion);
|
|
// console.log("rfc");
|
|
// console.log(rfc);
|
|
// console.log("nombre");
|
|
// console.log(nombre);
|
|
// console.log("element.Disciplina");
|
|
// console.log(element.Disciplina);
|
|
// console.log("element.objetivo_general");
|
|
// console.log(element.objetivo_general);
|
|
// console.log("element.Hipotesis_original");
|
|
// console.log(element.Hipotesis_original);
|
|
// console.log("element.resumen_original");
|
|
// console.log(element.resumen_original);
|
|
// console.log("element.fecha_inicio");
|
|
// console.log(fecha_inicio);
|
|
// console.log("element.fecha_termino");
|
|
// console.log(fecha_termino);
|
|
// console.log("element.estatus");
|
|
// console.log(element.estatus);
|
|
// console.log("porciento");
|
|
// console.log(porciento);
|
|
// console.log("element.duracion");
|
|
// console.log(element.duracion);
|
|
// console.log("element.financiamiento");
|
|
// console.log(element.financiamiento);
|
|
// console.log("element.numero_registro");
|
|
// console.log(element.numero_registro);
|
|
|
|
// console.log("presupuesto");
|
|
// console.log(presupuesto);
|
|
// console.log("c_f");
|
|
// console.log(f_c)
|
|
let resultado;
|
|
if (fecha_inicio == null && fecha_termino == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", " ", " ", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", ${fecha_inicio}, ${fecha_termino}, "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else {
|
|
if (fecha_inicio == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", ${fecha_inicio}, "${fecha_termino}", "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else
|
|
if (fecha_termino == null) {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", "${fecha_inicio}", ${fecha_termino}, "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
} else {
|
|
let cad = `insert into proyecto values (null, "${element.nombre_proyecto_investigacion}", "${rfc}", "${nombre}", "${element.Disciplina}", '${element.linea_investigacion}' , "${element.objetivo_general}", "${element.Hipotesis_original}",
|
|
"${element.resumen_original}", "${fecha_inicio}", "${fecha_termino}", "${element.estatus}", ${porciento}, "${element.duracion}", "${element.financiamiento}",
|
|
"${element.numero_registro}", ${presupuesto}, 1, "${f_c}","${f_c}" )`;
|
|
resultado = query(cad);
|
|
resultado.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
let c = `select id_proyecto from proyecto where nombre_proyecto="${element.nombre_proyecto_investigacion}";`;
|
|
respuesta_id_proyecto = await query(c);
|
|
console.log(respuesta_id_proyecto);
|
|
|
|
let id = respuesta_id_proyecto[0].id_proyecto;
|
|
c = `select id_campo from campo_conocimiento where nombre="${element.Campo_de_conocimiento}";`
|
|
let respuesta = await query(c);
|
|
console.log(respuesta);
|
|
// console.log("Esta es la respuesta de campo: ", respuesta, " ", element.Campo_de_conocimiento);
|
|
if (respuesta.length != 0 && !respuesta) {
|
|
let id_campo = respuesta[0].id_campo;
|
|
console.log("Este es el id_campo: ", id_campo);
|
|
c = `insert into proyecto_campo values (null, ${id}, ${id_campo})`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
if (element.objetivo_particular_1 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_1}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
if (element.objetivo_particular_2 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_2}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
if (element.objetivo_particular_3 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_3}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
if (element.objetivo_particular_4 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_4}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
if (element.objetivo_particular_5 != "") {
|
|
c = `insert into proyecto_objetivo values (null, ${id}, "${element.objetivo_particular_5}");`;
|
|
respuesta = query(c);
|
|
respuesta.catch(error => {
|
|
console.log(error);
|
|
console.log(element);
|
|
return;
|
|
})
|
|
}
|
|
|
|
|
|
}
|
|
console.log(i);
|
|
}
|
|
console.log("maximo: ");
|
|
console.log(maximo_disc);
|
|
console.log(no);
|
|
return no;
|
|
|
|
|
|
}
|
|
|
|
llenar() |