BatchTaskJob.php 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Jobs;
  3. use App\Services\BatchService;
  4. use App\Services\LogService;
  5. use App\Traits\TestableInstant;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Queue\InteractsWithQueue;
  10. use Illuminate\Queue\SerializesModels;
  11. class BatchTaskJob implements ShouldQueue
  12. {
  13. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14. use TestableInstant;
  15. /** @var $batchService BatchService */
  16. protected $batchService;
  17. protected $batches;
  18. /**
  19. * Create a new job instance.
  20. *
  21. * @param $batches
  22. */
  23. public function __construct($batches)
  24. {
  25. $this->batches=$batches;
  26. }
  27. /**
  28. * Execute the job.
  29. *
  30. * @return void
  31. */
  32. public function handle()
  33. {
  34. $this->instant($this->batchService, 'BatchService');
  35. $this->batchService->assignTasks($this->batches); //在这里为波次注册任务执行!
  36. }
  37. }