|
|
@@ -67,7 +67,7 @@ class InventoryAccountService
|
|
|
$descr_c=Owner::where('id',$ownerId)->value('name');
|
|
|
$sql='select * from (select result.*,rownum rn from (';
|
|
|
$sql.=' select customer.Descr_C as 货主,stockLog.客户 客户, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码1, sku.ALTERNATE_SKU2 产品条码2, sku.ALTERNATE_SKU3 产品条码3, ';
|
|
|
- $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
|
|
|
+ $sql.=' sku.Descr_C 商品名称, MAX(lot.LotAtt05) 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
|
|
|
$sql.=' lot.LotAtt04 批号, lot.LotAtt01 生产日期';
|
|
|
$sql.=' , sum(移出数量)移出数量, sum(移入数量)移入数量 ';
|
|
|
$sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
|
|
|
@@ -97,12 +97,29 @@ class InventoryAccountService
|
|
|
$sql.=' left join INV_LOT_LOC_ID storeStatus on storeStatus.LOTNUM=stockLog.FMLOTNUM ';;
|
|
|
$sql.=' and storeStatus.LocationID=stockLog.库位 ';
|
|
|
$sql.=' group by 库位,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1,sku.ALTERNATE_SKU2,sku.ALTERNATE_SKU3 ';
|
|
|
- $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt05,lot.LotAtt01,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
|
|
|
+ $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt01,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
|
|
|
$sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,stockLog.客户 ';
|
|
|
$sql.=' )result where 1=1 ';
|
|
|
if ($descr_c)$sql.=" and 货主 = '".$descr_c."' ";
|
|
|
- if ($location)$sql.=" and 库位 like '".$location."%' ";
|
|
|
- if ($barcode)$sql=$this->动盘局部盘点按条码查询($sql,$barcode);
|
|
|
+// if ($location)$sql.=" and 库位 like '".$location."%' ";
|
|
|
+ if ($location){
|
|
|
+ $arr=array_filter(preg_split('/[,, ]+/is', $location));
|
|
|
+ if (count($arr)==1){
|
|
|
+ $sql.=" and 库位 like '".$location."%'";
|
|
|
+ }
|
|
|
+ if (count($arr)>1){
|
|
|
+ $sql.=" and (库位 like ";
|
|
|
+ foreach ($arr as $index=>$str){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$str."%'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.= "or 库位 like'".$str."%'";
|
|
|
+ }
|
|
|
+ $sql.=")";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($barcode)$sql=$this->按条码查询($sql,$barcode);
|
|
|
$sql.=' ) ';
|
|
|
return DB::connection('oracle')->select($sql);
|
|
|
}
|
|
|
@@ -111,64 +128,41 @@ class InventoryAccountService
|
|
|
$descr_c=Owner::where('id',$ownerId)->value('name');
|
|
|
$sql='select * from (select result.* from (';
|
|
|
$sql.=' select customer.Descr_C as 货主,storeStatus.CUSTOMERID 客户,storeStatus.LocationID 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码1, sku.ALTERNATE_SKU2 产品条码2, sku.ALTERNATE_SKU3 产品条码3, ';
|
|
|
- $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
|
|
|
+ $sql.=' sku.Descr_C 商品名称, MAX(lot.LotAtt05) 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
|
|
|
$sql.=' lot.LotAtt04 批号,lot.LotAtt01 生产日期 ';
|
|
|
$sql.=' , SUM(storeStatus.QTY) 在库数量, SUM(storeStatus.QtyAllocated) 占用数量 from ';
|
|
|
$sql.=' INV_LOT_LOC_ID storeStatus';
|
|
|
$sql.=' left join BAS_Customer customer on customer.CustomerID=storeStatus.CUSTOMERID ';
|
|
|
$sql.=' left join BAS_SKU sku on sku.SKU=storeStatus.SKU and sku.CUSTOMERID=storeStatus.CUSTOMERID ';
|
|
|
$sql.=' left join INV_LOT_ATT lot on lot.LOTNUM = storeStatus.LOTNUM AND lot.CUSTOMERID = storeStatus.CUSTOMERID ';
|
|
|
- if ($location)$sql.=" where storeStatus.LocationID like '".$location."%' ";
|
|
|
- if ($barcode&&$location)$sql=$this->局部盘点按条码查询_有库位前缀字母($sql,$barcode);
|
|
|
- if ($barcode&&!$location)$sql=$this->局部盘点按条码查询_无库位前缀字母($sql,$barcode);
|
|
|
$sql.=' group by storeStatus.LocationID,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1,sku.ALTERNATE_SKU2,sku.ALTERNATE_SKU3 ';
|
|
|
- $sql.=' ,sku.Descr_C,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
|
|
|
+ $sql.=' ,sku.Descr_C,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
|
|
|
$sql.=' ,storeStatus.CUSTOMERID,lot.LotAtt01 ';
|
|
|
$sql.=' )result where 1=1 ';
|
|
|
if ($descr_c)$sql.=" and 货主 = '".$descr_c."' ";
|
|
|
- if ($location&&$barcode)$sql.=" and 库位 like '".$location."%' ";
|
|
|
- $sql.=' ) ';
|
|
|
- return DB::connection('oracle')->select($sql);
|
|
|
-
|
|
|
- }
|
|
|
- private function 局部盘点按条码查询_有库位前缀字母($sql,$barcode){
|
|
|
- $arr=array_filter(preg_split('/[,, ]+/is', $barcode));
|
|
|
- if (count($arr)==1){
|
|
|
- $sql.=" and (sku.ALTERNATE_SKU1 like '".$barcode."%' or sku.ALTERNATE_SKU2 like '".$barcode."%' or sku.ALTERNATE_SKU3 like '".$barcode."%')";
|
|
|
- }
|
|
|
- if (count($arr)>1){
|
|
|
- $sql.=" and (sku.ALTERNATE_SKU1 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
- }
|
|
|
- $sql.=",'".$str."'";
|
|
|
+ if ($location){
|
|
|
+ $arr=array_filter(preg_split('/[,, ]+/is', $location));
|
|
|
+ if (count($arr)==1){
|
|
|
+ $sql.=" and 库位 like '".$location."%'";
|
|
|
}
|
|
|
- $sql.=")";
|
|
|
- $sql.=" or sku.ALTERNATE_SKU2 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
+ if (count($arr)>1){
|
|
|
+ $sql.=" and (库位 like ";
|
|
|
+ foreach ($arr as $index=>$str){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$str."%'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.= "or 库位 like'".$str."%'";
|
|
|
}
|
|
|
- $sql.=",'".$str."'";
|
|
|
+ $sql.=")";
|
|
|
}
|
|
|
- $sql.=")";
|
|
|
- $sql.=" or sku.ALTERNATE_SKU3 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
- }
|
|
|
- $sql.=",'".$str."'";
|
|
|
- }
|
|
|
- $sql.=")";
|
|
|
- $sql.=")";
|
|
|
}
|
|
|
- return $sql;
|
|
|
+ if ($barcode)$sql=$this->按条码查询($sql,$barcode);
|
|
|
+ $sql.=' ) ';
|
|
|
+ return DB::connection('oracle')->select($sql);
|
|
|
+
|
|
|
}
|
|
|
- private function 动盘局部盘点按条码查询($sql,$barcode){
|
|
|
+ private function 按条码查询($sql,$barcode){
|
|
|
$arr=array_filter(preg_split('/[,, ]+/is', $barcode));
|
|
|
if (count($arr)==1){
|
|
|
$sql.=" and (产品条码1 like '".$barcode."%' or 产品条码2 like '".$barcode."%' or 产品条码3 like '".$barcode."%')";
|
|
|
@@ -205,42 +199,6 @@ class InventoryAccountService
|
|
|
}
|
|
|
return $sql;
|
|
|
}
|
|
|
- private function 局部盘点按条码查询_无库位前缀字母($sql,$barcode){
|
|
|
- $arr=array_filter(preg_split('/[,, ]+/is', $barcode));
|
|
|
- if (count($arr)==1){
|
|
|
- $sql.="where sku.ALTERNATE_SKU1 like '".$barcode."%' or sku.ALTERNATE_SKU2 like '".$barcode."%' or sku.ALTERNATE_SKU3 like '".$barcode."%'";
|
|
|
- }
|
|
|
- if (count($arr)>1){
|
|
|
- $sql.="where sku.ALTERNATE_SKU1 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
- }
|
|
|
- $sql.=",'".$str."'";
|
|
|
- }
|
|
|
- $sql.=")";
|
|
|
- $sql.=" or sku.ALTERNATE_SKU2 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
- }
|
|
|
- $sql.=",'".$str."'";
|
|
|
- }
|
|
|
- $sql.=")";
|
|
|
- $sql.=" or sku.ALTERNATE_SKU3 in (";
|
|
|
- foreach ($arr as $index=>$str){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$str."'";
|
|
|
- continue;
|
|
|
- }
|
|
|
- $sql.=",'".$str."'";
|
|
|
- }
|
|
|
- $sql.=")";
|
|
|
- }
|
|
|
- return $sql;
|
|
|
- }
|
|
|
//创建盘点任务
|
|
|
public function createMission($date_start,$date_end,$ownerId,$location,$barcode){
|
|
|
if (!$ownerId) return null;
|
|
|
@@ -270,10 +228,7 @@ class InventoryAccountService
|
|
|
]);
|
|
|
$inventory->save();
|
|
|
$inventory->createSignCreator();
|
|
|
- LogService::log(__METHOD__,'createInventoryAccountMissionRecord -- start','createInventoryAccountMissionRecord');
|
|
|
$this->createInventoryAccountMissionRecord($ownerId,$inventory['id'],$wmsInventories);
|
|
|
- LogService::log(__METHOD__,'createInventoryAccountMissionRecord -- end','createInventoryAccountMissionRecord');
|
|
|
-
|
|
|
$request=[
|
|
|
'date_start'=>$date_start,
|
|
|
'date_end'=>$date_end,
|
|
|
@@ -288,6 +243,7 @@ class InventoryAccountService
|
|
|
|
|
|
//创建盘点记录任务
|
|
|
public function createInventoryAccountMissionRecord($ownerId,$inventoryAccountId,$wmsInventories){
|
|
|
+ ini_set('memory_limit','300M');
|
|
|
$commodities=Commodity::query()
|
|
|
->select('id','owner_id','name','sku')
|
|
|
->with('barcodes')
|
|
|
@@ -300,7 +256,6 @@ class InventoryAccountService
|
|
|
}
|
|
|
$commodityArr=[];
|
|
|
$inventoryAccountMissions=[];
|
|
|
- LogService::log(__METHOD__,'foreach -- strat','createInventoryAccountMissionRecord');
|
|
|
foreach ($wmsInventories as $wmsInventory){
|
|
|
$commodity=$commoditiesArr[$wmsInventory->商品名称.'|'.$wmsInventory->产品编码]??null;
|
|
|
if (!$commodity){
|
|
|
@@ -353,7 +308,6 @@ class InventoryAccountService
|
|
|
'location'=>$wmsInventory->库位,
|
|
|
'produced_at'=>$wmsInventory->生产日期,
|
|
|
'valid_at'=>$wmsInventory->失效日期,
|
|
|
-// 'stored_at'=>$wmsInventory->入库日期,
|
|
|
'batch_number'=>$wmsInventory->批号,
|
|
|
'erp_type_position'=>$wmsInventory->属性仓,
|
|
|
'quality'=>$quality,
|
|
|
@@ -364,7 +318,6 @@ class InventoryAccountService
|
|
|
];
|
|
|
array_push($inventoryAccountMissions,$inventoryAccountMission);
|
|
|
}
|
|
|
- LogService::log(__METHOD__,'foreach -- strat','createInventoryAccountMissionRecord');
|
|
|
|
|
|
$inventoryAccountMissions=InventoryAccountMission::query()->insert($inventoryAccountMissions);
|
|
|
if ($commodityArr){
|