Fix
parent
13e6b05ef3
commit
e9d8b6c341
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Exceptions\BizException;
|
||||||
use App\Models\LinkosDeviceLog;
|
use App\Models\LinkosDeviceLog;
|
||||||
use App\Services\LinkosService;
|
use App\Services\LinkosService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
@ -36,7 +37,7 @@ class LinkosDeviceLogSyncCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$time = now();
|
$now = now();
|
||||||
|
|
||||||
$device = $this->argument('device');
|
$device = $this->argument('device');
|
||||||
|
|
||||||
|
|
@ -45,16 +46,21 @@ class LinkosDeviceLogSyncCommand extends Command
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ($lastDate === null) {
|
if ($lastDate === null) {
|
||||||
$lastDate = Carbon::parse('2022-06-01');
|
$lastDate = Carbon::parse('2022-10-18');
|
||||||
} else {
|
} else {
|
||||||
$lastDate->addDay();
|
$lastDate->addDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = $lastDate->copy()->startOfDay();
|
$start = $lastDate->copy()->startOfDay();
|
||||||
|
|
||||||
|
if ($start->gt($now)) {
|
||||||
|
throw new BizException('开始时间大约当前时间');
|
||||||
|
}
|
||||||
|
|
||||||
$end = $lastDate->copy()->endOfDay();
|
$end = $lastDate->copy()->endOfDay();
|
||||||
|
|
||||||
if ($end->gt($time)) {
|
if ($end->gt($now)) {
|
||||||
$end = $time;
|
$end = $now;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('----------------------------------');
|
$this->info('----------------------------------');
|
||||||
|
|
@ -67,8 +73,12 @@ class LinkosDeviceLogSyncCommand extends Command
|
||||||
$this->info('Done!');
|
$this->info('Done!');
|
||||||
$this->info('----------------------------------');
|
$this->info('----------------------------------');
|
||||||
|
|
||||||
|
if ($now->isSameDay($lastDate)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$this->setLastDate($device, $lastDate);
|
$this->setLastDate($device, $lastDate);
|
||||||
} while (! $lastDate->isToday());
|
} while (true);
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue