update wagons

This commit is contained in:
alexmorenograu 2021-03-16 13:09:52 +01:00
parent da9e81d746
commit 6b99d508fa
5 changed files with 79 additions and 37 deletions

View File

@ -1,24 +1,19 @@
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 O en leida de la bbdd?
var shelving = "BCD";///introducida por el usuario
var collectionFk = '274286';
function ticketCollection(collectionFk){//parametro collectionFk
select.select(collectionFk, function(err,data){
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!")
//}
});
if(filter.isShelving(shelving)){
//insert.insertTicket(data, shelving,)
}
else{
console.log("¡MATRICULA INCORRECTA!")
}
});
}

View File

@ -1,20 +0,0 @@
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);

25
bindTicketShelvingWW.js Normal file
View File

@ -0,0 +1,25 @@
const insert = require('./insertTicketWW');
const filter = require('./filter');
const select = require('./db/selectDB');
const maxWagon = require('./db/maxWagon');
var barcode = "A0A3B820690F";
//var shelving = "BCD";///introducida por el usuario O en leida de la bbdd?
var collectionFk = '274286';
function ticketCollection(collectionFk){//parametro collectionFk
select.select(collectionFk, function(err,data){
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, max)
//}else{
//console.log("¡MATRICULA INCORRECTA!")
//}
});
});
}
ticketCollection(collectionFk);

View File

@ -8,8 +8,8 @@ function insertTicket(consultaSql, shelving, max){
(async() => {
for(var i=0;i<consultaSql.length;i++){
for(var j=0;j<max;j++){
for(var k=0;k<consultaSql[k].Level.toString().length;k++){
//for(var j=0;j<max;j++){
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,
@ -20,7 +20,7 @@ function insertTicket(consultaSql, shelving, max){
{
attrCategory: "verdnatura",
attrName: "conTicket",
barCode: shelving[j] + consultaSql[i].Level.toString().charAt(k),//Matricula + nivel
barCode: shelving + consultaSql[i].Level.toString().charAt(j),//Matricula + nivel
itemTitle: "Etiqueta Con ticket",
productCode: consultaSql[i].Ticket, //Ticket
custFeature1: consultaSql[i].Client, //Client
@ -33,9 +33,9 @@ function insertTicket(consultaSql, shelving, max){
"Authorization": key
}
})
console.log(body + ':' + consultaSql[i].Ticket)
console.log(body)
}
}
//}
}
})();
})();

42
insertTicketWW.js Normal file
View File

@ -0,0 +1,42 @@
function insertTicket(consultaSql, shelving, max){
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() => {
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].Wagon-1] + 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,consultaSql[i].Ticket,shelving[consultaSql[i].Wagon-1],consultaSql[i].Level.toString().charAt(j))
}
}
})();
})();
}
exports.insertTicket = insertTicket;