This commit is contained in:
alexmorenograu 2021-03-16 12:25:47 +01:00
parent 4b70a5c419
commit 2e3047ecbe
4 changed files with 24 additions and 15 deletions

View File

@ -4,11 +4,11 @@ const filter = require('./filter');
const insertDB = require('./db/insertDB')
function bindShelvingTag(barcode, shelving, level){
let shelvingId = shelving + level;
if(filter.filterBarcode(barcode)){
if(filter.filterShelving(shelving)){
bindShelving.bindShelving(barcode, shelvingId);
insertShelving.insertShelving(shelvingId);
var shelvingId = shelving + level;
//insertShelving.insertShelving(shelvingId);
//bindShelving.bindShelving(barcode, shelvingId);
insertDB.insertDB(barcode, shelving, level);
}else{
console.log("¡MATRICULA INCORRECTA!")
@ -18,9 +18,9 @@ function bindShelvingTag(barcode, shelving, level){
}
}
///DATOS INTRODUCIDOS POR EL USUARIO////
var barcode = "A0A3B8224DBF"; //valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F)
var shelving = "BCD"; //valido = 3 CARACTERES LETRAS (A-Z)
var level = "1";
var barcode = "A0A3B8224DFF"; //valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F)
var shelving = "ABC"; //valido = 3 CARACTERES LETRAS (A-Z)
var level = "4";
//////////////////////////////////////
bindShelvingTag(barcode, shelving, level);

View File

@ -1,14 +1,23 @@
const con = require('./connect')
function insertDB(barcode, shelving, level){
con.con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sql = `INSERT INTO vn.smartTag (code, shelvingFk, level) VALUES ('${barcode}', '${shelving}', ${level})`;
con.con.query(sql, function (err, result) {
con.con.connect(function(err) {
if (err) throw err;
console.log("1 record inserted");
console.log("Connected!");
var sql = `IF EXISTS(SELECT * FROM vn.smartTag WHERE code='${barcode}')
THEN
UPDATE vn.smartTag
SET shelvingFk = '${shelving}', level = ${level}
WHERE code='${barcode}';
ELSE
INSERT
INTO vn.smartTag (code, shelvingFk, level)
VALUES ('${barcode}', '${shelving}', ${level});
END IF;`;
con.con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
});
}
exports.insertDB = insertDB;

View File

@ -14,4 +14,4 @@ const encryptPassword = async(password) => {
return crypto.publicEncrypt(externKey, buffer).toString("base64");
};
exports.encryptPassword = encryptPassword;
exports.encryptPassword = encryptPassword;

View File

@ -1,7 +1,7 @@
const config = require('./config');
const got = require('got');
function insertShelving(shelving, level){
function insertShelving(shelvingId){
(async() => {
const info = await config.info
let key = info.data.token