LD 5 лет назад
Родитель
Сommit
51443c3fa0

+ 19 - 9
app/Http/Controllers/api/thirdPart/haiq/PickStationController.php

@@ -18,15 +18,25 @@ class PickStationController
         $this->service=app('ForeignHaiRoboticsService');
     }
 
-    public function processed(Request $request){
-        $this->service->markBinProcessed(
-            $request->input('workStation'),
-            $request->input('binCode'),
-            $request->input('success'),
-            $request->input('created_at'),
-            $request->input('exception'),
-            $request->input('is_in_plan')
-        );
+    public function processed(Request $request): array
+    {
+        $failed=
+            ($processedResult=
+                $this->service->markBinProcessed(
+                    $request->input('workStation'),
+                    $request->input('binCode'),
+                    $request->input('success'),
+                    $request->input('created_at'),
+                    $request->input('exception'),
+                    $request->input('is_in_plan')
+                ))!==true;
+
+        $result = ["code" => 200, "data" => json_encode($request->all())];
+        if($failed){
+            $result["code"] = 500;
+            $result["errMsg"] = $processedResult;
+        }
+        return $result;
     }
 
 }

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

@@ -259,8 +259,7 @@ class StorageController
         }
     }
     public function exception(Request $request){
-        $this->service->excepted();
-        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
+        $this->service->excepted('海柔异常','',json_encode($request));
         return ['code'=>200,'errMsg'=>'','data'=>$request->all()];
     }
 }

+ 27 - 13
app/Services/ForeignHaiRoboticsService.php

@@ -50,7 +50,8 @@ class ForeignHaiRoboticsService
         $groupId=''
         , $priority=10
         , $isSequenced=1
-    ){
+    ): array
+    {
         $timestampSuffix = microtime(true);
         $taskMode=(function()use($modeName){
             switch ($modeName){
@@ -130,10 +131,11 @@ class ForeignHaiRoboticsService
                 :(function(){throw new ErrorException('呼叫机器人回收U型线料箱失败');})();
             $this->stationTaskMaterialBoxService
                 ->markProcessed($stationTaskMaterialBox);
+            return true;
         }catch (\Exception $e){
             $this->stationTaskMaterialBoxService
                 ->excepted($stationTaskMaterialBox??$materialBox??null);
-            return false;
+            return $e->getMessage();
         }
     }
 
@@ -170,16 +172,22 @@ class ForeignHaiRoboticsService
             })()){
                 throw new ErrorException('发回的料箱和任务号(ID)不匹配');
             }
-            if(($isPut
-                    =$updateEventType)==1){
-                $this->stationTaskMaterialBoxService->markHasPut($stationTaskMaterialBox);
-            }
-            if(($isGet
-                    =$updateEventType)==0){
-                $this->stationTaskMaterialBoxService->markTaken($stationTaskMaterialBox);
-            }
+            ($标记已放置在库外=
+                function()use($updateEventType,$stationTaskMaterialBox){
+                if(($isPut
+                        =$updateEventType)==1){
+                    $this->stationTaskMaterialBoxService->markHasPut($stationTaskMaterialBox);
+                }
+            })();
+            ($标记已入立架=
+                function()use($updateEventType,$stationTaskMaterialBox){
+                    if(($isGet
+                            =$updateEventType)==0){
+                        $this->stationTaskMaterialBoxService->markTaken($stationTaskMaterialBox);
+                    }
+            })();
         }catch (\Exception $e){
-            $this->excepted($taskCode, $binCode);
+            $this->excepted($taskCode, $binCode, $e->getMessage());
             return false;
         }
         return true;
@@ -199,8 +207,14 @@ class ForeignHaiRoboticsService
 //    }
 
 
-    public function excepted($taskCode,$binCode):bool{
-
+    public function excepted($taskCode='',$binCode='', $msg=''):bool{
+        try{
+            throw new ErrorException(
+                "taskCode任务号:$taskCode , binCode箱号:$binCode 海柔运行报错: $msg"
+            );
+        }catch (\Exception $e){
+            return true;
+        }
     }
 
     /**

+ 15 - 0
app/Services/StationTaskBatchService.php

@@ -199,6 +199,21 @@ class StationTaskBatchService
             );
     }
 
+//    function markFinished($stationTaskBatches)
+//    {
+//        if (get_class($stationTaskBatches)==StationTaskBatch::class){
+//            $stationTaskBatches = collect($stationTaskBatches);
+//        }
+//        StationTaskBatch::query()
+//            ->whereIn('id', data_get($stationTaskBatches, '*.id'))
+//            ->update(['status'=>'完成']);
+//
+//        $this->stationTaskService
+//            ->markProcessing_byId(
+//                data_get($stationTaskBatches, '*.station_id')
+//            );
+//    }
+
     function markExcepted(StationTaskBatch $stationTaskBatch)
     {
         $stationTaskBatch['status'] = '异常';

+ 1 - 1
app/Services/StationTaskMaterialBoxService.php

@@ -123,7 +123,7 @@ class StationTaskMaterialBoxService
     }
 
     function markTaken($stationTaskMaterialBox){
-
+            标记料箱任务为完成
     }
     function markProcessed(StationTaskMaterialBox $stationTaskMaterialBox){
         $stationTaskMaterialBox['status'] = '完成';

+ 3 - 2
public/t.php

@@ -1,4 +1,5 @@
 <?php
 
-$s = function (){};
-var_dump();
+$failed=!$success=true;
+
+var_dump($failed,$success);