get(self::CURSOR_KEY) ?: intval(microtime(true) * 1000); $nextMicrotime = intval(microtime(true) * 1000); $utcDateTime = new UTCDateTime($microtime); $total = TblCard::where('pNo', 'No00000000768')->where('oRDate', '>', $utcDateTime)->where('sDate', 'exists', true)->count(); $this->line('待同步条数:'.$total); if ($total) { Artisan::call('real:sync-bloc'); } $page = 2; $jobs = new Collection(); while ($total) { if (($page - 1) * $this->limit >= $total) { break; } $jobs->push(new MongoSyncJob($page, $this->limit, $utcDateTime)); $page++; } $total && MongoSyncJob::withChain($jobs->toArray()) ->dispatch(1, $this->limit, $utcDateTime) ->allOnQueue('sync'); app(ConfigService::class)->set(self::CURSOR_KEY, intval($nextMicrotime)); } }