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()
: 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 {
if (!file_exists($filePath)) {
throw new Exception("File not found: $filePath");
@@ -37,23 +37,20 @@
set_time_limit(24 * 60 * 60);
if (!file_exists($filePath)) {
throw new Exception("File not found: {$filePath}");
}
$handle = fopen($filePath, "r");
if ($handle !== false) {
$headers = (new TempArrangement())->getFillable();
while (($row = fgetcsv($handle, 0, ";")) !== false) {
unset($row[0]); // Remove the first empty column if present
while (($row = fgetcsv($handle, 0, "~")) !== false) {
if (count($headers) === count($row)) {
$data = array_combine($headers, $row);
TempArrangement::updateOrCreate(
['arrangement_id' => $data['arrangement_id']], // key to find existing record
$data // data to update or create
);
if($data['arrangement_id']!== 'arrangement_id') {
TempArrangement::updateOrCreate(
['arrangement_id' => $data['arrangement_id']], // key to find existing record
$data // data to update or create
);
}
}
}
fclose($handle);