Browse Source

半箱入库逻辑纠正

Zhouzhendong 4 năm trước cách đây
mục cha
commit
3fdfeeb23d

+ 5 - 4
app/Http/Controllers/StorageController.php

@@ -125,8 +125,6 @@ class StorageController extends Controller
             $data .= "存在任务待处理,无法调取";
             $boxes = array_values($boxes);
         }
-        //清理原有任务
-        app("StorageService")->clearTask($boxes);//TODO 改为机器人防置时触发 但需要阿君修改任务参数为指定格口而非整个缓存架
         //重新调取料箱
         $result = app("ForeignHaiRoboticsService")->paddingCacheShelf(Station::query()->whereIn("code",$boxes)->get());
         if ($result===null)$this->error("任务下发错误,检查日志");
@@ -157,9 +155,9 @@ class StorageController extends Controller
                     ->where("status",0)->where(DB::raw("{$model->maximum}-amount"),">=",request("amount"))->get()->each(function ($box)use(&$boxId){
                         if (app("MaterialBoxService")->checkUsableBox($box->id)){
                             $boxId = $box->id;
-                            return true;
+                            return false;
                         }
-                        return false;
+                        return true;
                     });
                 if ($boxId)break;
             }
@@ -176,7 +174,9 @@ class StorageController extends Controller
             if (!$box)$this->error("无可用料箱");
             $boxId = $box->id;
         }
+        if (!$boxId)$this->error("无可用料箱");
         //发起取箱任务
+        DB::beginTransaction();
         $collection = new Collection();
         $task = StationTask::query()->create([
             'status' => "待处理",
@@ -202,6 +202,7 @@ class StorageController extends Controller
             "user_id" => Auth::id(),
             "mark" => 1
         ]);
+        DB::commit();
         //亮灯
         app("CacheShelfService")->stationLightUp($station->code,null,'2');
         $this->success();

+ 5 - 3
app/Http/Controllers/TestController.php

@@ -143,9 +143,11 @@ class TestController extends Controller
 
     public function test1()
     {
-        $order = Order::query()->find(3330884);
-        $a = new OrderService();
-        $a->createInstantBill($order);
+        Unit::query()->get()->each(function ($unit){
+            dump($unit->name);
+            if ($unit->name == '日')return  false;
+            return true;
+        });
     }
 
     public function test2()

+ 5 - 3
app/Services/StorageService.php

@@ -67,6 +67,9 @@ class StorageService
                 "station_id" => $stationTaskMaterialBox->station_id,
                 "material_box_id" => $stationTaskMaterialBox->material_box_id,
             ]);
+            $stationTaskMaterialBox->loadMissing("station");
+            //清理原有任务
+            app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]);
             DB::commit();
         }catch (\Exception $e){
             DB::rollBack();
@@ -87,8 +90,6 @@ class StorageService
         if ($storage->status == 1)$update["status"] = 0;
         if ($storage->station_id)$update["station_id"] = null;
         if ($update)$storage->update($update);
-        //一号缓存架操作完下达补充料箱
-        if ($stationTaskMaterialBox->station->parent_id == 6)app("ForeignHaiRoboticsService")->paddingCacheShelf(Station::query()->where("code",$stationTaskMaterialBox->station_id)->get());
     }
 
     /**
@@ -133,7 +134,6 @@ class StorageService
                         DB::connection("oracle")->rollBack();
                         return false;
                     };
-                    DB::connection("oracle")->commit();
                 }catch(\Exception $e){
                     DB::connection("oracle")->rollBack();
                     return false;
@@ -148,9 +148,11 @@ class StorageService
                 $collection = new Collection([$taskMaterialBox]);
                 app("ForeignHaiRoboticsService")->fetchGroup($station->code,$collection,'','缓存架入立架'); //呼叫机器人入库
                 DB::commit();
+                DB::connection("oracle")->commit();
                 return true;
             }catch(\Exception $e){
                 DB::rollBack();
+                DB::connection("oracle")->rollBack();
                 return false;
             }
         }