فهرست منبع

手持收货入库页面及后台逻辑调整

haozi 4 سال پیش
والد
کامیت
7271ecac16

+ 3 - 2
app/Http/Controllers/HandInStorageController.php

@@ -120,8 +120,9 @@ class HandInStorageController extends Controller
         }
         if ($info['customerid']=='JIANSHANG'&&$handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
         try {
-            $result = $handInStorageService->fluxHandIn($info);
-            if ($result){
+            $resultIn = $handInStorageService->fluxHandIn($info);
+            if ($resultIn===1)$this->error("超收");
+            if ($resultIn){
                 $asnQty=$handInStorageService->getAsnQty($info['asnno']);
                 $end=microtime(true);
                 if(($end-$start)>2)Log::warning('手持收货超时',$request->all());

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

@@ -389,4 +389,24 @@ sql;
         }
         return ['success' => true];
     }
+
+    public function testChangeLabor()
+    {
+        $laborReports=LaborReport::query()
+            ->where('created_at','like','2021-09-13%')
+            ->where('user_workgroup_id',4)
+            ->where('online_duration','>',13)
+            ->get();
+        foreach ($laborReports as $laborReport){
+          LaborReport::query()->find($laborReport->id)
+              ->update([
+                  'online_duration'=>round(Carbon::parse($laborReport->check_out_at)->diffInSeconds(Carbon::parse($laborReport->check_in_at))/3600,2),
+                  'working_duration'=>(round(Carbon::parse($laborReport->check_out_at)->diffInSeconds(Carbon::parse($laborReport->check_in_at))/3600,2)-1),
+              ]);
+          LaborReportStatus::query()->where('labor_report_id',$laborReport->id)
+              ->where('status','已退场')
+              ->update(['created_at'=>$laborReport->check_out_at]);
+        }
+    }
+
 }

+ 57 - 42
app/Services/HandInStorageService.php

@@ -538,13 +538,12 @@ sql;
         return $arr;
     }
 
-
     /**
      * @param array $info
-     * @return bool
+     * @return bool|int
      * fulx 手持收货
      */
