Browse Source

多隔口料箱号

LD 5 years ago
parent
commit
8117c0e0ca

+ 8 - 8
app/OrderCommodity.php

@@ -30,20 +30,20 @@ class OrderCommodity extends Model
         return '';
     }
     public function getNameAttribute(){
-        return $this['name']??'';
+        return $this->commodity['name']??'';
     }
     public function getSkuAttribute(){
-        return $this['sku']??'';
+        return $this->commodity['sku']??'';
     }
-    public function getLocationAttribute(){
-        if($this['location']){
-            $this['location']=preg_replace('/_\d$/','',$this['location']);
+    public function getLocationAttribute($var){
+        if($var){
+            return preg_replace('/_\d$/','',$var);
         }
-        return $this['location']??'';
+        return $var??'';
     }
     public function getMaterialBoxPositionAttribute(){
-        if($this['location']){
-            preg_match('/_(\d)$/',$this['location'],$arr);
+        if($this->attributes['location']){
+            preg_match('/_(\d)$/',$this->attributes['location'],$arr);
             if(isset($arr[1]))
                 return $arr[1];
         }

+ 1 - 0
app/Services/StationTaskCommodityService.php

@@ -109,6 +109,7 @@ class StationTaskCommodityService
                 new StationTaskCommodity([
                     'station_id'=>$station['id'],
                     'material_box_id'=>$materialBox['id'],
+                    'material_box_position'=>$orderCommodity['material_box_position'],
                     'commodity_id'=>$orderCommodity['commodity_id'],
                     'amount'=>$orderCommodity['amount'],
                     'bin_number'=>$orderCommodity['orderBin']['number']??'',

+ 1 - 1
app/StationTaskCommodity.php

@@ -11,7 +11,7 @@ class StationTaskCommodity extends Model
 {
     use ModelLogChanging;
 
-    protected $fillable= ['station_id','material_box_id','commodity_id','amount','order_id','status',"bin_number","station_task_batch_id"];
+    protected $fillable= ['station_id','material_box_id','commodity_id','amount','order_id','status',"bin_number","station_task_batch_id","material_box_position"];
 
     public function commodity(): BelongsTo
     {   //商品

+ 18 - 8
resources/views/station/monitor/show.blade.php

@@ -340,14 +340,24 @@
             },
             watch:{
                 station(newStation){
-                    let taskMaterialBox=null;
-                    newStation.current_station_task.station_task_material_boxes.some(function(taskMaterialBox_in){
-                        if(taskMaterialBox_in.status==='处理中'){
-                            taskMaterialBox=taskMaterialBox_in;
-                        }
-                    });
-                    let gridsAmount=taskMaterialBox.grids_amount;
-                    let commoditiesProcessing
+                    let gridsAmount=function(){
+                        let taskMaterialBox=null;
+                        newStation.current_station_task.station_task_material_boxes.some(function(taskMaterialBox_in){
+                            if(taskMaterialBox_in.status==='处理中'){
+                                taskMaterialBox=taskMaterialBox_in;
+                            }
+                        });
+                        return taskMaterialBox.grids_amount;
+                    }
+                    let taskCommodities_Processing=function(){
+                        let taskCommodities=[];
+                        newStation.current_station_task['station_task_commodities'].forEach(function(taskCommodity){
+                            if(taskCommodity.status==='处理中'){
+                                taskCommodities.push(taskCommodity)
+                            }
+                        });
+                        return taskCommodities;
+                    };
                     this.grids={
                         single:{status:'',},
                         half:{

+ 30 - 28
tests/Services/BatchService/AssignTasksTest.php

@@ -12,6 +12,7 @@ use App\StationTask;
 use App\StationTaskBatch;
 use App\StationTaskCommodity;
 use App\StationTaskMaterialBox;
+use Ramsey\Uuid\Uuid;
 use Tests\TestCase;
 use App\Batch;
 use App\Traits\TestMockSubServices;
@@ -61,7 +62,8 @@ class AssignTasksTest extends TestCase
         $this->data['orderCommodities'] =
             factory(OrderCommodity::class)
                 ->createMany($this->makeArray($this->orderCommodityAmount,[
-                    'order_id' => function(){return $this->getTargetFieldCirculately($this->data['orders']);}
+                    'order_id' => function(){return $this->getTargetFieldCirculately($this->data['orders']);},
+                    'location' => function(){return Uuid::uuid4() . '_' . rand(1, 6);},
                 ]));
         $this->data['station_rule_batches']
             = factory(StationRuleBatch::class)
@@ -85,33 +87,33 @@ class AssignTasksTest extends TestCase
 
     function tearDown(): void
     {
-        MaterialBox::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.materialBox.id')??[])
-            ->delete();
-        StationTaskMaterialBox::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.id')??[])
-            ->delete();
-        StationTaskCommodity::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskCommodities.*.id')??[])
-            ->delete();
-        StationTaskBatch::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.id')??[])
-            ->delete();
-        StationTask::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.id')??[])
-            ->delete();
-        StationRuleBatch::query()
-            ->whereIn('id',data_get($this->data['station_rule_batches'],'*.id')??[])
-            ->delete();
-        OrderCommodity::query()
-            ->whereIn('id',data_get($this->data['orderCommodities'],'*.id')??[])
-            ->delete();
-        Order::query()
-            ->whereIn('id',data_get($this->data['orders'],'*.id')??[])
-            ->delete();
-        Batch::query()
-            ->whereIn('id',data_get($this->data['batches'],'*.id')??[])
-            ->delete();
+//        MaterialBox::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.materialBox.id')??[])
+//            ->delete();
+//        StationTaskMaterialBox::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.id')??[])
+//            ->delete();
+//        StationTaskCommodity::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskCommodities.*.id')??[])
+//            ->delete();
+//        StationTaskBatch::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.id')??[])
+//            ->delete();
+//        StationTask::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.id')??[])
+//            ->delete();
+//        StationRuleBatch::query()
+//            ->whereIn('id',data_get($this->data['station_rule_batches'],'*.id')??[])
+//            ->delete();
+//        OrderCommodity::query()
+//            ->whereIn('id',data_get($this->data['orderCommodities'],'*.id')??[])
+//            ->delete();
+//        Order::query()
+//            ->whereIn('id',data_get($this->data['orders'],'*.id')??[])
+//            ->delete();
+//        Batch::query()
+//            ->whereIn('id',data_get($this->data['batches'],'*.id')??[])
+//            ->delete();
         parent::tearDown();
     }
 }