Bladeren bron

完善手持入库 收货逻辑

haozi 4 jaren geleden
bovenliggende
commit
f4e540ea83

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

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\OracleBasLocation;
 use App\OracleDOCASNHeader;
 use App\Services\HandInStorageService;
 use Illuminate\Http\Request;
@@ -68,16 +69,23 @@ class HandInStorageController extends Controller
         else $this->error('无效条码');
     }
 
+    /**
+     * @throws \Throwable
+     */
     public function fluxHandIn(Request $request)
     {
         $info=$request->input('info');
-//        dd($info);
         if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
         if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
+        if ($info['location']){
+            $location=OracleBasLocation::query()->where('locationid',$info['location'])->first();
+            if (!$location)$this->error('目标库位不存在');
+        }
         /** @var HandInStorageService $handInStorageService  */
         $handInStorageService=app('HandInStorageService');
-        $handInStorageService->fluxHandIn($info);
-//        dd($result,"111");
+        $result=$handInStorageService->fluxHandIn($info);
+        if ($result)$this->success("收货成功");
+        else $this->error("收货失败");
     }
 
 

+ 18 - 0
app/OracleBasLocation.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+
+class OracleBasLocation extends Model
+{
+    use ModelTimeFormat;
+    use ModelLogChanging;
+
+    protected $connection="oracle";
+    protected $table="BAS_Location";
+    //
+}

+ 18 - 18
app/Services/HandInStorageService.php

@@ -132,22 +132,20 @@ class HandInStorageService
         }
         $who= 'WAS'.(Auth::user() ? '-'.Auth::user()["name"] : '');
         $time=Carbon::now()->toDateTimeString();
-//        return DB::connection("oracle")->transaction(function ()use ($info,$invlotatt,$who,$time){
+        return DB::connection("oracle")->transaction(function ()use ($info,$invlotatt,$who,$time){
             //flux 批次号
-//            $lotNum=$this->getOrCreateLotNum($info,$invlotatt,$who,$time);
-//            if (!$lotNum) return false;
+            $lotNum=$this->getOrCreateLotNum($info,$invlotatt,$who,$time);
+            if (!$lotNum) return false;
             //flux 创建入库事务
-//            $actTransactionLog=$this->setFluxActTransactionLog($info,$lotNum,$who,$time);
-//            if (!$actTransactionLog)return false;
+            $actTransactionLog=$this->setFluxActTransactionLog($info,$lotNum,$who,$time);
+            if (!$actTransactionLog)return false;
             //flux 创建上架任务
-//            $this->setFluxTskTaskListPA($info,$invlotatt, $actTransactionLog, $who, $time);
+            $this->setFluxTskTaskListPA($info,$invlotatt, $actTransactionLog, $who, $time);
             //flux 完善库存余量
-//            $this->updateFluxInv($info,$lotNum,$who,$time,$actTransactionLog);
+            $this->updateFluxInv($info,$lotNum,$who,$time,$actTransactionLog);
             //flux 更新asn_detail 和 asn_header 状态
-            $re=$this->updateFluxAsn($info,$invlotatt,$time,$who);
-            dd($re);
-//            return true;
-//        });
+            return $this->updateFluxAsn($info,$invlotatt,$time,$who);
+        });
 
     }
 
@@ -171,21 +169,23 @@ class HandInStorageService
                 $asnDetail['customerid']==$info['customerid'] &&
                 $asnDetail['sku']==$info['sku']) $receiveAsn=$asnDetail;
         }
