From 8d7d26ebd4896d1cae50224e6ae515a595c23480 Mon Sep 17 00:00:00 2001 From: alexmorenograu <61759297+alexmorenograu@users.noreply.github.com> Date: Thu, 13 May 2021 16:21:34 +0200 Subject: [PATCH] flashOn prepare --- db/selectTicket.js | 6 +--- methods/bindTicketShelving.js | 1 + methods/flashOn.js | 58 +++++++++++++++++------------------ 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/db/selectTicket.js b/db/selectTicket.js index 804d7d4..7f4b289 100644 --- a/db/selectTicket.js +++ b/db/selectTicket.js @@ -1,11 +1,7 @@ const con = require('./connect'); function select(ticket, callback) { - let consSql = `SELECT st.ticketFk AS Ticket, st.shelvingFk AS Shelving, st.level AS Level, t.clientFk AS Client, am.name AS Agency - FROM smartTag st JOIN ticket t ON st.ticketFk = t.id JOIN client c ON t.clientFk = c.id - JOIN agencyMode am ON am.id = t.agencyModeFk - WHERE st.ticketFk = ${ticket}`; - + let consSql = `SELECT * FROM vn.collectionSmartTag WHERE ticketFk = ${ticket}`; con.con.query(consSql, function(err, result, fields) { callback(null, result); }); diff --git a/methods/bindTicketShelving.js b/methods/bindTicketShelving.js index fbec44c..f6b4109 100644 --- a/methods/bindTicketShelving.js +++ b/methods/bindTicketShelving.js @@ -7,6 +7,7 @@ router.get('/:collectionFk', async(req, res) => { const collectionFk = req.params.collectionFk; console.log(collectionFk); ticketShelving(collectionFk); + res.json({message: 'SUCCESS'}); }); module.exports = router; diff --git a/methods/flashOn.js b/methods/flashOn.js index 76c2651..8faa0e1 100644 --- a/methods/flashOn.js +++ b/methods/flashOn.js @@ -6,6 +6,7 @@ router.get('/:ticket', async(req, res) => { const ticket = req.params.ticket; console.log(ticket); searchTicket(ticket); + res.json({message: 'SUCCESS'}); }); module.exports = router; @@ -27,35 +28,34 @@ function insertFlash(consultaSql) { let currentUser = info.data.currentUser; (async() => { - for (let i = 0; i < consultaSql.length; i++) { - const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line - json: { - agencyId: currentUser.agencyId, - merchantId: currentUser.merchantId, - storeId: currentUser.storeId, - unitName: currentUser.unitName, - itemList: [ - { - attrCategory: 'verdnatura', - attrName: 'conTicket', - barCode: consultaSql[i].shelvingFk + consultaSql[i].level, // Matricula + nivel - itemTitle: 'Etiqueta Con ticket', - productCode: consultaSql[i].ticketFk, // Ticket - custFeature1: consultaSql[i].clientFk, // Cliente - custFeature2: consultaSql[i].agencyFk, // Agencia de transporte - custFeature3: 1, // Valor luz led - custFeature4: consultaSql[i].workerFk, // Trabajador - - } - ] - }, - responseType: 'json', - headers: { - 'Authorization': key - } - }); - console.log(body); - } + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line + json: { + agencyId: currentUser.agencyId, + merchantId: currentUser.merchantId, + storeId: currentUser.storeId, + unitName: currentUser.unitName, + itemList: [ + { + attrCategory: 'verdnatura', + attrName: 'conTicket', + barCode: consultaSql[0].shelvingFk + consultaSql[0].level, // Matricula + nivel + itemTitle: 'Etiqueta Con ticket', + productCode: consultaSql[0].ticketFk, // Ticket + qrCode: consultaSql[0].ticketFk, + custFeature1: consultaSql[0].clientFk, // Cliente + custFeature2: consultaSql[0].agencyFk, // Agencia de transporte + custFeature3: 1, // Luz LED + custFeature4: '', // consultaSql[0].workerFk, // Trabajador + custFeature5: consultaSql[0].wagon, // Wagon + } + ] + }, + responseType: 'json', + headers: { + 'Authorization': key + } + }); + console.log(body); })(); })(); }