소스 검색

添加SendPieceOwnerJob

loustwo 3 년 전
부모
커밋
a522819bdc
2개의 변경된 파일50개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      app/Http/Controllers/api/thirdPart/haochuang/SortingController.php
  2. 47 0
      app/Jobs/SendPieceOwnerJob.php

+ 3 - 1
app/Http/Controllers/api/thirdPart/haochuang/SortingController.php

@@ -6,6 +6,7 @@ use App\Batch;
 use App\CommodityBarcode;
 use App\Exceptions\Exception;
 use App\Http\Controllers\Controller;
+use App\Jobs\SendPieceOwnerJob;
 use App\OracleDOCWaveDetails;
 use App\Order;
 use App\OrderBin;
@@ -194,7 +195,8 @@ SQL;
                                             $warehouseId, date("Y-m-d H:i:s"), $number);
 
         try{
-            (new WaveService())->sendOwnerPiece($batch_id,UserToken::getUser($token)->id ?? '0',$warehouseId,$ownerId,date("Y-m-d H:i:s"));
+            SendPieceOwnerJob::dispatch($batch_id,UserToken::getUser($token)->id ?? '0',$warehouseId,$ownerId,date("Y-m-d H:i:s"));
+//            (new WaveService())->sendOwnerPiece($batch_id,UserToken::getUser($token)->id ?? '0',$warehouseId,$ownerId,date("Y-m-d H:i:s"));
         }catch (\Exception $e){
             app('LogService')->log("二次分拣货主计件",  "上传失败", $batch_id.$warehouseId.$ownerId.date("Y-m-d H:i:s").$e->getMessage());
         }

+ 47 - 0
app/Jobs/SendPieceOwnerJob.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\WaveService;
+use App\WorkOrder;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class SendPieceOwnerJob implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    private $batchId;
+    private $userId;
+    private $warehouseId;
+    private $ownerId;
+    private $date;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($batch_id,$userId, $warehouseId, $ownerId, $date)
+    {
+        $this->batchId = $batch_id;
+        $this->userId = $userId;
+        $this->warehouseId = $warehouseId;
+        $this->ownerId = $ownerId;
+        $this->date = $date;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        /** @var WaveService $service */
+        $service = app(WaveService::class);
+        $service->sendOwnerPiece($this->batchId,$this->userId,$this->warehouseId,$this->ownerId,$this->date);
+    }
+}