update insertShelving
This commit is contained in:
parent
366df0291a
commit
35cbbdfa94
|
@ -1,5 +1,7 @@
|
|||
|
||||
const insert = require('./utilities/inserts');
|
||||
const insert = require('./insertTicket');
|
||||
const filter = require('./filter');
|
||||
|
||||
|
||||
var barcode = "A0A3B820690F";
|
||||
var shelving = "ABC";///introducida por el usuario
|
||||
|
@ -35,7 +37,7 @@ var consultaSql1 = [
|
|||
function ticketCollection(){//parametro collectionFk
|
||||
/// CONSULTA SQL PER A TINDRE ELS DIFERENTS ticketsColletion DE UN colletionFK (consiltaSql1) ///
|
||||
/// CONSULTA SQL PER A CADA ticket DE CADA ticketCollection (consiltaSql2) ///
|
||||
if(insert.filter(shelving,"shelving")){
|
||||
if(filter.filterShelving(shelving)){
|
||||
insert.insertTicket(consultaSql1, shelving)
|
||||
}
|
||||
else{
|
||||
|
@ -43,5 +45,4 @@ function ticketCollection(){//parametro collectionFk
|
|||
}
|
||||
}
|
||||
|
||||
ticketCollection();
|
||||
//proba
|
||||
ticketCollection();
|
19
filter.js
19
filter.js
|
@ -1,13 +1,10 @@
|
|||
function filter(toFilter, type){
|
||||
let exp;
|
||||
|
||||
if(type=="barcode"){
|
||||
exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/
|
||||
}
|
||||
if(type=="shelving"){
|
||||
exp = /^[A-Z][A-Z][A-Z]$/
|
||||
}
|
||||
function filterBarcode(toFilter){
|
||||
const exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/
|
||||
return exp.test(toFilter)
|
||||
}
|
||||
console.log(filter("A0A3B820690FF", "barcode"))
|
||||
|
||||
function filterShelving(toFilter){
|
||||
const exp = /^[A-F][A-F][A-F]$/
|
||||
return exp.test(toFilter)
|
||||
}
|
||||
exports.filterBarcode = filterBarcode;
|
||||
exports.filterShelving = filterShelving;
|
|
@ -0,0 +1,39 @@
|
|||
function insertTicket(sql, shelving){
|
||||
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<sql.length;i++){
|
||||
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 + sql[i].level,//Matricula + nivel
|
||||
itemTitle: "Etiqueta Con ticket",
|
||||
productCode: sql[i].ticketFk, //Ticket
|
||||
custFeature1: sql[i].nickname, //Client
|
||||
custFeature2: sql[i].agencyModeFk //Agencia de transporte
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
"Authorization": key
|
||||
}
|
||||
})
|
||||
console.log(body)
|
||||
}
|
||||
})();
|
||||
})();
|
||||
}
|
||||
|
||||
exports.insertTicket = insertTicket;
|
|
@ -1,42 +1,3 @@
|
|||
function insertTicket(sql, shelving){
|
||||
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<sql.length;i++){
|
||||
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 + sql[i].level,//Matricula + nivel
|
||||
itemTitle: "Etiqueta Con ticket",
|
||||
productCode: sql[i].ticketFk, //Ticket
|
||||
custFeature1: sql[i].nickname, //Client
|
||||
custFeature2: sql[i].agencyModeFk //Agencia de transporte
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
"Authorization": key
|
||||
}
|
||||
})
|
||||
console.log(body)
|
||||
}
|
||||
})();
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
function insertShelving(shelving, level){
|
||||
const config = require('../config');
|
||||
const got = require('got');
|
||||
|
@ -81,6 +42,5 @@ function filter(toFilter, type){
|
|||
return exp.test(toFilter)
|
||||
}
|
||||
|
||||
exports.insertTicket = insertTicket;
|
||||
exports.insertShelving = insertShelving;
|
||||
exports.filter = filter;
|
||||
|
|
Reference in New Issue