|
@@ -55,7 +55,9 @@ sql;
|
|
|
public function getEaInventoryByCustomerAndSku($customer,array $skuArr): array
|
|
public function getEaInventoryByCustomerAndSku($customer,array $skuArr): array
|
|
|
{
|
|
{
|
|
|
$db = DB::connection("oracle");
|
|
$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
|
|
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
|
|
from INV_LOT_LOC_ID
|
|
|
left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
|
|
left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
|
|
@@ -63,9 +65,9 @@ where BAS_LOCATION.LOCATIONUSAGE = 'EA'
|
|
|
AND customerid = ?
|
|
AND customerid = ?
|
|
|
|
|
|
|
|
sql;
|
|
sql;
|
|
|
- if (count($skuArr) > 0) {
|
|
|
|
|
|
|
+ if (count($item) > 0) {
|
|
|
$sql .= " and sku in (";
|
|
$sql .= " and sku in (";
|
|
|
- foreach ($skuArr as $index => $str) {
|
|
|
|
|
|
|
+ foreach ($item as $index => $str) {
|
|
|
if ($index == 0) {
|
|
if ($index == 0) {
|
|
|
$sql .= "'" . $str . "'";
|
|
$sql .= "'" . $str . "'";
|
|
|
continue;
|
|
continue;
|
|
@@ -74,8 +76,10 @@ sql;
|
|
|
}
|
|
}
|
|
|
$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下的拣货库位
|
|
//整合同sku下的拣货库位
|
|
|
$tmpArray = array();
|
|
$tmpArray = array();
|
|
|
foreach ($info as $row) {
|
|
foreach ($info as $row) {
|
|
@@ -108,26 +112,30 @@ sql;
|
|
|
public function getRsInventoryByCustomerAndSku($customer,array $skuArr): array
|
|
public function getRsInventoryByCustomerAndSku($customer,array $skuArr): array
|
|
|
{
|
|
{
|
|
|
$db = DB::connection("oracle");
|
|
$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
|
|
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
|
|
from INV_LOT_LOC_ID
|
|
|
left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
|
|
left join BAS_LOCATION on BAS_LOCATION.LOCATIONID = INV_LOT_LOC_ID.LOCATIONID
|
|
|
where BAS_LOCATION.LOCATIONUSAGE = 'RS'
|
|
where BAS_LOCATION.LOCATIONUSAGE = 'RS'
|
|
|
AND customerid = ?
|
|
AND customerid = ?
|
|
|
sql;
|
|
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下的存储库位
|
|
//整合同sku下的存储库位
|
|
|
$tmpArray = array();
|
|
$tmpArray = array();
|
|
|
foreach ($info as $row) {
|
|
foreach ($info as $row) {
|
|
@@ -146,4 +154,31 @@ sql;
|
|
|
}
|
|
}
|
|
|
return $tmpArray;
|
|
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;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|