5144-improveArc #5
|
@ -1,2 +1,2 @@
|
|||
node_modules
|
||||
config.local.yml
|
||||
config.*.yml
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
// Carácter predeterminado de final de línea.
|
||||
"files.eol": "\n",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
"source.fixAll.eslint": "explicit"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,4 +20,6 @@ $ npm run start | pino-pretty
|
|||
For test.
|
||||
```
|
||||
DELETE expedition in vn.expeditionScan
|
||||
```
|
||||
```
|
||||
Nuevas RFID
|
||||
519 a 527 511
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO vn.trys (palletFk, missing, powerType, extra, observation) VALUES(190582, '1', 'V19', '0', NULL);
|
||||
INSERT INTO vn.trys (palletFk, missing, powerType, extra, observation) VALUES(190600, '0', 'V19', '1', NULL);
|
||||
INSERT INTO vn.trys (palletFk, missing, powerType, extra, observation) VALUES(190602, '0', 'V19', '0', NULL);
|
||||
INSERT INTO vn.trys (palletFk, missing, powerType, extra, observation) VALUES(190603, '1', 'V19', '0', NULL);
|
||||
INSERT INTO vn.trys (palletFk, missing, powerType, extra, observation) VALUES(190604, '0', 'V19', '0', NULL);
|
|
@ -0,0 +1,4 @@
|
|||
import mysql from 'mysql2/promise';
|
||||
import getConfig from '../util/getConfig.js';
|
||||
export default mysql.createPool(getConfig('production').db);
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"engines": {
|
||||
"node": ">=18",
|
||||
"npm": ">=8"
|
||||
"npm": ">=8"
|
||||
},
|
||||
"keywords": [],
|
||||
"license": "GPL-3.0",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
|||
INSERT INTO vn.arcRead (id, printerFk, ip, counter, error, minimum) VALUES(1, NULL, '10.1.16.1', 17, NULL, 5);
|
||||
|
||||
CREATE TABLE `rfidTest` (
|
||||
`palletFk` int(11) DEFAULT NULL,
|
||||
`expeditionFk` int(11) DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`peakRssi` int(11) DEFAULT NULL,
|
||||
`antenna` int(11) DEFAULT NULL,
|
||||
`attempt` int(11) DEFAULT NULL,
|
||||
`power` int(11) DEFAULT NULL,
|
||||
`sensitivity` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
|
||||
CREATE TABLE `algorithm` (
|
||||
`palletFk` int(11) DEFAULT NULL,
|
||||
`expeditionArray` text DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT current_timestamp(),
|
||||
`expeditionCount` int(11) DEFAULT NULL,
|
||||
`model` text DEFAULT NULL,
|
||||
`attempt` int(11) DEFAULT NULL,
|
||||
`power` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
|
||||
CREATE TABLE `trys` (
|
||||
`palletFk` int(11) NOT NULL,
|
||||
`missing` text DEFAULT NULL,
|
||||
`powerType` varchar(255) NOT NULL DEFAULT 'V17',
|
||||
`extra` varchar(100) DEFAULT NULL,
|
||||
`observation` text DEFAULT NULL,
|
||||
`timestamp` timestamp NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`palletFk`,`powerType`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
-- powerTypes [PW13, PW15, V17, V19]
|
|
@ -4,12 +4,12 @@ let lastCounter;
|
|||
export default async(size, arcId) => {
|
||||
if (lastCounter == size) return;
|
||||
console.logger.info(`COUNTER: SIZE:${size} ARC_ID:${arcId}`);
|
||||
await con.query(`
|
||||
UPDATE vn.arcRead
|
||||
SET counter = ?,
|
||||
error = NULL
|
||||
WHERE id = ?;
|
||||
`, [size, arcId]);
|
||||
// await con.query(`
|
||||
// UPDATE vn.arcRead
|
||||
// SET counter = ?,
|
||||
// error = NULL
|
||||
// WHERE id = ?;
|
||||
// `, [size, arcId]);
|
||||
|
||||
lastCounter = size;
|
||||
};
|
||||
|
|
|
@ -30,18 +30,18 @@ export default async data => {
|
|||
antenna: jsonResult.tagInventoryEvent.antennaPort,
|
||||
transmitPowerCdbm: jsonResult.tagInventoryEvent.transmitPowerCdbm
|
||||
};
|
||||
await con.query(`
|
||||
INSERT INTO vn.rfidTest (palletFk, expeditionFk, peakRssi, antenna, attempt, power, sensitivity)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?);
|
||||
`, [
|
||||
palletFkFinding,
|
||||
rfidParsed.code,
|
||||
rfidParsed.peakRssi,
|
||||
rfidParsed.antenna,
|
||||
attempt,
|
||||
jsonResult.tagInventoryEvent.transmitPowerCdbm,
|
||||
sensitivity
|
||||
]);
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.rfidTest (palletFk, expeditionFk, peakRssi, antenna, attempt, power, sensitivity)
|
||||
// VALUES(?, ?, ?, ?, ?, ?, ?);
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// rfidParsed.code,
|
||||
// rfidParsed.peakRssi,
|
||||
// rfidParsed.antenna,
|
||||
// attempt,
|
||||
// jsonResult.tagInventoryEvent.transmitPowerCdbm,
|
||||
// sensitivity
|
||||
// ]);
|
||||
// console.log(rfidParsed);
|
||||
rfidsParsedExtended.push(rfidParsed);
|
||||
rfidsParsed.add(rfidParsed.code);
|
||||
|
|
|
@ -41,8 +41,8 @@ export default async(conf, cb) => {
|
|||
|
||||
// if (!conf.minimum || rfidbuffer.size > conf.minimum)
|
||||
// newPallet(rfidbuffer, conf.arcId);
|
||||
// rfidbuffer = new Set();
|
||||
// rfidbufferExtend = [];
|
||||
rfidbuffer = new Set();
|
||||
rfidbufferExtend = [];
|
||||
}
|
||||
|
||||
function counterIntervalManager() {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
import con from '../db/connect.js';
|
||||
import conMaster from '../db/connectMaster.js';
|
||||
|
||||
export default async reads => {
|
||||
console.log('reads: ', [...reads][0]);
|
||||
let [[palletFk]] = await conMaster.query(`SELECT palletFk FROM expeditionScan WHERE expeditionFk = ?`, [[...reads][0]]);
|
||||
palletFk = palletFk?.palletFk;
|
||||
console.log('palletFk: ', palletFk);
|
||||
if (!palletFk) return console.log('LA EXPEDICION NO esta en el pallet');
|
||||
let [realExpeditions] = await conMaster.query(
|
||||
`SELECT ep.id, e.id, ps.printerRfidFk, ps.code
|
||||
FROM expeditionPallet ep
|
||||
JOIN expeditionScan es ON es.palletFk = ep.id
|
||||
JOIN expedition e ON e.id = es.expeditionFk
|
||||
JOIN host h ON h.code = e.hostFk COLLATE utf8mb3_unicode_ci
|
||||
JOIN packingSite ps ON ps.hostFk = h.id
|
||||
WHERE ep.id = ?
|
||||
AND ps.printerRfidFk`,
|
||||
[palletFk]
|
||||
);
|
||||
realExpeditions = realExpeditions.map(r => r.id);
|
||||
console.log('realExpeditions: ', realExpeditions.length);
|
||||
|
||||
if (realExpeditions.length != reads.size)
|
||||
console.logger.warn('MISSING EXPEDITIONS');
|
||||
const missing = realExpeditions.filter(x => ![...reads].includes(x));
|
||||
const extra = [...reads].filter(x => !realExpeditions.includes(x));
|
||||
if (missing.length) console.warn('MISSING:', missing.length, missing);
|
||||
if (extra.length) console.warn('EXTRA:', extra.length, extra);
|
||||
await con.query(`
|
||||
REPLACE trys
|
||||
SET palletFk = ?,
|
||||
missing = ?,
|
||||
extra = ?,
|
||||
powerType = ?,
|
||||
observation = ?
|
||||
`, [palletFk, (missing.length + '/' + realExpeditions.length), (extra.length + '/' + realExpeditions.length), 'V19', extra.join('%')]);
|
||||
};
|
|
@ -0,0 +1,109 @@
|
|||
import con from '../db/connect.js';
|
||||
|
||||
export default async(parsed, conf) => {
|
||||
const palletFkFinding = 0;
|
||||
const attempt = 0;
|
||||
|
||||
if (conf.env != 'dev') return;
|
||||
// TOTAL
|
||||
// console.log('TOTAL BUFFER: ', parsed.codes.size);
|
||||
// console.log('BUFFER: ', parsed.codes);
|
||||
// console.log('BUFFER_EXTEND: ', parsed);
|
||||
|
||||
// TOTAL READS BY ANTENNA
|
||||
const totalRead = [0, 0, 0, 0];
|
||||
for (let read of parsed.extended)
|
||||
totalRead[read.antenna - 1]++;
|
||||
console.log('TOTAL READ ANTENNA:', totalRead);
|
||||
// UNIQUE READS BY ANTENNA
|
||||
const uniqueRead = [new Set(), new Set(), new Set(), new Set()];
|
||||
for (let read of parsed.extended)
|
||||
uniqueRead[read.antenna - 1].add(read.code);
|
||||
|
||||
console.log('UNIQUE READ ANTENNA:', uniqueRead[0].size, uniqueRead[1].size, uniqueRead[2].size, uniqueRead[3].size);
|
||||
|
||||
// console.log(uniqueRead[0], uniqueRead[1]);
|
||||
// console.log(uniqueRead[2], uniqueRead[3]);
|
||||
|
||||
// AL QUAD
|
||||
let quad1 = [...uniqueRead[0]].filter(value => uniqueRead[1].has(value));
|
||||
let quad2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
||||
const quad = quad1.filter(value => new Set(quad2).has(value));
|
||||
console.log('UNIQUE READ QUAD:', quad.length);
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
// VALUES(?, ?, ?, ?, ?, ?);
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// attempt,
|
||||
// quad.join(','),
|
||||
// quad.length,
|
||||
// 'QUAD',
|
||||
// quad[0]?.transmitPowerCdbm
|
||||
// ]);
|
||||
|
||||
// AL TRI
|
||||
let tri1 = [...uniqueRead[1]];
|
||||
let tri2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
||||
const tri = tri1.filter(value => new Set(tri2).has(value));
|
||||
console.log('UNIQUE READ TRI:', tri.length);
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
// VALUES(?, ?, ?, ?, ?, ?);
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// attempt,
|
||||
// tri.join(','),
|
||||
// tri.length,
|
||||
// 'TRI',
|
||||
// tri[0]?.transmitPowerCdbm
|
||||
// ]);
|
||||
|
||||
// AL BI
|
||||
// const uniqueReadLeft = new Set([...uniqueRead[0], ...uniquaeRead[1]]);
|
||||
// const uniqueReadRight = new Set([...uniqueRead[2], ...uniqueRead[3]]);
|
||||
// const bi = [...uniqueReadLeft].filter(value => uniqueReadRight.has(value));
|
||||
// console.log('UNIQUE READ BI:', bi.length);
|
||||
// console.log('UNIQUE READ: 1', [...uniqueRead[0]].length);
|
||||
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
||||
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size);
|
||||
// console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size); //USE for test
|
||||
console.logger.info('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
// VALUES(?, ?, ?, ?, ?, ?);
|
||||
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// attempt,
|
||||
// bi.join(','),
|
||||
// bi.length,
|
||||
// 'BI',
|
||||
// bi[0]?.transmitPowerCdbm
|
||||
// ]);
|
||||
|
||||
// // // AL BEST PEAK
|
||||
// MIRAR SI DOS LA HAN LEIDO ENTONCES BUENA, O TAMBIEN SE PUEDE MIRAR QUE SI EL PEAK ES MEJOR A X COJERLA POR BUENA
|
||||
// const allExpedition = [];
|
||||
// for ()
|
||||
// console.log('UNIQUE READ BI:', bi.length);
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model)
|
||||
// VALUES(?, ?, ?, ?, ?, ?);
|
||||
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// attempt,
|
||||
// bi,
|
||||
// bi.length,
|
||||
// 'BI'
|
||||
// ]);
|
||||
|
||||
// // WARNING IF AN ANTENNA READS LESS THAN IT SHOULD
|
||||
// for (const [index, set] of uniqueRead.entries()) {
|
||||
// if (((set.size * 100) / parsed.codes.size) < 25)
|
||||
// console.logger.warn(`[ANTENNA]: ${index + 1} ONLY ${set.size}`);
|
||||
// }
|
||||
|
||||
console.log('----------------------------------------------------------------');
|
||||
};
|
|
@ -1,14 +1,8 @@
|
|||
import con from '../db/connect.js';
|
||||
|
||||
import debugMissing from './debugMissing.js';
|
||||
|
||||
export default async(parsed, conf) => {
|
||||
const palletFkFinding = 0;
|
||||
const attempt = 0;
|
||||
|
||||
if (conf.env != 'dev') return;
|
||||
// TOTAL
|
||||
// console.log('TOTAL BUFFER: ', parsed.codes.size);
|
||||
// console.log('BUFFER: ', parsed.codes);
|
||||
// console.log('BUFFER_EXTEND: ', parsed);
|
||||
|
||||
// TOTAL READS BY ANTENNA
|
||||
const totalRead = [0, 0, 0, 0];
|
||||
|
@ -22,86 +16,21 @@ export default async(parsed, conf) => {
|
|||
|
||||
console.log('UNIQUE READ ANTENNA:', uniqueRead[0].size, uniqueRead[1].size, uniqueRead[2].size, uniqueRead[3].size);
|
||||
|
||||
// console.log(uniqueRead[0], uniqueRead[1]);
|
||||
// console.log(uniqueRead[2], uniqueRead[3]);
|
||||
|
||||
// AL QUAD
|
||||
let quad1 = [...uniqueRead[0]].filter(value => uniqueRead[1].has(value));
|
||||
let quad2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
||||
const quad = quad1.filter(value => new Set(quad2).has(value));
|
||||
console.log('UNIQUE READ QUAD:', quad.length);
|
||||
await con.query(`
|
||||
INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
VALUES(?, ?, ?, ?, ?, ?);
|
||||
`, [
|
||||
palletFkFinding,
|
||||
attempt,
|
||||
quad.join(','),
|
||||
quad.length,
|
||||
'QUAD',
|
||||
quad[0]?.transmitPowerCdbm
|
||||
]);
|
||||
|
||||
// AL TRI
|
||||
let tri1 = [...uniqueRead[1]];
|
||||
let tri2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
||||
const tri = tri1.filter(value => new Set(tri2).has(value));
|
||||
console.log('UNIQUE READ TRI:', tri.length);
|
||||
await con.query(`
|
||||
INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
VALUES(?, ?, ?, ?, ?, ?);
|
||||
`, [
|
||||
palletFkFinding,
|
||||
attempt,
|
||||
tri.join(','),
|
||||
tri.length,
|
||||
'TRI',
|
||||
tri[0]?.transmitPowerCdbm
|
||||
]);
|
||||
|
||||
// AL BI
|
||||
const uniqueReadLeft = new Set([...uniqueRead[0], ...uniqueRead[1]]);
|
||||
const uniqueReadRight = new Set([...uniqueRead[2], ...uniqueRead[3]]);
|
||||
const bi = [...uniqueReadLeft].filter(value => uniqueReadRight.has(value));
|
||||
console.log('UNIQUE READ BI:', bi.length);
|
||||
console.log('UNIQUE READ: 1', [...uniqueRead[0]].length);
|
||||
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size);
|
||||
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
||||
await con.query(`
|
||||
INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
||||
VALUES(?, ?, ?, ?, ?, ?);
|
||||
|
||||
`, [
|
||||
palletFkFinding,
|
||||
attempt,
|
||||
bi.join(','),
|
||||
bi.length,
|
||||
'BI',
|
||||
bi[0]?.transmitPowerCdbm
|
||||
]);
|
||||
|
||||
// // // AL BEST PEAK
|
||||
// MIRAR SI DOS LA HAN LEIDO ENTONCES BUENA, O TAMBIEN SE PUEDE MIRAR QUE SI EL PEAK ES MEJOR A X COJERLA POR BUENA
|
||||
// const allExpedition = [];
|
||||
// for ()
|
||||
// console.log('UNIQUE READ BI:', bi.length);
|
||||
// await con.query(`
|
||||
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model)
|
||||
// VALUES(?, ?, ?, ?, ?, ?);
|
||||
|
||||
// `, [
|
||||
// palletFkFinding,
|
||||
// attempt,
|
||||
// bi,
|
||||
// bi.length,
|
||||
// 'BI'
|
||||
// ]);
|
||||
|
||||
// // WARNING IF AN ANTENNA READS LESS THAN IT SHOULD
|
||||
// for (const [index, set] of uniqueRead.entries()) {
|
||||
// if (((set.size * 100) / parsed.codes.size) < 25)
|
||||
// console.logger.warn(`[ANTENNA]: ${index + 1} ONLY ${set.size}`);
|
||||
// }
|
||||
|
||||
const uniqueReads = new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]);
|
||||
// console.log('UNIQUE READ TRI:', tri.length);
|
||||
// console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
||||
// console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size);
|
||||
console.logger.info('UNIQUE READ:', uniqueReads);
|
||||
debugMissing(uniqueReads);
|
||||
console.log('----------------------------------------------------------------');
|
||||
};
|
||||
|
|
|
@ -2,10 +2,10 @@ import yml from 'require-yml';
|
|||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
export default function getConfig() {
|
||||
export default function getConfig(env = 'local') {
|
||||
const {pathname: root} = new URL('../', import.meta.url);
|
||||
let conf = yml(path.join(root, 'config.yml'));
|
||||
const localConfFile = path.join(root, 'config.local.yml');
|
||||
const localConfFile = path.join(root, `config.${env}.yml`);
|
||||
if (fs.existsSync(localConfFile))
|
||||
conf = Object.assign({}, conf, yml(localConfFile));
|
||||
|
||||
|
|
Loading…
Reference in New Issue