45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router(); // eslint-disable-line
|
|
const select = require('../db/selectTicket');
|
|
const config = require('../config');
|
|
|
|
router.get('/:ticket', async(req, res) => {
|
|
const ticket = req.params.ticket;
|
|
|
|
searchTicket(ticket);
|
|
res.json({message: 'SUCCESS'});
|
|
});
|
|
|
|
module.exports = router;
|
|
|
|
function searchTicket(ticket) {// parametro ticketFk
|
|
select.select(ticket, function(err, data) {
|
|
insertFlash(data);
|
|
});
|
|
}
|
|
|
|
function insertFlash(qrySql) {
|
|
const dataLogIn = require('../server');
|
|
const got = require('got');
|
|
(async() => {
|
|
const info = await dataLogIn.dataLogIn;
|
|
let key = info.data.token;
|
|
|
|
(async() => {
|
|
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
|
|
json: {
|
|
storeId: config.storeId,
|
|
lightCololr: 8,
|
|
lightTime: 30,
|
|
targetExecution: qrySql[0].shelvingFk + qrySql[0].level + '/tagWithTicket',
|
|
lightFrequency: 1
|
|
},
|
|
responseType: 'json',
|
|
headers: {
|
|
'Authorization': key
|
|
}
|
|
});
|
|
})();
|
|
})();
|
|
}
|