Browse Source

海柔接口开发

LD 5 years ago
parent
commit
1480ece3de

+ 5 - 5
app/Services/CommodityService.php

@@ -264,12 +264,12 @@ Class CommodityService
             return $barcodes;
         })();
         //
-        $commodities=$this->get_([$ownerId],[$sku],[],true);
-        if ($commodities->first()){
-            $commodity=$commodities->first();
-        }else{
+//        $commodities=$this->get_([$ownerId],[$sku],[],true);
+//        if ($commodities->first()){
+//            $commodity=$commodities->first();
+//        }else{
             $commodity = $this->firstOrCreate(['owner_id' => $ownerId, 'sku' => $sku]);
-        }
+//        }
         $commodityBarcodes = $commodity['barcodes'] ?? new Collection();
 
 

+ 7 - 6
app/StationTask.php

@@ -8,20 +8,21 @@ class StationTask extends Model
 {
     protected $fillable = ['status'];
 
+    public function tasks()
+    {
+        return $this->morphTo();
+    }
 
     public function taskCommodities()
     {   //任务商品列表
-        return $this->belongsToMany(StationTaskCommodity::class,"station_task_children","station_task_id","station_task_table_id")
-            ->where("station_task_table_type","station_task_commodities");
+        return $this->morphTo()->where("station_task_table_type","station_task_commodities");
     }
     public function taskBatches()
     {   //任务波次 目前为单个,取值时应取第一个即可
-        return $this->belongsToMany(StationTaskBatch::class,"station_task_children","station_task_id","station_task_table_id")
-            ->where("station_task_table_type","station_task_batches");
+        return $this->morphTo()->where("station_task_table_type","station_task_batches");
     }
     public function taskMaterialBoxes()
     {   //任务料箱
-        return $this->belongsToMany(StationTaskMaterialBox::class,"station_task_children","station_task_id","station_task_table_id")
-            ->where("station_task_table_type","station_task_material_boxes");
+        return $this->morphTo()->where("station_task_table_type","station_task_material_boxes");
     }
 }

+ 1 - 0
app/StationTaskBatch.php

@@ -3,6 +3,7 @@
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasOne;
 
 class StationTaskBatch extends Model
 {

+ 3 - 0
app/StationTaskCommodity.php

@@ -16,4 +16,7 @@ class StationTaskCommodity extends Model
     {   //料箱
         return $this->hasOne(MaterialBox::class,"id","material_box_id");
     }
+    function parentTask(){
+        return $this->morphOne(StationTask::class,'station_taskable');
+    }
 }

+ 3 - 0
app/StationTaskMaterialBox.php

@@ -12,4 +12,7 @@ class StationTaskMaterialBox extends Model
     {   //料箱
         return $this->hasOne(MaterialBox::class,"id","material_box_id");
     }
+    function parentTask(){
+        return $this->morphOne(StationTask::class,'station_taskable');
+    }
 }

+ 38 - 0
database/migrations/2020_12_11_173031_add_relation_column_and_drop_table_children.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddRelationColumnAndDropTableChildren extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('station_tasks', function (Blueprint $table) {
+            $table->string('station_taskable_type');
+            $table->bigInteger('station_taskable_id');
+            $table->index('station_taskable_id','station_taskable_type');
+        });
+        Schema::drop('station_task_children');
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('station_tasks', function (Blueprint $table) {
+            //
+        });
+        Schema::create('station_task_children', function (Blueprint $table) {
+            $table->id();
+        });
+    }
+}

+ 1 - 1
package-lock.json

