|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
+use App\Service\ClearDataService;
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
@@ -13,7 +14,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
-class SendDataJob extends Command implements ShouldQueue
|
|
|
+class SendDataJob implements ShouldQueue
|
|
|
{
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
@@ -27,8 +28,6 @@ class SendDataJob extends Command implements ShouldQueue
|
|
|
public function __construct($data)
|
|
|
{
|
|
|
$this->data = $data;
|
|
|
-
|
|
|
- parent::__construct(); // 调用父类的构造函数
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -38,13 +37,19 @@ class SendDataJob extends Command implements ShouldQueue
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- $url = '';
|
|
|
+ file_put_contents('record2.txt',json_encode($this->data) .PHP_EOL,8);
|
|
|
+
|
|
|
+ //数据要发送的地址
|
|
|
+ $url = ClearDataService::getUrl($this->data);
|
|
|
$return = $this->sendRequest($url,$this->data);
|
|
|
- file_put_contents('charge.txt',json_encode($this->data),8);
|
|
|
+
|
|
|
+// file_put_contents('send.txt',json_encode($return) .PHP_EOL,8);
|
|
|
+
|
|
|
+ //输出信息 测试
|
|
|
$this->echoMessage(new ConsoleOutput());
|
|
|
}
|
|
|
|
|
|
- private function sendRequest($url,$data){return true;
|
|
|
+ private function sendRequest($url,$data){
|
|
|
$data = json_encode($data);
|
|
|
$header[] = "Content-Type:application/json";
|
|
|
$ch=curl_init($url);
|
|
@@ -55,7 +60,6 @@ class SendDataJob extends Command implements ShouldQueue
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
$response=curl_exec($ch);
|
|
|
- file_put_contents('job_send.txt',$response.PHP_EOL,8);
|
|
|
$response=json_decode($response,true);
|
|
|
|
|
|
if(curl_errno($ch) ){
|
|
@@ -68,12 +72,4 @@ class SendDataJob extends Command implements ShouldQueue
|
|
|
{
|
|
|
$output->writeln('2222222');
|
|
|
}
|
|
|
-
|
|
|
- protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
- {
|
|
|
- $output->write('22222222');
|
|
|
- $output->writeln('2222222');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
}
|