Explorar el Código

动库报表增加条件查询

Zhouzhendong hace 4 años
padre
commit
0e332e713e

+ 0 - 1
app/Http/Controllers/InventoryController.php

@@ -27,7 +27,6 @@ class InventoryController extends Controller
         if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
         $oracleActTransactingLogs=app('inventoryService')->paginate($request->input());
         $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
-//        $owners=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
         $owners=Owner::filterAuthorities()->select(['code', 'name'])->get();
         $isTotalStock=false;
         $page = $request->page ?? 1;

+ 6 - 11
app/Services/InventoryService.php

@@ -30,6 +30,7 @@ class InventoryService
         $SKU=$params['SKU'] ?? null;
         $ALTERNATE_SKU1=$params['ALTERNATE_SKU1'] ?? null;
         $LotAtt02_end=$params['LotAtt02_end'] ?? null;
+        $commodityName=$params['commodity_name'] ?? null;
         $sql='select * from (select result.*,rownum rn from (';
         $sql.=' select customer.Descr_C as 货主,stockLog.客户 客户, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
         $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
@@ -40,8 +41,6 @@ class InventoryService
         $sql.=" from ACT_Transaction_Log where TransactionType='PA' ";
         if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
-//        if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."' ";
-//        if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
         if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"TOLocation");
         if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
         if ($customerid){
@@ -66,8 +65,6 @@ class InventoryService
         $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
         if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
-//        if ($TOLocation)$sql .= " and FMLOCATION like '".$TOLocation."' ";
-//        if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
         if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"FMLOCATION");
         if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
         if ($customerid){
@@ -92,8 +89,6 @@ class InventoryService
         $sql.=" from ACT_Transaction_Log  where TransactionType='MV' ";
         if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
-//        if ($TOLocation)$sql .= " and FMLocation like '".$TOLocation."' ";
-//        if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
         if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"FMLocation");
         if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
 
@@ -119,8 +114,6 @@ class InventoryService
         $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
         if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
         if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
-//        if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."' ";
-//        if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
         if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"TOLocation");
         if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
 
@@ -146,16 +139,18 @@ class InventoryService
         $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.库位 ';
+        $sql.=' and storeStatus.LocationID=stockLog.库位 WHERE 1=1 ';
+        if ($commodityName){
+            $commodityName = str_replace("'",'"',$commodityName);
+            $sql .= " AND sku.Descr_C like '".$commodityName."%' ";
+        }
         $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 where 1=1 ';
-//        if ($LotAtt05)$sql .=" and 属性仓 like '".$LotAtt05."' ";
         if ($LotAtt05)$sql=$this->sqlSearchWay($sql,$LotAtt05,"属性仓");
         if ($LotAtt02_start)$sql.=" and 失效日期 >='".$LotAtt02_start." 00:00:00' ";
         if ($LotAtt02_end)$sql.=" and 失效日期 <='".$LotAtt02_end." 23:59:59' ";
-//        if ($ALTERNATE_SKU1)$sql.=" and 产品条码 like '".$ALTERNATE_SKU1."' ";
         if ($ALTERNATE_SKU1)$sql=$this->sqlSearchWay($sql,$ALTERNATE_SKU1,"产品条码");
         if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
         $sql.=' )  ';

+ 1 - 1
app/Traits/ModelSearchWay.php

@@ -38,7 +38,7 @@ trait ModelSearchWay
                 $sql .= ') ';
                 unset($condition);
             } else {
-                $sql .= " and $column like '".$condition."' ";
+                $sql .= " and $column like '".$condition."%' ";
             }
         }
         return $sql;

+ 1 - 0
resources/views/inventory/statement/changeInventory.blade.php

@@ -86,6 +86,7 @@
                         {name:'SKU',type:'input',tip:'可支持多产品编码,糊模查找需要在左边打上%符号',placeholder: '产品编码'},
                         {name:'ALTERNATE_SKU1',type:'input',tip:'可支持多产品条码,糊模查找需要在左边打上%符号',placeholder: '产品条码'},
                         {name:'LotAtt02_end',type:'dateTime',tip:'选择显示失效日期的结束时间'},
+                        {name:'commodity_name',type:'input',tip:'商品名称模糊搜索,请配合其余条件一起使用,加%为全量模糊',placeholder: '商品名称'},
                     ],
                 ];
                 this.form = new query({