flashOn added
This commit is contained in:
parent
214aee2285
commit
fba0fdc0a2
|
@ -4,6 +4,7 @@ const filter = require('../utilities/filter');
|
|||
const config = require('../config');
|
||||
const insertDB = require('../db/insertDB');
|
||||
const express = require('express');
|
||||
const {con} = require('../db/connect');
|
||||
const router = express.Router(); // eslint-disable-line
|
||||
|
||||
router.get('/:barcode&:shelving&:level', async(req, res) => {
|
||||
|
@ -11,7 +12,7 @@ router.get('/:barcode&:shelving&:level', async(req, res) => {
|
|||
const shelving = req.params.shelving;// valido = 3 CARACTERES LETRAS (A-Z)
|
||||
const level = req.params.level;
|
||||
console.log(barcode);
|
||||
console.log(shelving, level);
|
||||
console.log(shelving + level);
|
||||
|
||||
const result = bindShelvingTag(barcode, shelving, level);
|
||||
if (result == 'INVALID_PLATE')
|
||||
|
@ -28,8 +29,7 @@ function bindShelvingTag(barcode, shelving, level) {
|
|||
if (filter.isBarcode(barcode)) {
|
||||
if (filter.isShelving(shelving)) {
|
||||
let shelvingId = shelving + level;
|
||||
insertShelving(shelvingId);
|
||||
bindShelving(barcode, shelvingId);
|
||||
insertShelving(shelvingId, barcode);
|
||||
insertDB.insertDB(barcode, shelving, level);
|
||||
} else
|
||||
return 'INVALID_PLATE';
|
||||
|
@ -37,10 +37,9 @@ function bindShelvingTag(barcode, shelving, level) {
|
|||
return 'INVALID_TAG_CODE';
|
||||
}
|
||||
|
||||
function insertShelving(shelvingId) {
|
||||
async function insertShelving(shelvingId, barcode) {
|
||||
(async() => {
|
||||
const info = await dataLogIn.dataLogIn;
|
||||
console.log(info);
|
||||
let key = info.data.token;
|
||||
let currentUser = info.data.currentUser;
|
||||
(async() => {
|
||||
|
@ -64,11 +63,13 @@ function insertShelving(shelvingId) {
|
|||
'Authorization': key
|
||||
}
|
||||
});
|
||||
await bindShelving(barcode, shelvingId);
|
||||
console.log('Insert Shelving:', body);
|
||||
})();
|
||||
})();
|
||||
}
|
||||
|
||||
function bindShelving(barcode, shelvingId) {
|
||||
async function bindShelving(barcode, shelvingId) {
|
||||
(async() => {
|
||||
const info = await dataLogIn.dataLogIn;
|
||||
let key = info.data.token;
|
||||
|
@ -87,7 +88,7 @@ function bindShelving(barcode, shelvingId) {
|
|||
'Authorization': key
|
||||
}
|
||||
});
|
||||
console.log(body);
|
||||
console.log('Bind', body);
|
||||
})();
|
||||
})();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
const express = require('express');
|
||||
const router = express.Router(); // eslint-disable-line
|
||||
const select = require('../db/selectTicket');
|
||||
|
||||
router.get('/:ticket', async(req, res) => {
|
||||
const ticket = req.params.ticket;
|
||||
console.log(ticket);
|
||||
searchTicket(ticket);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
function searchTicket(ticket) {// parametro collectionFk
|
||||
select.select(ticket, function(err, data) {
|
||||
console.log(data);
|
||||
insertFlash(data);
|
||||
});
|
||||
}
|
||||
|
||||
function insertFlash(consultaSql) {
|
||||
console.log('CONSULTASQL_TAMAÑO:', consultaSql.length);
|
||||
const dataLogIn = require('../server');
|
||||
const got = require('got');
|
||||
(async() => {
|
||||
const info = await dataLogIn.dataLogIn;
|
||||
let key = info.data.token;
|
||||
let currentUser = info.data.currentUser;
|
||||
|
||||
(async() => {
|
||||
for (let i = 0; i < consultaSql.length; i++) {
|
||||
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line
|
||||
json: {
|
||||
agencyId: currentUser.agencyId,
|
||||
merchantId: currentUser.merchantId,
|
||||
storeId: currentUser.storeId,
|
||||
unitName: currentUser.unitName,
|
||||
itemList: [
|
||||
{
|
||||
attrCategory: 'verdnatura',
|
||||
attrName: 'conTicket',
|
||||
barCode: consultaSql[i].Shelving + consultaSql[i].Level, // Matricula + nivel
|
||||
itemTitle: 'Etiqueta Con ticket',
|
||||
productCode: consultaSql[i].Ticket, // Ticket
|
||||
custFeature1: consultaSql[i].Client, // Client
|
||||
custFeature2: consultaSql[i].Agency, // Agencia de transporte
|
||||
custFeature3: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Authorization': key
|
||||
}
|
||||
});
|
||||
console.log(body);
|
||||
}
|
||||
})();
|
||||
})();
|
||||
}
|
|
@ -9,6 +9,7 @@ exports.dataLogIn = dataLogIn;
|
|||
app.use('/getNumShelving', require('./methods/setCollection'));
|
||||
app.use('/insertTicket', require('./methods/bindTicketShelving'));
|
||||
app.use('/bindShelving', require('./methods/bindShelvingTag'));
|
||||
app.use('/flashOn', require('./methods/flashOn'));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening at http://localhost:${port}`);
|
||||
|
|
Reference in New Issue