- Menonaktifkan pemanggilan fungsi-fungsi yang tidak diperlukan untuk data processing di `MigrasiController`: - `processTransactionData`, `processStmtNarrFormatData`, `processAccountData`, dan `ProcessCompanyData`. - Mengubah argumen di beberapa pemanggilan fungsi untuk data processing agar lebih spesifik ke periode tertentu: - Mengganti `$periods` menjadi `['20250512']` untuk `processArrangementData`, `processBillDetailData`, `processFundsTransferData`, dan `processStmtEntryData`. - Memodifikasi logika skipping folder `_parameter` pada `ProcessFtTxnTypeConditionJob` dengan mengomentari proses pengecekan. - Mengubah delimiter `fgetcsv` pada `ProcessBillDetailDataJob` dari `;` menjadi `~`. - Menambahkan file migrasi baru untuk mengubah tipe kolom pada tabel `temp_fund_transfer`: - Mengubah semua kolom pada tabel menjadi tipe `text` untuk mendukung data yang lebih besar. - Menyediakan metode `down` untuk rollback tipe data kembali ke `string`. Perubahan ini bertujuan untuk meningkatkan efisiensi proses data, mendukung fleksibilitas data lebih besar pada migrasi database, serta membuka jalan untuk refaktor atau penghapusan fungsi yang tidak digunakan. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
187 lines
6.8 KiB
PHP
187 lines
6.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Log;
|
|
use Modules\Webstatement\Jobs\ProcessAccountDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessArrangementDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessBillDetailDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessCompanyDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessCustomerDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessDataCaptureDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessFtTxnTypeConditionJob;
|
|
use Modules\Webstatement\Jobs\ProcessFundsTransferDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessStmtEntryDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessStmtNarrFormatDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessStmtNarrParamDataJob;
|
|
use Modules\Webstatement\Jobs\ProcessTransactionDataJob;
|
|
|
|
class MigrasiController extends Controller
|
|
{
|
|
|
|
public function processArrangementData($periods)
|
|
{
|
|
try {
|
|
ProcessArrangementDataJob::dispatch($periods);
|
|
return response()->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' => 'Data 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' => 'Data TempStmtEntry 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' => 'Data TempStmtEntry 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 TempStmtEntry 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->processCustomerData(['20250519']);
|
|
//$this->processAccountData(['20250519']);
|
|
$this->processArrangementData(['20250512']);
|
|
$this->processBillDetailData(['20250512']);
|
|
$this->processFundsTransferData(['20250512']);
|
|
$this->processStmtEntryData(['20250512']);
|
|
|
|
//$this->ProcessCompanyData($periods);
|
|
$this->ProcessDataCaptureData($periods);
|
|
|
|
return response()->json(['message' => 'Data processing job has been successfully']);
|
|
}
|
|
}
|