From 4a4269ca05dbb81c171fb506b13462722de9c410 Mon Sep 17 00:00:00 2001 From: llopis15 Date: Thu, 11 Mar 2021 16:39:10 +0100 Subject: [PATCH] update binShelving and bindShelvingTag --- bindShelving.js | 65 +++++++++++++++------------------------------- bindShelvingTag.js | 27 +++++++++++++++++++ insertShelving.js | 34 ++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 bindShelvingTag.js create mode 100644 insertShelving.js diff --git a/bindShelving.js b/bindShelving.js index 5da3dbb..5e9e8e8 100644 --- a/bindShelving.js +++ b/bindShelving.js @@ -1,50 +1,27 @@ -const insert = require('./utilities/inserts'); - - -function smartTag(barcode, shelving, level){ - const got = require('got'); +function bindShelving(barcode, shelving, level){ const config = require('./config'); + const got = require('got'); (async() => { - insert.insertShelving(shelving, level); + const info = await config.info + let key = info.data.token; (async() => { - const info = await config.info - let key = info.data.token; - - (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { - json: { - storeId: config.storeId, - tagItemBinds: [{ - eslBarcode: barcode, - itemBarcode: shelving + level - } - ] - }, - responseType: 'json', - headers: { - "Authorization": key - } - }) - console.log(body) - })(); - })(); + const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { + json: { + storeId: config.storeId, + tagItemBinds: [{ + eslBarcode: barcode, + itemBarcode: shelving + level + } + ] + }, + responseType: 'json', + headers: { + "Authorization": key + } + }) + console.log(body) + })(); })(); } -///DATOS INTRODUCIDOS POR EL USUARIO//// -var barcode = "A0A3B820690F"; //valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F) -var shelving = "BCD"; //valido = 3 CARACTERES LETRAS (A-Z) -var level = "1"; -////////////////////////////////////// - -if(insert.filter(barcode,"barcode")){ - if(insert.filter(shelving,"shelving")){ - smartTag(barcode, shelving, level); - } - else{ - console.log("¡MATRICULA INCORRECTA!") - } -} -else{ - console.log("¡CODIGO DE ETIQUETA INCORRECTO!") -} +exports.bindShelving = bindShelving; \ No newline at end of file diff --git a/bindShelvingTag.js b/bindShelvingTag.js new file mode 100644 index 0000000..15116a8 --- /dev/null +++ b/bindShelvingTag.js @@ -0,0 +1,27 @@ +const insertShelving = require('./insertShelving'); +const bindShelving = require('./bindShelving'); + +function smartTag(barcode, shelving, level){ + insertShelving.insertShelving(shelving, level); + bindShelving.bindShelving(barcode, shelving, level); +} + +///DATOS INTRODUCIDOS POR EL USUARIO//// +var barcode = "A0A3B820690F"; //valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F) +var shelving = "BCD"; //valido = 3 CARACTERES LETRAS (A-Z) +var level = "1"; +smartTag(barcode, shelving, level); +////////////////////////////////////// + +/*if(insert.filter(barcode,"barcode")){ + if(insert.filter(shelving,"shelving")){ + smartTag(barcode, shelving, level); + } + else{ + console.log("¡MATRICULA INCORRECTA!") + } +} +else{ + console.log("¡CODIGO DE ETIQUETA INCORRECTO!") +} +*/ \ No newline at end of file diff --git a/insertShelving.js b/insertShelving.js new file mode 100644 index 0000000..09ce96e --- /dev/null +++ b/insertShelving.js @@ -0,0 +1,34 @@ +function insertShelving(shelving, level){ + const config = require('./config'); + const got = require('got'); + (async() => { + const info = await config.info + let key = info.data.token + let currentUser = info.data.currentUser; + (async() => { + const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { + json: { + agencyId: currentUser.agencyId, + merchantId: currentUser.merchantId, + storeId: currentUser.storeId, + unitName: currentUser.unitName, + itemList: [ + { + attrCategory: "verdnatura", + attrName: "sinTicket", + barCode: shelving + level,//Matricula + nivel + itemTitle: "Etiqueta Sin ticket", + } + ] + }, + responseType: 'json', + headers: { + "Authorization": key + } + }) + console.log(body) + })(); + })(); +} + +exports.insertShelving = insertShelving; \ No newline at end of file