2021-03-25 12:38:48 +00:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router(); // eslint-disable-line
|
2022-04-01 12:17:36 +00:00
|
|
|
const selectTicket = require('../db/selectTicket');
|
2021-08-06 06:04:22 +00:00
|
|
|
const config = require('../config');
|
2022-04-01 12:17:36 +00:00
|
|
|
const dataLogIn = require('../server');
|
|
|
|
const got = require('got');
|
2021-03-25 12:38:48 +00:00
|
|
|
|
|
|
|
router.get('/:ticket', async(req, res) => {
|
2022-04-01 12:17:36 +00:00
|
|
|
const ticketId = req.params.ticket;
|
|
|
|
|
|
|
|
const ticket = selectTicket(ticketId);
|
|
|
|
await insertFlash(ticket);
|
2021-10-14 05:44:42 +00:00
|
|
|
|
2021-05-13 14:21:34 +00:00
|
|
|
res.json({message: 'SUCCESS'});
|
2021-03-25 12:38:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|
|
|
|
|
2022-04-01 12:17:36 +00:00
|
|
|
async function insertFlash(ticket) {
|
|
|
|
const info = await dataLogIn.dataLogIn;
|
|
|
|
const key = info.data.token;
|
2021-03-25 12:38:48 +00:00
|
|
|
|
2022-04-01 12:17:36 +00:00
|
|
|
await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
|
|
|
|
json: {
|
|
|
|
storeId: config.storeId,
|
|
|
|
lightCololr: 8,
|
|
|
|
lightTime: 30,
|
|
|
|
targetExecution: ticket[0].shelvingFk + ticket[0].level + '/tagWithTicket',
|
|
|
|
lightFrequency: 1
|
|
|
|
},
|
|
|
|
responseType: 'json',
|
|
|
|
headers: {
|
|
|
|
'Authorization': key
|
|
|
|
}
|
|
|
|
});
|
2021-03-25 12:38:48 +00:00
|
|
|
}
|