From e7772026eabb1dfc8c1d9ed779856e82147bff41 Mon Sep 17 00:00:00 2001 From: "allen.yan" Date: Fri, 9 May 2025 10:44:04 +0800 Subject: [PATCH] =?UTF-8?q?Song=20=E6=BB=99=E5=85=A5=E8=B3=87=E6=96=99?= =?UTF-8?q?=E5=8F=96=E6=99=82=E9=96=93=E8=B3=87=E6=96=99=E6=AD=A3=E8=A6=8F?= =?UTF-8?q?=E5=8C=96=2020250509?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Jobs/ImportSongChunkJob.php | 17 ++++++++++++++++- config/app.php | 2 +- 開發手冊.ini | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ImportSongChunkJob.php b/app/Jobs/ImportSongChunkJob.php index 5e6b0ca..5f6d258 100644 --- a/app/Jobs/ImportSongChunkJob.php +++ b/app/Jobs/ImportSongChunkJob.php @@ -48,7 +48,7 @@ class ImportSongChunkJob implements ShouldQueue $song = new Song([ 'id' => $songId, 'name' => trim($row['歌名'] ?? ''), - 'adddate' => trim($row['日期'] ?? null), + 'adddate' => $this->parseExcelDate($row['日期'] ?? null), 'filename' => trim($row['檔名'] ?? ''), 'language_type' => SongLanguageType::tryFrom(trim($row['語別'] ?? '')) ?? SongLanguageType::Unset, 'db_change' => trim($row['kk2'] ?? 0),//分貝增減 @@ -99,4 +99,19 @@ class ImportSongChunkJob implements ShouldQueue } } } + + private function parseExcelDate($value): ?string + { + if (is_numeric($value)) { + return \Carbon\Carbon::createFromFormat('Y-m-d', '1900-01-01') + ->addDays((int)$value - 2) + ->format('Y-m-d'); + } + + try { + return \Carbon\Carbon::parse($value)->format('Y-m-d'); + } catch (\Exception $e) { + return null; + } + } } \ No newline at end of file diff --git a/config/app.php b/config/app.php index 324b513..f467267 100644 --- a/config/app.php +++ b/config/app.php @@ -65,7 +65,7 @@ return [ | */ - 'timezone' => 'UTC', + 'timezone' => env('APP_TIMEZONE', 'UTC'), /* |-------------------------------------------------------------------------- diff --git a/開發手冊.ini b/開發手冊.ini index c5e2657..a93bc50 100644 --- a/開發手冊.ini +++ b/開發手冊.ini @@ -94,10 +94,10 @@ php artisan make:observer RoomObserver --model=Room - +--memory=5120 php artisan queue:work --timeout=600 --memory=1024 -php artisan queue:work --daemon --timeout=3600 --memory=5120 --tries=1 --queue=default +php artisan queue:work --daemon --timeout=3600 --tries=1 --queue=default composer install cp .env.example .env