TestAiTask.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Models\TaskAssignee;
  5. use App\Models\AiModel;
  6. class TestAiTask extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. * php artisan test:ai.task c77af42f-ffb5-48ae-af71-4c32e1c30dab
  11. * php artisan test:ai.task f42fa690-c590-400f-9de9-fbc81e838a5a
  12. * @var string
  13. */
  14. protected $signature = 'test:ai.task {id} {--test}';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'test ai task';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return int
  34. */
  35. public function handle()
  36. {
  37. $taskId = $this->argument('id');
  38. $taskAssignee = TaskAssignee::where('task_id', $taskId)
  39. ->select('assignee_id')->get();
  40. $aiAssistant = AiModel::whereIn('uid', $taskAssignee)->first();
  41. if ($aiAssistant) {
  42. $count = \App\Jobs\ProcessAITranslateJob::publish($taskId, $aiAssistant->uid);
  43. $this->info('publish total:' . $count);
  44. } else {
  45. $this->error('no ai assistant');
  46. }
  47. return 0;
  48. }
  49. }