|
|
@@ -61,7 +61,7 @@ class InventoryAccountService
|
|
|
->whereIn('id',explode(',',$queryParam['data']))->get();
|
|
|
}
|
|
|
//动盘查询
|
|
|
- public function conditionPortStock($date_start,$date_end,$ownerId,$location){
|
|
|
+ public function conditionPortStock($date_start,$date_end,$ownerId,$location,$barcode){
|
|
|
if (!$ownerId) return null;
|
|
|
$descr_c=Owner::where('id',$ownerId)->value('name');
|
|
|
$sql='select * from (select result.*,rownum rn from (';
|
|
|
@@ -95,25 +95,18 @@ class InventoryAccountService
|
|
|
$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.库位 ';
|
|
|
- if ($location)$sql.=" where storeStatus.LocationID like '".$location."%' ";
|
|
|
$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.=' , storeStatus.QTY, storeStatus.QtyAllocated,stockLog.客户 ';
|
|
|
$sql.=' )result where 1=1 ';
|
|
|
- if ($descr_c){
|
|
|
- $sql .= ' and 货主 in (';
|
|
|
- $descr_cs = explode(',',$descr_c);
|
|
|
- foreach ($descr_cs as $index => $descr_c){
|
|
|
- if ($index != 0)$sql .= ',';
|
|
|
- $sql .= "'".$descr_c."'";
|
|
|
- }
|
|
|
- $sql .= ') ';
|
|
|
- }
|
|
|
+ if ($descr_c)$sql.=" and 货主 = '".$descr_c."' ";
|
|
|
+ if ($location)$sql.=" and 库位 like '".$location."%' ";
|
|
|
+ if ($barcode)$sql=$this->动盘局部盘点按条码查询($sql,$barcode);
|
|
|
$sql.=' ) ';
|
|
|
return DB::connection('oracle')->select($sql);
|
|
|
}
|
|
|
//全盘查询
|
|
|
- private function conditionTotalStock($ownerId,$location){
|
|
|
+ private function conditionTotalStock($ownerId,$location,$barcode){
|
|
|
$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, ';
|
|
|
@@ -125,29 +118,142 @@ class InventoryAccountService
|
|
|
$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.=' ,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."'";
|
|
|
+ }
|
|
|
+ $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.=")";
|
|
|
+ $sql.=")";
|
|
|
+ }
|
|
|
+ return $sql;
|
|
|
+ }
|
|
|
+ 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."%')";
|
|
|
+ }
|
|
|
+ if (count($arr)>1){
|
|
|
+ $sql.=" and (产品条码1 in (";
|
|
|
+ foreach ($arr as $index=>$str){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$str."'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.=",'".$str."'";
|
|
|
+ }
|
|
|
+ $sql.=")";
|
|
|
+ $sql.=" or 产品条码2 in (";
|
|
|
+ foreach ($arr as $index=>$str){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$str."'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.=",'".$str."'";
|
|
|
+ }
|
|
|
+ $sql.=")";
|
|
|
+ $sql.=" or 产品条码3 in (";
|
|
|
+ foreach ($arr as $index=>$str){
|
|
|
+ if ($index==0){
|
|
|
+ $sql.="'".$str."'";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sql.=",'".$str."'";
|
|
|
+ }
|
|
|
+ $sql.=")";
|
|
|
+ $sql.=")";
|
|
|
+ }
|
|
|
+ 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){
|
|
|
+ public function createMission($date_start,$date_end,$ownerId,$location,$barcode){
|
|
|
if (!$ownerId) return null;
|
|
|
if ($date_start&&$date_end){
|
|
|
$date_end_time=$date_end.' 23:59:59';
|
|
|
$type='动盘';
|
|
|
- $wmsInventories=$this->conditionPortStock($date_start,$date_end,$ownerId,$location);
|
|
|
+ $wmsInventories=$this->conditionPortStock($date_start,$date_end,$ownerId,$location,$barcode);
|
|
|
}elseif (!$date_start&&!$date_end){
|
|
|
$name=Owner::where('id',$ownerId)->value('name');
|
|
|
$ownerName=OracleBasCustomer::where('customer_type','OW')->where('active_flag','Y')->where('descr_c',$name)->value('customerid');
|
|
|
$date_start=OracleInvLotLocId::where('customerid',$ownerName)->orderBy('addtime','ASC')->value('addtime');
|
|
|
$date_end_time=OracleInvLotLocId::where('customerid',$ownerName)->orderBy('addtime','DESC')->value('addtime');
|
|
|
$type='全盘';
|
|
|
- $wmsInventories=$this->conditionTotalStock($ownerId,$location);
|
|
|
+ $wmsInventories=$this->conditionTotalStock($ownerId,$location,$barcode);
|
|
|
}else{
|
|
|
return null;
|
|
|
}
|
|
|
@@ -169,6 +275,7 @@ class InventoryAccountService
|
|
|
'date_end'=>$date_end,
|
|
|
'ownerId'=>$ownerId,
|
|
|
'location'=>$location,
|
|
|
+ 'barcode'=>$barcode,
|
|
|
'inventoryId'=>$inventory['id'],
|
|
|
];
|
|
|
Controller::logS(__METHOD__,"创建盘点任务__".__FUNCTION__,json_encode($request),Auth::user()['id']);
|