Compare commits

..

5 Commits

Author SHA1 Message Date
Daeng Deni Mardaeni
e531193c06 Merge remote-tracking branch 'composer/master' 2025-05-24 19:44:32 +07:00
Daeng Deni Mardaeni
38987ce8e3 refactor(webstatement): remove _parameter folder skipping logic from processing jobs
- Menghapus logika pengecekan dan pengabaian folder `_parameter` di seluruh job pemrosesan data berikut:
  - `ProcessAccountDataJob`
  - `ProcessAtmTransactionJob`
  - `ProcessBillDetailDataJob`
  - `ProcessCategoryDataJob`
  - `ProcessCompanyDataJob`
  - `ProcessCustomerDataJob`
  - `ProcessDataCaptureDataJob`
  - `ProcessFundsTransferDataJob`
  - `ProcessStmtEntryDataJob`
  - `ProcessTellerDataJob`
- Menghapus konstanta `PARAMETER_FOLDER` yang terkait dengan folder `_parameter` pada beberapa job.
- Membersihkan code redundancy yang tidak relevan untuk meningkatkan keterbacaan dan efisiensi.
- Logika ini dianggap tidak diperlukan lagi dalam proses pemrosesan data.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-24 19:43:54 +07:00
Daeng Deni Mardaeni
cd447eb019 refactor(jobs): simplify jobs and controllers by replacing period array with single period parameter
- Mengganti parameter `$periods` (array) menjadi `$period` (string) pada semua Job terkait: `ProcessCustomerDataJob`, `ProcessFundsTransferDataJob, etc`.
- Menyederhanakan operasi loop dalam proses data dengan hanya memproses satu periode per eksekusi Job.
- Memodifikasi fungsi controller di `MigrasiController` agar sesuai dengan perubahan parameter dari array ke string.
- Menambahkan pengamanan jika `$period` kosong atau bernilai '_parameter' untuk mencegah proses yang tidak diperlukan.
- Mengurangi duplikasi kode dengan mengeliminasi metode yang mengelola array periode dan menggantinya dengan pendekatan tunggal.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-24 19:40:40 +07:00
Daeng Deni Mardaeni
85b8bfa07b fix(webstatement): perbaikan parameter dan refactor pada ProcessCompanyDataJob
- Mengubah parameter pada pemanggilan `$this->ProcessCompanyData()` dari array menjadi string untuk konsistensi data.
- Mengubah properti `protected` pada `ProcessCompanyDataJob` dari `$periods` menjadi `$period` untuk menggunakan string daripada array.
- Menyesuaikan constructor `__construct` untuk menerima parameter string `$period` alih-alih array `$periods`.
- Memperbaiki mekanisme validasi pada `handle()`, mengganti pengecekan array kosong `$this->periods` menjadi validasi string `$this->period` dengan nilai kosong.
- Menghapus iterasi `foreach` untuk mengakomodasi perubahan dari array ke string sederhana.
- Memastikan mapping data CSV tetap konsisten dan menambahkan identasi untuk peningkatan keterbacaan.
- Memperbaiki nama variabel dan properti agar lebih eksplisit (`$periods` menjadi `$period`, `$fileName` menjadi `$fileName`, dsb.).
- Menambahkan logging yang lebih jelas mengenai proses data dan kondisi error pada job `ProcessCompanyDataJob`.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-24 19:22:30 +07:00
Daeng Deni Mardaeni
bf7206f927 refactor(webstatement): ubah parameter periode dari array menjadi string
- Mengubah parameter pada metode `ProcessCategoryData` di `MigrasiController` dari array menjadi string untuk keseragaman dengan metode lainnya.
- Memperbarui konstruksi parameter pada instansi `ProcessCategoryDataJob` untuk menerima tipe data string sebagai pengganti array.
- Menghilangkan iterasi array `periods` pada `ProcessCategoryDataJob` dan menerapkan logika langsung pada single `period`.
- Menyesuaikan validasi periode untuk mengabaikan folder `_parameter` dalam proses.
- Memperlihatkan log lebih spesifik jika file tidak ditemukan, atau format kolom tidak sesuai ekspektasi.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-24 19:19:33 +07:00
11 changed files with 858 additions and 952 deletions

View File

