fpavon-ee-shared 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/documentos/application/documentos.useCase.d.ts +1 -1
- package/dist/documentos/application/documentos.useCase.js +5 -3
- package/dist/documentos/infrastructure/repository/documentos.ftp.repository.js +28 -28
- package/documentos/application/documentos.useCase.ts +6 -4
- package/documentos/infrastructure/repository/documentos.ftp.repository.ts +54 -54
- package/package.json +1 -1
|
@@ -8,5 +8,5 @@ export declare class DocumentosUseCase {
|
|
|
8
8
|
crearDocumentoByBuffer: (file: any) => Promise<import("../domain/documentoFTP").IDocumentoFTP>;
|
|
9
9
|
getDocumentoAdjunto: (uuid: string) => Promise<DocumentoFTP>;
|
|
10
10
|
deleteDocumento: (uuid: any) => Promise<Boolean>;
|
|
11
|
-
generarPinDeFirmaUseCase: (
|
|
11
|
+
generarPinDeFirmaUseCase: (registrosDeFirma: any) => Promise<any>;
|
|
12
12
|
}
|
|
@@ -36,9 +36,9 @@ class DocumentosUseCase {
|
|
|
36
36
|
this.deleteDocumento = (uuid) => __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
return yield this.documentosRepository.deleteDocumento(uuid);
|
|
38
38
|
});
|
|
39
|
-
this.generarPinDeFirmaUseCase = (
|
|
39
|
+
this.generarPinDeFirmaUseCase = (registrosDeFirma) => __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
// 1. Obtener la lista de PINs que ya están ocupados por el usuario
|
|
41
|
-
const pinsOcupados = yield this.documentosRepository.buscarPinesActivosPorUsuario(
|
|
41
|
+
const pinsOcupados = yield this.documentosRepository.buscarPinesActivosPorUsuario(registrosDeFirma.FirmanteUid);
|
|
42
42
|
// 2. Crear una lista de todos los PINs posibles (00 a 99)
|
|
43
43
|
const todosLosPins = [];
|
|
44
44
|
for (let i = 0; i < 100; i++) {
|
|
@@ -53,7 +53,9 @@ class DocumentosUseCase {
|
|
|
53
53
|
}
|
|
54
54
|
// 5. Seleccionar un PIN al azar de la lista de pines libres
|
|
55
55
|
const indiceAleatorio = Math.floor(Math.random() * pinsLibres.length);
|
|
56
|
-
|
|
56
|
+
registrosDeFirma.Pin = pinsLibres[indiceAleatorio];
|
|
57
|
+
yield this.documentosRepository.insertPinDeFirma(registrosDeFirma);
|
|
58
|
+
return registrosDeFirma;
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
bufferToStream(buffer) {
|
|
@@ -196,34 +196,34 @@ class DocumentosFTPRepository {
|
|
|
196
196
|
.input("Comentario", mssql_1.default.NVarChar(mssql_1.default.MAX), pin.Comentario) // nvarchar(max), null
|
|
197
197
|
.input("Pin", mssql_1.default.Char(2), pin.Pin)
|
|
198
198
|
.query(`
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
199
|
+
INSERT INTO dbo.RegistrosDeFirma (
|
|
200
|
+
ExpedienteId,
|
|
201
|
+
DocumentoUuidOriginal,
|
|
202
|
+
DocumentoUuidFirmado,
|
|
203
|
+
FirmanteUid,
|
|
204
|
+
FirmanteNombreCompleto,
|
|
205
|
+
FirmanteCargo,
|
|
206
|
+
DatosCertificado,
|
|
207
|
+
FechaFirma,
|
|
208
|
+
EsValida,
|
|
209
|
+
Decision,
|
|
210
|
+
Comentario,
|
|
211
|
+
Pin
|
|
212
|
+
)
|
|
213
|
+
VALUES (
|
|
214
|
+
@ExpedienteId,
|
|
215
|
+
@DocumentoUuidOriginal,
|
|
216
|
+
@DocumentoUuidFirmado,
|
|
217
|
+
@FirmanteUid,
|
|
218
|
+
@FirmanteNombreCompleto,
|
|
219
|
+
@FirmanteCargo,
|
|
220
|
+
@DatosCertificado,
|
|
221
|
+
@FechaFirma,
|
|
222
|
+
@EsValida,
|
|
223
|
+
@Decision,
|
|
224
|
+
@Comentario,
|
|
225
|
+
@Pin
|
|
226
|
+
)`);
|
|
227
227
|
yield transaction.commit();
|
|
228
228
|
return pin;
|
|
229
229
|
}
|
|
@@ -38,10 +38,10 @@ export class DocumentosUseCase{
|
|
|
38
38
|
return await this.documentosRepository.deleteDocumento(uuid)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
generarPinDeFirmaUseCase = async (
|
|
41
|
+
generarPinDeFirmaUseCase = async (registrosDeFirma:any)=>{
|
|
42
42
|
|
|
43
43
|
// 1. Obtener la lista de PINs que ya están ocupados por el usuario
|
|
44
|
-
const pinsOcupados: string[] = await this.documentosRepository.buscarPinesActivosPorUsuario(
|
|
44
|
+
const pinsOcupados: string[] = await this.documentosRepository.buscarPinesActivosPorUsuario(registrosDeFirma.FirmanteUid);
|
|
45
45
|
|
|
46
46
|
// 2. Crear una lista de todos los PINs posibles (00 a 99)
|
|
47
47
|
const todosLosPins: string[] = [];
|
|
@@ -60,8 +60,10 @@ export class DocumentosUseCase{
|
|
|
60
60
|
|
|
61
61
|
// 5. Seleccionar un PIN al azar de la lista de pines libres
|
|
62
62
|
const indiceAleatorio = Math.floor(Math.random() * pinsLibres.length);
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
registrosDeFirma.Pin = pinsLibres[indiceAleatorio];
|
|
64
|
+
|
|
65
|
+
await this.documentosRepository.insertPinDeFirma(registrosDeFirma)
|
|
66
|
+
return registrosDeFirma;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
}
|
|
@@ -176,67 +176,67 @@ export class DocumentosFTPRepository implements IDocumentosRepository{
|
|
|
176
176
|
const transaction = new sql.Transaction(pool);
|
|
177
177
|
|
|
178
178
|
try {
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
await transaction.begin();
|
|
180
|
+
started = true;
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
182
|
+
const insertResult = await transaction
|
|
183
|
+
.request()
|
|
184
|
+
.input("ExpedienteId", sql.Int, pin.ExpedienteId) // int, not null
|
|
185
|
+
.input("DocumentoUuidOriginal", sql.NVarChar(50), pin.DocumentoUuidOriginal) // nvarchar(50), not null
|
|
186
|
+
.input("DocumentoUuidFirmado", sql.NVarChar(50), pin.DocumentoUuidFirmado) // nvarchar(50), null (Debe ser NULL en la inserción inicial)
|
|
187
|
+
.input("FirmanteUid", sql.NVarChar(100), pin.FirmanteUid) // nvarchar(100), not null
|
|
188
|
+
.input("FirmanteNombreCompleto", sql.NVarChar(255), pin.FirmanteNombreCompleto) // nvarchar(255), not null
|
|
189
|
+
.input("FirmanteCargo", sql.NVarChar(255), pin.FirmanteCargo) // nvarchar(255), null
|
|
190
|
+
.input("DatosCertificado", sql.NVarChar(sql.MAX), pin.DatosCertificado) // nvarchar(max), null (Ajusta según tu necesidad, originalmente NOT NULL)
|
|
191
|
+
.input("FechaFirma", sql.DateTime2, pin.FechaFirma) // datetime2(7), not null
|
|
192
|
+
.input("EsValida", sql.Bit, pin.EsValida) // bit, not null (Debe ser 0/false inicialmente)
|
|
193
|
+
.input("Decision", sql.NVarChar(20), pin.Decision) // nvarchar(20), not null ('PENDIENTE' inicialmente)
|
|
194
|
+
.input("Comentario", sql.NVarChar(sql.MAX), pin.Comentario) // nvarchar(max), null
|
|
195
|
+
.input("Pin", sql.Char(2), pin.Pin)
|
|
196
|
+
.query(`
|
|
197
|
+
INSERT INTO dbo.RegistrosDeFirma (
|
|
198
|
+
ExpedienteId,
|
|
199
|
+
DocumentoUuidOriginal,
|
|
200
|
+
DocumentoUuidFirmado,
|
|
201
|
+
FirmanteUid,
|
|
202
|
+
FirmanteNombreCompleto,
|
|
203
|
+
FirmanteCargo,
|
|
204
|
+
DatosCertificado,
|
|
205
|
+
FechaFirma,
|
|
206
|
+
EsValida,
|
|
207
|
+
Decision,
|
|
208
|
+
Comentario,
|
|
209
|
+
Pin
|
|
210
|
+
)
|
|
211
|
+
VALUES (
|
|
212
|
+
@ExpedienteId,
|
|
213
|
+
@DocumentoUuidOriginal,
|
|
214
|
+
@DocumentoUuidFirmado,
|
|
215
|
+
@FirmanteUid,
|
|
216
|
+
@FirmanteNombreCompleto,
|
|
217
|
+
@FirmanteCargo,
|
|
218
|
+
@DatosCertificado,
|
|
219
|
+
@FechaFirma,
|
|
220
|
+
@EsValida,
|
|
221
|
+
@Decision,
|
|
222
|
+
@Comentario,
|
|
223
|
+
@Pin
|
|
224
|
+
)`
|
|
210
225
|
)
|
|
211
|
-
|
|
212
|
-
@ExpedienteId,
|
|
213
|
-
@DocumentoUuidOriginal,
|
|
214
|
-
@DocumentoUuidFirmado,
|
|
215
|
-
@FirmanteUid,
|
|
216
|
-
@FirmanteNombreCompleto,
|
|
217
|
-
@FirmanteCargo,
|
|
218
|
-
@DatosCertificado,
|
|
219
|
-
@FechaFirma,
|
|
220
|
-
@EsValida,
|
|
221
|
-
@Decision,
|
|
222
|
-
@Comentario,
|
|
223
|
-
@Pin
|
|
224
|
-
)`
|
|
225
|
-
)
|
|
226
|
-
|
|
226
|
+
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
await transaction.commit();
|
|
229
|
+
return pin;
|
|
230
230
|
} catch (error: any) {
|
|
231
231
|
if (started) {
|
|
232
232
|
try {
|
|
233
|
-
|
|
233
|
+
await transaction.rollback();
|
|
234
234
|
} catch (rollbackError) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
console.error(
|
|
236
|
+
"Error DocumentosSqlRepository.insertPinDeFirma durante rollback:",
|
|
237
|
+
rollbackError
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
240
|
}
|
|
241
241
|
console.error(
|
|
242
242
|
`Error DocumentosSqlRepository.insertPinDeFirma al crear pin: ${error.message}`
|