feat(salix): refs #5926 #5926 Remove unnecessary code

This commit is contained in:
Javier Segarra 2024-06-03 14:16:19 +02:00
parent 4c34ce66a0
commit 2072a3f404
4 changed files with 3 additions and 91 deletions

View File

@ -11,6 +11,7 @@ module.exports = Self => {
id,
type: 'deliveryNote'
}, myOptions);
// get ticket data
const ticket = await models.Ticket.findById(id, {
include: [{
@ -23,7 +24,6 @@ module.exports = Self => {
// upload file
const configTemplate = {
'N__ALBAR_N': {
type: 'string',
value: id,
@ -69,32 +69,9 @@ module.exports = Self => {
// delete old
await models.Docuware.deleteOld(id, fileCabinet, uri);
// const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, false);
// if (docuwareFile) {
// const deleteJson = {
// 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
// };
// const deleteUri = `${uri}/${docuwareFile.id}/Fields`;
// await axios.put(deleteUri, deleteJson, docuwareOptions.headers);
// }
const uploadUri = `${uri}?StoreDialogId=${dialogId}`;
const uploadOptions = models.Docuware.uploadOptions(deliveryNote[0], configTemplate);
// const FormData = require('form-data');
// const data = new FormData();
// data.append('document', JSON.stringify(templateJson), 'schema.json');
// data.append('file[]', deliveryNote[0], 'file.pdf');
// const uploadOptions = {
// headers: {
// 'Content-Type': 'multipart/form-data',
// 'X-File-ModifiedDate': Date.vnNew(),
// 'Cookie': docuwareOptions.headers.headers.Cookie,
// ...data.getHeaders()
// },
// };
try {
await axios.post(uploadUri, data, uploadOptions);
} catch (err) {

View File

@ -4,18 +4,16 @@ const UserError = require('vn-loopback/util/user-error');
const isProduction = require('vn-loopback/server/boot/isProduction');
module.exports = Self => {
Self.docuwareUpload = async({ctx, tabletFk, ids: id, myOptions, uri, fileCabinet, dialogId}) => {
// get delivery note
const pdaId = id[0];
ctx.args.id = pdaId;
delete ctx.args.ids;
// // get ticket data
// const pda = await models.DeviceProduction.findById(pdaId, myOptions);
// const user = await models.UserConfig.find({where: {tabletFk}, fields: ['userFk']}, myOptions);
// upload file
const signPda = await models.Worker.signPdaPdf(ctx,
pdaId
, myOptions);
const configTemplate = {
'N__DOCUMENTO': {
type: 'String',
@ -40,14 +38,6 @@ module.exports = Self => {
// delete old
await models.Docuware.deleteOld(id, fileCabinet, uri);
// const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, false);
// if (docuwareFile) {
// const deleteJson = {
// 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}]
// };
// const deleteUri = `${uri}/${docuwareFile.id}/Fields`;
// await axios.put(deleteUri, deleteJson, docuwareOptions.headers);
// }
const uploadUri = `${uri}?StoreDialogId=${dialogId}`;
const uploadOptions = models.Docuware.uploadOptions(signPda[0], configTemplate);

View File

@ -1,54 +0,0 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('isPDASigned', {
description: 'Deallocate the PDA of the worker',
accepts: [{
arg: 'ctx',
type: 'Object',
http: {source: 'context'}
}, {
arg: 'id',
type: 'number',
required: true,
description: 'The worker id',
http: {source: 'path'}
}, {
arg: 'pda',
type: 'number',
required: true,
description: 'The pda id'
}],
returns: {
type: ['object'],
root: true
},
http: {
path: '/:id/:pda/isPDASigned',
verb: 'GET'
}
});
Self.isPDASigned = async(ctx, options) => {
const models = Self.app.models;
const args = ctx.args;
let tx;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const pda = await models.DeviceProduction.findById(args.pda, myOptions);
if (pda.stateFk != 'idle') throw new UserError(`The PDA state is not idle`);
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};

View File

@ -18,7 +18,6 @@ module.exports = Self => {
require('../methods/worker/new')(Self);
require('../methods/worker/deallocatePDA')(Self);
require('../methods/worker/allocatePDA')(Self);
require('../methods/worker/signedPDA')(Self);
require('../methods/worker/signPdaPdf')(Self);
require('../methods/worker/search')(Self);
require('../methods/worker/isAuthorized')(Self);