LD 5 лет назад
Родитель
Сommit
434796902c

+ 7 - 7
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -245,13 +245,13 @@ class StorageController
     public function taskUpdate(ForeignHaiRobotic_taskUpdateRequest $request){
         try{
             $this->service->taskUpdate(
-                $request['groupCode'],
-                $request['taskCode'],
-                $request['updateEventType'],
-                $request['status'],
-                $request['binCode'],
-                $request['kubotId'],
-                $request['description']
+//                $request['groupCode']
+                $request['taskCode']
+                ,$request['updateEventType']
+                ,$request['status']
+                ,$request['binCode']
+//                ,$request['kubotId']
+//                ,$request['description']
             );
             return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
         }catch (\Exception $e){

+ 6 - 6
app/Services/BatchService.php

@@ -59,13 +59,13 @@ Class BatchService
         $this->stationTaskCommodityService=app('StationTaskCommodityService');
         $this->stationTaskMaterialBoxService=app('StationTaskMaterialBoxService');
 
-        $batches_canProcess = $this->stationRuleBatchService->getBatches_canProcess($batches); //按规则过滤需要的波次
-        if($batches_canProcess->isEmpty()) return;
+        $batches_shouldProcess = $this->stationRuleBatchService->getBatches_shouldProcess($batches); //按规则过滤需要的波次
+        if($batches_shouldProcess->isEmpty()) return;
 
-        $stationTasks =  $this->stationTaskService->create($batches_canProcess->count()); //生成总任务
-        $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_canProcess,$stationTasks); //注册波次任务
-        $this->stationTaskCommodityService->createByBatches($batches_canProcess,$stationTasks); //注册商品任务
-        $this->stationTaskMaterialBoxService->createByBatches($batches_canProcess,$stationTasks); //注册料箱任务
+        $stationTasks =  $this->stationTaskService->create($batches_shouldProcess->count()); //生成总任务
+        $stationTaskBatches=$this->stationTaskBatchService->createByBatches($batches_shouldProcess,$stationTasks); //注册波次任务
+        $this->stationTaskCommodityService->createByBatches($batches_shouldProcess,$stationTasks); //注册商品任务
+        $this->stationTaskMaterialBoxService->createByBatches($batches_shouldProcess,$stationTasks); //注册料箱任务
 
         $this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
     }

+ 47 - 41
app/Services/ForeignHaiRoboticsService.php

@@ -15,6 +15,13 @@ use Ramsey\Collection\Collection;
 
 class ForeignHaiRoboticsService
 {
+    /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService  */
+    private $stationTaskMaterialBoxService;
+    public function __construct()
+    {
+        $stationTaskMaterialBoxService=null;
+    }
+
     /**
      * @param string $modeName '输送线入立架'|'立架出至输送线'|'移动立架内位置'|'缓存架入立架'|'立架出至缓存架'
      * @param string $fromLocation
@@ -23,6 +30,7 @@ class ForeignHaiRoboticsService
      * @param string $groupId
      * @param int $priority
      * @param int $isSequenced
+     * @return array
      */
     private function makeJson_move(
         Collection $taskMaterialBoxes,
@@ -44,25 +52,24 @@ class ForeignHaiRoboticsService
                 default: throw new \Exception('发至海柔的移料箱请求,模式不存在');
             }
         })();
