info('开始检查图片生成任务状态...'); // 执行50s $time_start = time(); try { // 统计需要处理的任务数量(即梦AI的processing + 火山API的pending和processing) $jimengProcessingCount = DB::table('mp_generate_pic_tasks') ->where('status', 'processing') ->where('model', 'jimeng_4.0') ->count('id'); $volcPendingCount = DB::table('mp_generate_pic_tasks') ->where('status', 'pending') ->whereIn('model', BaseConst::VOLC_PIC_MODELS) ->count('id'); $totalCount = $jimengProcessingCount + $volcPendingCount; dLog('generate')->info("待处理任务统计 - 即梦AI处理中: {$jimengProcessingCount}, 火山API待处理: {$volcPendingCount}"); while ($totalCount > 0) { $time_diff = time() - $time_start; if ($time_diff > 50) { dLog('generate')->info('定时任务执行超过50秒,退出循环'); break; } sleep(3); // 执行任务更新 $aiImageGenerationService->updatePendingTasks(); // 重新统计任务数量 $jimengProcessingCount = DB::table('mp_generate_pic_tasks') ->where('status', 'processing') ->where('model', 'jimeng_4.0') ->count('id'); $volcPendingCount = DB::table('mp_generate_pic_tasks') ->where('status', 'pending') ->whereIn('model', BaseConst::VOLC_PIC_MODELS) ->count('id'); $totalCount = $jimengProcessingCount + $volcPendingCount; } dLog('generate')->info('任务状态检查完成'); } catch (\Exception $e) { dLog('generate')->error('任务状态检查失败: ' . $e->getMessage()); return 1; } return 0; } }