TestAiTask.php 1.3 KB

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