Просмотр исходного кода

缓存架入库:料箱清理的海柔状态变更
获取空箱时进行海柔任务校验

Zhouzhendong 4 лет назад
Родитель
Сommit
aa9990eb2e

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

@@ -54,7 +54,7 @@ class StorageController extends Controller
             //建立入库任务
             if (!app("StorageService")->putWareHousing($fromLocation,$box->id))$this->error("错误库位或库位已被下达任务");
             //库存记录
-            app("StorageService")->enterWarehouse($station->id, $box->id, $item->commodity_id ?? null, $amount, $box->material_box_model_id);
+            if (!app("StorageService")->enterWarehouse($station->id, $box->id, $item->commodity_id ?? null, $amount, $box->material_box_model_id))$this->error("库存异常");
 
             DB::connection("oracle")->transaction(function ()use($asns,$ide){ //单体嵌套事务 回滚FLUX失败任务
                 foreach ($asns as $asn)if (!app("StorageService")->fluxPA($asn,$ide,(int)$asn->fmqty)){
@@ -127,6 +127,12 @@ class StorageController extends Controller
             $data .= "存在任务待处理,无法释放";
             $boxes = array_values($boxes);
             $station = Station::query()->select("id")->whereIn("code",$boxes);
+            //清除海柔信息,标记料箱为出库
+            DB::connection("mysql_haiRobotics")->table("ks_bin")->whereIn("ks_bin_space_code",$boxes)
+                ->where("status",1)->update([
+                "ks_bin_space_code" => null,"ks_bin_space_id"=>null,"orig_ks_bin_space_code"=>null,"orig_ks_bin_space_id"=>null,
+                "status"=>4,
+            ]);
         }
         $task = StationTask::query()->select("id")->where("status","!=",'完成')->whereIn("station_id",$station);
         StationTaskMaterialBox::query()->where("status","!=",'完成')->whereIn("station_task_id",$task)->update([

+ 2 - 21
app/Http/Controllers/TestController.php

@@ -67,6 +67,7 @@ use App\Services\InventoryCompareService;
 use App\Services\LogisticService;
 use App\Services\LogisticZopService;
 use App\Services\LogService;
+use App\Services\MaterialBoxService;
 use App\Services\MenuService;
 use App\Services\OracleDocAsnHerderService;
 use App\Services\OracleDOCOrderHeaderService;
@@ -141,27 +142,7 @@ class TestController extends Controller
 
     public function test1()
     {
-        $storage = \App\Storage::query()->where("material_box_id",437)->lockForUpdate()->first();
-        $obj = [
-            "station_id" => 12,
-            "material_box_id" => 437,
-            "commodity_id" => null,
-            "amount" => 10,
-            "status" => 1,
-        ];
-        if ($storage){
-            $obj["amount"] = DB::raw("amount+10");
-            //$storage->update($obj);
-            $amount = (int)$storage->amount + (int)10;
-        } else //Storage::query()->create($obj);
-
-        dd($obj);
-        dd($obj);
-        $stations = Station::query()->select("id")->where("parent_id",6);
-        $storages = \App\Storage::query()->with("station:id,code")->whereIn("station_id",$stations)->where(function (Builder $query){
-            $query->whereNotNull("material_box_id")->orWhere("status",1);
-        })->get();
-        dd(array_column($storages->toArray(),"id"));
+        dd(app(MaterialBoxService::class)->getAnEmptyBox());
     }
 
     public function test2()

+ 9 - 0
app/Services/MaterialBoxService.php

@@ -32,6 +32,7 @@ class MaterialBoxService
     {
         $id = 0;
         while (true){
+            //检测WAS
             $boxes = MaterialBox::query()->select('id',"code")
                 ->whereNotIn("id",$blacklist)
                 ->where("id",">",$id)->where("code","like","IDE%")
@@ -41,11 +42,19 @@ class MaterialBoxService
             if ($modelId)$boxes->where("material_box_model_id",$modelId);
             $boxes = $boxes->get();
             if ($boxes->count()==0)break;
+            //检测海柔的有效料箱
             $haiBoxes = DB::connection("mysql_haiRobotics")->table("ks_bin")
                 ->where("status",1)->whereIn("ks_bin_code",array_column($boxes->toArray(),"code"))->get();
             if ($haiBoxes->count()==0)continue;
             $haiBoxes->each(function ($haiBox)use(&$codes){$codes[$haiBox->ks_bin_code] = true;});
             foreach ($boxes as $index=>$box)if (!isset($codes[$box->code]))$boxes->splice($index,1);
+            //剔除有任务待处理的料箱
+            $haiBoxes = DB::connection("mysql_haiRobotics_ess")->table("ks_ess_task_detail")
+                ->whereIn("bin_code",array_column($boxes->toArray(),"code"))
+                ->whereNotIn("status",[0,4])->get();
+            $haiBoxes->each(function ($haiBox)use(&$notCodes){$notCodes[$haiBox->bin_code] = true;});
+            foreach ($boxes as $index=>$box)if (isset($notCodes[$box->code]))$boxes->splice($index,1);
+            //检测FLUX
             $ides = [];
             $str = "(";
             for ($i=0;$i<count($boxes)-1;$i++){

+ 4 - 1
app/Services/StorageService.php

@@ -86,6 +86,8 @@ class StorageService
         if ($storage->status == 1)$update["status"] = 0;
         if ($storage->station_id)$update["station_id"] = null;
         if ($update)$storage->update($update);
+        //一号缓存架操作完下达补充料箱
+        if ($storage->prent_id == 6)app("ForeignHaiRoboticsService")->paddingCacheShelf(Station::query()->where("code",$stationTaskMaterialBox->station_id)->get());
     }
 
     /**
@@ -202,9 +204,10 @@ class StorageService
                 "status" => 1,
             ];
             if ($storage){
+                $amountTemp = (int)$storage->amount + (int)$amount;
                 $obj["amount"] = DB::raw("amount+{$amount}");
                 $storage->update($obj);
-                $amount = (int)$storage->amount + (int)$amount;
+                $amount = $amountTemp;
             } else Storage::query()->create($obj);
             if ($commodityId && $modelId){
                 //维护料箱最大上限 用于半箱补货

+ 15 - 0
config/database.php

@@ -78,6 +78,21 @@ return [
             'engine' => null,
         ],
 
+        'mysql_haiRobotics_ess' => [
+            'driver' => 'mysql',
+            'host' => '58.33.243.164',
+            'port' => '3306',
+            'database' => 'wms_ess',
+            'username' => 'root',
+            'password' => 'root',
+            'unix_socket' => '',
+            'charset' => 'utf8mb4',
+            'collation' => 'utf8mb4_unicode_ci',
+            'prefix' => '',
+            'strict' => false,
+            'engine' => null,
+        ],
+
         'oracle' => [
             'driver' => env('ORACLE_DRIVER', 'oracle'),
             'host' => env('ORACLE_HOST', '47.103.12.61'),