Merge pull request 'refactor' (#1) from 5144-arc-start into master
gitea/vn-rfid/pipeline/head This commit looks good
Details
gitea/vn-rfid/pipeline/head This commit looks good
Details
Reviewed-on: #1
This commit is contained in:
commit
544ef24ac8
|
@ -1,3 +1,4 @@
|
|||
arcId: 1
|
||||
port: 1234
|
||||
ip: 1.2.3.4
|
||||
env: dev
|
||||
|
@ -9,5 +10,5 @@ db:
|
|||
database: srt
|
||||
user: user
|
||||
password: password
|
||||
multipleStatements: true
|
||||
multipleStatements: false
|
||||
insecureAuth: true
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
import con from '../db/connect.js';
|
||||
|
||||
export default async rfids => {
|
||||
let response;
|
||||
|
||||
if (!rfids.length) return console.logger.warning({error: 'NOT_PARSED_RFIDS', rfids});
|
||||
|
||||
export default async(rfids, arcId) => {
|
||||
const codes = new Set();
|
||||
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 pallet = response[0][1][0]['@pallet'];
|
||||
if (pallet) {
|
||||
console.logger.info('PRINTING', pallet);
|
||||
await con.query(`CALL vn.expeditionPallet_printLabel(?);`, [pallet]);
|
||||
} else
|
||||
const palletId = await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(codes), arcId, null]);
|
||||
if (!palletId)
|
||||
console.logger.info({error: 'ERROR_CREATING_PALLET', expeditions: rfids});
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ export default async(conf, cb) => {
|
|||
if (parsed)
|
||||
rfidbuffer = rfidbuffer.concat(parsed);
|
||||
|
||||
debug();
|
||||
debug(parsed);
|
||||
|
||||
if (rfidbuffer && rfidbuffer.length && parsed && parsed.length) {
|
||||
clearInterval(interval);
|
||||
|
@ -32,12 +32,12 @@ export default async(conf, cb) => {
|
|||
function createPallet() {
|
||||
clearInterval(interval); // try remove
|
||||
if (!rfidbuffer.length) return;
|
||||
newPallet(rfidbuffer);
|
||||
newPallet(rfidbuffer, conf.arcId);
|
||||
rfidbuffer = [];
|
||||
rfidbufferSet = [new Set(), new Set(), new Set(), new Set()];
|
||||
}
|
||||
|
||||
function debug() {
|
||||
function debug(parsed) {
|
||||
if (conf.env != 'dev') return;
|
||||
let totalBuffer = rfidbuffer.map(rfid => rfid.code);
|
||||
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);
|
||||
for (const [index, set] of rfidbufferSet.entries()) {
|
||||
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('----------------------------------------------------------------');
|
||||
|
|
Loading…
Reference in New Issue