@@ -25,54 +25,10 @@ use Modules\Webstatement\Jobs\ProcessTransactionDataJob;
class MigrasiController extends Controller
{
public function processArrangementData($periods)
public function processTransactionData($period)
{
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);
ProcessTransactionDataJob::dispatch($period);
Log::info('Data Transaction processing job has been successfully');
return response()->json(['message' => 'Data Transaction processing job has been successfully']);
} catch (Exception $e) {
@@ -80,99 +36,36 @@ class MigrasiController extends Controller
}
}
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)
public function processStmtNarrParamData($period)
{
try {
ProcessStmtNarrParamDataJob::dispatch($periods);
ProcessStmtNarrParamDataJob::dispatch($period);
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){
public function processStmtNarrFormatData($period)
{
try {
ProcessStmtNarrFormatDataJob::dispatch($periods);
ProcessStmtNarrFormatDataJob::dispatch($period);
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){
public function ProcessFtTxnTypeConditioData($period)
{
try {
ProcessFtTxnTypeConditionJob::dispatch($periods);
ProcessFtTxnTypeConditionJob::dispatch($period);
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_manual()
{
//$disk = Storage::disk('sftpStatement');
@@ -180,10 +73,10 @@ class MigrasiController extends Controller
// Get all directories (periods) in the SFTP disk
//$allDirectories = $disk->directories();
//$this->processTransactionData(['_parameter']);
//$this->processStmtNarrParamData(['_parameter']);
//$this->processStmtNarrFormatData(['_parameter']);
//$this->ProcessFtTxnTypeConditioData(['_parameter']);
//$this->processTransactionData('_parameter');
//$this->processStmtNarrParamData('_parameter');
//$this->processStmtNarrFormatData('_parameter');
//$this->ProcessFtTxnTypeConditioData('_parameter');
// Filter out the _parameter folder
/*$periods = array_filter($allDirectories, function($dir) {
@@ -215,25 +108,141 @@ class MigrasiController extends Controller
}
foreach ($periods as $period) {
$this->ProcessCategoryData([$period]);
$this->ProcessCompanyData([$period]);
$this->ProcessCategoryData($period);
$this->ProcessCompanyData($period);
$this->processCustomerData([$period]);
$this->processAccountData([$period]);
$this->processCustomerData($period);
$this->processAccountData($period);
$this->processStmtEntryData([$period]);
$this->ProcessDataCaptureData([$period]);
$this->processFundsTransferData([$period]);
$this->ProcessTellerData([$period]);
$this->ProcessAtmTransaction([$period]);
$this->processStmtEntryData($period);
$this->ProcessDataCaptureData($period);
$this->processFundsTransferData($period);
$this->ProcessTellerData($period);
$this->ProcessAtmTransaction($period);
$this->processArrangementData([$period]);
$this->processBillDetailData([$period]);
$this->processArrangementData($period);
$this->processBillDetailData($period);
}
return response()->json(['message' => 'Data processing job has been successfully']);
}
public function ProcessCategoryData($period)
{
try {
ProcessCategoryDataJob::dispatch($period);
return response()->json(['message' => 'Category processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function ProcessCompanyData($period)
{
try {
ProcessCompanyDataJob::dispatch($period);
return response()->json(['message' => 'Company processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processCustomerData($period)
{
try {
// Pass the period to the job for processing
ProcessCustomerDataJob::dispatch($period);
return response()->json([
'message' => 'Data Customer processing job has been successfully queued',
'period' => $period
]);
} catch (Exception $e) {
Log::error('Error in processCustomerData: ' . $e->getMessage());
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processAccountData($period)
{
try {
ProcessAccountDataJob::dispatch($period);
return response()->json(['message' => 'Data Account processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processStmtEntryData($period)
{
try {
ProcessStmtEntryDataJob::dispatch($period);
return response()->json(['message' => 'Stmt Entry processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function ProcessDataCaptureData($period)
{
try {
ProcessDataCaptureDataJob::dispatch($period);
return response()->json(['message' => 'Data Capture processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processFundsTransferData($period)
{
try {
ProcessFundsTransferDataJob::dispatch($period);
return response()->json(['message' => 'Data Funds Transfer processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function ProcessTellerData($period)
{
try {
ProcessTellerDataJob::dispatch($period);
return response()->json(['message' => 'Teller processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function ProcessAtmTransaction($period)
{
try {
ProcessAtmTransactionJob::dispatch($period);
return response()->json(['message' => 'AtmTransaction processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processArrangementData($period)
{
try {
ProcessArrangementDataJob::dispatch($period);
return response()->json(['message' => 'Data Arrangement processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
public function processBillDetailData($period)
{
try {
ProcessBillDetailDataJob::dispatch($period);
return response()->json(['message' => 'Data Bill Details processing job has been successfully']);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
/**
* Process data migration for the previous day's period.
*
@@ -244,7 +253,8 @@ class MigrasiController extends Controller
* @return \Illuminate\Http\JsonResponse A JSON response indicating success or failure
* @throws \Exception If the period folder doesn't exist or if any processing job fails
*/
public function index(){
public function index()
{
$disk = Storage::disk('sftpStatement');
$period = date('Ymd', strtotime('-1 day'));
@@ -252,20 +262,20 @@ class MigrasiController extends Controller
return response()->json(["message" => "Period {$period} folder not found in SFTP storage"], 404);
}
$this->ProcessCategoryData([$period]);
$this->ProcessCompanyData([$period]);
$this->ProcessCategoryData($period);
$this->ProcessCompanyData($period);
$this->processCustomerData([$period]);
$this->processAccountData([$period]);
$this->processCustomerData($period);
$this->processAccountData($period);
$this->processStmtEntryData([$period]);
$this->ProcessDataCaptureData([$period]);
$this->processFundsTransferData([$period]);
$this->ProcessTellerData([$period]);
$this->ProcessAtmTransaction([$period]);
$this->processStmtEntryData($period);
$this->ProcessDataCaptureData($period);
$this->processFundsTransferData($period);
$this->ProcessTellerData($period);
$this->ProcessAtmTransaction($period);
$this->processArrangementData([$period]);
$this->processBillDetailData([$period]);
$this->processArrangementData($period);
$this->processBillDetailData($period);
return response()->json(['message' => "Data processing {$period} job has been successfully"]);
}

View File

@@ -17,20 +17,21 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
* Execute the job.
*/
public function handle(): void
public function handle()
: void
{
try {
set_time_limit(24 * 60 * 60);
@@ -38,27 +39,20 @@
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for account data processing');
if (empty($this->period)) {
Log::warning('No period provided for account data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.ACCOUNT.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.ACCOUNT.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing account file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -98,7 +92,7 @@
if (isset($data['open_actual_bal']) || isset($data['open_cleared_bal'])) {
$accountBalance = AccountBalance::firstOrNew([
'account_number' => $data['account_number'],
'period' => $period
'period' => $this->period
]);
// Set the balances
@@ -106,7 +100,7 @@
$accountBalance->cleared_balance = $data['open_cleared_bal'] ?? 0;
$accountBalance->save();
Log::info("Saved balance for account {$data['account_number']} for period $period");
Log::info("Saved balance for account {$data['account_number']} for period {$this->period}");
}
$processedCount++;
@@ -128,7 +122,6 @@
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Account data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -16,8 +16,6 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private const PARAMETER_FOLDER = '_parameter';
// Konstanta untuk nilai-nilai statis
private const FILE_EXTENSION = '.ST.ATM.TRANSACTION.csv';
private const CSV_DELIMITER = '~';
@@ -43,30 +41,31 @@
];
// Pemetaan bidang header ke kolom model
protected array $periods;
protected string $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
* Execute the job.
*/
public function handle(): void
public function handle()
: void
{
try {
set_time_limit(24 * 60 * 60);
if (empty($this->periods)) {
Log::warning('No periods provided for ATM transaction data processing');
if (empty($this->period)) {
Log::warning('No period provided for ATM transaction data processing');
return;
}
$stats = $this->processPeriods();
$stats = $this->processPeriodFile();
Log::info("ProcessAtmTransactionJob completed. Total processed: {$stats['processed']}, Total errors: {$stats['errors']}");
} catch (Exception $e) {
@@ -75,40 +74,15 @@
}
}
/**
* Process all periods and return statistics
*/
private function processPeriods(): array
{
$disk = Storage::disk(self::DISK_NAME);
$processedCount = 0;
$errorCount = 0;
foreach ($this->periods as $period) {
// Skip the parameter folder
if ($period === self::PARAMETER_FOLDER) {
Log::info("Skipping " . self::PARAMETER_FOLDER . " folder");
continue;
}
$result = $this->processPeriodFile($disk, $period);
$processedCount += $result['processed'];
$errorCount += $result['errors'];
}
return [
'processed' => $processedCount,
'errors' => $errorCount
];
}
/**
* Process a single period file
*/
private function processPeriodFile($disk, string $period): array
private function processPeriodFile()
: array
{
$filename = $period . self::FILE_EXTENSION;
$filePath = "$period/$filename";
$disk = Storage::disk(self::DISK_NAME);
$filename = $this->period . self::FILE_EXTENSION;
$filePath = "{$this->period}/$filename";
$processedCount = 0;
$errorCount = 0;
@@ -141,7 +115,8 @@
/**
* Create a temporary file for processing
*/
private function createTempFile($disk, string $filePath, string $filename): string
private function createTempFile($disk, string $filePath, string $filename)
: string
{
$tempFilePath = storage_path("app/temp_$filename");
file_put_contents($tempFilePath, $disk->get($filePath));
@@ -151,7 +126,8 @@
/**
* Process a CSV file and import data
*/
private function processCSVFile(string $tempFilePath, string $originalFilePath): array
private function processCSVFile(string $tempFilePath, string $originalFilePath)
: array
{
$processedCount = 0;
$errorCount = 0;
@@ -194,7 +170,8 @@
/**
* Process a single row from the CSV file
*/
private function processRow(array $headerRow, array $row, int $rowCount, string $filePath): array
private function processRow(array $headerRow, array $row, int $rowCount, string $filePath)
: array
{
// Combine the header row with the data row
$rawData = array_combine($headerRow, $row);

View File

@@ -2,28 +2,28 @@
namespace Modules\Webstatement\Jobs;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Modules\Webstatement\Models\TempBillDetail;
use Exception;
class ProcessBillDetailDataJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected string $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
@@ -37,27 +37,21 @@ class ProcessBillDetailDataJob implements ShouldQueue
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for bill detail data processing');
if (empty($this->period)) {
Log::warning('No period provided for bill detail data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.AA.BILL.DETAILS.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.AA.BILL.DETAILS.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing bill detail file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -78,7 +72,7 @@ class ProcessBillDetailDataJob implements ShouldQueue
try {
if (isset($data['_id']) && $data['_id'] !== '_id') {
TempBillDetail::updateOrCreate(
['_id' => $data['_id']], // Fixed the syntax error here
['_id' => $data['_id']],
$data
);
$processedCount++;
@@ -100,7 +94,6 @@ class ProcessBillDetailDataJob implements ShouldQueue
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Bill Detail data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -16,14 +16,14 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
@@ -38,27 +38,20 @@
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for category data processing');
if (empty($this->period)) {
Log::warning('No period provided for category data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.CATEGORY.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.CATEGORY.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing category file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -126,7 +119,6 @@
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Category data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -4,10 +4,10 @@ namespace Modules\Webstatement\Jobs;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Modules\Basicdata\Models\Branch;
@@ -16,22 +16,23 @@ class ProcessCompanyDataJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
protected $filename;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [], string $filename = "ST.COMPANY.csv")
public function __construct(string $period = '', string $filename = "ST.COMPANY.csv")
{
$this->periods = $periods;
$this->period = $period;
$this->filename = $filename;
}
/**
* Execute the job.
*/
public function handle(): void
public function handle()
: void
{
try {
set_time_limit(24 * 60 * 60);
@@ -39,27 +40,20 @@ class ProcessCompanyDataJob implements ShouldQueue
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for company data processing');
if (empty($this->period)) {
Log::warning('No period provided for company data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filepath based on the period folder name
$fileName = "$period.$this->filename";
$filePath = "$period/$fileName";
$fileName = "{$this->period}.{$this->filename}";
$filePath = "{$this->period}/$fileName";
Log::info("Processing company file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -71,9 +65,19 @@ class ProcessCompanyDataJob implements ShouldQueue
if ($handle !== false) {
// CSV headers from the file
$csvHeaders = [
'id', 'date_time', 'company_code', 'company_name', 'name_address',
'mnemonic', 'customer_company', 'customer_mnemonic', 'company_group',
'curr_no', 'co_code', 'l_vendor_atm', 'l_vendor_cpc'
'id',
'date_time',
'company_code',
'company_name',
'name_address',
'mnemonic',
'customer_company',
'customer_mnemonic',
'company_group',
'curr_no',
'co_code',
'l_vendor_atm',
'l_vendor_cpc'
];
// Field mapping from CSV to Branch model
@@ -142,7 +146,6 @@ class ProcessCompanyDataJob implements ShouldQueue
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Company data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -8,19 +8,19 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Modules\Webstatement\Models\Customer;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Modules\Webstatement\Models\Customer;
class ProcessCustomerDataJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
public function handle()
@@ -31,28 +31,20 @@ class ProcessCustomerDataJob implements ShouldQueue
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for customer data processing');
if (empty($this->period)) {
Log::warning('No period provided for customer data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.CUSTOMER.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.CUSTOMER.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing customer file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -95,8 +87,6 @@ class ProcessCustomerDataJob implements ShouldQueue
Log::error("Unable to open file: $filePath");
}
}
Log::info("Customer data processing completed. Total processed: $processedCount, Total errors: $errorCount");
} catch (Exception $e) {

View File

@@ -16,15 +16,15 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
protected $filename;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [], string $filename = "ST.DATA.CAPTURE.csv")
public function __construct(string $period = '', string $filename = "ST.DATA.CAPTURE.csv")
{
$this->periods = $periods;
$this->period = $period;
$this->filename = $filename;
}
@@ -40,27 +40,20 @@
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for data capture processing');
if (empty($this->period)) {
Log::warning('No period provided for data capture processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filepath based on the period folder name
$fileName = "$period.$this->filename";
$filePath = "$period/$fileName";
$fileName = "{$this->period}.{$this->filename}";
$filePath = "{$this->period}/$fileName";
Log::info("Processing data capture file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -173,7 +166,6 @@
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Data capture processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -16,20 +16,21 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
* Execute the job.
*/
public function handle(): void
public function handle()
: void
{
try {
set_time_limit(24 * 60 * 60);
@@ -37,27 +38,20 @@
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for funds transfer data processing');
if (empty($this->period)) {
Log::warning('No period provided for funds transfer data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.FUNDS.TRANSFER.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.FUNDS.TRANSFER.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing funds transfer file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -105,7 +99,6 @@
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Funds Transfer data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -11,26 +11,26 @@
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Modules\Webstatement\Models\StmtEntry;
use Modules\Webstatement\Models\TempStmtEntry;
class ProcessStmtEntryDataJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
* Execute the job.
*/
public function handle(): void
public function handle()
: void
{
try {
set_time_limit(24 * 60 * 60);
@@ -38,27 +38,20 @@
$processedCount = 0;
$errorCount = 0;
if (empty($this->periods)) {
Log::warning('No periods provided for statement entry data processing');
if (empty($this->period)) {
Log::warning('No period provided for statement entry data processing');
return;
}
foreach ($this->periods as $period) {
// Skip the _parameter folder
if ($period === '_parameter') {
Log::info("Skipping _parameter folder");
continue;
}
// Construct the filename based on the period folder name
$filename = "$period.ST.STMT.ENTRY.csv";
$filePath = "$period/$filename";
$filename = "{$this->period}.ST.STMT.ENTRY.csv";
$filePath = "{$this->period}/$filename";
Log::info("Processing statement entry file: $filePath");
if (!$disk->exists($filePath)) {
Log::warning("File not found: $filePath");
continue;
return;
}
// Create a temporary local copy of the file
@@ -106,7 +99,6 @@
} else {
Log::error("Unable to open file: $filePath");
}
}
Log::info("Statement Entry data processing completed. Total processed: $processedCount, Total errors: $errorCount");

View File

@@ -16,8 +16,6 @@
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private const PARAMETER_FOLDER = '_parameter';
// Konstanta untuk nilai-nilai statis
private const FILE_EXTENSION = '.ST.TELLER.csv';
private const CSV_DELIMITER = '~';
@@ -129,14 +127,14 @@
];
// Pemetaan bidang header ke kolom model
protected array $periods;
protected string $period;
/**
* Create a new job instance.
*/
public function __construct(array $periods = [])
public function __construct(string $period = '')
{
$this->periods = $periods;
$this->period = $period;
}
/**
@@ -148,12 +146,12 @@
try {
set_time_limit(24 * 60 * 60);
if (empty($this->periods)) {
Log::warning('No periods provided for teller data processing');
if (empty($this->period)) {
Log::warning('No period provided for teller data processing');
return;
}
$stats = $this->processPeriods();
$stats = $this->processPeriodFile();
Log::info("ProcessTellerDataJob completed. Total processed: {$stats['processed']}, Total errors: {$stats['errors']}");
} catch (Exception $e) {
@@ -163,41 +161,14 @@
}
/**
* Process all periods and return statistics
* Process a single period file
*/
private function processPeriods()
private function processPeriodFile()
: array
{
$disk = Storage::disk(self::DISK_NAME);
$processedCount = 0;
$errorCount = 0;
foreach ($this->periods as $period) {
// Skip the parameter folder
if ($period === self::PARAMETER_FOLDER) {
Log::info("Skipping " . self::PARAMETER_FOLDER . " folder");
continue;
}
$result = $this->processPeriodFile($disk, $period);
$processedCount += $result['processed'];
$errorCount += $result['errors'];
}
return [
'processed' => $processedCount,
'errors' => $errorCount
];
}
/**
* Process a single period file
*/
private function processPeriodFile($disk, string $period)
: array
{
$filename = $period . self::FILE_EXTENSION;
$filePath = "$period/$filename";
$filename = $this->period . self::FILE_EXTENSION;
$filePath = "{$this->period}/$filename";
$processedCount = 0;
$errorCount = 0;