refactor #1
|
@ -1,3 +1,4 @@
|
||||||
|
arcId: 1
|
||||||
port: 1234
|
port: 1234
|
||||||
ip: 1.2.3.4
|
ip: 1.2.3.4
|
||||||
env: dev
|
env: dev
|
||||||
|
@ -9,5 +10,5 @@ db:
|
||||||
database: srt
|
database: srt
|
||||||
user: user
|
user: user
|
||||||
password: password
|
password: password
|
||||||
multipleStatements: true
|
multipleStatements: false
|
||||||
insecureAuth: true
|
insecureAuth: true
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
import con from '../db/connect.js';
|
import con from '../db/connect.js';
|
||||||
|
|
||||||
export default async rfids => {
|
export default async(rfids, arcId) => {
|
||||||
let response;
|
|
||||||
|
|
||||||
if (!rfids.length) return console.logger.warning({error: 'NOT_PARSED_RFIDS', rfids});
|
|
||||||
|
|
||||||
const codes = new Set();
|
const codes = new Set();
|
||||||
for (let rfid of rfids)
|
for (let rfid of rfids)
|
||||||
codes.add(parseInt(rfid.code));
|
codes.add(rfid.code);
|
||||||
|
|
||||||
console.logger.info('CALL PALLET_BUILD', codes, ' TOTAL: ', codes.size);
|
console.logger.info('PRINTING...');
|
||||||
|
|
||||||
response = await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, @pallet);SELECT @pallet;`, [Array.from(codes), 19294]);
|
const palletId = await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(codes), arcId, null]);
|
||||||
|
if (!palletId)
|
||||||
const pallet = response[0][1][0]['@pallet'];
|
|
||||||
if (pallet) {
|
|
||||||
console.logger.info('PRINTING', pallet);
|
|
||||||
await con.query(`CALL vn.expeditionPallet_printLabel(?);`, [pallet]);
|
|
||||||
} else
|
|
||||||
console.logger.info({error: 'ERROR_CREATING_PALLET', expeditions: rfids});
|
console.logger.info({error: 'ERROR_CREATING_PALLET', expeditions: rfids});
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default async(conf, cb) => {
|
||||||
if (parsed)
|
if (parsed)
|
||||||
rfidbuffer = rfidbuffer.concat(parsed);
|
rfidbuffer = rfidbuffer.concat(parsed);
|
||||||
|
|
||||||
debug();
|
debug(parsed);
|
||||||
|
|
||||||
if (rfidbuffer && rfidbuffer.length && parsed && parsed.length) {
|
if (rfidbuffer && rfidbuffer.length && parsed && parsed.length) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
@ -32,12 +32,12 @@ export default async(conf, cb) => {
|
||||||
function createPallet() {
|
function createPallet() {
|
||||||
clearInterval(interval); // try remove
|
clearInterval(interval); // try remove
|
||||||
if (!rfidbuffer.length) return;
|
if (!rfidbuffer.length) return;
|
||||||
newPallet(rfidbuffer);
|
newPallet(rfidbuffer, conf.arcId);
|
||||||
rfidbuffer = [];
|
rfidbuffer = [];
|
||||||
rfidbufferSet = [new Set(), new Set(), new Set(), new Set()];
|
rfidbufferSet = [new Set(), new Set(), new Set(), new Set()];
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug() {
|
function debug(parsed) {
|
||||||
if (conf.env != 'dev') return;
|
if (conf.env != 'dev') return;
|
||||||
let totalBuffer = rfidbuffer.map(rfid => rfid.code);
|
let totalBuffer = rfidbuffer.map(rfid => rfid.code);
|
||||||
let totalBufferSet = new Set(totalBuffer);
|
let totalBufferSet = new Set(totalBuffer);
|
||||||
|
@ -53,7 +53,7 @@ export default async(conf, cb) => {
|
||||||
console.log('UNIQUE READ ANTENNA:', rfidbufferSet[0].size, rfidbufferSet[1].size, rfidbufferSet[2].size, rfidbufferSet[3].size);
|
console.log('UNIQUE READ ANTENNA:', rfidbufferSet[0].size, rfidbufferSet[1].size, rfidbufferSet[2].size, rfidbufferSet[3].size);
|
||||||
for (const [index, set] of rfidbufferSet.entries()) {
|
for (const [index, set] of rfidbufferSet.entries()) {
|
||||||
if (((set.size * 100) / totalBufferSet.size) < 25)
|
if (((set.size * 100) / totalBufferSet.size) < 25)
|
||||||
console.log('[WARNING_ANTENNA]: ', index, ' ONLY ', set.size);
|
console.log('[WARNING_ANTENNA]: ', index + 1, ' ONLY ', set.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('----------------------------------------------------------------');
|
console.log('----------------------------------------------------------------');
|
||||||
|
|
Loading…
Reference in New Issue