Selaa lähdekoodia

盘点生成动盘任务 在库数量为0的任务筛选是否生成

haozi 4 vuotta sitten
vanhempi
commit
8ce5574b25

+ 3 - 3
app/Http/Controllers/InventoryAccountController.php

@@ -41,7 +41,7 @@ class InventoryAccountController extends Controller
     public function createStockInventoryMission(Request $request)
     {
         if (!Gate::allows("库存管理-盘点")) {
-            return redirect(url('/'));
+            return ['success' => false ,'message' => '没有对应权限'];
         }
 //        $date_start=$request->input('formData.date_start');
 //        $date_end=$request->input('formData.date_end');
@@ -51,8 +51,8 @@ class InventoryAccountController extends Controller
         $ownerId = $request->input('owner_id');
         $location = $request->input('location');
         $barcode = $request->input('barcode');
-        $inventoryAccount = app('inventoryAccountService')->createMission($date_start, $date_end, $ownerId, $location, $barcode);
-        $inventoryAccount = InventoryAccount::with('owner')->find($inventoryAccount->id);
+        $inventory = app('inventoryAccountService')->createMission($date_start, $date_end, $ownerId, $location, $barcode);
+        $inventoryAccount = InventoryAccount::with('owner')->find($inventory->id);
         if (is_null($inventoryAccount)) return ['success' => false, 'data' => '参数错误!'];
         return ['success' => true, 'data' => $inventoryAccount];
     }

+ 2 - 2
app/Services/HandInStorageService.php

@@ -834,7 +834,7 @@ select BAS_SKU.SKU,INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_
 sql;
         if ($this->checkUserOwnerAuth($param)) { //输入条件为货主
             $sql .= ' INV_LOT_LOC_ID.CUSTOMERID= ?';
-        } else if (preg_match('/^[A-Z]{1,3}[0-9]{2,3}[-][0-9]{2,3}[-][0-9]{2,3}$/', $param)) { //判断是否为库位
+        } else if (preg_match('/^[A-Z]{1,3}[0-9]{2,3}[-][0-9]{2,3}[-][0-9]{2,3}$/', $param) ||strpos($param,'IDE') !== false) { //判断是否为库位
             $sql .= ' INV_LOT_LOC_ID.LOCATIONID= ?';
         } else {
             $sql .= " BAS_SKU.SKU in (  select SKU from BAS_SKU where ALTERNATE_SKU1=? union
@@ -848,7 +848,7 @@ sql;
         if ($this->checkUserOwnerAuth($param)){
             $invLots = DB::connection("oracle")->select(DB::raw($sql), [strtoupper($param)
             ]);
-        }else if(preg_match('/^[A-Z]{1,3}[0-9]{2,3}[-][0-9]{2,3}[-][0-9]{2,3}$/', $param)){
+        }else if(preg_match('/^[A-Z]{1,3}[0-9]{2,3}[-][0-9]{2,3}[-][0-9]{2,3}$/', $param) ||strpos($param,'IDE') !== false){
             $invLots = DB::connection("oracle")->select(DB::raw($sql), [$param]);
         }else{
             $invLots = DB::connection("oracle")->select(DB::raw($sql), [$param,$param,$param,$param]);

+ 14 - 0
app/Services/InventoryAccountService.php

@@ -77,21 +77,25 @@ class InventoryAccountService
         $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
         $sql.=' (select FMLotNum,FMSKU,TOCustomerID 客户,0 as 移出数量, sum(TOQty_Each) as 移入数量, TOLocation as 库位 ';
         $sql.=" from ACT_Transaction_Log where TransactionType='PA' ";
+        if ($code)$sql.=" and TOCustomerID = '".$code."' ";
         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') ";
         $sql.=' group by TOCustomerID, TOLocation,FMSKU,FMLotNum union all ';
         $sql.=' select FMLotNum,FMSKU,FMCUSTOMERID 客户,sum(FMQty_Each) as 移出数量, 0 as 移入数量, FMLOCATION as 库位 ';
         $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
+        if ($code)$sql.=" and FMCUSTOMERID = '".$code."' ";
         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') ";
         $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' ";
+        if ($code)$sql.=" and FMCUSTOMERID = '".$code."' ";
         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') ";
         $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' ";
+        if ($code)$sql.=" and TOCustomerID = '".$code."' ";
         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') ";
         $sql.=' group by TOLocation,TOCustomerID,FMSKU,FMLotNum)stockLog ';
@@ -211,7 +215,17 @@ class InventoryAccountService
             if ($location||$barcode)$type='局部盘点';
             if (!$location&&!$barcode)$type='动盘';
             $wmsInventories=$this->conditionPortStock($date_start,$date_end,$ownerId,$location,$barcode);
+            //动盘  判断库存为0的ide料想是否放有其他商品
+            foreach ($wmsInventories as $key=>$wmsInventory){
+                if (!$wmsInventory->在库数量 && strpos($wmsInventory->库位,'IDE') !== false){
+                    /** @var HandInStorageService $handInStorageService  */
+                    $handInStorageService=app('HandInStorageService');
+                    $invs=$handInStorageService->getInventoryInfos($wmsInventory->库位);
+                    if (count($invs)>0) unset($wmsInventories[$key]);
+                }
+            }
         }
+
         if (!$date_start&&!$date_end){
             $ownerName=Owner::where('id',$ownerId)->value('code');
             //$ownerName=OracleBasCustomer::where('customer_type','OW')->where('active_flag','Y')->where('descr_c',$name)->value('customerid');