| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Console\Commands;
- use App\Services\Anime\AnimeService;
- use Illuminate\Console\Command;
- class CheckProductPicTasksCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'Anime:checkProductPicTasks';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '检查产品图片生成任务状态并更新产品记录';
- protected $animeService;
- public function __construct(AnimeService $animeService)
- {
- parent::__construct();
- $this->animeService = $animeService;
- }
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- dLog('command')->info('====================开始检查产品图片生成任务状态====================');
- $time_start = microtime(true);
- $stats = $this->animeService->checkProductPicTasks();
- // 兼容:检查任务中心中 saveScriptProducts 类型的任务是否完成,完成则更新状态和结果
- $taskCenterUpdated = $this->animeService->checkSaveScriptProductTaskCenters();
- $time_end = microtime(true);
- $this->info('检查完成: ' . json_encode($stats, JSON_UNESCAPED_UNICODE));
- if ($taskCenterUpdated > 0) {
- $this->info('任务中心saveScriptProducts任务更新: ' . $taskCenterUpdated . ' 条');
- }
- dLog('command')->info('产品图片生成任务检查完成', [
- 'stats' => $stats,
- 'task_center_updated' => $taskCenterUpdated,
- 'cost_time' => round($time_end - $time_start, 2)
- ]);
- dLog('command')->info('====================结束检查产品图片生成任务状态====================');
- return 0;
- }
- }
|