@@ -8845,7 +8845,7 @@
         },
         "socket.io-client": {
             "version": "2.3.0",
-            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsocket.io-client%2Fdownload%2Fsocket.io-client-2.3.0.tgz",
+            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz",
             "integrity": "sha1-FNW6LgC5vNFFrkQ6uWs/hsvMG7Q=",
             "requires": {
                 "backo2": "1.0.2",

+ 99 - 0
sqlSleeping.txt

@@ -0,0 +1,99 @@
++-------+------------+-----------------------+-------+---------+------+--------------+------------------------------------------------------------------------------------------------------+----------+
+| Id    | User       | Host                  | db    | Command | Time | State        | Info                                                                                                 | Progress |
++-------+------------+-----------------------+-------+---------+------+--------------+------------------------------------------------------------------------------------------------------+----------+
+| 30573 | wacs       | localhost:60024       | bswas | Sleep   | 32   |              |                                                                                                      | 0.000    |
+| 30574 | wacs       | localhost:60026       | bswas | Sleep   | 2    |              |                                                                                                      | 0.000    |
+| 30576 | wacs       | localhost:60034       | bswas | Sleep   | 8    |              |                                                                                                      | 0.000    |
+| 30578 | wacs       | localhost:60044       | bswas | Sleep   | 5    |              |                                                                                                      | 0.000    |
+| 30579 | wacs       | localhost:60052       | bswas | Sleep   | 26   |              |                                                                                                      | 0.000    |
+| 30580 | wacs       | localhost:60054       | bswas | Sleep   | 35   |              |                                                                                                      | 0.000    |
+| 30581 | wacs       | localhost:60062       | bswas | Sleep   | 5    |              |                                                                                                      | 0.000    |
+| 30582 | wacs       | localhost:60066       | bswas | Sleep   | 35   |              |                                                                                                      | 0.000    |
+| 30583 | wacs       | localhost:60076       | bswas | Sleep   | 2    |              |                                                                                                      | 0.000    |
+| 82709 | wacs       | localhost:60110       | bswas | Sleep   | 80   |              |                                                                                                      | 0.000    |
+| 83531 | wacs       | localhost:36828       | bswas | Sleep   | 5853 |              |                                                                                                      | 0.000    |
+| 83537 | wacs       | localhost:36864       | bswas | Sleep   | 5841 |              |                                                                                                      | 0.000    |
+| 83545 | wacs       | localhost:36910       | bswas | Sleep   | 5828 |              |                                                                                                      | 0.000    |
+| 83549 | wacs       | localhost:36934       | bswas | Sleep   | 5814 |              |                                                                                                      | 0.000    |
+| 83565 | wacs       | localhost:37016       | bswas | Sleep   | 5802 |              |                                                                                                      | 0.000    |
+| 83566 | wacs       | localhost:37020       | bswas | Execute | 15   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83571 | wacs       | localhost:37054       | bswas | Sleep   | 5789 |              |                                                                                                      | 0.000    |
+| 83580 | wacs       | localhost:37106       | bswas | Sleep   | 5774 |              |                                                                                                      | 0.000    |
+| 83587 | wacs       | localhost:37150       | bswas | Sleep   | 5761 |              |                                                                                                      | 0.000    |
+| 83596 | wacs       | localhost:37208       | bswas | Sleep   | 5748 |              |                                                                                                      | 0.000    |
+| 83610 | wacs       | localhost:37288       | bswas | Sleep   | 5735 |              |                                                                                                      | 0.000    |
+| 83792 | wacs       | localhost:38180       | bswas | Sleep   | 5491 |              |                                                                                                      | 0.000    |
+| 83793 | wacs       | localhost:38184       | bswas | Execute | 16   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83802 | wacs       | localhost:38244       | bswas | Sleep   | 5477 |              |                                                                                                      | 0.000    |
+| 83803 | wacs       | localhost:38254       | bswas | Execute | 5    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83811 | wacs       | localhost:38302       | bswas | Sleep   | 5464 |              |                                                                                                      | 0.000    |
+| 83812 | wacs       | localhost:38310       | bswas | Execute | 7    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83815 | wacs       | localhost:38330       | bswas | Sleep   | 5452 |              |                                                                                                      | 0.000    |
+| 83816 | wacs       | localhost:38334       | bswas | Execute | 13   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83826 | wacs       | localhost:38386       | bswas | Sleep   | 5439 |              |                                                                                                      | 0.000    |
+| 83827 | wacs       | localhost:38390       | bswas | Execute | 6    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83832 | wacs       | localhost:38420       | bswas | Sleep   | 5426 |              |                                                                                                      | 0.000    |
+| 83840 | wacs       | localhost:38466       | bswas | Sleep   | 5413 |              |                                                                                                      | 0.000    |
+| 83848 | wacs       | localhost:38516       | bswas | Sleep   | 5400 |              |                                                                                                      | 0.000    |
+| 83849 | wacs       | localhost:38520       | bswas | Execute | 13   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83853 | wacs       | localhost:38548       | bswas | Sleep   | 5387 |              |                                                                                                      | 0.000    |
+| 83854 | wacs       | localhost:38552       | bswas | Execute | 1    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83864 | wacs       | localhost:38608       | bswas | Sleep   | 5374 |              |                                                                                                      | 0.000    |
+| 83865 | wacs       | localhost:38612       | bswas | Execute | 7    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83868 | wacs       | localhost:38632       | bswas | Sleep   | 5361 |              |                                                                                                      | 0.000    |
+| 83876 | wacs       | localhost:38676       | bswas | Sleep   | 5348 |              |                                                                                                      | 0.000    |
+| 83881 | wacs       | localhost:38706       | bswas | Sleep   | 5335 |              |                                                                                                      | 0.000    |
+| 83882 | wacs       | localhost:38710       | bswas | Execute | 5    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83890 | wacs       | localhost:38754       | bswas | Sleep   | 5322 |              |                                                                                                      | 0.000    |
+| 83900 | wacs       | localhost:38806       | bswas | Sleep   | 5309 |              |                                                                                                      | 0.000    |
+| 83906 | wacs       | localhost:38840       | bswas | Sleep   | 5296 |              |                                                                                                      | 0.000    |
+| 83907 | wacs       | localhost:38846       | bswas | Execute | 5    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83915 | wacs       | localhost:38902       | bswas | Sleep   | 5283 |              |                                                                                                      | 0.000    |
+| 83920 | wacs       | localhost:38934       | bswas | Sleep   | 5270 |              |                                                                                                      | 0.000    |
+| 83932 | wacs       | localhost:38996       | bswas | Sleep   | 5257 |              |                                                                                                      | 0.000    |
+| 83933 | wacs       | localhost:39000       | bswas | Execute | 9    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83937 | wacs       | localhost:39026       | bswas | Sleep   | 5244 |              |                                                                                                      | 0.000    |
+| 83938 | wacs       | localhost:39030       | bswas | Execute | 1    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 83946 | wacs       | localhost:39078       | bswas | Sleep   | 5231 |              |                                                                                                      | 0.000    |
+| 83953 | wacs       | localhost:39124       | bswas | Sleep   | 5218 |              |                                                                                                      | 0.000    |
+| 83959 | wacs       | localhost:39160       | bswas | Sleep   | 5205 |              |                                                                                                      | 0.000    |
+| 83986 | wacs       | localhost:39302       | bswas | Sleep   | 5179 |              |                                                                                                      | 0.000    |
+| 86075 | baoshiRoot | 180.174.192.107:59164 | bswas | Sleep   | 1042 |              |                                                                                                      | 0.000    |
+| 87490 | wacs       | localhost:58264       | bswas | Sleep   | 1894 |              |                                                                                                      | 0.000    |
+| 87492 | wacs       | localhost:58276       | bswas | Execute | 7    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 87552 | wacs       | localhost:58548       | bswas | Sleep   | 1868 |              |                                                                                                      | 0.000    |
+| 87594 | wacs       | localhost:58736       | bswas | Sleep   | 1855 |              |                                                                                                      | 0.000    |
+| 87634 | wacs       | localhost:58920       | bswas | Sleep   | 1842 |              |                                                                                                      | 0.000    |
+| 87635 | wacs       | localhost:58924       | bswas | Execute | 10   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 87673 | wacs       | localhost:59090       | bswas | Sleep   | 1829 |              |                                                                                                      | 0.000    |
+| 87675 | wacs       | localhost:59098       | bswas | Execute | 6    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 87687 | wacs       | localhost:59158       | bswas | Sleep   | 1814 |              |                                                                                                      | 0.000    |
+| 87690 | wacs       | localhost:59166       | bswas | Execute | 9    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 87720 | wacs       | localhost:59328       | bswas | Sleep   | 1802 |              |                                                                                                      | 0.000    |
+| 87723 | wacs       | localhost:59342       | bswas | Execute | 0    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 87736 | wacs       | localhost:59426       | bswas | Sleep   | 1789 |              |                                                                                                      | 0.000    |
+| 88693 | wacs       | localhost:36806       | bswas | Sleep   | 811  |              |                                                                                                      | 0.000    |
+| 88694 | wacs       | localhost:36810       | bswas | Execute | 7    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88710 | wacs       | localhost:36900       | bswas | Sleep   | 797  |              |                                                                                                      | 0.000    |
+| 88711 | wacs       | localhost:36904       | bswas | Execute | 10   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88750 | wacs       | localhost:37078       | bswas | Sleep   | 785  |              |                                                                                                      | 0.000    |
+| 88751 | wacs       | localhost:37082       | bswas | Execute | 1    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88765 | wacs       | localhost:37168       | bswas | Sleep   | 772  |              |                                                                                                      | 0.000    |
+| 88767 | wacs       | localhost:37178       | bswas | Execute | 6    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88780 | wacs       | localhost:37266       | bswas | Sleep   | 759  |              |                                                                                                      | 0.000    |
+| 88781 | wacs       | localhost:37270       | bswas | Execute | 2    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88795 | wacs       | localhost:37360       | bswas | Sleep   | 746  |              |                                                                                                      | 0.000    |
+| 88796 | wacs       | localhost:37364       | bswas | Execute | 4    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88818 | wacs       | localhost:37492       | bswas | Sleep   | 731  |              |                                                                                                      | 0.000    |
+| 88831 | wacs       | localhost:37546       | bswas | Execute | 11   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88842 | wacs       | localhost:37628       | bswas | Sleep   | 718  |              |                                                                                                      | 0.000    |
+| 88843 | wacs       | localhost:37632       | bswas | Execute | 13   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 88854 | wacs       | localhost:37704       | bswas | Sleep   | 705  |              |                                                                                                      | 0.000    |
+| 88855 | wacs       | localhost:37708       | bswas | Execute | 6    | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 89075 | wacs       | localhost:39056       | bswas | Sleep   | 490  |              |                                                                                                      | 0.000    |
+| 89078 | wacs       | localhost:39079       | bswas | Execute | 10   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 89084 | wacs       | localhost:39122       | bswas | Sleep   | 477  |              |                                                                                                      | 0.000    |
+| 89085 | wacs       | localhost:39126       | bswas | Execute | 12   | Sending data | select * from `commodity_barcodes` where exists (select * from `commodities` where `commodity_barcod | 0.000    |
+| 89458 | wacs       | localhost:41314       | bswas | Execute | 6    | Sending data | select order_issues.* ,order_issue_on_tops.id top_id ,order_issue_on_tops.remark,order_issue_on_tops | 0.000    |
+| 89465 | root       | localhost             |       | Query   | 0    |              | show processlist                                                                                     | 0.000    |
++-------+------------+-----------------------+-------+---------+------+--------------+------------------------------------------------------------------------------------------------------+----------+