update
This commit is contained in:
parent
4b70a5c419
commit
2e3047ecbe
|
@ -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);
|
||||
|
|
|
@ -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;
|
|
@ -14,4 +14,4 @@ const encryptPassword = async(password) => {
|
|||
return crypto.publicEncrypt(externKey, buffer).toString("base64");
|
||||
};
|
||||
|
||||
exports.encryptPassword = encryptPassword;
|
||||
exports.encryptPassword = encryptPassword;
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue