BatchTaskJob.php 969 B

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