Browse Source

多隔口料箱号

LD 5 years ago
parent
commit
e9fab6c250

+ 16 - 6
app/OrderCommodity.php

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

+ 0 - 10
app/Services/BatchService.php

@@ -62,32 +62,22 @@ class BatchService
     {
         try{
 
-//        $this->directTemp($batches);
-//            LogService::log(__CLASS__,__FUNCTION__,'1');
             $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
             $this->instant($this->stationRuleBatchService,'StationRuleBatchService');
             $this->instant($this->stationTaskService,'StationTaskService');
             $this->instant($this->stationTaskCommodityService,'StationTaskCommodityService');
             $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
 
-//            LogService::log(__CLASS__,__FUNCTION__,'2'.$batches->toJson());
 
             $batches_shouldProcess = $this->stationRuleBatchService->getBatches_shouldProcess($batches); //按规则过滤需要的波次
-//            LogService::log(__CLASS__,__FUNCTION__,'3 $batches_shouldProcess:'.$batches_shouldProcess->toJson());
             if($batches_shouldProcess->isEmpty()) return;
 
-//            LogService::log(__CLASS__,__FUNCTION__,'4');
             $stationTasks =  $this->stationTaskService->create($batches_shouldProcess->count()); //生成总任务
-//            LogService::log(__CLASS__,__FUNCTION__,'5'.$stationTasks->toJson());
             $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
-//            LogService::log(__CLASS__,__FUNCTION__,'6'.$stationTaskBatches->toJson());
             $stationTaskCommodities=$this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
-//            LogService::log(__CLASS__,__FUNCTION__,'7'.$stationTaskCommodities->toJson());
             $stationTaskMaterialBoxes=$this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
-//            LogService::log(__CLASS__,__FUNCTION__,'8'.$stationTaskMaterialBoxes->toJson());
 
             $ran=$this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
-//            LogService::log(__CLASS__,__FUNCTION__,'10'.json_encode([$ran]));
         }catch(Exception $e){
             throw new ErrorException('注册任务失败: '.json_encode($batches). $e->getMessage());
         }

+ 2 - 2
database/migrations/2021_03_11_120212_add_column_material_box_position_to_station_task_commodities.php

@@ -14,7 +14,7 @@ class AddColumnMaterialBoxPositionToStationTaskCommodities extends Migration
     public function up()
     {
         Schema::table('station_task_commodities', function (Blueprint $table) {
-//            $table
+            $table->unsignedTinyInteger('material_box_position')->nullable();
         });
     }
 
@@ -26,7 +26,7 @@ class AddColumnMaterialBoxPositionToStationTaskCommodities extends Migration
     public function down()
     {
         Schema::table('station_task_commodities', function (Blueprint $table) {
-            //
+            $table->dropColumn('material_box_position');
         });
     }
 }

+ 8 - 8
public/t.php

@@ -1,9 +1,9 @@
-<script>
+<?php
+
+$as = 'asdfsdf-234_1_2x';
+
+preg_match('/_(\d)$/',$as,$arr);
+var_dump(isset($arr[1]));
+var_dump(isset($arr[2]));
+var_dump($arr);
 
-    let a=[];
-    a[3]='aaa'
-    a[5] = 'bbb';
-    a[1] = 'xxx';
-    let c = a[1];
-    console.log(c)
-</script>