|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
-use App\Service\ClearDataService;
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
@@ -37,16 +36,10 @@ class SendDataJob implements ShouldQueue
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- file_put_contents('record2.txt',json_encode($this->data) .PHP_EOL,8);
|
|
|
-
|
|
|
- //数据要发送的地址
|
|
|
- $url = ClearDataService::getUrl($this->data);
|
|
|
- if(! empty($url)){
|
|
|
- $return = $this->sendRequest($url,$this->data);
|
|
|
+ if(isset($data['is_clear_data'])){
|
|
|
+ $this->sendToDevice($this->data);
|
|
|
}
|
|
|
|
|
|
-// file_put_contents('send.txt',json_encode($return) .PHP_EOL,8);
|
|
|
-
|
|
|
//输出信息 测试
|
|
|
$this->echoMessage(new ConsoleOutput());
|
|
|
}
|
|
@@ -70,6 +63,41 @@ class SendDataJob implements ShouldQueue
|
|
|
return $response;
|
|
|
}
|
|
|
|
|
|
+ public function sendToDevice($data){
|
|
|
+ $url = "http://121.36.142.167:7774/api/module-data/device_machine_record/device_machine_record";
|
|
|
+ $post = [
|
|
|
+ 'bizId' => -1,
|
|
|
+ 'bizTypeEk' => 'LOWCODE',
|
|
|
+ 'data' => [
|
|
|
+ 'device_machine_record' => [
|
|
|
+ 'machine_code' => $data['dev_eui'],
|
|
|
+ 'param_value' => $data['value']
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ 'dynamicFormId' => '477743923368955904',
|
|
|
+ 'showModelId' => '477745421456904192'
|
|
|
+ ];
|
|
|
+ $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json'];
|
|
|
+
|
|
|
+ $curl = curl_init();
|
|
|
+ curl_setopt_array($curl, array(
|
|
|
+ CURLOPT_URL => $url,
|
|
|
+ CURLOPT_RETURNTRANSFER => true,
|
|
|
+ CURLOPT_ENCODING => '',
|
|
|
+ CURLOPT_MAXREDIRS => 10,
|
|
|
+ CURLOPT_TIMEOUT => 0,
|
|
|
+ CURLOPT_FOLLOWLOCATION => true,
|
|
|
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
+ CURLOPT_CUSTOMREQUEST => 'POST',
|
|
|
+ CURLOPT_POSTFIELDS => json_encode($post),
|
|
|
+ CURLOPT_HTTPHEADER => $header,
|
|
|
+ ));
|
|
|
+ $response = curl_exec($curl);
|
|
|
+ curl_close($curl);
|
|
|
+
|
|
|
+ file_put_contents('record2.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL,8);
|
|
|
+ }
|
|
|
+
|
|
|
protected function echoMessage(OutputInterface $output)
|
|
|
{
|
|
|
$output->writeln('发送结束');
|