-    public function fluxHandIn(array $info): bool
+    public function fluxHandIn(array $info)
     {
         $lotatt = array_filter($info, function ($key) {
             return strpos($key, 'lotatt') === 0;
@@ -563,29 +562,34 @@ sql;
         $db = DB::connection("oracle");
         $db->beginTransaction();
         try {
-//        return DB::connection("oracle")->transaction(function () use ($info, $invlotatt, $who, $time) {
-            //flux 批次号
+            $asnHeader = OracleDOCASNHeader::query()->where('asnno', $info['asnno'])->first();
+            $asnDetail = OracleDOCASNDetail::query()->where('asnno', $info['asnno'])
+                ->where('asnlineno', $info['asnlineno'])->where('sku', $info['sku'])->first();
+            // 1:flux 获取批次号
             $lotNum = $this->getOrCreateLotNum($info, $invlotatt, $who, $time);
             if (!$lotNum){$db->rollBack();return false;}
 
-            //flux 创建入库事务
-            $actTransactionLog = $this->setFluxActTransactionLog($info, $lotNum, $who, $time);
+            // 2:flux 判断当前入库是否超收
+            $res=$this->judgeOverCharge($info,$asnDetail);
+            if (!$res) return 1; //超收
+
+            // 3:flux 创建状态为创建的入库事务
+            $actTransactionLog = $this->setFluxActTransactionLog($info, $lotNum, $who, $time,$asnHeader,$asnDetail);
             if (count($actTransactionLog) == 0){$db->rollBack();return false;}
-            //flux 创建上架任务
-            $res=$this->setFluxTskTaskListPA($info, $invlotatt, $actTransactionLog, $who, $time);
-            if (!$res){$db->rollBack();return false;}
-            //flux 完善库存余量
+
+            // 4:flux 新增一条上架任务记录
+            $this->setFluxTskTaskListPA($info, $invlotatt, $actTransactionLog, $who, $time);
+
+            // 5:flux 完善库存余量 入库完成修改库存余量
             $this->updateFluxInv($info, $lotNum, $who, $time, $actTransactionLog);
-            //flux 更新asn_detail 和 asn_header 状态
+
+            // 6: flux 更新 asn_detail 和 asn_header 状态
             $result=$this->updateFluxAsn($info, $invlotatt, $time, $who);
-            if ($result){
-                $db->commit();
-                return true;
-            }else{
-                $db->rollBack();
-                return false;
-            }
-//        });
+            if (!$result){$db->rollBack();return false;}
+            // 7:入库完成 -> 事务状态改为完成
+            // $this->updateActTransactionLogStatus($actTransactionLog,$time);
+            $db->commit();
+            return true;
         } catch (\Exception $e) {
             $db->rollBack();
             return false;
@@ -593,6 +597,34 @@ sql;
 
     }
 
+    /**
+     * @param array $actTransactionLog
+     * @param $time
+     * 更改事务表状态
+     */
+//    public function updateActTransactionLogStatus(array $actTransactionLog,$time)
+//    {
+//        $db = DB::connection("oracle");
+//        $db->update(DB::raw("UPDATE ACT_TRANSACTION_LOG SET status = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss') WHERE transactionid = ?"),
+//            [$time, $actTransactionLog['trid']]);
+//
+//    }
+    /**
+     * @param array $info
+     * @param $asnDetail
+     * @return bool
+     * 判断是否超收
+     */
+    public function judgeOverCharge(array $info,$asnDetail): bool
+    {
+        //添加超收判断
+        $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 false;
+        return true;
+    }
+
     /**
      * @param array $info
      * @param array $invlotatt
@@ -670,7 +702,6 @@ sql;
     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 = ? FOR UPDATE"), [
             $lotNum, $info['customerid'], $info['sku']
@@ -722,7 +753,6 @@ sql;
                 $lotNum, $actTransactionLog['location'], $actTransactionLog['trackid'], $actTransactionLog['customerid'], $actTransactionLog['sku'], (int)$info['amount'], (int)$info['amount'], $time, $who, $time, $who,
             ]);
         }
-//        });
     }
 
     /**
@@ -731,19 +761,17 @@ sql;
      * @param $actTransactionLog
      * @param $who
      * @param $time
-     * @return bool
      * 生成上架任务
      */
-    public function setFluxTskTaskListPA(array $info, array $invlotatt, $actTransactionLog, $who, $time): bool
+    public function setFluxTskTaskListPA(array $info, array $invlotatt, $actTransactionLog, $who, $time)
     {
         $db = DB::connection("oracle");
-//        $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;
-        return $db->insert(DB::raw($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'],
@@ -751,7 +779,6 @@ sql;
             $invlotatt['lotatt05'], $invlotatt['lotatt06'], $invlotatt['lotatt07'], $invlotatt['lotatt08'], $actTransactionLog['trid'], $who, $time, null, null, null, null,
             $actTransactionLog['userdefine1'], $actTransactionLog['userdefine2'], $actTransactionLog['userdefine3'], $actTransactionLog['warehouseid']
         ]);
-//        });
     }
 
     /**
@@ -759,24 +786,16 @@ sql;
      * @param $lotNum
      * @param $who
      * @param $time
+     * @param $asnHeader
+     * @param $asnDetail
      * @return array
      * 创建入库事务
      */
-    public function setFluxActTransactionLog(array $info, $lotNum, $who, $time): array
+    public function setFluxActTransactionLog(array $info, $lotNum, $who, $time,$asnHeader,$asnDetail): 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('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,?,?,?,?,?,?,?,?,
@@ -799,7 +818,6 @@ sql;
             'userdefine3' => $asnHeader->userdefine3, 'trackid' => $trackNumber
         ];
         return $actTransactionLog;
-//        });
     }
 
     /**
@@ -820,7 +838,6 @@ sql;
 
         $db = DB::connection("oracle");
         list($num, $max) = $this->getLtNum();
-//        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'),?)
@@ -831,8 +848,6 @@ sql;
         ]);
         $this->setLtNum();
         return $num;
-//        });
-
     }
 
     /**

+ 19 - 12
resources/views/store/handInStorage/putaway.blade.php

@@ -358,14 +358,20 @@
                         ensure() {
                             this.errors={};//初始errors状态
                             this.verifyInfoAndCheckData();
-                            tempTip.setDuration(1000);
+                            if (JSON.stringify(this.errors) !== '{}')return;
+                            this.ensureSubmit();
+
+                        },
+                        ensureSubmit() {
+                            tempTip.setDuration(99999);
                             tempTip.waitingTip('提交中');
                             let url = '{{url('store/handInStorage/handFluxPa')}}';
                             if (JSON.stringify(this.errors)==='{}') window.axios.post(url,{info:this.info,checkData:this.checkData})
                                 .then(res=>{
                                     if (res.data.success){
-                                        window.tempTip.setDuration(3000);
-                                        window.tempTip.showSuccess(res.data.data);
+                                        tempTip.setDuration(3000);
+                                        tempTip.cancelWaitingTip();
+                                        tempTip.showSuccess(res.data.data);
                                         // this.info={};
                                         this.clearInfo();
                                         this.checkData=[];
@@ -375,15 +381,16 @@
                                         document.getElementById("trackNumber").select();
                                         return;
                                     }
-                                    window.tempTip.setDuration(3000);
-                                    window.tempTip.show(res.data.data);
-                                    window.tempTip.showErrorAudio();
+                                    tempTip.setDuration(3000);
+                                    tempTip.cancelWaitingTip();
+                                    tempTip.show(res.data.data);
+                                    tempTip.showErrorAudio();
                                 }).catch(err=>{
-                                window.tempTip.setDuration(3000);
-                                window.tempTip.show("网络错误:"+err);
-                                window.tempTip.showErrorAudio();
-                            })
-
+                                    tempTip.setDuration(3000);
+                                    tempTip.cancelWaitingTip();
+                                    tempTip.show("网络错误:"+err);
+                                    tempTip.showErrorAudio();
+                                })
                         },
                         cancel() {
                             setTimeout(function () {
@@ -405,7 +412,7 @@
                             if (!this.info.amount) error.amount = ["上架数量必填"];
                             if (Number(this.info.paTotal)!==0 && Number(this.info.amount)>Number(this.info.paTotal)) error.amount = ["上架数量不能超过上架总数必填"];
                             if (!this.info.location) error.location = ["目标库位必填"];
-                            if (JSON.stringify(error) !== '{}') {this.errors = error;return;}
+                            if (JSON.stringify(error) !== '{}') {this.errors = error;}
                         },
                     },
                 });

+ 17 - 10
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -318,14 +318,19 @@
                     if (Number(this.info.receivedqty)===Number(this.info.expectedqty)){
                         window.tempTip.setDuration(2000); window.tempTip.show("收货已完成");
                     }
-                    tempTip.setDuration(1000);
+                   if(JSON.stringify(this.errors)!=='{}')return;
+                   this.ensureSubmit();
+                },
+                ensureSubmit(){
+                    tempTip.setDuration(99999);
                     tempTip.waitingTip('提交中');
                     let url = '{{url('store/handInStorage/fluxHandIn')}}';
                     if (JSON.stringify(this.errors)==='{}') window.axios.post(url,{info:this.info})
                         .then(res=>{
                             if (res.data.success){
-                                window.tempTip.setDuration(2000);
-                                window.tempTip.showSuccess('收货成功');
+                                tempTip.setDuration(2000);
+                                tempTip.cancelWaitingTip();
+                                tempTip.showSuccess('收货成功');
                                 // this.info={};
                                 this.clearInfo();
                                 this.asn_expectedqty=res.data.data.expectedqty;
@@ -338,14 +343,16 @@
                                     window.location.href="{{url('store/handInStorage/receive')}}";
                                 return;
                             }
-                            window.tempTip.setDuration(3000);
-                            window.tempTip.show(res.data.data);
-                            window.tempTip.showErrorAudio();
+                            tempTip.setDuration(3000);
+                            tempTip.cancelWaitingTip();
+                            tempTip.show(res.data.data);
+                            tempTip.showErrorAudio();
                         }).catch(err=>{
-                        window.tempTip.setDuration(2000);
-                        window.tempTip.show("网络错误:"+err);
-                        window.tempTip.showErrorAudio();
-                    })
+                            tempTip.setDuration(2000);
+                            tempTip.cancelWaitingTip();
+                            tempTip.show("网络错误:"+err);
+                            tempTip.showErrorAudio();
+                        })
                 },
                 cancel(){
                     setTimeout(function () {