Преглед изворни кода

Merge branch 'master' into yang-package

ANG YU пре 4 година
родитељ
комит
508e1490c2

+ 7 - 0
app/Http/Controllers/HandInStorageController.php

@@ -8,6 +8,7 @@ use App\OracleDOCASNHeader;
 use App\Services\HandInStorageService;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
 
 class HandInStorageController extends Controller
 {
@@ -81,12 +82,15 @@ class HandInStorageController extends Controller
      */
     public function getBasSkuWithLot(Request $request): array
     {
+        $start=microtime(true);
         $customerid= $request->input('customerid');
         $skuOrBarcode= $request->input('sku');
         $asnno= $request->input('asnno');
         $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
         if (!$asnDetail)$this->error('无效条码');
         $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
+        $end=microtime(true);
+        if(($end-$start)>1)Log::warning('手持条码获取详情超时',$request->all());
         if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
         else $this->error('无效条码');
     }
@@ -97,6 +101,7 @@ class HandInStorageController extends Controller
      */
     public function fluxHandIn(Request $request)
     {
+        $start=microtime(true);
         $this->gate("入库管理-手持入库-收货");
         $info=$request->input('info');
         if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期');
@@ -119,6 +124,8 @@ class HandInStorageController extends Controller
             $result = $handInStorageService->fluxHandIn($info);
             if ($result){
                 $asnQty=$handInStorageService->getAsnQty($info['asnno']);
+                $end=microtime(true);
+                if(($end-$start)>2)Log::warning('手持收货超时',$request->all());
                 $this->success($asnQty);
             } else $this->error("收货失败");
         } catch (\Exception $e) {

+ 7 - 6
app/Http/Controllers/TestController.php

@@ -133,14 +133,15 @@ sql;
             dd($e);
         }
     }
-
     public function test()
     {
-        /** @var OwnerPriceOperationService $service */
-        $service = app("OwnerPriceOperationService");
-        $GLOBALS["FEE_INFO"] = [];
-        $store = Store::query()->where('asn_code',"ASN2108271548")->first();
-        dd($service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库"),$store->toArray());
+        $models = app("MaterialBoxModelService")->getModelSortedByOwner(null);
+        foreach ($models as $model){
+            $box = app("MaterialBoxService")->getAnEmptyBox($model,[],2);
+            dd($box);
+            if ($box)return $box;
+        }
+        dd();
         TaskTransaction::query()->where("id",">=",280)->delete();
         /*$a= new StorageService();
         $a->clearTask(["HAIB1-01-01"]);

+ 3 - 9
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -354,14 +354,8 @@ class StorageController
     public function paddingEmptyBox()
     {
         $amount = \request("amount") ?: 1;
-        $blacklist = [];
-        $boxes = "";
-        for ($i=0;$i<$amount;$i++){
-            $box = app("MaterialBoxService")->getAnEmptyBoxSortedByOwner(null,$blacklist);
-            if (!$box)break;
-            $boxes .= $box->code.",";
-            $blacklist[] = $box->id;
-        }
-        $this->success(rtrim($boxes,","));
+        $boxes = app("MaterialBoxService")->getAnEmptyBoxSortedByOwner(null,[],$amount);
+        if (!is_array($boxes))$boxes = [$boxes];
+        $this->success(implode(",",array_column($boxes,"code")));
     }
 }

+ 2 - 2
app/OracleIdxAsrsReceive.php

@@ -40,9 +40,9 @@ class OracleIdxAsrsReceive extends Model
             foreach($logisticNumbers_toInsert as $logisticNumber){
                 if (!$logisticNumber)continue;
                 $inserts .= " into idx_asrs_receive (grouptaskid,grouptasksequence,userdefine1,userdefine2,addwho,addtime)values(?,?,?,?,?,?) ";
-                $values[] = $logisticNumber??'';
+                $values[] = $logisticNumber;
                 $values[] = 1;
-                $values[] = $logisticNumber??'';
+                $values[] = $logisticNumber;
                 $values[] = $weight;
                 $values[] = 'WAS';
                 $values[] = Carbon::now();

+ 27 - 9
app/Services/MaterialBoxService.php

@@ -23,12 +23,14 @@ class MaterialBoxService
      *
      * @param MaterialBoxModel|\stdClass $model
      * @param array $blacklist
+     * @param int $multi
      *
-     * @return MaterialBox|null
+     * @return MaterialBox|null|array
      */
-    public function getAnEmptyBox(MaterialBoxModel $model,array $blacklist = []):?MaterialBox
+    public function getAnEmptyBox(MaterialBoxModel $model,array $blacklist = [], int $multi = 1)
     {
         $id = 0;
+        $tarBoxes = [];
         while (true){
             //检测WAS
             $boxes = MaterialBox::query()->select('id',"code")
@@ -60,9 +62,14 @@ SELECT LOCATIONID FROM (SELECT LOCATIONID FROM (SELECT LOCATIONID,SUM(QTY+QTYPA)
                             LOCATIONID HAVING (COUNT(*)>={$model->maximum_kind})
 sql;
             foreach (DB::connection("oracle")->select(DB::raw($sql)) as $item)unset($ides[$item->locationid]);
-            if ($ides)return current($ides);
+            foreach ($ides as $box){
+                $tarBoxes[] = $box;
+                $multi--;
+                if (!$multi)break 2;
+            }
         }
-        return null;
+        $len = count($tarBoxes);
+        return $len==1 ? $tarBoxes[0] : ($len==0 ? null : $tarBoxes);
     }
 
     public function checkHaiQ(array $boxCodes)
@@ -85,17 +92,28 @@ sql;
      *
      * @param integer|null $ownerId
      * @param array $blacklist
+     * @param int $multi
      *
-     * @return MaterialBox|null
+     * @return MaterialBox|null|array
      */
-    public function getAnEmptyBoxSortedByOwner(?int $ownerId=null, array $blacklist=[]):?MaterialBox
+    public function getAnEmptyBoxSortedByOwner(?int $ownerId=null, array $blacklist=[], int $multi = 1)
     {
         $models = app("MaterialBoxModelService")->getModelSortedByOwner($ownerId);
+        $tarBoxes = [];
         foreach ($models as $model){
-            $box = $this->getAnEmptyBox($model,$blacklist);
-            if ($box)return $box;
+            $box = $this->getAnEmptyBox($model,$blacklist,$multi);
+            if (!$box)continue;
+            if (is_array($box)){
+                $tarBoxes = array_merge($tarBoxes,$box);
+                $multi -= count($box);
+            }else{
+                $tarBoxes[] = $box;
+                $multi--;
+            }
+            if (!$multi)break;
         }
-        return null;
+        $len = count($tarBoxes);
+        return $len==1 ? $tarBoxes[0] : ($len==0 ? null : $tarBoxes);
     }
 
     /**

+ 0 - 1
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -295,7 +295,6 @@
                             if (res.data.success){
                                 this.asnDetails=res.data.data;
                                 this.$forceUpdate()
-                                return;
                             }else {
                                 window.tempTip.setDuration(3000);
                                 window.tempTip.show(res.data.data);