feat(job): perbarui jalur file dan pemisah CSV pada ProcessArrangementDataJob

- Mengganti pemisah CSV dari ';' menjadi '~'.
- Menghapus pemeriksaan keberadaan data yang redundan.
This commit is contained in:
Daeng Deni Mardaeni
2025-04-09 14:03:23 +07:00
parent 0b7931b145
commit ca2619be9e

View File

@@ -29,7 +29,7 @@
public function handle() public function handle()
: void : void
{ {
$filePath = storage_path('app/20240901.ST.AA.ARRANGEMENT.csv'); // Adjust this path as needed $filePath = storage_path('app/20250207.ST.AA.ARRANGEMENT.csv'); // Adjust this path as needed
try { try {
if (!file_exists($filePath)) { if (!file_exists($filePath)) {
throw new Exception("File not found: $filePath"); throw new Exception("File not found: $filePath");
@@ -37,23 +37,20 @@
set_time_limit(24 * 60 * 60); set_time_limit(24 * 60 * 60);
if (!file_exists($filePath)) {
throw new Exception("File not found: {$filePath}");
}
$handle = fopen($filePath, "r"); $handle = fopen($filePath, "r");
if ($handle !== false) { if ($handle !== false) {
$headers = (new TempArrangement())->getFillable(); $headers = (new TempArrangement())->getFillable();
while (($row = fgetcsv($handle, 0, ";")) !== false) { while (($row = fgetcsv($handle, 0, "~")) !== false) {
unset($row[0]); // Remove the first empty column if present
if (count($headers) === count($row)) { if (count($headers) === count($row)) {
$data = array_combine($headers, $row); $data = array_combine($headers, $row);
TempArrangement::updateOrCreate( if($data['arrangement_id']!== 'arrangement_id') {
['arrangement_id' => $data['arrangement_id']], // key to find existing record TempArrangement::updateOrCreate(
$data // data to update or create ['arrangement_id' => $data['arrangement_id']], // key to find existing record
); $data // data to update or create
);
}
} }
} }
fclose($handle); fclose($handle);