소스 검색

补货查询修改

haozi 4 년 전
부모
커밋
a163dbabf3
2개의 변경된 파일52개의 추가작업 그리고 17개의 파일을 삭제
  1. 51 16
      app/Services/ReplenishmentService.php
  2. 1 1
      resources/views/personnel/laborReport/index.blade.php

+ 51 - 16
app/Services/ReplenishmentService.php

@@ -55,7 +55,9 @@ sql;
     public function getEaInventoryByCustomerAndSku($customer,array $skuArr): array
     {
         $db = DB::connection("oracle");
-        $sql = <<<sql
+        $info=array();
+        foreach (array_chunk($skuArr,1000) as $item){
+            $sql = <<<sql
 select INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,sum(INV_LOT_LOC_ID.QTY) qty
 from INV_LOT_LOC_ID
          left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
@@ -63,9 +65,9 @@ where BAS_LOCATION.LOCATIONUSAGE = 'EA'
   AND customerid = ?
 
 sql;
-        if (count($skuArr) > 0) {
+        if (count($item) > 0) {
             $sql .= " and sku in (";
-            foreach ($skuArr as $index => $str) {
+            foreach ($item as $index => $str) {
                 if ($index == 0) {
                     $sql .= "'" . $str . "'";
                     continue;
@@ -74,8 +76,10 @@ sql;
             }
             $sql .= ")";
         }
-        $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID';
-        $info= $db->select(DB::raw($sql),[$customer]);
+            $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID';
+            $info[]= $db->select(DB::raw($sql),[$customer]);
+        }
+        $info = array_merge(...$info);
         //整合同sku下的拣货库位
         $tmpArray = array();
         foreach ($info as $row) {
@@ -108,26 +112,30 @@ sql;
     public function getRsInventoryByCustomerAndSku($customer,array $skuArr): array
     {
         $db = DB::connection("oracle");
-        $sql = <<<sql
+        $info=array();
+        foreach (array_chunk($skuArr,1000) as $item){
+            $sql = <<<sql
 select INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM,sum(INV_LOT_LOC_ID.QTY) qty
 from INV_LOT_LOC_ID
          left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
 where BAS_LOCATION.LOCATIONUSAGE = 'RS'
   AND customerid = ?
 sql;
-        if (count($skuArr) > 0) {
-            $sql .= " and sku in (";
-            foreach ($skuArr as $index => $str) {
-                if ($index == 0) {
-                    $sql .= "'" . $str . "'";
-                    continue;
+            if (count($item) > 0) {
+                $sql .= " and sku in (";
+                foreach ($item as $index => $str) {
+                    if ($index == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
                 }
-                $sql .= ",'" . $str . "'";
+                $sql .= ")";
             }
-            $sql .= ")";
+            $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM order by qty desc';
+            $info[]= $db->select(DB::raw($sql),[$customer]);
         }
-        $sql.= ' group by INV_LOT_LOC_ID.CUSTOMERID,INV_LOT_LOC_ID.SKU,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM order by qty desc';
-        $info= $db->select(DB::raw($sql),[$customer]);
+        $info=array_merge(...$info);
         //整合同sku下的存储库位
         $tmpArray = array();
         foreach ($info as $row) {
@@ -146,4 +154,31 @@ sql;
         }
         return $tmpArray;
     }
+
+    public function combinationSql(array $skuArr,$sql)
+    {
+        foreach (array_chunk($skuArr,1000) as $index=>$item){
+            if ($index==0){
+                $sql .= " and sku in (";
+                foreach ($item as $i => $str) {
+                    if ($i == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
+                }
+            }else{
+                $sql .= " or sku in (";
+                foreach ($item as $a => $str) {
+                    if ($a == 0) {
+                        $sql .= "'" . $str . "'";
+                        continue;
+                    }
+                    $sql .= ",'" . $str . "'";
+                }
+            }
+            $sql .= ")";
+        }
+        return $sql;
+    }
 }

+ 1 - 1
resources/views/personnel/laborReport/index.blade.php

@@ -326,7 +326,7 @@
                     if(tokenOfBroadcastEnterAndLeave){
                         Echo.channel('{{$laravelEchoPrefix}}'+tokenOfBroadcastEnterAndLeave).listen('ImportEvent',(e)=>{
                             let labor=e.laborReport;
-                            laborReports.push(labor);
+                            laborReports.unshift(labor);
 
                             // setTimeout(function () {
                             //     window.location.reload();