fix bugs
gitea/vn-rfid/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-01-31 14:59:05 +01:00
parent ebbc27b56d
commit 99d6f81671
4 changed files with 12 additions and 9 deletions

View File

@ -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});
};

View File

@ -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);
}
}

View File

@ -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);

View File

@ -1,6 +1,5 @@
export default parsed => {
export default (parsed, conf) => {
if (conf.env != 'dev') return;
// TOTAL
console.log('TOTAL BUFFER: ', parsed.codes.size);