json(['message' => 'Data Arrangement processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processCustomerData($periods) { try { // Pass the periods to the job for processing ProcessCustomerDataJob::dispatch($periods); return response()->json([ 'message' => 'Data Customer processing job has been successfully queued', 'periods' => $periods ]); } catch (Exception $e) { Log::error('Error in processCustomerData: ' . $e->getMessage()); return response()->json(['error' => $e->getMessage()], 500); } } public function processBillDetailData($periods) { try { ProcessBillDetailDataJob::dispatch($periods); return response()->json(['message' => 'Data Bill Details processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processAccountData($periods){ try{ ProcessAccountDataJob::dispatch($periods); return response()->json(['message' => 'Data Account processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processTransactionData($periods){ try{ ProcessTransactionDataJob::dispatch($periods); Log::info('Data Transaction processing job has been successfully'); return response()->json(['message' => 'Data Transaction processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processFundsTransferData($periods){ try{ ProcessFundsTransferDataJob::dispatch($periods); return response()->json(['message' => 'Data Funds Transfer processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processStmtNarrParamData($periods) { try { ProcessStmtNarrParamDataJob::dispatch($periods); return response()->json(['message' => 'Data TempStmtNarrParam processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processStmtNarrFormatData($periods){ try { ProcessStmtNarrFormatDataJob::dispatch($periods); return response()->json(['message' => 'Data TempStmtNarrFormat processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessFtTxnTypeConditioData($periods){ try { ProcessFtTxnTypeConditionJob::dispatch($periods); return response()->json(['message' => 'FtTxnTypeCondition processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function processStmtEntryData($periods){ try { ProcessStmtEntryDataJob::dispatch($periods); return response()->json(['message' => 'Stmt Entry processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessCompanyData($periods){ try { ProcessCompanyDataJob::dispatch($periods); return response()->json(['message' => 'Company processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessDataCaptureData($periods){ try { ProcessDataCaptureDataJob::dispatch($periods); return response()->json(['message' => 'Data Capture processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessCategoryData($periods){ try { ProcessCategoryDataJob::dispatch($periods); return response()->json(['message' => 'Category processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessTellerData($periods){ try { ProcessTellerDataJob::dispatch($periods); return response()->json(['message' => 'Teller processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function ProcessAtmTransaction($periods){ try { ProcessAtmTransactionJob::dispatch($periods); return response()->json(['message' => 'AtmTransaction processing job has been successfully']); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); } } public function index() { $disk = Storage::disk('sftpStatement'); // Get all directories (periods) in the SFTP disk $allDirectories = $disk->directories(); //$this->processTransactionData(['_parameter']); //$this->processStmtNarrParamData(['_parameter']); //$this->processStmtNarrFormatData(['_parameter']); //$this->ProcessFtTxnTypeConditioData(['_parameter']); // Filter out the _parameter folder $periods = array_filter($allDirectories, function($dir) { return $dir !== '_parameter'; }); // Sort periods by date (descending) usort($periods, function($a, $b) { return strcmp($b, $a); // Reverse comparison for descending order }); if (empty($periods)) { return response()->json(['message' => 'No valid period folders found in SFTP storage'], 404); } $this->ProcessCategoryData($periods); //$this->processCustomerData($periods); //$this->processAccountData($periods); //$this->processStmtEntryData($periods); //$this->ProcessDataCaptureData($periods); //$this->processFundsTransferData($periods); $this->ProcessTellerData($periods); $this->ProcessAtmTransaction($periods); //$this->processArrangementData($periods); //$this->processBillDetailData($periods); return response()->json(['message' => 'Data processing job has been successfully']); } }