Fix
parent
13e6b05ef3
commit
e9d8b6c341
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue