update TicketShelving
This commit is contained in:
parent
7eb3fb62c8
commit
64090b161e
|
@ -2,11 +2,12 @@ const mysql = require('mysql');
|
|||
const config = require('../config');
|
||||
|
||||
let con = mysql.createConnection({
|
||||
host: 'test-db.static.verdnatura.es', // 'test-db.verdnatura.es',
|
||||
host: 'test-db.verdnatura.es', // 'test-db.verdnatura.es',
|
||||
database: 'vn',
|
||||
user: config.userDev,
|
||||
password: config.passwordDev,
|
||||
port: 3307
|
||||
port: 3307,
|
||||
insecureAuth: true
|
||||
});
|
||||
|
||||
exports.con = con;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CREATE TABLE `workerShelving` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`workerFk` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`workerFk` int(11) NOT NULL,
|
||||
`shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL,
|
||||
`collectionFk` int(11) DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -8,7 +8,7 @@ CREATE TABLE `workerShelving` (
|
|||
KEY `workerShelving_shelving_fk` (`shelvingFk`),
|
||||
KEY `workerShelving_FK` (`workerFk`),
|
||||
KEY `workerShelving_FK_1` (`collectionFk`),
|
||||
CONSTRAINT `workerShelving_worker_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`code`),
|
||||
CONSTRAINT `workerShelving_worker_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`),
|
||||
CONSTRAINT `workerShelving_collection_fk` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`),
|
||||
CONSTRAINT `workerShelving_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='utilizaremos el id para establecer la prioridad de los carros a asignar'
|
||||
|
|
|
@ -12,6 +12,7 @@ function insertSmartTag(smartTagFk, shelving, level) {
|
|||
VALUES ('${smartTagFk}', '${shelving}', ${level});
|
||||
END IF;`;
|
||||
con.con.query(sql, function(err, result) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
exports.insertSmartTag = insertSmartTag;
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
const con = require('./connect');
|
||||
|
||||
function selectCollectionSmartTag(collectionFk, callback) {
|
||||
let consSql = `SELECT code, ticketFk, level, wagon, shelvingFk FROM vn.collectionSmartTag WHERE collectionFk = ${collectionFk}`;
|
||||
let consSql = `SELECT * FROM vn.collectionSmartTag WHERE collectionFk = ${collectionFk};`;
|
||||
console.log(consSql);
|
||||
con.con.query(consSql, function(err, result, fields) {
|
||||
console.log(result);
|
||||
callback(null, result);
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const router = express.Router(); // eslint-disable-line
|
|||
const select = require('../db/selectCollection');
|
||||
const insertTicketDB = require('../db/insertTicket');
|
||||
|
||||
router.get('/collectionFk', async(req, res) => {
|
||||
router.get('/:collectionFk', async(req, res) => {
|
||||
const collectionFk = req.params.collectionFk;
|
||||
console.log(collectionFk);
|
||||
ticketShelving(collectionFk);
|
||||
|
@ -12,7 +12,7 @@ module.exports = router;
|
|||
|
||||
function ticketShelving(collectionFk) {// parametro collectionFk
|
||||
select.selectCollectionSmartTag(collectionFk, function(err, data) {
|
||||
console.log(data);
|
||||
console.log('DATA', data);
|
||||
insertTicket(data);
|
||||
});
|
||||
}
|
||||
|
@ -29,38 +29,36 @@ function insertTicket(consultaSql) {
|
|||
|
||||
(async() => {
|
||||
for (let i = 0; i < consultaSql.length; i++) {
|
||||
for (let j = 0; j < consultaSql[i].level; j++) {
|
||||
console.log('SHELVING: ', consultaSql.shelvingFk, consultaSql.level);
|
||||
console.log('SHELVING: ', consultaSql[i].shelvingFk, consultaSql[i].level);
|
||||
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].shelvingFk + consultaSql[i].level, // Matricula + nivel
|
||||
itemTitle: 'Etiqueta Con ticket',
|
||||
productCode: consultaSql[i].ticketFk, // Ticket
|
||||
qrCode: consultaSql[i].ticketFk,
|
||||
custFeature1: consultaSql[i].clientFk, // Cliente
|
||||
custFeature2: consultaSql[i].agencyFk, // Agencia de transporte
|
||||
custFeature3: 0, // Luz LED
|
||||
custFeature4: '', // consultaSql[i].workerFk, // Trabajador
|
||||
custFeature5: consultaSql[i].wagon, // Wagon
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Authorization': key
|
||||
}
|
||||
});
|
||||
insertTicketDB.insertTicket(consultaSql[i].ticketFk, consultaSql[i].shelvingFk, consultaSql[i].level);
|
||||
console.log(i, body);
|
||||
}
|
||||
json: {
|
||||
agencyId: currentUser.agencyId,
|
||||
merchantId: currentUser.merchantId,
|
||||
storeId: currentUser.storeId,
|
||||
unitName: currentUser.unitName,
|
||||
itemList: [
|
||||
{
|
||||
attrCategory: 'verdnatura',
|
||||
attrName: 'conTicket',
|
||||
barCode: consultaSql[i].shelvingFk + consultaSql[i].level, // Matricula + nivel
|
||||
itemTitle: 'Etiqueta Con ticket',
|
||||
productCode: consultaSql[i].ticketFk, // Ticket
|
||||
qrCode: consultaSql[i].ticketFk,
|
||||
custFeature1: consultaSql[i].clientFk, // Cliente
|
||||
custFeature2: consultaSql[i].agencyFk, // Agencia de transporte
|
||||
custFeature3: 0, // Luz LED
|
||||
custFeature4: '', // consultaSql[i].workerFk, // Trabajador
|
||||
custFeature5: consultaSql[i].wagon, // Wagon
|
||||
}
|
||||
]
|
||||
},
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Authorization': key
|
||||
}
|
||||
});
|
||||
insertTicketDB.insertTicket(consultaSql[i].ticketFk, consultaSql[i].shelvingFk, consultaSql[i].level);
|
||||
console.log(i, body);
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
|
Reference in New Issue