This repository has been archived on 2024-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
smart-tag/methods/flashOn.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-03-25 12:38:48 +00:00
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);
2021-05-13 14:21:34 +00:00
res.json({message: 'SUCCESS'});
2021-03-25 12:38:48 +00:00
});
module.exports = router;
2021-03-29 07:38:41 +00:00
function searchTicket(ticket) {// parametro ticketFk
2021-03-25 12:38:48 +00:00
select.select(ticket, function(err, data) {
console.log(data);
insertFlash(data);
});
2021-07-01 06:55:17 +00:00
// insertFlash();
2021-03-25 12:38:48 +00:00
}
function insertFlash(consultaSql) {
2021-07-01 06:55:17 +00:00
// console.log('CONSULTASQL_TAMAÑO:', consultaSql.length);
2021-03-25 12:38:48 +00:00
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() => {
2021-07-01 06:55:17 +00:00
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
2021-05-13 14:21:34 +00:00
json: {
storeId: currentUser.storeId,
2021-07-01 06:55:17 +00:00
lightColor: 8,
lightTime: 30,
targetExecution: 1, // consultaSql[0].shelvingFk + consultaSql[0].level + '/Etiqueta Con Ticket',
lightFrequency: 1
2021-05-13 14:21:34 +00:00
},
responseType: 'json',
headers: {
'Authorization': key
}
});
console.log(body);
2021-03-25 12:38:48 +00:00
})();
})();
}