浏览代码

清理历史缓存架测试任务
调整任务完成逻辑

Zhouzhendong 4 年之前
父节点
当前提交
aa770aaa2e

+ 4 - 19
app/Http/Controllers/TestController.php

@@ -125,25 +125,10 @@ class TestController extends Controller
     }
     public function test1()
     {
-        dd(Unit::query()->first());
-        DB::beginTransaction();
-        try{
-            DB::beginTransaction();
-            try{
-                $unit = Unit::query()->first();
-                $unit->update(["name"=>2222]);
-                //$a = 0/0;
-                DB::commit();
-            }catch(\Exception $e){
-                dump(1);
-                DB::rollBack();
-            }
-            $a = 0/0;
-            DB::commit();
-        }catch(\Exception $e){
-            dump(2);
-            DB::rollBack();
-        }
+        $stations = Station::query()->select("id")->where("parent_id",6);
+        \App\Storage::query()->whereIn("station_id",$stations)->delete();
+        StationTask::query()->whereIn("station_id",$stations)->delete();
+        StationTaskMaterialBox::query()->whereIn("station_id",$stations)->delete();
     }
     public function test()
     {

+ 16 - 4
app/Services/StationTaskMaterialBoxService.php

@@ -172,10 +172,7 @@ class StationTaskMaterialBoxService
                     $stationTaskMaterialBox->materialBox->update();
                     break;
                 case '入立库':
-                    $this->set($stationTaskMaterialBox,[
-                        'id' => $stationTaskMaterialBox['station_id'],
-                        'status' => '完成',
-                    ]);
+                    $this->taskCompleted($stationTaskMaterialBox);
                     $this->cacheShelfService->putStationTaskMaterialBoxProcess($stationTaskMaterialBox);
                     $stationTaskMaterialBox->materialBox['status']='在立库';
                     $stationTaskMaterialBox->materialBox->update();
@@ -184,6 +181,7 @@ class StationTaskMaterialBoxService
                     $this->storageService->checkMark($stationTaskMaterialBox); //检查标记并做一些特殊处理
                     break;
                 case '入缓存架':
+                    $this->taskCompleted($stationTaskMaterialBox);
                     $stationTaskMaterialBox->materialBox['status']='在缓存架';
                     $stationTaskMaterialBox->materialBox->update();
                     $this->storageService->putCacheShelf($stationTaskMaterialBox);
@@ -195,6 +193,20 @@ class StationTaskMaterialBoxService
         }
     }
 
+    private function taskCompleted($stationTaskMaterialBox)
+    {
+        $this->set($stationTaskMaterialBox,[
+            'id' => $stationTaskMaterialBox['station_id'],
+            'status' => '完成',
+        ]);
+        if (!$stationTaskMaterialBox->station_task_id)return;
+        $task = StationTaskMaterialBox::query()->select(DB::raw(1))
+            ->where("station_task_id",$stationTaskMaterialBox->station_task_id)
+            ->where("status","!=","完成")->first();
+        if (!$task)StationTask::query()->where("id",$stationTaskMaterialBox->station_task_id)
+            ->update(["status"=>"完成"]);
+    }
+
     // TODO 料箱处理
     function markHasTaken($stationTaskMaterialBox)
     {

+ 2 - 1
app/Services/StorageService.php

@@ -380,7 +380,8 @@ sql;
      */
     public function putWareHousing(string $fromLocation, $boxId):?int
     {
-        $station = Station::query()->select("id")->where("code",$fromLocation)->first();
+        $station = Station::query()->select("id")
+            ->where("station_type_id",5)->where("code",$fromLocation)->first();
         if (!$station)return null;
         if (StationTask::query()->select("id")->where("status","!=",'完成')->where("station_id",$station->id)->first())return null;
         /** @var StationTaskMaterialBox|\stdClass $stmb */