ソースを参照

库存查询功能,收货校验数量

haozi 4 年 前
コミット
3393e009ea

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

@@ -195,6 +195,17 @@ class HandInStorageController extends Controller
         }
     }
 
+    public function getInventoryInfos(Request $request)
+    {
+        $this->gate("入库管理-手持入库-库存查询");
+        $param=$request->input('location');
+        /** @var HandInStorageService $handInStorageService  */
+        $handInStorageService=app('HandInStorageService');
+        $invs=$handInStorageService->getInventoryInfos($param);
+        if (count($invs)>0)$this->success($invs);
+        else $this->error('未查询到库存信息');
+    }
+
 
 
 

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

@@ -171,16 +171,4 @@ class TestController extends Controller
     {
         SettlementBillReportTask::dispatchNow('2021-08-01');
     }
-
-    public function testLoc()
-    {
-        /** @var HandInStorageService $handInStorageService  */
-        $handInStorageService=app('HandInStorageService');
-        //判断当前库位是否能放该商品
-        $info=['location'=>'C02-065-4'];
-        $checkData=['customerid'=>'', 'sku'=>'', 'plantolotnum'=>''];
-        $res=$handInStorageService->checkLocation($info,$checkData);
-        dd($res);
-    }
-
 }

+ 51 - 9
app/Services/HandInStorageService.php

@@ -3,6 +3,7 @@
 namespace App\Services;
 
 use App\CommodityBarcode;
+use App\OracleActTransactionLog;
 use App\OracleBasCode;
 use App\OracleBasCustomer;
 use App\OracleBasForwardingLoc;
@@ -526,16 +527,12 @@ sql;
         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) return false;
+
             //flux 创建入库事务
             $actTransactionLog = $this->setFluxActTransactionLog($info, $lotNum, $who, $time);
-            if (!$actTransactionLog) {
-                DB::connection("oracle")->rollBack();
-                return false;
-            }
+            if (count($actTransactionLog)==0) return false;
+
             //flux 创建上架任务
             $this->setFluxTskTaskListPA($info, $invlotatt, $actTransactionLog, $who, $time);
             //flux 完善库存余量
@@ -692,7 +689,13 @@ sql;
             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();
+            $asnDetail = OracleDOCASNDetail::query()->where('asnno', $info['asnno'])
+                ->where('asnlineno',$info['asnlineno'])->where('sku', $info['sku'])->first();
+            //添加超收判断
+            $actTransactionLogQty=OracleActTransactionLog::query()->where('docno',$info['asnno'])
+                ->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,?,?,?,?,?,?,?,?,
@@ -796,4 +799,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)) { //判断是否为库位
+            $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)){
+            $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;
+    }
 }

+ 149 - 0
resources/views/store/handInStorage/inventoryInfo.blade.php

