|
|
@@ -17,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;
|
|
|
@@ -124,19 +125,26 @@ 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; //当前库位无库存余量 可直接入库
|
|
|
|
|
|
@@ -146,13 +154,18 @@ class HandInStorageService
|
|
|
$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()->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']) return true;
|
|
|
@@ -552,19 +565,14 @@ sql;
|
|
|
// return DB::connection("oracle")->transaction(function () use ($info, $invlotatt, $who, $time) {
|
|
|
//flux 批次号
|
|
|
$lotNum = $this->getOrCreateLotNum($info, $invlotatt, $who, $time);
|
|
|
- if (!$lotNum){
|
|
|
- $db->rollBack();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (!$lotNum){$db->rollBack();return false;}
|
|
|
|
|
|
//flux 创建入库事务
|
|
|
$actTransactionLog = $this->setFluxActTransactionLog($info, $lotNum, $who, $time);
|
|
|
- if (count($actTransactionLog) == 0){
|
|
|
- $db->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 状态
|
|
|
@@ -654,15 +662,18 @@ sql;
|
|
|
$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 = ? "), [
|
|
|
+ $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'),?)"), [
|
|
|
- $lotNum, $info['customerid'], $info['sku'], $info['amount'], $time, $who, $time, $who
|
|
|
- ]);
|
|
|
+ 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'),?)"), [
|
|
|
+ $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']
|
|
|
@@ -692,12 +703,15 @@ 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,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
// });
|
|
|
}
|
|
|
|
|
|
@@ -707,9 +721,10 @@ sql;
|
|
|
* @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) {
|
|
|
@@ -718,7 +733,7 @@ INSERT INTO TSK_TASKLISTS VALUES(?,'1','PA',?,?,'ASN',?,?,?,?,?,?,?,?,?,?,?,?,?,
|
|
|
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), [
|
|
|
+ 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'],
|