Merge pull request '4550-printServer' (!1131) from 4550-printServer into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1131 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
abe816bbe5
|
@ -47,12 +47,8 @@ module.exports = class Docker {
|
||||||
if (ci) network = `--network="${networkName}"`;
|
if (ci) network = `--network="${networkName}"`;
|
||||||
|
|
||||||
log('Starting container...');
|
log('Starting container...');
|
||||||
const container = await this.execP(`
|
const container = await this.execP(
|
||||||
docker run \
|
`docker run ${network} --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`);
|
||||||
${network} \
|
|
||||||
--env RUN_CHOWN=${runChown} \
|
|
||||||
-d ${dockerArgs} salix-db
|
|
||||||
`);
|
|
||||||
this.id = container.stdout.trim();
|
this.id = container.stdout.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -239,5 +239,6 @@
|
||||||
"This route does not exists": "Esta ruta no existe",
|
"This route does not exists": "Esta ruta no existe",
|
||||||
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
"Claim pickup order sent": "Reclamación Orden de recogida enviada [({{claimId}})]({{{claimUrl}}}) al cliente *{{clientName}}*",
|
||||||
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
"You don't have grant privilege": "No tienes privilegios para dar privilegios",
|
||||||
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario"
|
"You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario",
|
||||||
|
"Empty data source": "Origen de datos vacio"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
const {Report} = require('vn-print');
|
||||||
|
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('collectionLabel', {
|
||||||
|
description: 'Returns the collection label',
|
||||||
|
accessType: 'READ',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The ticket id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'body',
|
||||||
|
type: 'file',
|
||||||
|
root: true
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Type',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}, {
|
||||||
|
arg: 'Content-Disposition',
|
||||||
|
type: 'String',
|
||||||
|
http: {target: 'header'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/:id/collection-label',
|
||||||
|
verb: 'GET'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.collectionLabel = async(ctx, id) => {
|
||||||
|
const args = Object.assign({}, ctx.args);
|
||||||
|
const params = {lang: ctx.req.getLocale()};
|
||||||
|
|
||||||
|
delete args.ctx;
|
||||||
|
for (const param in args)
|
||||||
|
params[param] = args[param];
|
||||||
|
|
||||||
|
const report = new Report('collection-label', params);
|
||||||
|
const stream = await report.toPdfStream();
|
||||||
|
|
||||||
|
return [stream, 'application/pdf', `filename="doc-${id}.pdf"`];
|
||||||
|
};
|
||||||
|
};
|
|
@ -33,4 +33,5 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket/closeByTicket')(Self);
|
require('../methods/ticket/closeByTicket')(Self);
|
||||||
require('../methods/ticket/closeByAgency')(Self);
|
require('../methods/ticket/closeByAgency')(Self);
|
||||||
require('../methods/ticket/closeByRoute')(Self);
|
require('../methods/ticket/closeByRoute')(Self);
|
||||||
|
require('../methods/ticket/collectionLabel')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const vnPrintPath = path.resolve('print');
|
||||||
|
|
||||||
|
module.exports = new Stylesheet([
|
||||||
|
`${vnPrintPath}/common/css/spacing.css`,
|
||||||
|
`${vnPrintPath}/common/css/misc.css`,
|
||||||
|
`${vnPrintPath}/common/css/layout.css`,
|
||||||
|
`${vnPrintPath}/common/css/report.css`,
|
||||||
|
`${__dirname}/style.css`])
|
||||||
|
.mergeStyles();
|
|
@ -0,0 +1,37 @@
|
||||||
|
html {
|
||||||
|
font-family: "Roboto";
|
||||||
|
margin-top: -7px;
|
||||||
|
}
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
|
#vertical {
|
||||||
|
writing-mode: vertical-rl;
|
||||||
|
height: 226px;
|
||||||
|
margin-left: -13px;
|
||||||
|
}
|
||||||
|
.outline {
|
||||||
|
border: 1px solid black;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
#nickname {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
#agencyDescripton {
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#barcode{
|
||||||
|
width: 390px;
|
||||||
|
}
|
||||||
|
#shipped {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#ticketFk, #vertical {
|
||||||
|
font-size: 34px;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html v-bind:lang="$i18n.locale">
|
||||||
|
<body>
|
||||||
|
<table v-for="labelData in labelsData" style="break-before: page;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td rowspan="6"><span id="vertical">{{labelData.levelV}}</span></td>
|
||||||
|
<td id="ticketFk" >{{labelData.ticketFk}} ⬸ {{labelData.clientFk}}</td>
|
||||||
|
<td colspan="2" id="shipped">{{labelData.shipped}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td rowspan="3"><div v-html="getBarcode(labelData.ticketFk)" id="barcode"></div></td>
|
||||||
|
<td class="outline">{{labelData.workerCode}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="outline">{{labelData.labelCount}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="outline">{{labelData.size}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><div id="agencyDescripton">{{labelData.agencyDescription}}</div></td>
|
||||||
|
<td id="bold">{{labelData.lineCount}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="nickname">{{labelData.nickName}}</td>
|
||||||
|
<td id="bold">{{labelData.agencyHour}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,46 @@
|
||||||
|
const jsBarcode = require('jsbarcode');
|
||||||
|
const {DOMImplementation, XMLSerializer} = require('xmldom');
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'collection-label',
|
||||||
|
props: {
|
||||||
|
id: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
description: 'The ticket or collection id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async serverPrefetch() {
|
||||||
|
let ticketIds;
|
||||||
|
const res = await this.rawSqlFromDef('tickets', [this.id]);
|
||||||
|
|
||||||
|
if (res.length) {
|
||||||
|
ticketIds = [];
|
||||||
|
for (const row of res)
|
||||||
|
ticketIds.push(row.ticketFk);
|
||||||
|
} else
|
||||||
|
ticketIds = [this.id];
|
||||||
|
|
||||||
|
this.labelsData = await this.rawSqlFromDef('labelsData', [ticketIds]);
|
||||||
|
|
||||||
|
if (!this.labelsData.length)
|
||||||
|
throw new UserError('Empty data source');
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getBarcode(id) {
|
||||||
|
const xmlSerializer = new XMLSerializer();
|
||||||
|
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
|
||||||
|
const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||||
|
|
||||||
|
jsBarcode(svgNode, id, {
|
||||||
|
xmlDocument: document,
|
||||||
|
format: 'code128',
|
||||||
|
displayValue: false,
|
||||||
|
width: 3.8,
|
||||||
|
height: 110,
|
||||||
|
});
|
||||||
|
return xmlSerializer.serializeToString(svgNode);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1 @@
|
||||||
|
reportName: labelCollection
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"width": "10.4cm",
|
||||||
|
"height": "4.8cm",
|
||||||
|
"margin": {
|
||||||
|
"top": "0cm",
|
||||||
|
"right": "0.5cm",
|
||||||
|
"bottom": "0cm",
|
||||||
|
"left": "0cm"
|
||||||
|
},
|
||||||
|
"printBackground": true
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
SELECT c.itemPackingTypeFk,
|
||||||
|
CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color,
|
||||||
|
CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.`level`) levelV,
|
||||||
|
tc.ticketFk,
|
||||||
|
LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription,
|
||||||
|
am.name,
|
||||||
|
t.clientFk,
|
||||||
|
CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 ,
|
||||||
|
CAST(IF(ic.code = 'plant', CONCAT(MAX(i.`size`),' cm'), COUNT(*)) AS CHAR) size,
|
||||||
|
w.code workerCode,
|
||||||
|
tt.labelCount,
|
||||||
|
IF(HOUR(t.shipped), TIME_FORMAT(t.shipped, '%H:%i'), TIME_FORMAT(zo.`hour`, '%H:%i')) agencyHour,
|
||||||
|
DATE_FORMAT(t.shipped, '%d/%m/%y') shipped,
|
||||||
|
COUNT(*) lineCount,
|
||||||
|
t.nickName
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN vn.ticketCollection tc ON tc.ticketFk = t.id
|
||||||
|
JOIN vn.collection c ON c.id = tc.collectionFk
|
||||||
|
LEFT JOIN vn.collectionColors cc ON cc.shelve = tc.`level`
|
||||||
|
AND cc.wagon = tc.wagon
|
||||||
|
AND cc.trainFk = c.trainFk
|
||||||
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
|
LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id
|
||||||
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN vn.itemCategory ic ON ic.id = it.categoryFk
|
||||||
|
JOIN vn.worker w ON w.id = c.workerFk
|
||||||
|
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
|
||||||
|
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
|
||||||
|
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
|
||||||
|
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
|
||||||
|
LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk
|
||||||
|
WHERE tc.ticketFk IN (?)
|
||||||
|
GROUP BY t.id
|
||||||
|
ORDER BY cc.`code`;
|
|
@ -0,0 +1,3 @@
|
||||||
|
SELECT ticketFk
|
||||||
|
FROM ticketCollection
|
||||||
|
WHERE collectionFk = ?
|
Loading…
Reference in New Issue