Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/smart-tag into test
This commit is contained in:
commit
da9e81d746
|
@ -4,12 +4,11 @@ const filter = require('./filter');
|
|||
const insertDB = require('./db/insertDB')
|
||||
|
||||
function bindShelvingTag(barcode, shelving, level){
|
||||
if(filter.filterBarcode(barcode)){
|
||||
if(filter.filterShelving(shelving)){
|
||||
var shelvingId = shelving + level;
|
||||
//insertShelving.insertShelving(shelvingId);
|
||||
//bindShelving.bindShelving(barcode, shelvingId);
|
||||
insertDB.insertDB(barcode, shelving, level);
|
||||
if(filter.isBarcode(barcode)){
|
||||
if(filter.isShelving(shelving)){
|
||||
bindShelving.bindShelving(barcode, shelving, level);
|
||||
insertShelving.insertShelving(shelving, level);
|
||||
//insertDB.insertDB(barcode, shelving, level);
|
||||
}else{
|
||||
console.log("¡MATRICULA INCORRECTA!")
|
||||
}
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
const insert = require('./insertTicket');
|
||||
const filter = require('./filter');
|
||||
const select = require('./db/selectDB');
|
||||
const maxWagon = require('./db/maxWagon');
|
||||
|
||||
var barcode = "A0A3B820690F";
|
||||
var shelving = "BCD";///introducida por el usuario
|
||||
var collectionFk = '254';
|
||||
//var shelving = "BCD";///introducida por el usuario O en leida de la bbdd?
|
||||
var collectionFk = '274286';
|
||||
|
||||
function ticketCollection(collectionFk, shelving){//parametro collectionFk
|
||||
function ticketCollection(collectionFk){//parametro collectionFk
|
||||
select.select(collectionFk, function(err,data){
|
||||
if(filter.filterShelving(shelving)){
|
||||
insert.insertTicket(data, shelving,)
|
||||
}
|
||||
else{
|
||||
console.log("¡MATRICULA INCORRECTA!")
|
||||
}
|
||||
maxWagon.maxWagon(collectionFk,function(err,max){
|
||||
console.log('Entra')
|
||||
//aqui iria una función para pedir el numero de shelvings correspondientes
|
||||
var shelving = ['ABC','DFG','HIJ']
|
||||
//if(filter.isShelving(shelving)){
|
||||
insert.insertTicket(data, shelving, 1)
|
||||
//}else{
|
||||
//console.log("¡MATRICULA INCORRECTA!")
|
||||
//}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ticketCollection(collectionFk, shelving);
|
||||
ticketCollection(collectionFk);
|
|
@ -0,0 +1,20 @@
|
|||
const insert = require('./insertTicket');
|
||||
const filter = require('./filter');
|
||||
const select = require('./db/selectDB');
|
||||
|
||||
var barcode = "A0A3B820690F";
|
||||
var shelving = "BCD";///introducida por el usuario
|
||||
var collectionFk = '254';
|
||||
|
||||
function ticketCollection(collectionFk){//parametro collectionFk
|
||||
select.select(collectionFk, function(err,data){
|
||||
if(filter.filterShelving(shelving)){
|
||||
insert.insertTicket(data, shelving,)
|
||||
}
|
||||
else{
|
||||
console.log("¡MATRICULA INCORRECTA!")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ticketCollection(collectionFk);
|
11
db/db.sql
11
db/db.sql
|
@ -3,8 +3,11 @@ CREATE TABLE vn.smartTag (
|
|||
shelvingFk varchar(10) NULL,
|
||||
`level` int(11) NULL,
|
||||
CONSTRAINT `PRIMARY` PRIMARY KEY (code)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci;
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8
|
||||
COLLATE=utf8_unicode_ci;
|
||||
|
||||
ALTER TABLE vn.smartTag MODIFY COLUMN shelvingFk varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL NULL;
|
||||
|
||||
ALTER TABLE vn.smartTag ADD CONSTRAINT smartTag_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
const con = require('./connect')
|
||||
|
||||
function maxWagon(collectionFk, callback){
|
||||
|
||||
let consSql = `SELECT MAX(tc.wagon)
|
||||
FROM ticketCollection tc
|
||||
WHERE tc.collectionFk = ${collectionFk}`;
|
||||
con.con.query(consSql, function (err, result, fields) {
|
||||
console.log(result);
|
||||
callback(null,result);
|
||||
});
|
||||
}
|
||||
|
||||
exports.maxWagon = maxWagon;
|
17
encrypted.js
17
encrypted.js
|
@ -1,17 +0,0 @@
|
|||
const crypto = require('crypto');
|
||||
const got = require('got');
|
||||
const config = require('./config');
|
||||
|
||||
const encryptPassword = async(password) => {
|
||||
const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', {
|
||||
});
|
||||
const publicKey=`-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`;
|
||||
const externKey = {
|
||||
key: publicKey,
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING
|
||||
};
|
||||
let buffer = Buffer.from(password);
|
||||
return crypto.publicEncrypt(externKey, buffer).toString("base64");
|
||||
};
|
||||
|
||||
exports.encryptPassword = encryptPassword;
|
|
@ -1,10 +1,10 @@
|
|||
function filterBarcode(toFilter){
|
||||
function isBarcode(toFilter){
|
||||
const exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/
|
||||
return exp.test(toFilter)
|
||||
}
|
||||
function filterShelving(toFilter){
|
||||
function isShelving(toFilter){
|
||||
const exp = /^[A-Z][A-Z][A-Z]$/
|
||||
return exp.test(toFilter)
|
||||
}
|
||||
exports.filterBarcode = filterBarcode;
|
||||
exports.filterShelving = filterShelving;
|
||||
exports.isBarcode = isBarcode;
|
||||
exports.isShelving = isShelving;
|
|
@ -1,4 +1,4 @@
|
|||
function insertTicket(consultaSql, shelving){
|
||||
function insertTicket(consultaSql, shelving, max){
|
||||
const config = require('./config');
|
||||
const got = require('got');
|
||||
(async() => {
|
||||
|
@ -8,31 +8,33 @@ function insertTicket(consultaSql, shelving){
|
|||
|
||||
(async() => {
|
||||
for(var i=0;i<consultaSql.length;i++){
|
||||
for(var j=0;j<consultaSql[i].Level.toString().length;j++){
|
||||
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: "conTicket",
|
||||
barCode: shelving + consultaSql[i].Level.toString().charAt(j),//Matricula + nivel
|
||||
itemTitle: "Etiqueta Con ticket",
|
||||
productCode: consultaSql[i].Ticket, //Ticket
|
||||
custFeature1: consultaSql[i].Client, //Client
|
||||
custFeature2: consultaSql[i].Agency //Agencia de transporte
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
"Authorization": key
|
||||
}
|
||||
})
|
||||
console.log(body)
|
||||
for(var j=0;j<max;j++){
|
||||
for(var k=0;k<consultaSql[k].Level.toString().length;k++){
|
||||
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: "conTicket",
|
||||
barCode: shelving[j] + consultaSql[i].Level.toString().charAt(k),//Matricula + nivel
|
||||
itemTitle: "Etiqueta Con ticket",
|
||||
productCode: consultaSql[i].Ticket, //Ticket
|
||||
custFeature1: consultaSql[i].Client, //Client
|
||||
custFeature2: consultaSql[i].Agency //Agencia de transporte
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
"Authorization": key
|
||||
}
|
||||
})
|
||||
console.log(body + ':' + consultaSql[i].Ticket)
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const crypto = require('crypto');
|
||||
const got = require('got');
|
||||
const config = require('./config');
|
||||
const config = require('../config');
|
||||
|
||||
const encryptPassword = async(password) => {
|
||||
const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', {
|
||||
|
|
Reference in New Issue