Эх сурвалжийг харах

修改库位占用,留存缓存架入库信息

Zhouzhendong 4 жил өмнө
parent
commit
ecd4bbdae0

+ 1 - 1
app/Http/Controllers/StorageController.php

@@ -29,7 +29,7 @@ class StorageController extends Controller
         //check info
         if (!$asn || !$ide || !$barCode || !$amount)$this->error("信息不完整");
         $fromLocation = app("MaterialBoxService")->getBoxLocation($ide);
-        if (!$fromLocation)$this->error("海柔无此库位信息");
+        if (!$fromLocation)$this->error("WAS无此库位信息");
         $box = MaterialBox::query()->select("id")->where("code",$ide)->first();
         if (!$box)$this->error("WAS无此料箱");
 

+ 6 - 4
app/Services/MaterialBoxService.php

@@ -7,6 +7,7 @@ namespace App\Services;
 use App\MaterialBox;
 use App\Station;
 use App\StationTaskMaterialBox;
+use App\Storage;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Cache;
@@ -84,11 +85,12 @@ sql;
      *
      * @return string|null
      */
-    public function getBoxLocation(string $ide)
+    public function getBoxLocation(string $ide):?string
     {
-        $bin = DB::connection("mysql_haiRobotics")->table("ks_bin")->select("ks_bin_space_code")
-            ->where("ks_bin_code",$ide)->where("status",1)->first();
-        return $bin->ks_bin_space_code ?? null;
+        $storage = Storage::query()->with("station")->whereHas("materialBox",function (Builder $box)use($ide){
+            $box->where("code",$ide);
+        })->whereNotNull("station_id")->first();
+        return $storage->station->code ?? null;
     }
 
     /**

+ 1 - 5
app/Services/StorageService.php

@@ -72,7 +72,7 @@ class StorageService
             ]);
             $stationTaskMaterialBox->loadMissing("station");
             //清理原有任务
-            app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]);
+            $this->clearTask([$stationTaskMaterialBox->station->code]);
             DB::commit();
         }catch (\Exception $e){
             DB::rollBack();
@@ -630,10 +630,6 @@ sql;
         StationTask::query()->where("status","!=",'完成')->whereIn("station_id",$station)->update([
             "status" => "完成"
         ]);
-        Storage::query()->whereIn("station_id",$station)->update([
-            "status" => 1,
-            "station_id" => null,
-        ]);
     }
 
     /**