From 99d6f8167147e903d03ec3d8e274bbbf68deb8b3 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 31 Jan 2023 14:59:05 +0100 Subject: [PATCH] fix bugs --- src/newPallet.js | 8 +++++--- src/rfidParser.js | 5 +++-- src/stream.js | 5 +++-- util/debugStream.js | 3 +-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/newPallet.js b/src/newPallet.js index 4659056..f15d537 100644 --- a/src/newPallet.js +++ b/src/newPallet.js @@ -3,9 +3,11 @@ import counter from './counter.js'; export default async(rfids, arcId) => { console.logger.info('PRINTING...'); - - const palletId = await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(codes), arcId, null]); + console.log([Array.from(rfids), arcId, null]); + await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(rfids), arcId, null]); + const palletId = await con.query(`SELECT @palletId;`); + console.log(palletId); await counter(null, arcId); if (!palletId) - console.logger.info({error: 'ERROR_CREATING_PALLET', expeditions: rfids}); + console.logger.error({error: 'ERROR_CREATING_PALLET', expeditions: rfids}); }; diff --git a/src/rfidParser.js b/src/rfidParser.js index 1b960c5..9df302e 100644 --- a/src/rfidParser.js +++ b/src/rfidParser.js @@ -10,7 +10,7 @@ export default async data => { const jsonResult = JSON.parse(crudeRfid); let epcHex = jsonResult?.tagInventoryEvent?.epcHex; - if (!epcHex) return; + if (!epcHex) continue; if (epcHex.search('AABB') == -1) continue; epcHex = epcHex.replace('AABB', ''); @@ -23,8 +23,9 @@ export default async data => { antenna: jsonResult.tagInventoryEvent.antennaPort }; + const rfidsParsedExtended = []; + rfidsParsedExtended.push(rfidParsed); rfidsParsed.add(rfidParsed.code); - rfidsParsed.push(rfidParsed); } } diff --git a/src/stream.js b/src/stream.js index 131459a..6853ba9 100644 --- a/src/stream.js +++ b/src/stream.js @@ -1,7 +1,7 @@ import got from 'got'; import rfidParser from './rfidParser.js'; import newPallet from './newPallet.js'; -import debug from '../util/streamDebug.js'; +import debug from '../util/debugStream.js'; import counter from './counter.js'; let interval; @@ -16,10 +16,11 @@ export default async(conf, cb) => { stream .on('data', async value => { const parsed = await rfidParser(value); + console.log(parsed.codes); rfidbuffer = new Set([...rfidbuffer, ...parsed.codes]); rfidbufferExtend = rfidbufferExtend.concat(parsed.extended); - debug(rfidbuffer, rfidbufferExtend); + debug({codes: rfidbuffer, extended: rfidbufferExtend}, conf); if (rfidbuffer.size) { clearTimeout(interval); diff --git a/util/debugStream.js b/util/debugStream.js index 112a22f..d08ce80 100644 --- a/util/debugStream.js +++ b/util/debugStream.js @@ -1,6 +1,5 @@ -export default parsed => { +export default (parsed, conf) => { if (conf.env != 'dev') return; - // TOTAL console.log('TOTAL BUFFER: ', parsed.codes.size);