Zhouzhendong 5 éve
szülő
commit
8f552e8ae5
1 módosított fájl, 15 hozzáadás és 11 törlés
  1. 15 11
      app/Http/Controllers/InventoryController.php

+ 15 - 11
app/Http/Controllers/InventoryController.php

@@ -25,7 +25,7 @@ class InventoryController extends Controller
         $ALTERNATE_SKU1=$request->input('ALTERNATE_SKU1');
         $LotAtt02_end=$request->input('LotAtt02_end');
         $sql='select * from (select result.*,rownum rn from (';
-        $sql.=' select customer.Descr_C 货主,stockLog.客户, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
+        $sql.=' select customer.Descr_C as 货主,stockLog.客户 客户, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
         $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
         $sql.=' lot.LotAtt04 批号 ';
         $sql.=' , sum(移出数量)移出数量, sum(移入数量)移入数量 ';
@@ -36,6 +36,7 @@ class InventoryController extends Controller
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
         if (!$date_start && !$date_end)$sql .= " and addtime >to_date('".date('Y-m-d H:i:s',strtotime("-1 day"))."','yyyy-mm-dd hh24:mi:ss') ";
         if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."%' ";
+        if ($SKU)$sql.=" and FMSKU like '".$SKU."%' ";
         $sql.=' group by TOCustomerID, TOLocation,FMSKU,FMLotNum union all ';
         $sql.=' select /*+INDEX(ACT_Transaction_Log I_ACT_TRANSACTION_LOG_TS)*/ FMLotNum,FMSKU,FMCUSTOMERID 客户,sum(FMQty_Each) as 移出数量, 0 as 移入数量, FMLOCATION as 库位 ';
         $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
@@ -43,6 +44,7 @@ class InventoryController extends Controller
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
         if (!$date_start && !$date_end)$sql .= " and addtime >to_date('".date('Y-m-d H:i:s',strtotime("-1 day"))."','yyyy-mm-dd hh24:mi:ss') ";
         if ($TOLocation)$sql .= " and FMLOCATION like '".$TOLocation."%' ";
+        if ($SKU)$sql.=" and FMSKU like '".$SKU."%' ";
         $sql.=' group by FMCustomerID, FMLocation,FMSKU,FMLotNum union all ';
         $sql.=' select FMLotNum,FMSKU,FMCUSTOMERID 客户,sum(FMQty_Each) as 移出数量,0 as 移入数量, FMLocation as 库位 ';
         $sql.=" from ACT_Transaction_Log  where TransactionType='MV' ";
@@ -50,6 +52,7 @@ class InventoryController extends Controller
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
         if (!$date_start && !$date_end)$sql .= " and addtime >to_date('".date('Y-m-d H:i:s',strtotime("-1 day"))."','yyyy-mm-dd hh24:mi:ss') ";
         if ($TOLocation)$sql .= " and FMLocation like '".$TOLocation."%' ";
+        if ($SKU)$sql.=" and FMSKU like '".$SKU."%' ";
         $sql.=' group by FMLocation,FMCUSTOMERID,FMSKU,FMLotNum union all ';
         $sql.=' select FMLotNum,FMSKU,TOCustomerID 客户,0 as 移出数量,sum(TOQty_Each)as 移入数量, TOLocation as 库位 ';
         $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
@@ -57,24 +60,25 @@ class InventoryController extends Controller
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
         if (!$date_start && !$date_end)$sql .= " and addtime >to_date('".date('Y-m-d H:i:s',strtotime("-1 day"))."','yyyy-mm-dd hh24:mi:ss') ";
         if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."%' ";
+        if ($SKU)$sql.=" and FMSKU like '".$SKU."%' ";
         $sql.=' group by TOLocation,TOCustomerID,FMSKU,FMLotNum)stockLog ';
         $sql.=' left join BAS_Customer customer on customer.CustomerID=stockLog.客户 ';
         $sql.=' left join BAS_SKU sku on sku.SKU=stockLog.FMSKU and sku.CUSTOMERID=stockLog.客户 ';
         $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM=stockLog.FMLOTNUM ';
         $sql.=' left join INV_LOT_LOC_ID storeStatus on storeStatus.LOTNUM=stockLog.FMLOTNUM ';;
-        $sql.=' and storeStatus.LocationID=stockLog.库位 where 1=1';
-        if ($LotAtt05)$sql .=" and lot.LotAtt05 like '".$LotAtt05."%' ";
-        if ($LotAtt02_start)$sql.=" and lot.LotAtt02 >='".$LotAtt02_start." 00:00:00' ";
-        if ($LotAtt02_end)$sql.=" and lot.LotAtt02 <='".$LotAtt02_end." 23:59:59' ";
-        if ($descr_c)$sql.=" and customer.descr_c ='".$descr_c."' ";
-        if ($SKU)$sql.=" and sku.SKU like '".$SKU."%' ";
-        if ($ALTERNATE_SKU1)$sql.=" and sku.ALTERNATE_SKU1 like '".$ALTERNATE_SKU1."%' ";
-        if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
+        $sql.=' and storeStatus.LocationID=stockLog.库位 ';
         $sql.=' group by 库位,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
         $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
         $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,stockLog.客户  ';
-        $sql.=' )result)  ';
-        if ($page&&$paginate)$sql.="  where rn>'".($page-1)*$paginate."'";dd($sql);
+        $sql.=' )result where 1=1 ';
+        if ($LotAtt05)$sql .=" and 属性仓 like '".$LotAtt05."%' ";
+        if ($LotAtt02_start)$sql.=" and 失效日期 >='".$LotAtt02_start." 00:00:00' ";
+        if ($LotAtt02_end)$sql.=" and 失效日期 <='".$LotAtt02_end." 23:59:59' ";
+        if ($descr_c)$sql.=" and 货主 ='".$descr_c."' ";
+        if ($ALTERNATE_SKU1)$sql.=" and 产品条码 like '".$ALTERNATE_SKU1."%' ";
+        if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
+        $sql.=' )  ';
+        if ($page&&$paginate)$sql.="  where rn>'".($page-1)*$paginate."'";
         return DB::connection('oracle')->select($sql);
     }