-        $bins=$taskMaterialBoxes->map(function (StationTaskMaterialBox $taskMaterialBox)use($timestampSuffix){
+        $bins=$taskMaterialBoxes->map(function (StationTaskMaterialBox $taskMaterialBox)use($timestampSuffix,$fromLocation,$toLocation){
             return [
-                "taskCode"  =>"{$taskMaterialBox['id']}_{$taskMaterialBox['material_box_id']}_{$timestampSuffix}",
+                "taskCode"  =>$taskMaterialBox['id'],
                 "binCode"   => $taskMaterialBox['materialBox']['code'],
                 "fromLocCode" => $fromLocation??'',
                 "toLocCode" => $toLocation??'',
             ];
         });
-        $groupId .= $timestampSuffix;
         return [
             "taskMode"  =>$taskMode,
             "bins"=>$bins,
-            "groupCode"=>$groupId,
+            "groupCode"=>$groupId.$timestampSuffix,
             "priority"=>$priority,
             "sequenceFlag"=>$isSequenced,
         ];
     }
 
-    public function fetchGroupToProcessor($toLocation, Collection $taskMaterialBoxes, $groupIdPrefix=''): bool
+    public function fetchGroup($toLocation, Collection $taskMaterialBoxes, $groupIdPrefix=''): bool
     {
         $dataToPost=$this->makeJson_move(
             $taskMaterialBoxes,
@@ -104,50 +111,49 @@ class ForeignHaiRoboticsService
     public function markBinProcessed(){
 
     }
+
     public function taskUpdate(
-        $groupCode,
+//        $groupCode,
         $taskCode,
         $updateEventType,   //0:task_begin(取货)1:task_end(放货)
         $status,            //0:任务成功1:任务失败
-        $binCode,
-        $robotId,
-        $description
+        $binCode
     ):bool{
-        if(($failed
-                =$status)==1){
-            return $this->excepted();
-        }
-        if(($isPut
-                =$updateEventType)==0){
-            return $this->markHasPut();
-        }
-        if(($isGet
-                =$updateEventType)==1){
-            return $this->markHasGot();
+        try{
+            if(($failed
+                    =$status)==1){
+                throw new ErrorException('海柔任务失败');
+            }
+            if(($isPut
+                    =$updateEventType)==0){
+                $this->stationTaskMaterialBoxService->markHasPut($taskCode,$binCode);
+            }
+            if(($isGet
+                    =$updateEventType)==1){
+                $this->stationTaskMaterialBoxService->markHasTaken($taskCode,$binCode);
+            }
+        }catch (\Exception $e){
+            $this->excepted($taskCode,$binCode);
+            return false;
         }
-
+        return true;
     }
-    public function markHasPut(
-        $groupCode,
-        $taskCode,
-        $binCode,
-        $description
-    ):bool{
-
-
-    }
-    public function markHasGot(
-        $groupCode,
-        $taskCode,
-        $binCode,
-        $description
-    ):bool{
-
-
-    }
-
 
-    public function excepted():bool{
+//    public function markHasPut($taskCode,$binCode):bool{
+//        try{
+//            //标记料箱进入位置
+////            $taskMaterialBoxesService->markDone();//
+//        }catch (\Exception $e){
+//            switch ($e->getCode()){
+//                case 'taskBinNotMatch';
+//                case 'taskGetFailed';
+//            }
+//        }
+//
+//    }
+
+
+    public function excepted($taskCode,$binCode):bool{
 
     }
 

+ 1 - 1
app/Services/StationRuleBatchService.php

@@ -33,7 +33,7 @@ class StationRuleBatchService
      * @param Batch[] $batches
      * @return Collection
      */
-    function getBatches_canProcess(array $batches): Collection
+    function getBatches_shouldProcess(array $batches): Collection
     {
         $batches_toProcess=collect();
         foreach ($batches as $batch){

+ 1 - 1
app/Services/StationTaskBatchService.php

@@ -150,7 +150,7 @@ class StationTaskBatchService
                 throw new Exception('找不到料箱:' . json_encode($stationTaskBatch));
             };
         $isFetchedFromRobotics          = $this->foreignHaiRoboticsService->
-                                    fetchGroupToProcessor($toLocation, $taskMaterialBoxes, $groupPrefix);
+                                    fetchGroup($toLocation, $taskMaterialBoxes, $groupPrefix);
         ($markNewStatus
             =function()use($isFetchedFromRobotics,$stationTaskBatch){
             $isFetchedFromRobotics?

+ 23 - 7
app/Services/StationTaskMaterialBoxService.php

@@ -28,13 +28,18 @@ class StationTaskMaterialBoxService
     }
     function createByBatches(array $batches,Collection $stationTasks_toAttach): Collection
     {
-        $stationTaskMaterialBoxes_listByBatch=new Collection();
-        foreach ($batches as $batch){
-            $stationTaskMaterialBoxes_listByBatch->push(
-                $this->createByBatch($batch)
-            );
-        }
-        $this->stationTaskService->registerSubTasks($stationTasks_toAttach,$stationTaskMaterialBoxes_listByBatch);
+        return $this->stationTaskService
+            ->registerSubTasks(
+                $stationTasks_toAttach,
+                (function()use($batches){
+                    $stationTaskMaterialBoxes_listByBatch=new Collection();
+                    foreach ($batches as $batch){
+                        $stationTaskMaterialBoxes_listByBatch->push(
+                            $this->createByBatch($batch)
+                        );
+                    }
+                    return $stationTaskMaterialBoxes_listByBatch;
+                })());
 
     }
 
@@ -78,4 +83,15 @@ class StationTaskMaterialBoxService
             '||'.json_encode(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),0,3)));
         return $inserted;
     }
+
+    function markHasPut($taskCode,$binCode){
+        //如果
+        //标记箱子任务处理中
+        //标记箱子关联的商品任务处理中
+        //标记波次处理中
+    }
+
+    function markHasTaken($taskCode,$binCode){
+
+    }
 }

+ 4 - 1
database/migrations/2020_12_24_155647_drop_station_mission_tables.php → database/migrations/2020_12_24_155647_add_column_material_task_type_drop_station_mission_tables.php

@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
-class DropStationMissionTables extends Migration
+class AddColumnMaterialTaskTypeDropStationMissionTables extends Migration
 {
     /**
      * Run the migrations.
@@ -17,6 +17,9 @@ class DropStationMissionTables extends Migration
         Schema::dropIfExists('station_mission_batches');
         Schema::dropIfExists('station_mission_commodities');
         Schema::dropIfExists('station_mission_material_boxes');
+        Schema::table('station_task_material_boxes',function($table){
+            $table->enum('type',['取','放','移动']);
+        });
     }
 
     /**