diff --git a/main.js b/main.js index 41de272..7fe7b2a 100644 --- a/main.js +++ b/main.js @@ -5,7 +5,7 @@ async function main() { await printServer.start(); process.on('SIGINT', async function() { - console.log('Got SIGINT.'); + console.log(`\nBye ( ◕ ‿ ◕ )っ`); try { await printServer.stop(); } catch (err) { diff --git a/print-server.js b/print-server.js index 9e96540..e46a859 100644 --- a/print-server.js +++ b/print-server.js @@ -88,7 +88,8 @@ class PrintServer { if (!printJob) return; jobId = printJob.id; - + this.method = printJob.method; + await conn.query(updateQuery, ['printing', null, jobId]); await conn.commit(); } catch (err) { @@ -102,9 +103,10 @@ class PrintServer { for (const row of res[0]) args[row.name] = row.value; try { + let methodPath = this.method.replace('{id}', args.param); const response = await axios({ method: 'get', - url: `${conf.salix.url}/api/Tickets/${args.param}/collection-label?access_token=${this.token}`, + url: `${conf.salix.url}/api/${methodPath}?access_token=${this.token}`, responseType: 'arraybuffer', headers: { 'Content-Type': 'application/json', diff --git a/sql/selectQueued.sql b/sql/selectQueued.sql index c87c9ef..e5ac781 100644 --- a/sql/selectQueued.sql +++ b/sql/selectQueued.sql @@ -2,12 +2,14 @@ SELECT pq.id, r.name report, p.name printer, pqa.name arg, - pqa.value + pqa.value, + r.method FROM printQueue pq JOIN report r ON r.id = pq.reportFk JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id LEFT JOIN printer p ON p.id = pq.printerFk WHERE r.name = ? - AND statusCode = 'queued' - ORDER BY priorityFk ASC + AND pq.statusCode = 'queued' + AND NOT r.method IS NULL + ORDER BY pq.priorityFk ASC LIMIT 1 \ No newline at end of file