configurationError()) { $this->error($error); return self::FAILURE; } $limit = $this->option('limit') === null ? null : max(1, min(100, (int) $this->option('limit'))); $count = 0; do { try { $batch = $service->startDue(); if ($batch) $this->info('自动创建批次 #'.$batch->id.',企业数 '.$batch->total); $count = $service->runGroup($limit); if ($count) $this->line(now()->toDateTimeString()." 本组已处理 {$count} 个企业任务"); } catch (\Throwable $e) { if (!$this->option('watch')) throw $e; report($e); $this->error('采集暂时中断,将重试检查任务:'.$e->getMessage()); } if (!$this->option('watch')) break; $count = 0; sleep(5); } while (true); $this->info("本次已处理 {$count} 个企业任务"); return self::SUCCESS; } }