diff --git a/funtions.js b/funtions.js index b43e0e0..f9b2368 100644 --- a/funtions.js +++ b/funtions.js @@ -153,20 +153,27 @@ async function ConsultaClaves(cedula, chang = null){ var array = {'ok': false, 'data':[], 'msg':null}; var _ur = 'consulta_predios_detalle/2/'+cedula+'?boot=true'; if(chang != null){ - var _ur = 'consulta_predios_detalle/1/'+cedula+'?boot=true&cc=1'; + var _ur = 'consulta_predios_detalle/1/'+cedula+'?boot=true'; } console.log(_ur); AxiosGET(_ur, {}).then(function (result) { - if(result['ok'] && result['data_bot']['data'].length > 0){ - array['ok'] = true; array['data'] = result['data_bot']['data']; array['msg'] = 'Consulta exitosa'; - }else{ - array['msg'] = 'el número de cédula '+cedula+' no posee predios catastrales registrados en el GAD MANTA'; - if(chang != null){ - array['msg'] = 'la clave catastral '+cedula+' no existe en los registros del GAD MANTA'; - } + if(result['ok']){ + array['ok'] = true; + array['data'] = result['data_bot']; + array['msg'] = 'Consulta exitosa'; + }else{ + array['msg'] = result['message']; } - console.log("array procedure server"); - console.log(array); + // if(result['ok'] && result['data_bot']['data'].length > 0){ + // array['ok'] = true; array['data'] = result['data_bot']['data']; array['msg'] = 'Consulta exitosa'; + // }else{ + // array['msg'] = 'el número de cédula '+cedula+' no posee predios catastrales registrados en el GAD MANTA'; + // if(chang != null){ + // array['msg'] = 'la clave catastral '+cedula+' no existe en los registros del GAD MANTA'; + // } + // } + // console.log("array procedure server"); + // console.log(array); resolve(array); }).catch(function (error) { array['msg'] = error; diff --git a/index.js b/index.js index 9f07c56..9e8a28c 100644 --- a/index.js +++ b/index.js @@ -193,7 +193,7 @@ app.post("/webhook", express.json(), function (req, res) { -let port = 3000; +let port = process.env.port || 3092; app.listen(port, () => { console.log("Estamos ejecutando el servidor en el puerto " + port); }); \ No newline at end of file diff --git a/metodos.js b/metodos.js index 3c680f3..8eb1993 100644 --- a/metodos.js +++ b/metodos.js @@ -656,39 +656,37 @@ async function Fun_ConsultarClavesCatastrales(agent, req, res, _cedula = null, n const regex = /^[0-9]*$/; _cedula = _cedula.replace(/-/g, ""); if (regex.test(_cedula)) { - console.log('legion') let legion = await funcion.ConsultaClaves(_cedula, nuevo); console.log(legion) if (legion['ok'] == true) { - let coun = legion['data'].length; - let mensjae_predios = ''; - legion['data'].forEach((element, index) => { - var rec = element['valor']['boot']['anteriores']; + // let mensjae_predios = ''; + // legion['data'].forEach((element, index) => { + // var rec = element['valor']['boot']['anteriores']; - if (element['valor']['boot']['total'] != null) { - if (element['valor']['boot']['anteriores'] == 'Recaudación al día') { - rec = element['valor']['boot']['actual'] + '\n' + element['valor']['boot']['total']; - }else{ - rec += '\n' + element['valor']['boot']['actual'] + '\n' + element['valor']['boot']['total']; - } - } - if (mensjae_predios.length > 0) { - mensjae_predios += '\n\n'; - } - mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; - // if (index == (coun - 1)) { - // mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; - // // agent.add(element['text'] + '\n' + element['direccion'] + '\n' + rec); - // // return Fun_RetornarAlinicio(agent, req, res, funcion.conver_name(data_context.name)); - // } else { - // mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; - // // agent.add(element['text'] + '\n' + funcion.conver_capitalice(element['direccion']) + '\n' + rec); - // } - }); - - if (mensjae_predios.length > 0) { - agent.add(mensjae_predios); - } + // if (element['valor']['boot']['total'] != null) { + // if (element['valor']['boot']['anteriores'] == 'Recaudación al día') { + // rec = element['valor']['boot']['actual'] + '\n' + element['valor']['boot']['total']; + // }else{ + // rec += '\n' + element['valor']['boot']['actual'] + '\n' + element['valor']['boot']['total']; + // } + // } + // if (mensjae_predios.length > 0) { + // mensjae_predios += '\n\n'; + // } + // mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; + // // if (index == (coun - 1)) { + // // mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; + // // // agent.add(element['text'] + '\n' + element['direccion'] + '\n' + rec); + // // // return Fun_RetornarAlinicio(agent, req, res, funcion.conver_name(data_context.name)); + // // } else { + // // mensjae_predios += element['text'] + '\n' + element['direccion'] + '\n' + rec; + // // // agent.add(element['text'] + '\n' + funcion.conver_capitalice(element['direccion']) + '\n' + rec); + // // } + // }); + // if (mensjae_predios.length > 0) { + // agent.add(mensjae_predios); + // } + agent.add(legion['data_text']); return Fun_RetornarAlinicio(agent, req, res, funcion.conver_name(data_context.name)); } else { agent.add(funcion.conver_name(data_context.name) + ', ' + legion['msg']);