|
|
@@ -138,8 +138,6 @@ class AsyncValidateLoadArchivesController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// Compare Excel file listings with ZIP contents
|
|
|
$comparison = $this->compareExcelWithZip($filesValidation['files'], $request->file('zip_file'));
|
|
|
|
|
|
@@ -149,55 +147,45 @@ class AsyncValidateLoadArchivesController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!$comparison['valid']) {
|
|
|
+ // Upload temp files
|
|
|
+ $tempFiles = $this->uploadTempFiles($request);
|
|
|
+ if ($tempFiles['error']) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- 'Los archivos no coinciden entre Excel y ZIP',
|
|
|
- $comparison,
|
|
|
+ $tempFiles['message'],
|
|
|
+ [
|
|
|
+ 'valid' => false,
|
|
|
+ 'missing_in_zip' => $comparison['missing_in_zip'] ?? [],
|
|
|
+ 'extra_in_zip' => $comparison['extra_in_zip'] ?? []
|
|
|
+ ],
|
|
|
400
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- // Upload temp files
|
|
|
- $tempFiles = $this->uploadTempFiles($request);
|
|
|
- if ($tempFiles['error']) {
|
|
|
- return $this->responseController->makeResponse(true, $tempFiles['message'], [], 400);
|
|
|
+ if (!$comparison['valid']) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ 'Los archivos no coinciden entre Excel y ZIP',
|
|
|
+ [
|
|
|
+ 'valid' => false,
|
|
|
+ 'missing_in_zip' => $comparison['missing_in_zip'],
|
|
|
+ 'extra_in_zip' => $comparison['extra_in_zip']
|
|
|
+ ],
|
|
|
+ 400
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
- // Log::info($tempFiles);
|
|
|
|
|
|
$idFileZip = $this->encryptionController->decrypt($tempFiles['files']['zip']);
|
|
|
if(!$idFileZip){
|
|
|
return $this->responseController->makeResponse(true, "El id del archivo que desea eliminar no fue encriptado correctamente", [], 400);
|
|
|
}
|
|
|
-
|
|
|
- // Log::info($idFileZip);
|
|
|
-
|
|
|
- // //Recuperar objeto del registro del zip
|
|
|
- // $zipFile = DB::table('S002V01TARTE')->where([
|
|
|
- // ['ARTE_IDAR', '=', $idFileZip],
|
|
|
- // ['ARTE_NULI', '=', $request['linea']]
|
|
|
- // ])->first();
|
|
|
-
|
|
|
- // //hay que usar la funcion de registerActivity para registrar en bd los movimiento como el de registrar un nuevo archivo en tmep
|
|
|
|
|
|
$idFileExcel = $this->encryptionController->decrypt($tempFiles['files']['excel']);
|
|
|
if(!$idFileExcel){
|
|
|
return $this->responseController->makeResponse(true, "El id del archivo que desea eliminar no fue encriptado correctamente", [], 400);
|
|
|
}
|
|
|
|
|
|
- // Log::info($idFileExcel);
|
|
|
-
|
|
|
- // //Recuperar objeto del registro del excel
|
|
|
- // $excelFile = DB::table('S002V01TARTE')->where([
|
|
|
- // ['ARTE_IDAR', '=', $idFileExcel],
|
|
|
- // ['ARTE_NULI', '=', $request['linea']]
|
|
|
- // ])->first();
|
|
|
-
|
|
|
- Log::info($idFileExcel);
|
|
|
- Log::info($idFileZip);
|
|
|
-
|
|
|
-
|
|
|
// Guardar en bd::S002V01TVAJO
|
|
|
$validationJobId = DB::table('S002V01TVAJO')->insertGetId([
|
|
|
'VAJO_COJO' => $jobId,
|
|
|
@@ -214,7 +202,13 @@ class AsyncValidateLoadArchivesController extends Controller
|
|
|
return $this->responseController->makeResponse(
|
|
|
false,
|
|
|
'Validación iniciada',
|
|
|
- ['job_id' => $validationJobId, 'status' => 'queued']
|
|
|
+ [
|
|
|
+ 'job_id' => $validationJobId,
|
|
|
+ 'status' => 'queued',
|
|
|
+ 'valid' => $comparison['valid'],
|
|
|
+ 'missing_in_zip' => $comparison['missing_in_zip'],
|
|
|
+ 'extra_in_zip' => $comparison['extra_in_zip']
|
|
|
+ ]
|
|
|
);
|
|
|
}
|
|
|
|