cqpCow 2 anos atrás
pai
commit
4488f50299
2 arquivos alterados com 17 adições e 10 exclusões
  1. 16 9
      app/Jobs/DesktopDeviceJob.php
  2. 1 1
      config/app.php

+ 16 - 9
app/Jobs/DesktopDeviceJob.php

@@ -7,6 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\Redis;
 use Symfony\Component\Console\Output\ConsoleOutput;
 use Symfony\Component\Console\Output\OutputInterface;
 
@@ -33,20 +34,27 @@ class DesktopDeviceJob implements ShouldQueue
      */
     public function handle()
     {
-        file_put_contents('record_complete.txt',json_encode($this->data) . PHP_EOL,8);
-
         try{
             $first = ltrim($this->data[0],'0');//取第一个值
             $order_num = hex2bin($first); //十六进制字符串转回 原来字符串
+            file_put_contents('record_complete.txt',date("Y-m-d H:i:s",time())."原数据:$first" . "解析后:" . $order_num . PHP_EOL,8);
             if(! $order_num) return;
-            $dispatchList = $this->getDispatchList($order_num);
-            if(empty($dispatchList) || empty($dispatchList['content'])) return;
-            $this->completionOrders($dispatchList);
+
+            // 使用Redis Facade设置键名为order_number的值,当键名不存在时才设置成功
+            if (Redis::setnx($order_num, $order_num)) {
+                Redis::expire($order_num, 60);
+
+                $dispatchList = $this->getDispatchList($order_num);
+                if(empty($dispatchList) || empty($dispatchList['content'])) return;
+                $this->completionOrders($dispatchList);
+
+                file_put_contents('send_record.txt',date('Y-m-d H:i:s').$order_num . PHP_EOL,8);
+            }
 
             //输出信息 测试
             $this->echoMessage(new ConsoleOutput());
         }catch (\Exception $exception){
-            file_put_contents('record_complete.txt',json_encode($this->data) . PHP_EOL.$exception->getMessage().PHP_EOL,8);
+            file_put_contents('record_error.txt',date("Y-m-d H:i:s",time()).json_encode($this->data) . PHP_EOL.$exception->getMessage().PHP_EOL,8);
         }
     }
 
@@ -70,7 +78,7 @@ class DesktopDeviceJob implements ShouldQueue
             "developmentSystemId" => null,
             "debugFlag" => true,
         ];
-        $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json'];
+        $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json','Site:010800179'];
 
         $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
 
@@ -176,9 +184,8 @@ class DesktopDeviceJob implements ShouldQueue
             "showModelId" => "474382714828959744"
         ];
         //组织数据------
-
         $url = 'http://121.36.142.167:7774/jbl/api/module-data/completion_orders/completion_orders';
-        $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json'];
+        $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json','Site:010800179'];
 
         $curl = curl_init();
         curl_setopt_array($curl, array(

+ 1 - 1
config/app.php

@@ -67,7 +67,7 @@ return [
     |
     */
 
-    'timezone' => 'UTC',
+    'timezone' => 'PRC',
 
     /*
     |--------------------------------------------------------------------------