|
|
@@ -0,0 +1,41 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Jobs;
|
|
|
+
|
|
|
+use App\Services\BatchService;
|
|
|
+use App\Traits\TestableInstant;
|
|
|
+use Illuminate\Bus\Queueable;
|
|
|
+use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
+use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
+use Illuminate\Queue\InteractsWithQueue;
|
|
|
+use Illuminate\Queue\SerializesModels;
|
|
|
+
|
|
|
+class BatchTaskJob implements ShouldQueue
|
|
|
+{
|
|
|
+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
+ use TestableInstant;
|
|
|
+
|
|
|
+ /** @var $batchService BatchService */
|
|
|
+ protected $batchService;
|
|
|
+ protected $batches;
|
|
|
+ /**
|
|
|
+ * Create a new job instance.
|
|
|
+ *
|
|
|
+ * @param $batches
|
|
|
+ */
|
|
|
+ public function __construct($batches)
|
|
|
+ {
|
|
|
+ $this->batches=$batches;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the job.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ $this->instant($this->batchService, 'BatchService');
|
|
|
+ $this->batchService->assignTasks($this->batches); //在这里为波次注册任务执行!
|
|
|
+ }
|
|
|
+}
|