This commit is contained in:
Guillermo Bonet 2022-11-10 18:25:21 +01:00
parent f57ad11409
commit 11f960b7a5
3 changed files with 10 additions and 6 deletions

View File

@ -5,7 +5,7 @@ async function main() {
await printServer.start(); await printServer.start();
process.on('SIGINT', async function() { process.on('SIGINT', async function() {
console.log('Got SIGINT.'); console.log(`\nBye ( ◕ ‿ ◕ )っ`);
try { try {
await printServer.stop(); await printServer.stop();
} catch (err) { } catch (err) {

View File

@ -88,7 +88,8 @@ class PrintServer {
if (!printJob) return; if (!printJob) return;
jobId = printJob.id; jobId = printJob.id;
this.method = printJob.method;
await conn.query(updateQuery, ['printing', null, jobId]); await conn.query(updateQuery, ['printing', null, jobId]);
await conn.commit(); await conn.commit();
} catch (err) { } catch (err) {
@ -102,9 +103,10 @@ class PrintServer {
for (const row of res[0]) for (const row of res[0])
args[row.name] = row.value; args[row.name] = row.value;
try { try {
let methodPath = this.method.replace('{id}', args.param);
const response = await axios({ const response = await axios({
method: 'get', 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', responseType: 'arraybuffer',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@ -2,12 +2,14 @@ SELECT pq.id,
r.name report, r.name report,
p.name printer, p.name printer,
pqa.name arg, pqa.name arg,
pqa.value pqa.value,
r.method
FROM printQueue pq FROM printQueue pq
JOIN report r ON r.id = pq.reportFk JOIN report r ON r.id = pq.reportFk
JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id JOIN printQueueArgs pqa ON pqa.printQueueFk = pq.id
LEFT JOIN printer p ON p.id = pq.printerFk LEFT JOIN printer p ON p.id = pq.printerFk
WHERE r.name = ? WHERE r.name = ?
AND statusCode = 'queued' AND pq.statusCode = 'queued'
ORDER BY priorityFk ASC AND NOT r.method IS NULL
ORDER BY pq.priorityFk ASC
LIMIT 1 LIMIT 1