瀏覽代碼

出标测试

cqpCow 1 年之前
父節點
當前提交
ed8c173074
共有 3 個文件被更改,包括 74 次插入0 次删除
  1. 8 0
      app/Http/Controllers/Api/JobController.php
  2. 65 0
      app/Jobs/LabelDealCsJob.php
  3. 1 0
      routes/api.php

+ 8 - 0
app/Http/Controllers/Api/JobController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
 
 
 use App\Jobs\DesktopDeviceJob;
+use App\Jobs\LabelDealCsJob;
 use App\Jobs\LabelDealJob;
 use App\Jobs\ManDeviceJob;
 use App\Jobs\ProcessDataJob;
@@ -53,4 +54,11 @@ class JobController extends BaseController
 
         return ['status'=>200,'msg'=>'success'];
     }
+
+    public function labelDealCs(Request $request){
+        $header = $request->header('Authorization');
+        dispatch(new LabelDealCsJob($request->all(), $header))->onQueue('label_deal_cs');
+
+        return ['status'=>200,'msg'=>'success'];
+    }
 }

+ 65 - 0
app/Jobs/LabelDealCsJob.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Service\DwyService;
+use App\Service\LabelDealService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Support\Facades\Log;
+use Symfony\Component\Console\Output\ConsoleOutput;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class LabelDealCsJob implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $data;
+    protected $header;
+    protected $id;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($data,$header)
+    {
+        $this->data = $data;
+        $this->header = $header;
+    }
+
+    public function handle()
+    {
+        try {
+            $data = $this->data;
+            $dv = $data['key'];
+            $return = $box_list = [];
+            Log::channel('apiLog')->info('测试--出库源数据', ["param" => $data]);
+
+            //处理数据
+            LabelDealService::getInstance()->clearData($data,$return,$box_list);
+            Log::channel('apiLog')->info('测试--出库(清洗数据)', ["param" => $return]);
+
+            //调用外部方法
+            list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData($this->header,$dv,$return,$box_list,$data);
+
+            //删除限制
+            DwyService::getInstance()->delLimitForBoxOut($lead_bind);
+
+            //调用保存接口 cs todo
+            LabelDealService::getInstance()->boxOut($lead_bind,$lead_out,$this->header,$this->id);
+        }catch (\Throwable $exception){
+            Log::channel('apiLog')->info('测试--队列捕获(出库异常)', ["message" => $exception->getFile() . "|" . $exception->getLine() . "|" . $exception->getMessage(). "|"  . $exception->getCode()]);
+            $this->delete();
+        }
+    }
+
+    protected function echoMessage(OutputInterface $output)
+    {
+        $output->writeln($this->data);
+    }
+}

+ 1 - 0
routes/api.php

@@ -64,6 +64,7 @@ Route::any('tttt', 'Api\DwyController@tttt');
 Route::any('getBoxTrademark', 'Api\DwyController@getBoxTrademark');
 Route::any('aaaa', 'Api\DwyController@setBoxTrademark');
 Route::any('boxOut', 'Api\JobController@labelDeal');
+Route::any('boxOutCs', 'Api\JobController@labelDealCs');
 Route::any('getObsUrl', 'Api\DwyController@getObsUrl');
 Route::any('getCbLog', 'Api\LoginController@getCbLog');