-        return $db->transaction(function ()use($db,$info,$receiveAsn,$invlotatt,$time,$who){
+        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 linestatus = '30',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,
-             lotatt01=?,lotatt02=?,lotatt03=?,lotatt04=?,lotatt05=?,lotatt06=?,lotatt07=?,lotatt08=? WHERE asnno = ?"),
-                    [$time,$who,$invlotatt['lotatt01'],$invlotatt['lotatt02'],$invlotatt['lotatt03'],$invlotatt['lotatt04'],
+                $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 = ?"),
+                    [(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']]);
                 //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 linestatus = '40',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ?,
-             lotatt01=?,lotatt02=?,lotatt03=?,lotatt04=?,lotatt05=?,lotatt06=?,lotatt07=?,lotatt08=? WHERE asnno = ?"),
-                    [$time,$who,$invlotatt['lotatt01'],$invlotatt['lotatt02'],$invlotatt['lotatt03'],$invlotatt['lotatt04'],
+                $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 = ?"),
+                    [(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']]);
                 //当asn_detail 所有状态都为完全收货是  asn_header 状态修改为 完全收货(asnstatus=40)
                 if (OracleDOCASNDetail::query()->where('asnno',$info['asnno'])->where('linestatus',40)->count()==$asn->asn_details_count){

+ 1 - 1
resources/views/store/handInStorage/receive.blade.php

@@ -12,7 +12,7 @@
                     <span class="font-weight-bold">ASN号:</span>
                     <div class="form-group row mt-2">
                         <label for="asn"></label>
-                        <input type="text" class="form-control col-8" id="asn"
+                        <input type="text" class="form-control col-8" id="asn" autocomplete="off"
                                :class="errors.asn ? 'is-invalid' : ''" @keydown.enter="selectCustomerid($event)" v-model="info.asn">
                         <span class="ml-2">
                              <button type="button" id="select" class="btn btn-info" @click="selectAsn()">搜索</button>

+ 16 - 15
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -13,7 +13,7 @@
                             <span class="fa fa-search fa-lg" aria-hidden="true" @click="selectAsnDetails()"></span>
                             <label for="sku" class="text-right text-danger font-weight-bold">条码:</label>
                         </span>
-                    <input type="text" class="form-control form-control-sm col-8" id="sku"
+                    <input type="text" class="form-control form-control-sm col-8" id="sku" autocomplete="off"
                            :class="errors.sku ? 'is-invalid' : ''" @keydown.enter="enterVal($event)" v-model="info.sku" @blur="checkedSku()">
                     <span class="invalid-feedback offset-3" role="alert" v-if="errors.sku">
                             <strong>@{{ errors.sku[0] }}</strong>
@@ -31,7 +31,7 @@
                     </div>
                     <div class="form-group row m-1">
                         <label for="amount" class="text-right text-danger font-weight-bold">实收数量:</label>
-                        <input type="number" class="form-control form-control-sm col-8" id="amount"
+                        <input type="number" class="form-control form-control-sm col-8" id="amount" autocomplete="off"
                                :class="errors.amount ? 'is-invalid' : ''" v-model="info.amount" @keydown.enter="enterVal($event)">
                         <span class="invalid-feedback offset-3" role="alert" v-if="errors.amount">
                             <strong>@{{ errors.amount[0] }}</strong>
@@ -39,12 +39,12 @@
                     </div>
                     <div class="form-group row m-1">
                         <label for="location" class="text-right">目标库位:</label>
-                        <input type="text" class="form-control form-control-sm col-8" id="location"
+                        <input type="text" class="form-control form-control-sm col-8" id="location" autocomplete="off"
                                @keydown.enter="enterVal($event)" v-model="info.location">
                     </div>
                     <div class="form-group row m-1">
                         <label for="trackNumber" class="text-right">托盘号:</label>
-                        <input type="text" class="form-control form-control-sm col-8" id="trackNumber"
+                        <input type="text" class="form-control form-control-sm col-8" id="trackNumber" autocomplete="off"
                                @keydown.enter="enterVal($event)" v-model="info.trackNumber">
                     </div>
                 </div>
@@ -89,7 +89,7 @@
                 <div class="form-group row">
                     <span class="col-6" v-if="basSku.lot_id.lotkey04==='Y'">
                         <label for="lotatt04" class=" text-right text-danger">批号:</label><br>
-                        <input type="text" class="form-control form-control-sm" :class="errors.lotatt04 ? 'is-invalid' : ''"
+                        <input type="text" class="form-control form-control-sm" :class="errors.lotatt04 ? 'is-invalid' : ''" autocomplete="off"
                                id="lotatt04" v-model="info.lotatt04">
                          <span class="invalid-feedback offset-3" role="alert" v-if="errors.lotatt04">
                             <strong>@{{ errors.lotatt04[0] }}</strong>
@@ -182,7 +182,6 @@
                         this.selectTr=0
                     }else {
                         this.selectTr=i+1;
-                        // this.info.sku=sku;
                     }
                 },
                 checkedSku(){
@@ -232,6 +231,7 @@
                     this.info.name=asnDetail.skudescrc;
                     this.info.expectedqty=asnDetail.expectedqty;
                     this.info.receivedqty=asnDetail.receivedqty;
+                    this.info.amount=Number(this.info.expectedqty)-Number(this.info.receivedqty);
                     this.info.asnlineno=asnDetail.asnlineno;
                 },
                 //聚焦 白名单
@@ -249,8 +249,7 @@
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey04==='Y' && !this.info.lotatt04) error.lotatt04=["批号未填"];
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey05==='Y' && !this.info.lotatt05) error.lotatt05=["属性仓未选"];
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey08==='Y' && !this.info.lotatt08) error.lotatt08=["质量状态未选"];
-                    if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
-                    if (!this.info.amount && this.info.maximum)this.info.amount = this.info.maximum;
+                    if (JSON.stringify(error)!=='{}'){this.errors = error;}
                 },
                 enterVal(e){
                     let index = this.element.indexOf(e.target.id)+1;
@@ -278,21 +277,23 @@
                     })
                 },
                 ensure(){
+                    this.errors={};//初始errors状态
                     this.checkInfo();
                     this.info.customerid=this.customerid;
                     this.info.asnno=this.asnno;
-                    console.log( this.info.trackNumber,this.info.location)
                     if (this.info.trackNumber==''||this.info.trackNumber==null||this.info.trackNumber==undefined)this.info.trackNumber='';
                     if (this.info.location==''||this.info.location==null||this.info.location==undefined)this.info.location='';
-                    // this.info.trackNumber='';
-                    // this.info.location='';
-                    console.log(this.info)
+                    if (Number(this.info.receivedqty)===Number(this.info.expectedqty)){
+                        window.tempTip.setDuration(2000); window.tempTip.show("收货已完成");
+                    }
                     let url = '{{url('store/handInStorage/fluxHandIn')}}';
-                    window.axios.post(url,{info:this.info})
+                    if (JSON.stringify(this.errors)==='{}') window.axios.post(url,{info:this.info})
                         .then(res=>{
                             if (res.data.success){
-                                // this.asnDetails=res.data.data;
-                                // this.$forceUpdate()
+                                window.tempTip.setDuration(2000);
+                                window.tempTip.showSuccess(res.data.data);
+                                this.info={};
+                                this.$forceUpdate();
                                 return;
                             }
                             window.tempTip.setDuration(2000);