This commit is contained in:
alexmorenograu 2021-03-17 09:11:55 +01:00
parent 8dfe2f7d3e
commit 73a59ca65d
6 changed files with 104 additions and 104 deletions

View File

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

20
bindTicketShelvingOld.js Normal file
View File

@ -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 = '274286';
function ticketCollection(collectionFk){//parametro collectionFk
select.select(collectionFk, function(err,data){
if(filter.isShelving(shelving)){
//insert.insertTicket(data, shelving,)
}
else{
console.log("¡MATRICULA INCORRECTA!")
}
});
}
ticketCollection(collectionFk);

View File

@ -1,25 +0,0 @@
const insert = require('./insertTicketWW');
const filter = require('./utilities/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 = '273449';
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,34 +8,32 @@ function insertTicket(consultaSql, shelving, max){
(async() => {
for(var i=0;i<consultaSql.length;i++){
//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,
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<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))
}
}
})();
})();

44
insertTicketOld.js Normal file
View File

@ -0,0 +1,44 @@
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<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,
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)
}
//}
}
})();
})();
}
exports.insertTicket = insertTicket;

View File

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