@@ -0,0 +1,149 @@
+@extends('layouts.app')
+@section('title')手持入库-库存查询@endsection
+
+@section('content')
+    <div class="d-none" id="container">
+        <div class="card offset-md-3 col-md-6">
+            <div class="card-header text-center bg-transparent" id="header_title">
+                <span class="font-weight-bold h3">库存查询</span>
+            </div>
+            <div >
+                <div class="offset-1 mt-2">
+                    <span class="font-weight-bold h5">库位/货主/条码:</span><br>
+                    <p class="small font-weight-light">可输入商品条码,库位,货主编号(如:YOUWU)_查询</p>
+                    <div class="form-group row mt-2">
+                        <label for="location"></label>
+                        <input type="text" class="form-control col-8" id="location" autocomplete="off"
+                               :class="errors.location ? 'is-invalid' : ''" v-model="info.location">
+                        <span class="ml-2">
+                             <button type="button" id="select" class="btn btn-info font-weight-bold" @click="getInventoryInfos()">查询</button>
+                        </span>
+                        <span class="invalid-feedback" role="alert" v-if="errors.location">
+                            <strong>@{{ errors.location[0] }}</strong>
+                        </span>
+                    </div>
+                </div>
+                <div style="overflow: auto;overflow-x: hidden" id="cardTable">
+                    <table class="table-sm table-striped table-bordered table-hover mb-3" style="background: rgb(255, 255, 255);" v-if="invs.length>0">
+                    <tr v-for="(invLot,i) in invs" @click="selectTrOne(i)" :class="selectTr===i+1?'focusing' : ''">
+                        <td style="filter:grayscale(30%);">
+                            <div>
+                                <div style="transform:scale(1)" class="pl-0">
+                                        <span v-if="invLot.customerid">
+                                            <span class="text-black">货主:</span>
+                                            <span class="text-black font-weight-bold">@{{ invLot.customerid }}</span>
+                                        </span>
+                                    <span v-if="invLot.sku">
+                                            <span class="text-black">SKU:</span>
+                                            <span class="text-black font-weight-bold">@{{ invLot.sku }}</span>
+                                    </span>
+                                    <span v-if="invLot.alternate_sku1">
+                                            <span class="text-black">条码:</span>
+                                            <span class="text-danger">@{{ invLot.alternate_sku1 }}</span></span>
+                                    <span v-if="invLot.locationid">
+                                            <span>库位:</span>
+                                            <span class="font-weight-bold">@{{ invLot.locationid }} </span>
+                                        </span>
+                                    <span v-if="invLot.qty">
+                                            <span class="text-lowercase">数量:</span>
+                                            <span class="text-lowercase font-weight-bold">@{{ invLot.qty }} </span><span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt01">
+                                            <span class="text-black">生产日期:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt01 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt02">
+                                            <span class="text-black">失效日期:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt02 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt03">
+                                            <span class="text-black">入库日期:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt03 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt04">
+                                            <span class="text-black">批号:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt04 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt05">
+                                            <span class="text-black">属性仓:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt05 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                    <span v-if="invLot.lotatt08">
+                                            <span class="text-black">质量状态:</span><span class="text-black font-weight-bold">@{{ invLot.lotatt08 }}</span>
+                                            <span>&nbsp;&nbsp;</span>
+                                        </span>
+                                </div>
+                            </div>
+                        </td>
+                    </tr>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+@stop
+
+@section('lastScript')
+    <script type="text/javascript">
+        new Vue({
+            el:"#container",
+            data:{
+                height:0,//屏幕高度
+                info:{},
+                errors:{},
+                invs:[],
+                selectTr:'',
+                isAndroid:false,
+            },
+            mounted(){
+                if (navigator.userAgent.indexOf("Android")!==-1)this.isAndroid = true;
+                this.pageInit();
+                $("#container").removeClass("d-none");
+                this.height=window.screen.availHeight;
+                document.getElementById('cardTable').style.height=this.height*0.50+'px';
+                $('#location').trigger("click").focus();
+            },
+            methods:{
+                //页面初始化
+                pageInit(){
+                    if (!this.isAndroid)return;
+                    let element = document.getElementById("navbarSupportedContent").parentElement;
+                    element.className = "row";
+                    element.children[0].className += " col-5";
+                    element.innerHTML = element.children[0].outerHTML;
+                    let e1 = document.getElementById("menu");
+                    let e2 = document.getElementById("demand-div");
+                    if (e1)e1.remove();
+                    if (e2)e2.remove();
+                    document.getElementById('app').firstElementChild.style.display = 'none';
+                },
+                selectTrOne(i){
+                    if (this.selectTr===i+1){
+                        this.selectTr=0
+                    }else {
+                        this.selectTr=i+1;
+                    }
+                },
+                getInventoryInfos(){
+                    let error = {};
+                    if (!this.info.location)error.location = ["库位/货主/条码必填"];
+                    if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
+                    let url = '{{url('store/handInStorage/getInventoryInfos')}}';
+                    window.axios.post(url,{location:this.info.location})
+                        .then(res=>{
+                            if (res.data.success){
+                                this.invs=res.data.data;
+                                this.$forceUpdate()
+                                return;
+                            }
+                            window.tempTip.setDuration(2000);
+                            window.tempTip.show(res.data.data);
+                        }).catch(err=>{
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.show("网络错误:"+err);
+                    })
+                },
+            },
+        });
+    </script>
+@stop

+ 1 - 1
resources/views/store/inStorage/androidIndex.blade.php

@@ -22,7 +22,7 @@
 <!--                <a href="{{url('store/inStorage/cacheRackStorage')}}"><button class="btn btn-info w-75 text-white" style="height: 60px"><h4>整箱入库</h4></button></a>-->
                 @can("入库管理-手持入库-收货")<a href="{{url('store/handInStorage/receive')}}"><button class="btn btn-info w-75 h-25 text-white" style="height: 60px"><h4>收货</h4></button></a>@endcan
                 @can("入库管理-手持入库-上架")<a href="{{url('store/handInStorage/putaway')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>上架</h4></button></a>@endcan
-{{--                @can("入库管理-手持入库-库存查询")<a href="{{url('store/handInStorage/inventoryInfo')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>库存查询</h4></button></a>@endcan--}}
+                @can("入库管理-手持入库-库存查询")<a href="{{url('store/handInStorage/inventoryInfo')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>库存查询</h4></button></a>@endcan
                 @can("入库管理-入库-半箱补货入库")<a href="{{url('store/inStorage/halfChestStorage')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>半箱入库</h4></button></a>
                 <a href="{{url('store/inStorage/boxBindShelf')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>新箱上架</h4></button></a>
                 <a href="{{url('store/inStorage/boxBindModel')}}"><button class="btn btn-info w-75 h-25 mt-3 text-white" style="height: 60px"><h4>料箱型号</h4></button></a>

+ 2 - 0
routes/web.php

@@ -507,8 +507,10 @@ Route::group(['prefix'=>'package'],function(){
         Route::group(['prefix'=>'handInStorage'],function() {
             Route::get('receive',function (){return view('store.handInStorage.receive');});//收货页面
             Route::get('putaway',function (){return view('store.handInStorage.putaway');});//上架页面
+            Route::get('inventoryInfo',function (){return view('store.handInStorage.inventoryInfo');});//库存查询页面
             Route::get('android.index',function (){return view('store.handInStorage.androidIndex');});
             Route::post('selectAsn','HandInStorageController@selectAsn');
+            Route::post('getInventoryInfos','HandInStorageController@getInventoryInfos');
             Route::post('checkAsnOperation','HandInStorageController@checkAsnOperation');
             Route::post('selectAsnDetails','HandInStorageController@selectAsnDetails');
             Route::post('getBasSkuWithLot','HandInStorageController@getBasSkuWithLot');