49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router(); // eslint-disable-line
|
|
const select = require('../db/selectTicket');
|
|
|
|
router.get('/:ticket', async(req, res) => {
|
|
const ticket = req.params.ticket;
|
|
console.log(ticket);
|
|
searchTicket(ticket);
|
|
res.json({message: 'SUCCESS'});
|
|
});
|
|
|
|
module.exports = router;
|
|
|
|
function searchTicket(ticket) {// parametro ticketFk
|
|
select.select(ticket, function(err, data) {
|
|
console.log(data);
|
|
insertFlash(data);
|
|
});
|
|
// insertFlash();
|
|
}
|
|
|
|
function insertFlash(consultaSql) {
|
|
// console.log('CONSULTASQL_TAMAÑO:', consultaSql.length);
|
|
const dataLogIn = require('../server');
|
|
const got = require('got');
|
|
(async() => {
|
|
const info = await dataLogIn.dataLogIn;
|
|
let key = info.data.token;
|
|
let currentUser = info.data.currentUser;
|
|
|
|
(async() => {
|
|
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
|
|
json: {
|
|
storeId: currentUser.storeId,
|
|
lightColor: 8,
|
|
lightTime: 30,
|
|
targetExecution: 1, // consultaSql[0].shelvingFk + consultaSql[0].level + '/Etiqueta Con Ticket',
|
|
lightFrequency: 1
|
|
},
|
|
responseType: 'json',
|
|
headers: {
|
|
'Authorization': key
|
|
}
|
|
});
|
|
console.log(body);
|
|
})();
|
|
})();
|
|
}
|