浏览代码

海柔 修复

LD 5 年之前
父节点
当前提交
fd5413cc4f

+ 0 - 1
app/Console/Commands/SyncBatchTask.php

@@ -258,7 +258,6 @@ sql;
             }
         }
         ValueStore::query()->where("name","wave_detail_last_sync_date")->update(["value"=>$details[count($details)-1]->edittime]);
-
         $this->batchService->assignTasks($batches);    //在这里为波次注册任务!
     }
 

+ 27 - 21
app/Services/BatchService.php

@@ -7,6 +7,7 @@ use App\OracleActAllocationDetails;
 use App\Order;
 use App\OrderCommodity;
 use App\Owner;
+use ErrorException;
 use Exception;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Http;
@@ -57,32 +58,37 @@ class BatchService
      */
     public function assignTasks(Collection $batches)
     {
+        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__,'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());
+            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;
+            $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());
+            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]));
+            $ran=$this->stationTaskBatchService->runMany($stationTaskBatches);//执行波次任务
+            LogService::log(__CLASS__,__FUNCTION__,'10'.json_encode([$ran]));
+        }catch(Exception $e){
+            throw new ErrorException('注册任务失败: '.json_encode($batches). $e->getMessage());
+        }
     }
 
 //    public function directTemp($batches){

+ 2 - 0
app/Services/StationRuleBatchService.php

@@ -20,6 +20,8 @@ class StationRuleBatchService
     {
         $batchType = $batch['type'] ?? 'null';
         $ownerId = $batch['owner_id'] ?? 'null';
+        $batch->loadMissing('stationTaskBatch');
+        if($batch['stationTaskBatch'])return null;
         return Cache::remember('stationRuleBatch_batchType_'.$batchType.'_ownerId_'.$ownerId, config('cache.expirations.rarelyChange'),function()use($batch){
             $builder= StationRuleBatch::query()->with('stationType')
                 ->where('owner_id',$batch['owner_id']);

+ 7 - 3
app/Services/StationTaskBatchService.php

@@ -164,9 +164,13 @@ class StationTaskBatchService
             (function () use ($stationTaskBatch) {
                 throw new Exception('找不到料箱:' . json_encode($stationTaskBatch));
             })();
-        $isFetchedFromRobotics
-            = $this->foreignHaiRoboticsService->
-        fetchGroup($toLocation, $taskMaterialBoxes, $groupPrefix);
+        try{
+            $isFetchedFromRobotics
+                = $this->foreignHaiRoboticsService->
+            fetchGroup($toLocation, $taskMaterialBoxes, $groupPrefix);
+        }catch(Exception $e){
+            throw new ErrorException('$stationTaskBatch运行波次机器人任务失败,获取组失败: '.$stationTaskBatch->toJson() . $e->getMessage());
+        }
         ($markNewStatus
             =function()use($isFetchedFromRobotics,$stationTaskBatch){
             $isFetchedFromRobotics?