zhouzhendong 4 лет назад
Родитель
Сommit
cba3dad495

+ 2 - 2
app/Console/Commands/CreateProcurementTotalBill.php

@@ -43,10 +43,10 @@ class CreateProcurementTotalBill extends Command
     {
         $date=$this->getDate();
         $procurementCheckSheets=ProcurementCheckSheet::query()
-            ->selectRaw('procurements.supplier_id supplier_id,procurement_check_sheets.created_at created_at,procurement_check_sheets.status status,SUM(procurement_check_sheets.account_payable) account_payable')
+            ->selectRaw('procurements.supplier_id supplier_id,procurement_deliveries.signed_at signed_at,procurement_check_sheets.status status,SUM(procurement_check_sheets.account_payable) account_payable')
             ->leftJoin('procurement_deliveries','procurement_check_sheets.procurement_delivery_id','procurement_deliveries.id')
             ->leftJoin('procurements','procurement_deliveries.procurement_id','procurements.id')
-            ->where('procurement_check_sheets.created_at','like',$date."%")
+            ->where('procurement_deliveries.signed_at','like',$date."%")
             ->groupBy('supplier_id')
             ->get();
         $totalBill=[];

+ 1 - 1
app/Http/Controllers/HandInStorageController.php

@@ -114,7 +114,7 @@ class HandInStorageController extends Controller
             if ($result===1)$this->error('需要维护产品档案');
             if ($result===2)$this->error('需要维护该产品档案中的重量体积');
         }
-        if ($handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
+        if ($info['customerid']=='JIANSHANG'&&$handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
         try {
             $result = $handInStorageService->fluxHandIn($info);
             if ($result){

+ 1 - 0
app/Http/Controllers/TestController.php

@@ -32,6 +32,7 @@ use App\OwnerFeeOperationDetail;
 use App\OwnerFeeStorage;
 use App\OwnerPriceOperation;
 use App\OrderPackageCountingRecord;
+use App\ProcurementCheckSheet;
 use App\RejectedBill;
 use App\Services\CacheShelfService;
 use App\Services\ForeignHaiRoboticsService;

+ 4 - 0
app/OracleInvLotLocId.php

@@ -24,4 +24,8 @@ class OracleInvLotLocId extends Model
     *         QTY 在库数量
     *         QtyAllocated 占用数量
     * */
+    public function oracleInvLotAtt(): \Illuminate\Database\Eloquent\Relations\BelongsTo
+    {
+       return $this->belongsTo(OracleInvLotAtt::class,'lotnum','lotnum');
+    }
 }

+ 44 - 29
app/Services/HandInStorageService.php

@@ -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'],