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

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

LD пре 5 година
родитељ
комит
50ee6bf3c6

+ 21 - 5
app/Imports/UpdatePickZone.php

@@ -103,7 +103,7 @@ class UpdatePickZone implements ToCollection,WithHeadingRow
             $result = null;
             if (count($lots) == 1)$result = $lots[0];
             else {
-                $zone = ["拣货","存储","虚拟"];
+                $zone = ["存储","拣货","虚拟"];
                 $zones = [[],[],[]];
                 foreach ($lots as $lot){
                     foreach ($zone as $ind=>$str){
@@ -114,9 +114,15 @@ class UpdatePickZone implements ToCollection,WithHeadingRow
                     }
                 }
                 foreach ($zones as $zl){
-                    $result = $this->matching($zl,$item["数量"]);
+                    $result = $this->matchingMax($zl,$item["数量"]);
                     if ($result)break;
                 }
+                if (!$result){
+                    foreach ($zones as $zl){
+                        $result = $this->matchingMin($zl,$item["数量"]);
+                        if ($result)break;
+                    }
+                }
             }
             if ($result){
                 try{
@@ -170,19 +176,29 @@ class UpdatePickZone implements ToCollection,WithHeadingRow
         Cache::put("commodityAssign",["success"=>true,"data"=>$models,"errors"=>$errors]);
     }
 
-    private function matching($lots, $amount)
+    private function matchingMax($lots, $amount)
     {
         if (!$lots) return null;
-        $min = null;
         $max = null;
         $map = [];
         foreach ($lots as $i => $l){
             $qty = (int)$l->qty;
             $map[$qty] = $i;
             if (($qty >= $amount && $qty<=$max) || $max===null)$max = $qty;
-            if (($qty < $amount && $qty>=$min) || $min===null)$min = $qty;
         }
         if ($max !== null)return $lots[$map[$max]];
+        return null;
+    }
+    private function matchingMin($lots, $amount)
+    {
+        if (!$lots) return null;
+        $min = null;
+        $map = [];
+        foreach ($lots as $i => $l){
+            $qty = (int)$l->qty;
+            $map[$qty] = $i;
+            if (($qty < $amount && $qty>=$min) || $min===null)$min = $qty;
+        }
         if ($min !== null)return $lots[$map[$min]];
         return null;
     }

+ 1 - 1
resources/views/customer/customer/_relatedOwner.blade.php

@@ -9,7 +9,7 @@
                     <div class="row">
                         <label for="ownerSelectpicker" class="col-2 offset-1">选择货主</label>
                         <select data-none-results-text="货主不存在" id="ownerSelectpicker" class="selectpicker col-5" multiple data-live-search="true" title="项目(多选)" {{--v-model="ownerIds[customers[index]['id']]"--}}>
-                            <option v-for="owner in owners" :value="owner.id">@{{ owner.name }}</option>
+                            <option v-for="owner in owners" :value="owner">@{{ owner.name }}</option>
                         </select>
                     </div>
                     <div class="row m-2" v-if="index!==''">