|
|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
use App\CommodityBarcode;
|
|
|
+use App\OracleActTransactionLog;
|
|
|
use App\OracleBasCode;
|
|
|
use App\OracleBasCustomer;
|
|
|
use App\OracleBasForwardingLoc;
|
|
|
@@ -16,6 +17,7 @@ use App\OracleInvLotLocId;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
use App\ValueStore;
|
|
|
use Carbon\Carbon;
|
|
|
+use Decimal\Decimal;
|
|
|
use Doctrine\DBAL\Schema\AbstractAsset;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
@@ -35,20 +37,31 @@ class HandInStorageService
|
|
|
* @return object
|
|
|
* 根据asn单号获取 总预期数量 总已收数量
|
|
|
*/
|
|
|
- public function getAsnQty($asnno)
|
|
|
+ public function getAsnQty($asnno): object
|
|
|
{
|
|
|
- $asnQty=OracleDOCASNDetail::query()
|
|
|
- ->select('expectedqty','receivedqty')
|
|
|
- ->where('asnno',$asnno)
|
|
|
+ $asnQty = OracleDOCASNDetail::query()
|
|
|
+ ->select('expectedqty', 'receivedqty','receivedqty_each','expectedqty_each')
|
|
|
+ ->where('asnno', $asnno)
|
|
|
->get();
|
|
|
$expectedqty=0;
|
|
|
$receivedqty=0;
|
|
|
foreach ($asnQty as $qty){
|
|
|
- $expectedqty+=$qty->expectedqty;
|
|
|
- $receivedqty+=$qty->receivedqty;
|
|
|
+ if ($qty->expectedqty) {
|
|
|
+ $expectedqty+=$qty->expectedqty;
|
|
|
+ }else{
|
|
|
+ $expectedqty+=$qty->expectedqty_each??0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($qty->receivedqty){
|
|
|
+ $receivedqty+=$qty->receivedqty;
|
|
|
+ }else{
|
|
|
+ $receivedqty+=$qty->receivedqty_each??0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- return (object)array('expectedqty'=>$expectedqty,'receivedqty'=>$receivedqty);
|
|
|
+ return (object)array('expectedqty' => $expectedqty, 'receivedqty' => $receivedqty);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param array $info
|
|
|
* @return bool|int
|
|
|
@@ -56,19 +69,20 @@ class HandInStorageService
|
|
|
*/
|
|
|
public function checkForwardingLoc(array $info)
|
|
|
{
|
|
|
- $res=OracleBasCustomer::query()
|
|
|
- ->where('customerid',$info['customerid'])
|
|
|
- ->where('customer_type','OW')
|
|
|
- ->where('udf1','Y')->count(); //查询此货主是否必须有拣货位
|
|
|
- if ($res>0) {
|
|
|
- $amount=OracleBasForwardingLoc::query()
|
|
|
- ->where('customerid',$info['customerid'])
|
|
|
- ->where('sku',$info['sku'])
|
|
|
+ $res = OracleBasCustomer::query()
|
|
|
+ ->where('customerid', $info['customerid'])
|
|
|
+ ->where('customer_type', 'OW')
|
|
|
+ ->where('udf1', 'Y')->count(); //查询此货主是否必须有拣货位
|
|
|
+ if ($res > 0) {
|
|
|
+ $amount = OracleBasForwardingLoc::query()
|
|
|
+ ->where('customerid', $info['customerid'])
|
|
|
+ ->where('sku', $info['sku'])
|
|
|
->count();
|
|
|
- if ($amount==0)return 1;//请维护拣货位!
|
|
|
+ if ($amount == 0) return 1;//请维护拣货位!
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param array $info
|
|
|
* @return bool|int
|
|
|
@@ -76,9 +90,9 @@ class HandInStorageService
|
|
|
*/
|
|
|
public function checkWidthHeight(array $info)
|
|
|
{
|
|
|
- $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
|
|
|
- if (!$basSku)return 1;//需要维护产品档案
|
|
|
- if ($basSku->skulength<=0||$basSku->skuwidth<=0||$basSku->skuhigh<=0)return 2;//需要维护该产品档案中的长宽高
|
|
|
+ $basSku = OracleBasSKU::query()->where('customerid', $info['customerid'])->where('sku', $info['sku'])->first();
|
|
|
+ if (!$basSku) return 1;//需要维护产品档案
|
|
|
+ if ($basSku->skulength <= 0 || $basSku->skuwidth <= 0 || $basSku->skuhigh <= 0) return 2;//需要维护该产品档案中的长宽高
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -89,11 +103,12 @@ class HandInStorageService
|
|
|
*/
|
|
|
public function checkCubicWeight(array $info)
|
|
|
{
|
|
|
- $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
|
|
|
- if (!$basSku)return 1;//需要维护产品档案
|
|
|
- if ($basSku->grossweight<=0||$basSku->cube<=0)return 2;//需要维护该产品档案中的重量体积
|
|
|
+ $basSku = OracleBasSKU::query()->where('customerid', $info['customerid'])->where('sku', $info['sku'])->first();
|
|
|
+ if (!$basSku) return 1;//需要维护产品档案
|
|
|
+ if ($basSku->grossweight <= 0 || $basSku->cube <= 0) return 2;//需要维护该产品档案中的重量体积
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param array $info
|
|
|
* @param array $param
|
|
|
@@ -110,38 +125,52 @@ class HandInStorageService
|
|
|
if (!$location) return 1;//库位不存在
|
|
|
|
|
|
if ($location['mix_flag'] == 'N' && $location['mix_lotflag'] == 'N') { // 库位:产品和批次都不可混放
|
|
|
- $inv = OracleInvLotLocId::query()->where('locationid', $info['location'])->first();
|
|
|
+ $inv = OracleInvLotLocId::query()->with('oracleInvLotAtt:lotnum,lotatt01,lotatt02,lotatt03,lotatt04,lotatt05,lotatt08')
|
|
|
+ ->where('locationid', $info['location'])->first();
|
|
|
|
|
|
if (!$inv) return true; //当前库位无库存余量 可直接入库
|
|
|
|
|
|
if ($inv['customerid'] == $param['customerid'] && $inv['sku'] == $param['sku']
|
|
|
- && $inv['lotnum'] == $param['plantolotnum'])
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt01'] == $param['lotatt01']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt02'] == $param['lotatt02']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt04'] == $param['lotatt04']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt05'] == $param['lotatt05']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt08'] == $param['lotatt08']
|
|
|
+ )
|
|
|
return true;
|
|
|
else return 2; //库位:产品和批次不可混放
|
|
|
}
|
|
|
|
|
|
|
|
|
if ($location['mix_flag'] == 'Y' && $location['mix_lotflag'] == 'N') {//库位:产品可混放,批次不可
|
|
|
- $invs = OracleInvLotLocId::query()->where('locationid', $info['location'])->get();
|
|
|
+ $invs = OracleInvLotLocId::query()->with('oracleInvLotAtt:lotnum,lotatt01,lotatt02,lotatt03,lotatt04,lotatt05,lotatt08')
|
|
|
+ ->where('locationid', $info['location'])->get();
|
|
|
|
|
|
if ($invs->count() == 0) return true; //当前库位无库存余量 可直接入库
|
|
|
|
|
|
$skuInvs = []; // 库位没有该商品
|
|
|
foreach ($invs as $inv) {
|
|
|
- if ($inv['customerid'] != $param['customerid'] || $inv['sku'] != $param['sku']) { // 库位没有该商品
|
|
|
+ if ($inv['customerid'] != $param['customerid'] && $inv['sku'] != $param['sku']) { // 库位没有该商品
|
|
|
$skuInvs[] = $inv;
|
|
|
continue;
|
|
|
}
|
|
|
- if ($inv['lotnum'] == $param['plantolotnum']) return true; // 批次相同
|
|
|
+ if ($inv['oracleInvLotAtt']['lotatt01'] == $param['lotatt01']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt02'] == $param['lotatt02']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt04'] == $param['lotatt04']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt05'] == $param['lotatt05']
|
|
|
+ && $inv['oracleInvLotAtt']['lotatt08'] == $param['lotatt08']) return true; // 批次相同
|
|
|
return 3; //库位:产品相同,不能混放批次
|
|
|
}
|
|
|
if (count($skuInvs) == count($invs)) return true;
|
|
|
}
|
|
|
if ($location['mix_flag'] == 'N' && $location['mix_lotflag'] == 'Y') { //库位:产品不可混放,批次可混放
|
|
|
- $inv = OracleInvLotLocId::query()->where('locationid', $info['location'])->first();
|
|
|
+ $inv = OracleInvLotLocId::query()
|
|
|
+ ->where('locationid', $info['location'])
|
|
|
+ ->where('qty','>',0) //占用库位忽略当条库存余量
|
|
|
+ ->first();
|
|
|
if (!$inv) return true; //当前库位无库存余量 可直接入库
|
|
|
|
|
|
- if ($inv['customerid'] == $param['customerid'] || $inv['sku'] == $param['sku']) return true;
|
|
|
+ if ($inv['customerid'] == $param['customerid'] && $inv['sku'] == $param['sku']) return true;
|
|
|
else return 4; //库位:产品不能混放
|
|
|
}
|
|
|
// 库位
|
|
|
@@ -186,7 +215,7 @@ class HandInStorageService
|
|
|
public function selectAsn($asn)
|
|
|
{
|
|
|
if (!$asn) return OracleDOCASNHeader::query() //空扫
|
|
|
- ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype','notes'])
|
|
|
+ ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype', 'notes'])
|
|
|
->where('asnstatus', '00')
|
|
|
->orderByDesc('addtime')
|
|
|
->limit(50)
|
|
|
@@ -194,13 +223,13 @@ class HandInStorageService
|
|
|
|
|
|
if (strpos(strtoupper($asn), 'ASN') !== false) { //asn 单号
|
|
|
return OracleDOCASNHeader::query()
|
|
|
- ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype','notes'])
|
|
|
+ ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype', 'notes'])
|
|
|
->where('asnno', $asn)
|
|
|
->whereIn('asnstatus', ['00', '30'])
|
|
|
->get();
|
|
|
} else {
|
|
|
$asns = OracleDOCASNHeader::query() //货主
|
|
|
- ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype','notes'])
|
|
|
+ ->select(['asnno', 'asnreference1', 'asnstatus', 'addtime', 'customerid', 'asntype', 'notes'])
|
|
|
->where('customerid', strtoupper($asn))
|
|
|
->whereIn('asnstatus', ['00', '30'])
|
|
|
->get();
|
|
|
@@ -231,7 +260,7 @@ SQL;
|
|
|
{
|
|
|
$sql = <<<sql
|
|
|
SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,
|
|
|
- DOC_ASN_DETAILS.receivedqty,BAS_SKU.alternate_sku1
|
|
|
+ DOC_ASN_DETAILS.receivedqty,DOC_ASN_DETAILS.receivedqty_each,BAS_SKU.alternate_sku1
|
|
|
FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
|
|
|
WHERE asnno = ? AND linestatus IN ('00','30')
|
|
|
sql;
|
|
|
@@ -252,15 +281,15 @@ sql;
|
|
|
SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
|
|
|
DOC_ASN_DETAILS.lotatt01, DOC_ASN_DETAILS.lotatt02, DOC_ASN_DETAILS.lotatt03, DOC_ASN_DETAILS.lotatt04,
|
|
|
DOC_ASN_DETAILS.lotatt05, DOC_ASN_DETAILS.lotatt06, DOC_ASN_DETAILS.lotatt07, DOC_ASN_DETAILS.lotatt08,
|
|
|
- DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty FROM DOC_ASN_DETAILS
|
|
|
+ DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty,DOC_ASN_DETAILS.receivedqty_each FROM DOC_ASN_DETAILS
|
|
|
LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
|
|
|
WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?)
|
|
|
sql;
|
|
|
$asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql), [$asnno, $skuOrBarcode, $skuOrBarcode, $skuOrBarcode]);
|
|
|
if ($asn_detail) return $asn_detail;
|
|
|
else return OracleDOCASNDetail::query()
|
|
|
- ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty',
|
|
|
- 'lotatt01','lotatt02','lotatt03','lotatt04','lotatt05','lotatt06','lotatt07','lotatt08'])
|
|
|
+ ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty','receivedqty_each',
|
|
|
+ 'lotatt01', 'lotatt02', 'lotatt03', 'lotatt04', 'lotatt05', 'lotatt06', 'lotatt07', 'lotatt08'])
|
|
|
->where('asnno', $asnno)
|
|
|
->where('sku', $skuOrBarcode)
|
|
|
->whereIn('linestatus', ['00', '30'])
|
|
|
@@ -317,18 +346,19 @@ sql;
|
|
|
*/
|
|
|
public function getInvotlocid($barcode): array
|
|
|
{
|
|
|
- $sql=<<<sql
|
|
|
+ $sql = <<<sql
|
|
|
select INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08,
|
|
|
+ INV_LOT_ATT.LOTATT01,INV_LOT_ATT.LOTATT02,INV_LOT_ATT.LOTATT03,INV_LOT_ATT.LOTATT04,
|
|
|
sum(INV_LOT_LOC_ID.QTY) AS QTY from INV_LOT_LOC_ID
|
|
|
left join BAS_SKU on INV_LOT_LOC_ID.CUSTOMERID=BAS_SKU.CUSTOMERID and INV_LOT_LOC_ID.SKU =BAS_SKU.SKU
|
|
|
left join INV_LOT_ATT on INV_LOT_ATT.LOTNUM=INV_LOT_LOC_ID.LOTNUM
|
|
|
where BAS_SKU.SKU in (select SKU from BAS_SKU where ALTERNATE_SKU1=? union
|
|
|
select SKU from BAS_SKU where ALTERNATE_SKU2=? union
|
|
|
select SKU from BAS_SKU where ALTERNATE_SKU3=? )
|
|
|
-group by INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08
|
|
|
+group by INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08,INV_LOT_ATT.LOTATT01,INV_LOT_ATT.LOTATT02,INV_LOT_ATT.LOTATT03,INV_LOT_ATT.LOTATT04
|
|
|
sql;
|
|
|
$invLots = DB::connection("oracle")->select(DB::raw($sql), [$barcode, $barcode, $barcode]);
|
|
|
- if (!$invLots)return [];
|
|
|
+ if (!$invLots) return [];
|
|
|
else return $invLots;
|
|
|
}
|
|
|
|
|
|
@@ -337,10 +367,10 @@ sql;
|
|
|
* @return array|int
|
|
|
* 根据商品条码 获取完全收货状态 部分收货状态的 PA任务
|
|
|
*/
|
|
|
- public function getTsk($trackNumber,$barCode): array
|
|
|
+ public function getTsk($trackNumber, $barCode): array
|
|
|
{
|
|
|
$sql = <<<sql
|
|
|
-select t.*, DOC_ASN_DETAILS.RECEIVEDQTY
|
|
|
+select t.*, DOC_ASN_DETAILS.RECEIVEDQTY,DOC_ASN_DETAILS.ReceivedQty_Each
|
|
|
from (select TSK_TASKLISTS.CustomerID,
|
|
|
TSK_TASKLISTS.DOCNO,
|
|
|
TSK_TASKLISTS.Sku,
|
|
|
@@ -348,6 +378,12 @@ from (select TSK_TASKLISTS.CustomerID,
|
|
|
TSK_TASKLISTS.PlanToID,
|
|
|
DOC_ASN_DETAILS.SKUDESCRC,
|
|
|
TSK_TASKLISTS.DOCLINENO,
|
|
|
+ TSK_TASKLISTS.LOTATT01,
|
|
|
+ TSK_TASKLISTS.LOTATT02,
|
|
|
+ TSK_TASKLISTS.LOTATT03,
|
|
|
+ TSK_TASKLISTS.LOTATT04,
|
|
|
+ TSK_TASKLISTS.LOTATT05,
|
|
|
+ TSK_TASKLISTS.LOTATT08,
|
|
|
sum(TSK_TASKLISTS.PlanToQty) as qty
|
|
|
from TSK_TASKLISTS
|
|
|
LEFT JOIN DOC_ASN_DETAILS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND
|
|
|
@@ -355,43 +391,45 @@ from (select TSK_TASKLISTS.CustomerID,
|
|
|
where TSK_TASKLISTS.TASKTYPE = 'PA'
|
|
|
AND TSK_TASKLISTS.TASKPROCESS = '00'
|
|
|
sql;
|
|
|
- if (!$trackNumber){ //没有输入条件 空扫
|
|
|
+ if (!$trackNumber) { //没有输入条件 空扫
|
|
|
$owner_codes = app('OwnerService')->getIntersectPermitting(['code']);
|
|
|
- if (count($owner_codes)>0){
|
|
|
- $sql.=' AND TSK_TASKLISTS.CustomerID IN (';
|
|
|
- foreach ($owner_codes as $index => $no){
|
|
|
- if ($index==0){
|
|
|
- $sql.="'".$no->code."'";
|
|
|
+ if (count($owner_codes) > 0) {
|
|
|
+ $sql .= ' AND TSK_TASKLISTS.CustomerID IN (';
|
|
|
+ foreach ($owner_codes as $index => $no) {
|
|
|
+ if ($index == 0) {
|
|
|
+ $sql .= "'" . $no->code . "'";
|
|
|
continue;
|
|
|
}
|
|
|
- $sql.=",'".$no->code."'";
|
|
|
+ $sql .= ",'" . $no->code . "'";
|
|
|
}
|
|
|
- $sql.=')';
|
|
|
- }else{
|
|
|
+ $sql .= ')';
|
|
|
+ } else {
|
|
|
$sql .= ' AND TSK_TASKLISTS.CustomerID IS NULL ';
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- if (strpos(strtoupper($trackNumber), 'ASN') !== false){
|
|
|
- $sql.='AND TSK_TASKLISTS.DOCNO= ?'; //输入条件为asn单号
|
|
|
- } else{ //不为asn号时 判断是否为货主
|
|
|
- if ($this->checkUserOwnerAuth($trackNumber)){ //输入条件为货主
|
|
|
- $sql.=' AND TSK_TASKLISTS.CustomerID= ?';
|
|
|
- }else{
|
|
|
- $sql.=' AND TSK_TASKLISTS.PlanToID= ?'; //不是货主 判断是否为跟踪号
|
|
|
+ } else {
|
|
|
+ if (strpos(strtoupper($trackNumber), 'ASN') !== false) {
|
|
|
+ $sql .= 'AND TSK_TASKLISTS.DOCNO= ?'; //输入条件为asn单号
|
|
|
+ } else { //不为asn号时 判断是否为货主
|
|
|
+ if ($this->checkUserOwnerAuth($trackNumber)) { //输入条件为货主
|
|
|
+ $sql .= ' AND TSK_TASKLISTS.CustomerID= ?';
|
|
|
+ } else {
|
|
|
+ $sql .= ' AND TSK_TASKLISTS.PlanToID= ?'; //不是货主 判断是否为跟踪号
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ($barCode)$sql.=" AND TSK_TASKLISTS.sku in (select SKU from BAS_SKU where ALTERNATE_SKU1='".$barCode."' union
|
|
|
- select SKU from BAS_SKU where ALTERNATE_SKU2='".$barCode."' union
|
|
|
- select SKU from BAS_SKU where ALTERNATE_SKU3='".$barCode."' )";
|
|
|
+ if ($barCode) $sql .= " AND TSK_TASKLISTS.sku in (
|
|
|
+ select SKU from BAS_SKU where ALTERNATE_SKU1='" . $barCode . "' union
|
|
|
+ select SKU from BAS_SKU where ALTERNATE_SKU2='" . $barCode . "' union
|
|
|
+ select SKU from BAS_SKU where ALTERNATE_SKU3='" . $barCode . "' union
|
|
|
+ select SKU from BAS_SKU where SKU='" . $barCode . "' )";
|
|
|
|
|
|
- $sql.=' group by TSK_TASKLISTS.CustomerID, TSK_TASKLISTS.DOCNO, TSK_TASKLISTS.Sku, TSK_TASKLISTS.PlanToLotNum,
|
|
|
- TSK_TASKLISTS.PlanToID, DOC_ASN_DETAILS.SKUDESCRC, TSK_TASKLISTS.DOCLINENO) t
|
|
|
+ $sql.=' group by TSK_TASKLISTS.CustomerID, TSK_TASKLISTS.DOCNO, TSK_TASKLISTS.Sku, TSK_TASKLISTS.PlanToLotNum, TSK_TASKLISTS.PlanToID, DOC_ASN_DETAILS.SKUDESCRC,
|
|
|
+ TSK_TASKLISTS.DOCLINENO, TSK_TASKLISTS.LOTATT01, TSK_TASKLISTS.LOTATT02, TSK_TASKLISTS.LOTATT03, TSK_TASKLISTS.LOTATT04, TSK_TASKLISTS.LOTATT05, TSK_TASKLISTS.LOTATT08) t
|
|
|
left join DOC_ASN_DETAILS on t.DOCLINENO = DOC_ASN_DETAILS.ASNLINENO and t.DOCNO = DOC_ASN_DETAILS.ASNNO';
|
|
|
- if ($trackNumber){
|
|
|
- if ($this->checkUserOwnerAuth($trackNumber))$tasks = DB::connection("oracle")->select(DB::raw($sql), [strtoupper($trackNumber)]);
|
|
|
+ if ($trackNumber) {
|
|
|
+ if ($this->checkUserOwnerAuth($trackNumber)) $tasks = DB::connection("oracle")->select(DB::raw($sql), [strtoupper($trackNumber)]);
|
|
|
else $tasks = DB::connection("oracle")->select(DB::raw($sql), [$trackNumber]);
|
|
|
}else {$tasks = DB::connection("oracle")->select(DB::raw($sql));}
|
|
|
if (!$tasks) return [];
|
|
|
@@ -406,8 +444,8 @@ sql;
|
|
|
public function checkUserOwnerAuth($owner_code): bool
|
|
|
{
|
|
|
$owner_codes = app('OwnerService')->getIntersectPermitting(['code']);
|
|
|
- $owner=$owner_codes->where('code','=',strtoupper($owner_code));
|
|
|
- if ($owner->count()>0)return true;
|
|
|
+ $owner = $owner_codes->where('code', '=', strtoupper($owner_code));
|
|
|
+ if ($owner->count() > 0) return true;
|
|
|
else return false;
|
|
|
}
|
|
|
|
|
|
@@ -421,8 +459,8 @@ sql;
|
|
|
if (!$tasks) return false; //获取任务失败
|
|
|
return DB::connection("oracle")->transaction(function () use ($tasks, $info) { //单体嵌套事务 回滚FLUX失败任务
|
|
|
foreach ($tasks as $task) {
|
|
|
- $res=$this->checkExpiryPa($task,$info['location']);
|
|
|
- if ($res!==true)return $res;
|
|
|
+ $res = $this->checkExpiryPa($task, $info['location']);
|
|
|
+ if ($res !== true) return $res;
|
|
|
if (!app("StorageService")->fluxPA($task, $info['location'])) {
|
|
|
DB::connection("oracle")->rollBack();
|
|
|
return false; //上架失败
|
|
|
@@ -431,23 +469,22 @@ sql;
|
|
|
return true; //上架成功
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* @param $task
|
|
|
* @param $location
|
|
|
* @return bool|int
|
|
|
* 上架校验效期
|
|
|
*/
|
|
|
- public function checkExpiryPa($task,$location)
|
|
|
+ public function checkExpiryPa($task, $location)
|
|
|
{
|
|
|
- if (!$task->taskid)return 0;//任务id不存在
|
|
|
- if (strpos($task->taskid,'MIX') !== false)return true;//合并拣货,不校验
|
|
|
+ if (!$task->taskid) return 0;//任务id不存在
|
|
|
+ if (strpos($task->taskid, 'MIX') !== false) return true;//合并拣货,不校验
|
|
|
|
|
|
$sql = <<<sql
|
|
|
select instr(DESCR,'拣货') as var_IsPickingArea from BAS_Zone where ZONE=(select PutawayZone from BAS_Location where LocationID = ?)
|
|
|
sql;
|
|
|
$basZone = DB::connection("oracle")->selectOne(DB::raw($sql), [$location]);
|
|
|
- if ($basZone&&$basZone->var_ispickingarea>0) return true; //不是存储区,不校验
|
|
|
+ if ($basZone && $basZone->var_ispickingarea > 0) return true; //不是存储区,不校验
|
|
|
|
|
|
$sql1 = <<<sql
|
|
|
select SKU,LotAtt02,CustomerID from INV_LOT_ATT WHERE LOTNUM=?
|
|
|
@@ -464,8 +501,8 @@ sql;
|
|
|
and attres.LotAtt02 > ?
|
|
|
and zone.DESCR like '%拣货%'
|
|
|
sql;
|
|
|
- $invLotLocId=DB::connection("oracle")->selectOne(DB::raw($sql2), [$invLotAtt->sku,$invLotAtt->customerid,$task->fmlotnum,$invLotAtt->lotatt02]);
|
|
|
- if ($invLotLocId&&$invLotLocId->var_amountofdecaying>0)return 1;//拣货区找到效期更新的同样货品,不能上架至存储区
|
|
|
+ $invLotLocId = DB::connection("oracle")->selectOne(DB::raw($sql2), [$invLotAtt->sku, $invLotAtt->customerid, $task->fmlotnum, $invLotAtt->lotatt02]);
|
|
|
+ if ($invLotLocId && $invLotLocId->var_amountofdecaying > 0) return 1;//拣货区找到效期更新的同样货品,不能上架至存储区
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -503,10 +540,11 @@ sql;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @throws \Throwable
|
|
|
+ * @param array $info
|
|
|
+ * @return bool
|
|
|
* fulx 手持收货
|
|
|
*/
|
|
|
- public function fluxHandIn(array $info)
|
|
|
+ public function fluxHandIn(array $info): bool
|
|
|
{
|
|
|
$lotatt = array_filter($info, function ($key) {
|
|
|
return strpos($key, 'lotatt') === 0;
|
|
|
@@ -522,31 +560,46 @@ sql;
|
|
|
}
|
|
|
$who = 'WAS' . (Auth::user() ? '-' . Auth::user()["name"] : '');
|
|
|
$time = Carbon::now()->toDateTimeString();
|
|
|
- return DB::connection("oracle")->transaction(function () use ($info, $invlotatt, $who, $time) {
|
|
|
+ $db = DB::connection("oracle");
|
|
|
+ $db->beginTransaction();
|
|
|
+ try {
|
|
|
+// return DB::connection("oracle")->transaction(function () use ($info, $invlotatt, $who, $time) {
|
|
|
//flux 批次号
|
|
|
$lotNum = $this->getOrCreateLotNum($info, $invlotatt, $who, $time);
|
|
|
- if (!$lotNum) {
|
|
|
- DB::connection("oracle")->rollBack();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!$lotNum){$db->rollBack();return false;}
|
|
|
+
|
|
|
//flux 创建入库事务
|
|
|
$actTransactionLog = $this->setFluxActTransactionLog($info, $lotNum, $who, $time);
|
|
|
- if (!$actTransactionLog) {
|
|
|
- DB::connection("oracle")->rollBack();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (count($actTransactionLog) == 0){$db->rollBack();return false;}
|
|
|
//flux 创建上架任务
|
|
|
- $this->setFluxTskTaskListPA($info, $invlotatt, $actTransactionLog, $who, $time);
|
|
|
+ $res=$this->setFluxTskTaskListPA($info, $invlotatt, $actTransactionLog, $who, $time);
|
|
|
+ if (!$res){$db->rollBack();return false;}
|
|
|
//flux 完善库存余量
|
|
|
$this->updateFluxInv($info, $lotNum, $who, $time, $actTransactionLog);
|
|
|
//flux 更新asn_detail 和 asn_header 状态
|
|
|
- return $this->updateFluxAsn($info, $invlotatt, $time, $who);
|
|
|
- });
|
|
|
+ $result=$this->updateFluxAsn($info, $invlotatt, $time, $who);
|
|
|
+ if ($result){
|
|
|
+ $db->commit();
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ $db->rollBack();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+// });
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $db->rollBack();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @throws \Throwable
|
|
|
+ * @param array $info
|
|
|
+ * @param array $invlotatt
|
|
|
+ * @param $time
|
|
|
+ * @param $who
|
|
|
+ * @return bool
|
|
|
+ * 更新asn状态
|
|
|
*/
|
|
|
public function updateFluxAsn(array $info, array $invlotatt, $time, $who): bool
|
|
|
{
|
|
|
@@ -565,59 +618,67 @@ sql;
|
|
|
$asnDetail['customerid'] == $info['customerid'] &&
|
|
|
$asnDetail['sku'] == $info['sku']) $receiveAsn = $asnDetail;
|
|
|
}
|
|
|
- return $db->transaction(function () use ($db, $info, $receiveAsn, $invlotatt, $time, $who, $asn) {
|
|
|
- if ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] < (int)$receiveAsn['expectedqty']) {
|
|
|
- //asn_detail 收货数量+已收数量<预期数量
|
|
|
- $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty = receivedqty + ?,receivedqty_each = receivedqty_each + ?,linestatus = '30',holdrejectcode ='OK',
|
|
|
+// return $db->transaction(function () use ($db, $info, $receiveAsn, $invlotatt, $time, $who, $asn) {
|
|
|
+ if ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] < (int)$receiveAsn['expectedqty']) {
|
|
|
+ //asn_detail 收货数量+已收数量<预期数量
|
|
|
+ $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty = receivedqty + ?,receivedqty_each = receivedqty_each + ?,linestatus = '30',holdrejectcode ='OK',
|
|
|
reserve_flag ='Y',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),receivedtime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,
|
|
|
lotatt01 =?,lotatt02 =?,lotatt03 =?,lotatt04 =?,lotatt05 =?,lotatt06 =?,lotatt07 =?,lotatt08=? WHERE asnno = ? and asnlineno = ?"),
|
|
|
- [(int)$info['amount'], (int)$info['amount'], $time, $time, $who, $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
- $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $info['asnno'], $info['asnlineno']]);
|
|
|
+ [(int)$info['amount'], (int)$info['amount'], $time, $time, $who, $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
+ $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $info['asnno'], $info['asnlineno']]);
|
|
|
+ //asn_header 部分收货状态
|
|
|
+ $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '30',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
|
|
|
+ [$time, $who, $info['asnno']]);
|
|
|
+ } elseif ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] == (int)$receiveAsn['expectedqty']) {
|
|
|
+ //asn_detail 收货数量+已收数量=预期数量
|
|
|
+ $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty=receivedqty+?,receivedqty_each=receivedqty_each+?,linestatus = '40',
|
|
|
+ edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),receivedtime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,holdrejectcode='OK',
|
|
|
+ reserve_flag='Y',lotatt01=?,lotatt02=?,lotatt03=?,lotatt04=?,lotatt05=?,lotatt06=?,lotatt07=?,lotatt08=? WHERE asnno = ? and asnlineno = ?"),
|
|
|
+ [(int)$info['amount'], (int)$info['amount'], $time, $time, $who, $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
+ $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $info['asnno'], $info['asnlineno']]);
|
|
|
+ //当asn_detail 所有状态都为完全收货是 asn_header 状态修改为 完全收货(asnstatus=40)
|
|
|
+ if (OracleDOCASNDetail::query()->where('asnno', $info['asnno'])->where('linestatus', 40)->count() == $asn->asn_details_count) {
|
|
|
+ $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '40',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
|
|
|
+ [$time, $who, $info['asnno']]);
|
|
|
+ } else {
|
|
|
//asn_header 部分收货状态
|
|
|
$db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '30',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
|
|
|
[$time, $who, $info['asnno']]);
|
|
|
- } elseif ($receiveAsn && (int)$receiveAsn['receivedqty'] + (int)$info['amount'] == (int)$receiveAsn['expectedqty']) {
|
|
|
- //asn_detail 收货数量+已收数量=预期数量
|
|
|
- $db->update(DB::raw("UPDATE DOC_ASN_DETAILS SET receivedqty=receivedqty+?,receivedqty_each=receivedqty_each+?,linestatus = '40',
|
|
|
- edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),receivedtime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,holdrejectcode='OK',
|
|
|
- reserve_flag='Y',lotatt01=?,lotatt02=?,lotatt03=?,lotatt04=?,lotatt05=?,lotatt06=?,lotatt07=?,lotatt08=? WHERE asnno = ? and asnlineno = ?"),
|
|
|
- [(int)$info['amount'], (int)$info['amount'], $time, $time, $who, $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
- $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $info['asnno'], $info['asnlineno']]);
|
|
|
- //当asn_detail 所有状态都为完全收货是 asn_header 状态修改为 完全收货(asnstatus=40)
|
|
|
- if (OracleDOCASNDetail::query()->where('asnno', $info['asnno'])->where('linestatus', 40)->count() == $asn->asn_details_count) {
|
|
|
- $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '40',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
|
|
|
- [$time, $who, $info['asnno']]);
|
|
|
- } else {
|
|
|
- //asn_header 部分收货状态
|
|
|
- $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '30',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
|
|
|
- [$time, $who, $info['asnno']]);
|
|
|
- }
|
|
|
}
|
|
|
- return true;
|
|
|
- });
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @throws \Throwable
|
|
|
+ * @param array $info
|
|
|
+ * @param $lotNum
|
|
|
+ * @param $who
|
|
|
+ * @param $time
|
|
|
+ * @param array $actTransactionLog
|
|
|
+ * 更新flux 库存
|
|
|
*/
|
|
|
public function updateFluxInv(array $info, $lotNum, $who, $time, array $actTransactionLog)
|
|
|
{
|
|
|
$db = DB::connection("oracle");
|
|
|
- $db->transaction(function () use ($db, $info, $lotNum, $actTransactionLog, $who, $time) {
|
|
|
- //更新 inv_lot 批次 库存表
|
|
|
- $invLot = $db->selectOne(DB::raw("SELECT * FROM INV_LOT WHERE lotnum = ? AND customerid = ? AND sku = ? "), [
|
|
|
- $lotNum, $info['customerid'], $info['sku']
|
|
|
- ]);
|
|
|
- if ($invLot) $db->update(DB::raw("UPDATE INV_LOT SET qty = qty+?,edittime=?,editwho=? WHERE lotnum = ? AND customerid = ? AND sku = ?"), [
|
|
|
+// $db->transaction(function () use ($db, $info, $lotNum, $actTransactionLog, $who, $time) {
|
|
|
+ //更新 inv_lot 批次 库存表
|
|
|
+ $invLot = $db->selectOne(DB::raw("SELECT * FROM INV_LOT WHERE lotnum = ? AND customerid = ? AND sku = ? FOR UPDATE"), [
|
|
|
+ $lotNum, $info['customerid'], $info['sku']
|
|
|
+ ]);
|
|
|
+ if ($invLot){
|
|
|
+ $db->update(DB::raw("UPDATE INV_LOT SET qty = qty+?,edittime=?,editwho=? WHERE lotnum = ? AND customerid = ? AND sku = ?"), [
|
|
|
(int)$info['amount'], $time, $who, $lotNum, $info['customerid'], $info['sku'],
|
|
|
]);
|
|
|
- else $db->insert(DB::raw("INSERT INTO INV_LOT VALUES(?,?,?,?,0,0,0,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?)"), [
|
|
|
+ }else {
|
|
|
+ $db->insert(DB::raw("INSERT INTO INV_LOT VALUES(?,?,?,?,0,0,0,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?)"), [
|
|
|
$lotNum, $info['customerid'], $info['sku'], $info['amount'], $time, $who, $time, $who
|
|
|
]);
|
|
|
- //更新 inv_lot_loc_id 批次/库位/跟踪号 库存表
|
|
|
- $invLotId = $db->selectOne(DB::raw("SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND locationid = ? AND customerid = ? AND sku = ? AND traceid = ? FOR UPDATE"), [
|
|
|
- $lotNum, $actTransactionLog['location'], $actTransactionLog['customerid'], $actTransactionLog['sku'], $actTransactionLog['trackid']
|
|
|
- ]);
|
|
|
+ }
|
|
|
+ //更新 inv_lot_loc_id 批次/库位/跟踪号 库存表
|
|
|
+ $invLotId = $db->selectOne(DB::raw("SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND locationid = ? AND customerid = ? AND sku = ? AND traceid = ? FOR UPDATE"), [
|
|
|
+ $lotNum, $actTransactionLog['location'], $actTransactionLog['customerid'], $actTransactionLog['sku'], $actTransactionLog['trackid']
|
|
|
+ ]);
|
|
|
|
|
|
// if ($info['location']) { //存在目标库位
|
|
|
// $invLotIdHasPreLocation = $db->selectOne(DB::raw("SELECT * FROM inv_lot_loc_id WHERE lotnum = ? AND locationid = ? AND customerid = ? AND sku = ? AND traceid = ? FOR UPDATE"), [
|
|
|
@@ -643,36 +704,45 @@ sql;
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
- if ($invLotId) $db->update(DB::raw("UPDATE inv_lot_loc_id SET qty = qty+?,qtymvout = qtymvout+?,edittime=?,editwho=? WHERE lotnum = ? AND locationid = ? AND traceid = ?"), [
|
|
|
- (int)$info['amount'],(int)$info['amount'], $time, $who, $lotNum, $actTransactionLog['location'], $actTransactionLog['trackid']
|
|
|
- ]);
|
|
|
- else $db->insert(DB::raw("INSERT INTO inv_lot_loc_id VALUES(?,?,?,?,?,?,0,0,0,0,?,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,0,'*',0,null)"), [
|
|
|
- $lotNum, $actTransactionLog['location'], $actTransactionLog['trackid'], $actTransactionLog['customerid'], $actTransactionLog['sku'], (int)$info['amount'], (int)$info['amount'], $time, $who, $time, $who,
|
|
|
- ]);
|
|
|
- });
|
|
|
+ if ($invLotId){
|
|
|
+ $db->update(DB::raw("UPDATE inv_lot_loc_id SET qty = qty+?,qtymvout = qtymvout+?,edittime=?,editwho=? WHERE lotnum = ? AND locationid = ? AND traceid = ?"), [
|
|
|
+ (int)$info['amount'], (int)$info['amount'], $time, $who, $lotNum, $actTransactionLog['location'], $actTransactionLog['trackid']
|
|
|
+ ]);
|
|
|
+ }else {
|
|
|
+ $db->insert(DB::raw("INSERT INTO inv_lot_loc_id VALUES(?,?,?,?,?,?,0,0,0,0,?,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,0,'*',0,null)"), [
|
|
|
+ $lotNum, $actTransactionLog['location'], $actTransactionLog['trackid'], $actTransactionLog['customerid'], $actTransactionLog['sku'], (int)$info['amount'], (int)$info['amount'], $time, $who, $time, $who,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @throws \Throwable
|
|
|
+ * @param array $info
|
|
|
+ * @param array $invlotatt
|
|
|
+ * @param $actTransactionLog
|
|
|
+ * @param $who
|
|
|
+ * @param $time
|
|
|
+ * @return bool
|
|
|
+ * 生成上架任务
|
|
|
*/
|
|
|
- public function setFluxTskTaskListPA(array $info, array $invlotatt, $actTransactionLog, $who, $time)
|
|
|
+ public function setFluxTskTaskListPA(array $info, array $invlotatt, $actTransactionLog, $who, $time): bool
|
|
|
{
|
|
|
$db = DB::connection("oracle");
|
|
|
- $db->transaction(function () use ($db, $info, $invlotatt, $actTransactionLog, $who, $time) {
|
|
|
- $sql = <<<sql
|
|
|
+// $db->transaction(function () use ($db, $info, $invlotatt, $actTransactionLog, $who, $time) {
|
|
|
+ $sql = <<<sql
|
|
|
INSERT INTO TSK_TASKLISTS VALUES(?,'1','PA',?,?,'ASN',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,null,null,?,?,?,?,?,?,?,?,null,null,null,null,
|
|
|
0,0,0,0,null,?,null,null,null,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),null,null,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),'N',null,null,
|
|
|
?,?,?,'N',null,?,'*',null,null,null,'N',null,null)
|
|
|
sql;
|
|
|
- $db->insert(DB::raw($sql), [
|
|
|
- $actTransactionLog['tsid'], $actTransactionLog['customerid'], $actTransactionLog['sku'], $actTransactionLog['docno'], $actTransactionLog['doclineno'],
|
|
|
- $actTransactionLog['lotNum'], $actTransactionLog['packid'], 'EA', $info['amount'], $info['amount'], $actTransactionLog['location'], $actTransactionLog['location'],
|
|
|
- $actTransactionLog['trackid'], $actTransactionLog['lotNum'], $actTransactionLog['packid'], 'EA', $info['amount'], $info['amount'],
|
|
|
- $info['location'], $info['location'], $actTransactionLog['trackid'], '00', 'Putaway Task', '3', $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
- $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $actTransactionLog['trid'], $who, $time, null, null, null, null,
|
|
|
- $actTransactionLog['userdefine1'], $actTransactionLog['userdefine2'], $actTransactionLog['userdefine3'], $actTransactionLog['warehouseid']
|
|
|
- ]);
|
|
|
- });
|
|
|
+ return $db->insert(DB::raw($sql), [
|
|
|
+ $actTransactionLog['tsid'], $actTransactionLog['customerid'], $actTransactionLog['sku'], $actTransactionLog['docno'], $actTransactionLog['doclineno'],
|
|
|
+ $actTransactionLog['lotNum'], $actTransactionLog['packid'], 'EA', $info['amount'], $info['amount'], $actTransactionLog['location'], $actTransactionLog['location'],
|
|
|
+ $actTransactionLog['trackid'], $actTransactionLog['lotNum'], $actTransactionLog['packid'], 'EA', $info['amount'], $info['amount'],
|
|
|
+ $info['location'], $info['location'], $actTransactionLog['trackid'], '00', 'Putaway Task', '3', $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
+ $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $actTransactionLog['trid'], $who, $time, null, null, null, null,
|
|
|
+ $actTransactionLog['userdefine1'], $actTransactionLog['userdefine2'], $actTransactionLog['userdefine3'], $actTransactionLog['warehouseid']
|
|
|
+ ]);
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -680,48 +750,56 @@ sql;
|
|
|
* @param $lotNum
|
|
|
* @param $who
|
|
|
* @param $time
|
|
|
- * @return mixed
|
|
|
- * @throws \Throwable
|
|
|
+ * @return array
|
|
|
* 创建入库事务
|
|
|
*/
|
|
|
- public function setFluxActTransactionLog(array $info, $lotNum, $who, $time)
|
|
|
+ public function setFluxActTransactionLog(array $info, $lotNum, $who, $time): array
|
|
|
{
|
|
|
$db = DB::connection("oracle");
|
|
|
- return $db->transaction(function () use ($db, $info, $lotNum, $time, $who) {
|
|
|
- if ($info['trackNumber']) $trackNumber = $info['trackNumber'];
|
|
|
- else $trackNumber = substr(md5($time), 0, 30);
|
|
|
- $asnHeader = OracleDOCASNHeader::query()->where('asnno', $info['asnno'])->first();
|
|
|
- $asnDetail = OracleDOCASNDetail::query()->where('asnno', $info['asnno'])->where('sku', $info['sku'])->first();
|
|
|
- $sql = <<<sql
|
|
|
+// return $db->transaction(function () use ($db, $info, $lotNum, $time, $who) {
|
|
|
+ if ($info['trackNumber']) $trackNumber = $info['trackNumber'];
|
|
|
+ else $trackNumber = substr(md5($time), 0, 30);
|
|
|
+ $asnHeader = OracleDOCASNHeader::query()->where('asnno', $info['asnno'])->first();
|
|
|
+ $asnDetail = OracleDOCASNDetail::query()->where('asnno', $info['asnno'])
|
|
|
+ ->where('asnlineno', $info['asnlineno'])->where('sku', $info['sku'])->first();
|
|
|
+ //添加超收判断
|
|
|
+ $actTransactionLogQty = OracleActTransactionLog::query()->where('docno', $info['asnno'])
|
|
|
+ ->where('status','99')->where('transactiontype','IN')//事务状态,类型限定
|
|
|
+ ->where('doclineno', $info['asnlineno'])->where('fmsku', $info['sku'])->count('fmqty');
|
|
|
+ if ((int)($info['amount'] + $actTransactionLogQty) > (int)$asnDetail['expectedqty']) return [];
|
|
|
+
|
|
|
+ $sql = <<<sql
|
|
|
INSERT INTO ACT_TRANSACTION_LOG VALUES(?,'IN',?,?,?,?,'ASN',?,?,?,?,?,?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,
|
|
|
TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,?,null,null,null,?,?,?,?,?,?,?,?,
|
|
|
?,?,?,?,'1','Y',null,?,?,?,?,null,null,?,null,null)
|
|
|
sql;
|
|
|
- list($trid, $max) = app('StorageService')->getTrNumber();
|
|
|
- list($tsid, $max) = $this->getTsNum();
|
|
|
- $db->insert(DB::raw($sql), [
|
|
|
- $trid, $asnDetail->customerid, $asnDetail->sku,
|
|
|
- $asnDetail->asnno, $asnDetail->asnlineno, $lotNum, $asnDetail->receivinglocation, '*', $asnDetail->packid, 'EA', $info['amount'], $info['amount'], '99', $time, $who,
|
|
|
- $time, $who, $time, $asnDetail->customerid, $asnDetail->sku, $trackNumber, $asnDetail->receivinglocation, $who, $asnDetail->packid, 'EA', $info['amount'], $info['amount'], $lotNum,
|
|
|
- '*', '0', 'N', $tsid, substr($asnDetail->receivinglocation, -4), $asnHeader->userdefine1, $asnHeader->userdefine2,
|
|
|
- $asnHeader->userdefine3, 'O'
|
|
|
- ]);
|
|
|
- app('StorageService')->setTrNumber();
|
|
|
- $this->setTsNum();
|
|
|
- $actTransactionLog = [
|
|
|
- 'trid' => $trid, 'docno' => $asnDetail->asnno, 'customerid' => $asnDetail->customerid, 'sku' => $asnDetail->sku, 'doclineno' => $asnDetail->asnlineno, 'lotNum' => $lotNum, 'location' => $asnDetail->receivinglocation,
|
|
|
- 'packid' => $asnDetail->packid, 'tsid' => $tsid, 'warehouseid' => substr($asnDetail->receivinglocation, -4), 'userdefine1' => $asnHeader->userdefine1, 'userdefine2' => $asnHeader->userdefine2,
|
|
|
- 'userdefine3' => $asnHeader->userdefine3, 'trackid' => $trackNumber
|
|
|
- ];
|
|
|
- return $actTransactionLog;
|
|
|
- });
|
|
|
+ list($trid, $max) = app('StorageService')->getTrNumber();
|
|
|
+ list($tsid, $max) = $this->getTsNum();
|
|
|
+ $db->insert(DB::raw($sql), [
|
|
|
+ $trid, $asnDetail->customerid, $asnDetail->sku,
|
|
|
+ $asnDetail->asnno, $asnDetail->asnlineno, $lotNum, $asnDetail->receivinglocation, '*', $asnDetail->packid, 'EA', $info['amount'], $info['amount'], '99', $time, $who,
|
|
|
+ $time, $who, $time, $asnDetail->customerid, $asnDetail->sku, $trackNumber, $asnDetail->receivinglocation, $who, $asnDetail->packid, 'EA', $info['amount'], $info['amount'], $lotNum,
|
|
|
+ '*', '0', 'N', $tsid, substr($asnDetail->receivinglocation, -4), $asnHeader->userdefine1, $asnHeader->userdefine2,
|
|
|
+ $asnHeader->userdefine3, 'O'
|
|
|
+ ]);
|
|
|
+ app('StorageService')->setTrNumber();
|
|
|
+ $this->setTsNum();
|
|
|
+ $actTransactionLog = [
|
|
|
+ 'trid' => $trid, 'docno' => $asnDetail->asnno, 'customerid' => $asnDetail->customerid, 'sku' => $asnDetail->sku, 'doclineno' => $asnDetail->asnlineno, 'lotNum' => $lotNum, 'location' => $asnDetail->receivinglocation,
|
|
|
+ 'packid' => $asnDetail->packid, 'tsid' => $tsid, 'warehouseid' => substr($asnDetail->receivinglocation, -4), 'userdefine1' => $asnHeader->userdefine1, 'userdefine2' => $asnHeader->userdefine2,
|
|
|
+ 'userdefine3' => $asnHeader->userdefine3, 'trackid' => $trackNumber
|
|
|
+ ];
|
|
|
+ return $actTransactionLog;
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param array $info
|
|
|
+ * @param array $invlotatt
|
|
|
+ * @param $who
|
|
|
+ * @param $time
|
|
|
* @return mixed
|
|
|
- * @throws \Throwable
|
|
|
- * 或去flux 批次号
|
|
|
+ * 获取flux 批次号
|
|
|
*/
|
|
|
public function getOrCreateLotNum(array $info, array $invlotatt, $who, $time)
|
|
|
{
|
|
|
@@ -733,18 +811,18 @@ sql;
|
|
|
|
|
|
$db = DB::connection("oracle");
|
|
|
list($num, $max) = $this->getLtNum();
|
|
|
- return $db->transaction(function () use ($db, $info, $invlotatt, $num, $who, $time) {
|
|
|
- $sql = <<<sql
|
|
|
+// return $db->transaction(function () use ($db, $info, $invlotatt, $num, $who, $time) {
|
|
|
+ $sql = <<<sql
|
|
|
INSERT INTO INV_LOT_ATT VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,
|
|
|
TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?)
|
|
|
sql;
|
|
|
- $db->insert(DB::raw($sql), [
|
|
|
- $num, $info['customerid'], $info['sku'], $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
- $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], null, null, null, null, $time, $who, $time, $who, $time, null
|
|
|
- ]);
|
|
|
- $this->setLtNum();
|
|
|
- return $num;
|
|
|
- });
|
|
|
+ $db->insert(DB::raw($sql), [
|
|
|
+ $num, $info['customerid'], $info['sku'], $invlotatt['lotatt01'], $invlotatt['lotatt02'], $invlotatt['lotatt03'], $invlotatt['lotatt04'],
|
|
|
+ $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], null, null, null, null, $time, $who, $time, $who, $time, null
|
|
|
+ ]);
|
|
|
+ $this->setLtNum();
|
|
|
+ return $num;
|
|
|
+// });
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -795,4 +873,43 @@ sql;
|
|
|
->where("name", "flux_ts_number")
|
|
|
->update(["value" => DB::raw("value+1")]);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $param
|
|
|
+ * @return array
|
|
|
+ * 获取库存信息
|
|
|
+ */
|
|
|
+ public function getInventoryInfos($param): array
|
|
|
+ {
|
|
|
+ $sql = <<<sql
|
|
|
+select BAS_SKU.SKU,INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08,
|
|
|
+ INV_LOT_ATT.LOTATT01,INV_LOT_ATT.LOTATT02,INV_LOT_ATT.LOTATT03,INV_LOT_ATT.LOTATT04,
|
|
|
+ sum(INV_LOT_LOC_ID.QTY) AS QTY from INV_LOT_LOC_ID
|
|
|
+ left join BAS_SKU on INV_LOT_LOC_ID.CUSTOMERID=BAS_SKU.CUSTOMERID and INV_LOT_LOC_ID.SKU =BAS_SKU.SKU
|
|
|
+ left join INV_LOT_ATT on INV_LOT_ATT.LOTNUM=INV_LOT_LOC_ID.LOTNUM where
|
|
|
+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) ||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
|
|
|
+ select SKU from BAS_SKU where ALTERNATE_SKU2=? union
|
|
|
+ select SKU from BAS_SKU where ALTERNATE_SKU3=? union
|
|
|
+ select SKU from BAS_SKU where SKU=? )";
|
|
|
+ }
|
|
|
+
|
|
|
+ $sql .= ' group by BAS_SKU.SKU,INV_LOT_LOC_ID.CUSTOMERID,BAS_SKU.ALTERNATE_SKU1,INV_LOT_LOC_ID.LOCATIONID,
|
|
|
+ INV_LOT_ATT.LOTATT05,INV_LOT_ATT.LOTATT08,INV_LOT_ATT.LOTATT01,INV_LOT_ATT.LOTATT02,INV_LOT_ATT.LOTATT03,INV_LOT_ATT.LOTATT04';
|
|
|
+ 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) ||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]);
|
|
|
+ }
|
|
|
+ if (!$invLots) return [];
|
|
|
+ else return $invLots;
|
|
|
+ }
|
|
|
}
|