| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | <?phpnamespace App\Jobs;use App\Service\ClearDataService;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Foundation\Bus\Dispatchable;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Symfony\Component\Console\Output\ConsoleOutput;use Symfony\Component\Console\Output\OutputInterface;class ProcessDataJob implements ShouldQueue{    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;    protected $data;    /**     * Create a new job instance.     *     * @return void     */    public function __construct($data)    {        $this->data = $data;    }    /**     * Execute the job.     *     * @return void     */    public function handle()    {        //标记        file_put_contents('record.txt',json_encode($this->data) . PHP_EOL,8);        //处理数据        $return = ClearDataService::clearData($this->data);        //传递数据给下一个队列        dispatch(new SendDataJob($return))->onQueue('cloud_device');        //输出信息        $this->echoMessage(new ConsoleOutput());    }    protected function echoMessage(OutputInterface $output)    {        $output->writeln(json_encode($this->data));    }}
 |