|
@@ -0,0 +1,55 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Jobs;
|
|
|
+
|
|
|
+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 ManDeviceJob 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()
|
|
|
+ {
|
|
|
+ try{
|
|
|
+ if(is_array($this->data) || is_object($this->data)){
|
|
|
+ $data = json_encode($this->data);
|
|
|
+ }else {
|
|
|
+ $data = $this->data;
|
|
|
+ }
|
|
|
+ file_put_contents('send_man.txt',date('Y-m-d H:i:s').PHP_EOL . $data . PHP_EOL,8);
|
|
|
+
|
|
|
+ //输出信息 测试
|
|
|
+ $this->echoMessage(new ConsoleOutput());
|
|
|
+ }catch (\Exception $exception){
|
|
|
+ file_put_contents('send_man_error.txt',date("Y-m-d H:i:s").PHP_EOL.$exception->getMessage().PHP_EOL,8);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function echoMessage(OutputInterface $output)
|
|
|
+ {
|
|
|
+ $output->writeln($this->data);
|
|
|
+ }
|
|
|
+}
|