[ADD] NUEVOS ENLACES PARA CARPETAS EVIDENCIA POR AREA

parent aef48d52
......@@ -157,6 +157,7 @@ export class ConformidadComponent implements AfterViewInit {
archivosEvidencia : interFile[] = [];
archivosProblema : interFile[] = [];
archivosSolucion : interFile[] = [];
//INICIALIZACION DE VARIABLES UTILIZABLES
// GRUPO DE FORMULARIO
......@@ -341,7 +342,7 @@ export class ConformidadComponent implements AfterViewInit {
this.listPersonal.push({ index: this.listPersonal.length , id: 0 , nombre: '' }); // Agregar uno más
}
//QUITAR UN TECNICP
//QUITAR UN TECNICO
onEventoQuitarPersonal(){
if(this.listPersonal.length === 1){
......@@ -505,7 +506,6 @@ export class ConformidadComponent implements AfterViewInit {
//Obtener todos los datos del form Group datos_personal
const datosPersonal = this.datos_personal.getRawValue();
const personal = this.listPersonal;
//const datosPasajes = this.dataSource; // Obtener todos los datos de la tabla de pasajes
const datosServicio = this.datos_servicio.getRawValue();
const requerimientoRelacionados = this.listRequerimientos;
const datosTrabajo = this.datos_trabajo.getRawValue();
......@@ -523,6 +523,11 @@ export class ConformidadComponent implements AfterViewInit {
const ordenSalidaMaterial = this.ordenSalidaComponent?.datos_materialSobrante?.get('numeroOrden')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('numeroOrden')?.value : '';
const descripcionMaterial = this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value : '';
// OBTENER EL VALOR attr.data-value DEL formControlName="tipoCargoPersonal"
const tipoCargoPersonal = this.datos_personal.get('tipoCargoPersonal')?.value;
const especialidad = this.cargosU_list.find((item: any) => item.cargou === tipoCargoPersonal);
const codTipoEspecialidad = especialidad.codtipocargo
Notiflix.Loading.standard('Cargando...');
if(evidenciaMaterial.length > 0){
......@@ -573,7 +578,7 @@ export class ConformidadComponent implements AfterViewInit {
let codigoConformidad = respuestaConformidad.data.codconformidad;
const registroCarpeta = await this.conformidadHelper.creacionCarpeta({codconformidad: codigoConformidad});
const registroCarpeta = await this.conformidadHelper.creacionCarpeta({codconformidad: codigoConformidad, tipoespecialidad: codTipoEspecialidad});
if (registroCarpeta.status) {
//UNIR LOS DATOS archivosEP Y archivosES EN UN SOLO ARRAY
......
......@@ -53,17 +53,6 @@ export class ConformidadHelper {
}
}
async subidaEvidencia( json : any ){
const respuesta = await this.ConformidadService.subidaEvidencia(json);
return respuesta
}
async subidaEvidencia2( json : any ){
const respuesta = await this.ConformidadService.subidaEvidencia2(json);
//console.log(respuesta);
return respuesta
}
async subidaEvidencia3( json : any ){
const respuesta = await this.ConformidadService.subidaEvidencia3(json);
//console.log(respuesta);
......
......@@ -12,6 +12,8 @@ export class ConformidadService {
t_horizon_rest_link = environment.horizon_services_link;
t_facturacion_electronica_link = environment.facturacion_electronica_link;
value_idDrive = environment.ID_CARPETA_DRIVE_LOGISTICA;
value_idDriveElectricista = environment.ID_CARPETA_DRIVE_LOGISTICA_ELECTRICISTA;
value_idDriveGasfiteria = environment.ID_CARPETA_DRIVE_LOGISTICA_GASFITERIA;
value_correoDrive = environment.CORREO_DRIVE_LOGISTICA;
t_redireccionamiento = environment.redireccionamiento;
......@@ -96,7 +98,7 @@ export class ConformidadService {
const jsonData = {
carpeta_nombre : 'CONFORMIDAD_' + json.codconformidad ,
carpeta_id : this.value_idDrive ,
carpeta_id : (json.tipoespecialidad == 1 ) ? this.value_idDriveElectricista : this.value_idDriveGasfiteria ,
correo : this.value_correoDrive
}
......@@ -128,143 +130,6 @@ export class ConformidadService {
return respuesta;
}
async subidaEvidencia(json:any){
const url = `${this.t_redireccionamiento}/google/drive`;
let respuesta: any;
for(let i = 0 ; i < json.length ; i++){
const datos = json[i];
const formData = new FormData();
formData.append('archivo_nombre', datos.nombreArchivo);
formData.append('archivo_binario', datos.archivo);
formData.append('archivo_id_actual', '');
formData.append('carpeta_id', datos.idCarpeta || this.value_idDrive);
formData.append('correo', this.value_correoDrive);
formData.append('app_nombre', 'ORDEN_COMPRA'); // USANDO ESTE NOMBRE DE APP(ORDEN_COMPRA) YA QUE NO CUENTA CON LA CONFIGURACION DE SUBCARPETAS
formData.append('carpeta_nombre', datos.tipoEvidencia === 1 ? 'EVIDENCIAS_PROBLEMAS' :
datos.tipoEvidencia === 2 ? 'EVIDENCIAS_SOLUCIONES' : 'EVIDENCIAS_EXTRAS' );
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 60000); // 30 segundos
try {
const response = await fetch(url, {
method: 'POST',
body: formData,
signal: controller.signal, // 30 segundos de timeout
});
const statusCode = response.status;
const responseBody = await response.json();
//console.log(response)
clearTimeout(timeout); // Limpiar, REVISA SI ESTO ESTA BIEN O QUITARLO
if (statusCode === 200) {
const registroEvidencia = await this.registroDocumento({
codconformidad: datos.codconformidad || 0,
tipoEvidencia: datos.tipoEvidencia || 0,
idDrive: responseBody.data.archivo_id || '',
enlaceDrive: responseBody.data.archivo_url_vista || '',
enlaceDescarga: responseBody.data.archivo_url || '',
nombreDocumento: datos.nombreArchivo || '',
idCarpeta : datos.idCarpeta || ''
});
//console.log(registroEvidencia);
if (responseBody?.status) {
respuesta = {status: true, message: "Imagenes subidas"};
} else {
respuesta = {status: false, message: "Fallo en subir imagene"};
break;
}
} else {
respuesta = {status: false, message: "Fallo en subir imagene " + response};
break;
}
//return respuesta;
} catch (error) {
console.error('Error al registrar el archivo:', error);
//throw error;
respuesta = {status: false, message: error};
}
}
return respuesta;
}
// REEMPLAZO DE SUBIDA DE ARCHIVOS
// FUNCION , RECONOCER QUE TODOS LOS ARCHIVOS SE SUBIERON
async subidaEvidencia2(json:any){
const url = `${this.t_redireccionamiento}/google/drive`;
const respuestas: any[] = [];
let archivosSubidos = 0;
const totalArchivos = json.length;
const promesas = json.map(async (datos: { nombreArchivo: string | Blob; archivo: string | Blob; idCarpeta: any; tipoEvidencia: number; codconformidad: any; }, index: any) => {
const formData = new FormData();
formData.append("archivo_nombre", datos.nombreArchivo);
formData.append("archivo_binario", datos.archivo);
formData.append("archivo_id_actual", "");
formData.append("carpeta_id", datos.idCarpeta || this.value_idDrive);
formData.append("correo", this.value_correoDrive);
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 90000);
const response = await fetch(url, {
method: "POST",
body: formData,
signal: controller.signal,
});
clearTimeout(timeout);
if (!response.ok) {
console.error("Error en la respuesta del servidor:", response);
return { status: false, message: "Error al subir el archivo" };
}
const responseBody = await response.json();
if (responseBody?.status) {
await this.registroDocumento({
codconformidad: datos.codconformidad || 0,
tipoEvidencia: datos.tipoEvidencia || 0,
idDrive: responseBody.data.archivo_id || "",
enlaceDrive: responseBody.data.archivo_url_vista || "",
enlaceDescarga: responseBody.data.archivo_url || "",
nombreDocumento: datos.nombreArchivo || "",
idCarpeta: datos.idCarpeta || "",
});
archivosSubidos++;
//this.progresoSubida.next(Math.round((archivosSubidos / totalArchivos) * 100));
const progreso = Math.round((archivosSubidos / totalArchivos) * 100);
this.progresoSubida.next(progreso);
// Actualizar Notiflix con el progreso
Notiflix.Loading.change(`Carga al ${progreso}%`);
return { status: true, message: "Archivo subido correctamente" };
} else {
return { status: false, message: "Error al registrar evidencia" };
}
} catch (error) {
console.error("Error al registrar el archivo:", error);
return { status: false, message: error };
}
});
return Promise.all(promesas);
}
async subidaEvidencia3(json: any[]) {
const url = `${this.t_redireccionamiento}/google/drive`;
const totalArchivos = json.length;
......
......@@ -7,5 +7,7 @@ export const environment = {
horizon_services_link: 'https://api-horizon.sacooliveros.edu.pe',
ID_CARPETA_DRIVE_LOGISTICA:'13mGZo3AnFqgkNRyiVAgJoW9mUoQdABdC',
CORREO_DRIVE_LOGISTICA : 'trismegisto.logistica@sacooliveros.edu.pe',
opcion : 2
opcion : 2,
ID_CARPETA_DRIVE_LOGISTICA_ELECTRICISTA : '1p5OOR3HxBgqSojuPJCk0W_ll3w3zuK-G',
ID_CARPETA_DRIVE_LOGISTICA_GASFITERIA : '17DvKNiua3__AS_0Rbhv9mztj-fjkZflh',
};
......@@ -7,5 +7,7 @@ export const environment = {
horizon_services_link: 'http://localhost:8080/trismegisto-api-horizons',
ID_CARPETA_DRIVE_LOGISTICA:'1zYWsmpIAKR6nBmO5dnnBSAHJr81img0s',
CORREO_DRIVE_LOGISTICA : 'trismegisto.logistica@sacooliveros.edu.pe',
opcion : 1
opcion : 1,
ID_CARPETA_DRIVE_LOGISTICA_ELECTRICISTA : '1T8r10oVJos40bAcHKy-E-zpovd0iK_B3',
ID_CARPETA_DRIVE_LOGISTICA_GASFITERIA : '1vu8UHyPh4sbTGwmQWjySqcGXsABE7WYN',
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment