Bladeren bron

海柔任务下发

LD 5 jaren geleden
bovenliggende
commit
c62220de7a

+ 2 - 2
app/Http/Controllers/TestController.php

@@ -1002,8 +1002,8 @@ where (commodities.owner_id,commodity_barcodes.code) in (select commodities.owne
         return view('test');
     }
     public function tdel(){
-        echo '223232323';
-        return 'asdfsadfsdf';
+        $batch=Batch::query()->first();
+        dd(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),0,3));
     }
     public function cleanOrderRepeat(){
 

+ 13 - 4
app/Services/BatchService.php

@@ -9,12 +9,18 @@ Class BatchService
 {
     /** @var StationTaskBatchService $stationTaskBatchService */
     private $stationTaskBatchService;
+    /** @var StationRuleBatchService $stationRuleBatchService */
+    private $stationRuleBatchService;
+    /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
+    private $stationTaskMaterialBoxService;
     public function __construct(){
         $this->stationTaskBatchService=null;
+        $this->stationRuleBatchService=null;
+        $this->stationTaskMaterialBoxService=null;
     }
 
     public function get(array $params)
-    {
+    {~
         $query = Batch::query();
         foreach ($params as $column=>$param){
             if (is_array($param))$query->whereIn($column,$param);
@@ -42,11 +48,14 @@ Class BatchService
     public function assignTasks(array $batches)
     {
         $this->stationTaskBatchService=app('StationTaskBatchService');
-        //按规则过滤需要的波次
-        //分配
+        $this->stationRuleBatchService=app('StationRuleBatchService');
+
+        $batches_canProcess = $this->stationRuleBatchService->getBatches_canProcess($batches); //按规则过滤需要的波次
+        if($batches_canProcess->isEmpty()) return;
+
         $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches); //注册波次任务
-        //注册料箱任务
         //注册商品任务
+        //注册料箱任务
         //注册总任务
     }
 

+ 1 - 1
app/Services/StationService.php

@@ -18,7 +18,7 @@ class StationService
      * @return Station
      * @throws Exception
      */
-    function getDefaultStation(string $typeName):Station{
+    function getStation_byType(string $typeName):Station{
         $station= Cache::remember('StationType_default_name_'.$typeName,config('rarelyChange'), function ()use($typeName) {
             $stationType= StationType::query()->where('name',$typeName)->orderBy('id')->get('id')->first();
             if(!$stationType) throw new Exception('指定站类型获取不到');

+ 18 - 7
app/Services/StationTaskBatchService.php

@@ -5,6 +5,7 @@ namespace App\Services;
 
 
 use App\Batch;
+use App\Log;
 use App\Station;
 use App\StationTaskBatch;
 use App\StationTaskBatchType;
@@ -20,34 +21,39 @@ class StationTaskBatchService
     private $stationTaskBatchTypeService;
     /** @var BatchService $batchService */
     private $batchService;
+    /** @var StationTypeService $stationTypeService */
+    private $stationTypeService;
     public function __construct(){
         $this->stationService=null;
+        $this->stationTypeService=null;
         $this->stationTaskBatchTypeService=null;
         $this->batchService=null;
     }
 
     /**
      * @param $batches Batch[]
-     * @param Station $station
      * @return Collection
+     * @throws Exception
      */
-    public function createByBatches(array $batches,Station $station): Collection
+     function createByBatches(array $batches): Collection
     {
         $this->stationService=app('StationService');
+        $this->stationTypeService=app('StationTypeService');
         $this->stationTaskBatchTypeService=app('StationTaskBatchTypeService');
         $this->batchService=app('BatchService');
 
         $stationMissionBatches_toCreate=new Collection();
-//        $station=$this->stationService->getDefaultStation('料箱出货口');
-        $id_stationMissionBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
+        $id_stationTaskBatchType=$this->stationTaskBatchTypeService->firstByWhere('name','U型线分捡');
 
         $batches_handled=[];
         foreach ($batches as $batch){
             if ($batch['status']=='未处理'){
+                $stationType=$this->stationTypeService->getByBatch($batch);
+                $station=$this->stationService->getStation_byType($stationType['name']);
                 $stationMissionBatches_toCreate->push([
                     'batch_id'=>$batch['id'],
                     'station_id'=>$station['id'],
-                    'station_mission_batch_type_id'=> $id_stationMissionBatchType,
+                    'station_task_batch_type_id'=> $id_stationTaskBatchType,
                     'status'=>'待处理'
                 ]);
                 $batches_handled[]=$batch;
@@ -55,10 +61,15 @@ class StationTaskBatchService
         }
         $this->batchService->updateWhereIn('id',data_get($batches_handled,'*.id'),['status'=>'处理中']);
         $this->insert($stationMissionBatches_toCreate->toArray());
+
         return $stationMissionBatches_toCreate;
     }
 
-    public function insert(array $stationMissionBatches_inArray){
-        return StationTaskBatch::query()->insert($stationMissionBatches_inArray);
+    public function insert(array $stationMissionBatches): bool
+    {
+        $inserted = StationTaskBatch::query()->insert($stationMissionBatches);
+        LogService::log(__METHOD__,__FUNCTION__,json_encode($stationMissionBatches).
+            '||'.json_encode(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),0,3)));
+        return $inserted;
     }
 }

+ 15 - 0
app/Services/StationTaskCommodityService.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace App\Services;
+
+
+use Illuminate\Support\Collection;
+
+class StationTaskCommodityService
+{
+    function createByBatches(array $batches): Collection
+    {
+
+    }
+}

+ 15 - 0
app/Services/StationTaskMaterialBoxService.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace App\Services;
+
+
+use Illuminate\Support\Collection;
+
+class StationTaskMaterialBoxService
+{
+    function createByBatches(array $batches): Collection
+    {
+
+    }
+}

+ 26 - 0
app/Services/StationTypeService.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Batch;
+use App\StationRuleBatch;
+use Illuminate\Support\Facades\Cache;
+
+class StationTypeService
+{
+    /** @var StationRuleBatchService $stationRuleBatchService */
+    private $stationRuleBatchService;
+    public function __construct()
+    {
+        $this->stationRuleBatchService=null;
+    }
+
+    function getByBatch(Batch $batch): StationRuleBatch
+    {
+        $this->stationRuleBatchService=app('StationRuleBatchService');
+        $stationRuleBatch=$this->stationRuleBatchService->getByBatch($batch);
+        return $stationRuleBatch['stationType'];
+    }
+}

+ 6 - 0
app/StationRuleBatch.php

@@ -3,8 +3,14 @@
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasOne;
 
 class StationRuleBatch extends Model
 {
     protected $fillable=['name','station_type_id','batch_type','owner_id'];
+
+    public function stationType(): HasOne
+    {
+        return $this->hasOne(StationType::class);
+    }
 }