From e9d8b6c3416372ebb14950f7c24699756ec7836d Mon Sep 17 00:00:00 2001 From: Jing Li Date: Wed, 19 Oct 2022 16:15:59 +0800 Subject: [PATCH] Fix --- .../Commands/LinkosDeviceLogSyncCommand.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/LinkosDeviceLogSyncCommand.php b/app/Console/Commands/LinkosDeviceLogSyncCommand.php index 0d56992..fc03211 100644 --- a/app/Console/Commands/LinkosDeviceLogSyncCommand.php +++ b/app/Console/Commands/LinkosDeviceLogSyncCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Exceptions\BizException; use App\Models\LinkosDeviceLog; use App\Services\LinkosService; use Illuminate\Console\Command; @@ -36,7 +37,7 @@ class LinkosDeviceLogSyncCommand extends Command */ public function handle() { - $time = now(); + $now = now(); $device = $this->argument('device'); @@ -45,16 +46,21 @@ class LinkosDeviceLogSyncCommand extends Command do { if ($lastDate === null) { - $lastDate = Carbon::parse('2022-06-01'); + $lastDate = Carbon::parse('2022-10-18'); } else { $lastDate->addDay(); } $start = $lastDate->copy()->startOfDay(); + + if ($start->gt($now)) { + throw new BizException('开始时间大约当前时间'); + } + $end = $lastDate->copy()->endOfDay(); - if ($end->gt($time)) { - $end = $time; + if ($end->gt($now)) { + $end = $now; } $this->info('----------------------------------'); @@ -67,8 +73,12 @@ class LinkosDeviceLogSyncCommand extends Command $this->info('Done!'); $this->info('----------------------------------'); + if ($now->isSameDay($lastDate)) { + break; + } + $this->setLastDate($device, $lastDate); - } while (! $lastDate->isToday()); + } while (true); return Command::SUCCESS; }