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

45 lines
1.3 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');
const config = require('../config');
2021-03-25 12:38:48 +00:00
router.get('/:ticket', async(req, res) => {
const ticket = req.params.ticket;
2021-03-25 12:38:48 +00:00
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) {
insertFlash(data);
});
}
function insertFlash(qrySql) {
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;
(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: config.storeId,
2021-08-06 07:17:48 +00:00
lightCololr: 8,
2021-07-01 06:55:17 +00:00
lightTime: 30,
2021-08-06 07:17:48 +00:00
targetExecution: qrySql[0].shelvingFk + qrySql[0].level + '/tagWithTicket',
2021-07-01 06:55:17 +00:00
lightFrequency: 1
2021-05-13 14:21:34 +00:00
},
responseType: 'json',
headers: {
'Authorization': key
}
});
2021-03-25 12:38:48 +00:00
})();
})();
}