Ver Fonte

手持收货上架增加校验规则

haozi há 4 anos atrás
pai
commit
30ec49f7e5

+ 17 - 10
app/Http/Controllers/HandInStorageController.php

@@ -6,6 +6,7 @@ use App\Components\AsyncResponse;
 use App\OracleBasLocation;
 use App\OracleBasLocation;
 use App\OracleDOCASNHeader;
 use App\OracleDOCASNHeader;
 use App\Services\HandInStorageService;
 use App\Services\HandInStorageService;
+use Carbon\Carbon;
 use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
 use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 
 
@@ -47,7 +48,6 @@ class HandInStorageController extends Controller
      * @param $asnno
      * @param $asnno
      * 跳转到收货明细页面
      * 跳转到收货明细页面
      */
      */
-
     public function receiveDetailPage($asnno,$customerid)
     public function receiveDetailPage($asnno,$customerid)
     {
     {
         $this->gate("入库管理-手持入库-收货");
         $this->gate("入库管理-手持入库-收货");
@@ -57,6 +57,7 @@ class HandInStorageController extends Controller
             $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
             $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid');
         $qualityStatus=$handInStorageService->getQualityStatus();
         $qualityStatus=$handInStorageService->getQualityStatus();
         $attributeLocations=$handInStorageService->getAttributeLocation();
         $attributeLocations=$handInStorageService->getAttributeLocation();
+//        dd($qualityStatus,$attributeLocations);
         return view('store.handInStorage.receiveDetailPage')
         return view('store.handInStorage.receiveDetailPage')
             ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
             ->with(['asnno'=>$asnno,'customerid'=>$customerid,'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]);
     }
     }
@@ -97,17 +98,22 @@ class HandInStorageController extends Controller
     {
     {
         $this->gate("入库管理-手持入库-收货");
         $this->gate("入库管理-手持入库-收货");
         $info=$request->input('info');
         $info=$request->input('info');
+        if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期');
         if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
         if (!$info['customerid']||!$info['sku']||!$info['asnno']) $this->error('参数错误');
         if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
         if ($info['amount']+$info['receivedqty']>$info['expectedqty'])$this->error('收货数大于预期数');
-//        if ($info['location']){
-//            $location=OracleBasLocation::query()
-//                ->where('locationid',$info['location'])
-//                ->where('status','OK')
-//                ->first();
-//            if (!$location)$this->error('目标库位不存在');
-//        }
         /** @var HandInStorageService $handInStorageService  */
         /** @var HandInStorageService $handInStorageService  */
         $handInStorageService=app('HandInStorageService');
         $handInStorageService=app('HandInStorageService');
+        if ($info['customerid']=='ONKYO'||$info['customerid']=='ANMEILAI'||$info['customerid']=='FEIHE'){
+            $res=$handInStorageService->checkWidthHeight($info);
+            if ($res===1)$this->error('需要维护产品档案');
+            if ($res===2)$this->error('需要维护该产品档案中的长宽高');
+        }
+        if ($info['customerid']=='TANGENBEI'||$info['customerid']=='ANMEILAI'){
+            $result=$handInStorageService->checkCubicWeight($info);
+            if ($result===1)$this->error('需要维护产品档案');
+            if ($result===2)$this->error('需要维护该产品档案中的重量体积');
+        }
+        if ($handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位');
         try {
         try {
             $result = $handInStorageService->fluxHandIn($info);
             $result = $handInStorageService->fluxHandIn($info);
             if ($result)$this->success("收货成功");
             if ($result)$this->success("收货成功");
@@ -156,8 +162,9 @@ class HandInStorageController extends Controller
         if ($res===4)$this->error('库位:产品不能混放');
         if ($res===4)$this->error('库位:产品不能混放');
         try {
         try {
             $result = $handInStorageService->fluxHandPa($info, $checkData);
             $result = $handInStorageService->fluxHandPa($info, $checkData);
-            if ($result)$this->success("上架成功");
-            else $this->error("上架失败");
+            if ($result===true)$this->success("上架成功");
+            if ($result===false) $this->error("上架失败");
+            if ($result===1)$this->error("拣货区找到效期更新的同样货品,不能上架至存储区");
         } catch (\Exception $e) {
         } catch (\Exception $e) {
             app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
             app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
         }
         }

+ 15 - 0
app/OracleBasForwardingLoc.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+use App\Traits\ModelLogChanging;
+
+class OracleBasForwardingLoc extends Model
+{
+    use ModelLogChanging;
+
+    protected $connection="oracle";
+    protected $table="BAS_Forwarding_LOC";
+}

+ 97 - 1
app/Services/HandInStorageService.php

@@ -4,6 +4,8 @@ namespace App\Services;
 
 
 use App\CommodityBarcode;
 use App\CommodityBarcode;
 use App\OracleBasCode;
 use App\OracleBasCode;
+use App\OracleBasCustomer;
+use App\OracleBasForwardingLoc;
 use App\OracleBasLocation;
 use App\OracleBasLocation;
 use App\OracleBasLotId;
 use App\OracleBasLotId;
 use App\OracleBasSKU;
 use App\OracleBasSKU;
@@ -21,11 +23,63 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\DB;
+use Monolog\Handler\IFTTTHandler;
 
 
 class HandInStorageService
 class HandInStorageService
 {
 {
     use ServiceAppAop;
     use ServiceAppAop;
 
 
+    /**
+     * @param array $info
+     * @return bool|int
+     * 校验货主拣货位
+     */
+    public function checkForwardingLoc(array $info)
+    {
+        $res=OracleBasCustomer::query()
+            ->where('customerid',$info['customerid'])
+            ->where('customer_type','OW')
+            ->where('udf1','Y')->count(); //查询此货主是否必须有拣货位
+        if ($res>0) {
+            $amount=OracleBasForwardingLoc::query()
+                ->where('customerid',$info['customerid'])
+                ->where('sku',$info['sku'])
+                ->count();
+            if ($amount==0)return 1;//请维护拣货位!
+        }
+        return true;
+    }
+    /**
+     * @param array $info
+     * @return bool|int
+     * 校验产品档案长宽高
+     */
+    public function checkWidthHeight(array $info)
+    {
+        $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
+        if (!$basSku)return 1;//需要维护产品档案
+        if ($basSku->skulength<=0||$basSku->skuwidth<=0||$basSku->skuhigh<=0)return 2;//需要维护该产品档案中的长宽高
+        return true;
+    }
+
+    /**
+     * @param array $info
+     * @return bool|int
+     * 校验产品档案重量体积
+     */
+    public function checkCubicWeight(array $info)
+    {
+        $basSku=OracleBasSKU::query()->where('customerid',$info['customerid'])->where('sku',$info['sku'])->first();
+        if (!$basSku)return 1;//需要维护产品档案
+        if ($basSku->grossweight<=0||$basSku->cube<=0)return 2;//需要维护该产品档案中的重量体积
+        return true;
+    }
+    /**
+     * @param array $info
+     * @param array $param
+     * @return bool|int
+     * 校验库位
+     */
     public function checkLocation(array $info, array $param)
     public function checkLocation(array $info, array $param)
     {
     {
         $location = OracleBasLocation::query()
         $location = OracleBasLocation::query()
@@ -174,6 +228,8 @@ sql;
     {
     {
         $sql = <<<sql
         $sql = <<<sql
 SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
 SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
+       DOC_ASN_DETAILS.lotatt01, DOC_ASN_DETAILS.lotatt02, DOC_ASN_DETAILS.lotatt03, DOC_ASN_DETAILS.lotatt04,
+       DOC_ASN_DETAILS.lotatt05, DOC_ASN_DETAILS.lotatt06, DOC_ASN_DETAILS.lotatt07, DOC_ASN_DETAILS.lotatt08,
        DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty FROM DOC_ASN_DETAILS
        DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,DOC_ASN_DETAILS.receivedqty FROM DOC_ASN_DETAILS
          LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
          LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
 WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ?  OR ALTERNATE_SKU3 = ?)
 WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ?  OR ALTERNATE_SKU3 = ?)
@@ -181,7 +237,8 @@ sql;
         $asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql), [$asnno, $skuOrBarcode, $skuOrBarcode, $skuOrBarcode]);
         $asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql), [$asnno, $skuOrBarcode, $skuOrBarcode, $skuOrBarcode]);
         if ($asn_detail) return $asn_detail;
         if ($asn_detail) return $asn_detail;
         else return OracleDOCASNDetail::query()
         else return OracleDOCASNDetail::query()
-            ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty'])
+            ->select(['sku', 'expectedqty', 'skudescrc', 'asnlineno', 'asnno', 'receivedqty',
+                'lotatt01','lotatt02','lotatt03','lotatt04','lotatt05','lotatt06','lotatt07','lotatt08'])
             ->where('asnno', $asnno)
             ->where('asnno', $asnno)
             ->where('sku', $skuOrBarcode)
             ->where('sku', $skuOrBarcode)
             ->whereIn('linestatus', ['00', '30'])
             ->whereIn('linestatus', ['00', '30'])
@@ -267,6 +324,8 @@ sql;
         if (!$tasks) return false; //获取任务失败
         if (!$tasks) return false; //获取任务失败
         return DB::connection("oracle")->transaction(function () use ($tasks, $info) { //单体嵌套事务 回滚FLUX失败任务
         return DB::connection("oracle")->transaction(function () use ($tasks, $info) { //单体嵌套事务 回滚FLUX失败任务
             foreach ($tasks as $task) {
             foreach ($tasks as $task) {
+                $res=$this->checkExpiryPa($task,$info['location']);
+                if ($res!==true)return $res;
                 if (!app("StorageService")->fluxPA($task, $info['location'])) {
                 if (!app("StorageService")->fluxPA($task, $info['location'])) {
                     DB::connection("oracle")->rollBack();
                     DB::connection("oracle")->rollBack();
                     return false; //上架失败
                     return false; //上架失败
@@ -276,6 +335,43 @@ sql;
         });
         });
     }
     }
 
 
+    /**
+     * @param $task
+     * @param $location
+     * @return bool|int
+     * 上架校验效期
+     */
+    public function checkExpiryPa($task,$location)
+    {
+        if (!$task->taskid)return 0;//任务id不存在
+        if (strpos($task->taskid,'MIX') !== false)return true;//合并拣货,不校验
+
+        $sql = <<<sql
+select instr(DESCR,'拣货') as var_IsPickingArea from BAS_Zone where ZONE=(select PutawayZone from BAS_Location where LocationID = ?)
+sql;
+        $basZone = DB::connection("oracle")->selectOne(DB::raw($sql), [$location]);
+        if ($basZone&&$basZone->var_ispickingarea>0) return true; //不是存储区,不校验
+
+        $sql1 = <<<sql
+select SKU,LotAtt02,CustomerID from INV_LOT_ATT WHERE LOTNUM=?
+sql;
+        $invLotAtt = DB::connection("oracle")->selectOne(DB::raw($sql1), [$task->fmlotnum]);
+        $sql2 = <<<sql
+    select count(*) as var_amountOfDecaying from INV_LOT_LOC_ID store
+                                                       left join BAS_Location location on store.LocationID=location.locationId
+                                                       left join BAS_Zone zone on zone.zone=location.PickZone
+                                                       left join INV_LOT_ATT attres on store.LOTNUM=attres.LOTNUM
+    where store.SKU=?
+      and store.CustomerID=?
+      and store.LOTNUM!=?
+      and attres.LotAtt02 > ?
+      and zone.DESCR like '%拣货%'
+sql;
+        $invLotLocId=DB::connection("oracle")->selectOne(DB::raw($sql2), [$invLotAtt->sku,$invLotAtt->customerid,$task->fmlotnum,$invLotAtt->lotatt02]);
+        if ($invLotLocId&&$invLotLocId->var_amountofdecaying>0)return 1;//拣货区找到效期更新的同样货品,不能上架至存储区
+        return true;
+    }
+
     /**
     /**
      * @param $taskParam
      * @param $taskParam
      * @param $amount
      * @param $amount

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

@@ -3,6 +3,8 @@
 
 
 @section('content')
 @section('content')
     <div class="d-none" id="container">
     <div class="d-none" id="container">
+        <form  :action="'{{url('store/handInStorage/receiveDetailPage')}}/'+asnno+'/'+customerid" method="get" id="submitForm" class="d-none">
+        </form>
         <div class="card offset-md-3 col-md-6">
         <div class="card offset-md-3 col-md-6">
             <div class="card-header text-center mt-2 bg-transparent" id="header_title">
             <div class="card-header text-center mt-2 bg-transparent" id="header_title">
                 <span class="font-weight-bold h4">收货</span>
                 <span class="font-weight-bold h4">收货</span>
@@ -82,6 +84,8 @@
                 asns:[],
                 asns:[],
                 selectTr:'',
                 selectTr:'',
                 isAndroid:false,
                 isAndroid:false,
+                asnno:'',
+                customerid:'',
             },
             },
             mounted(){
             mounted(){
                 if (navigator.userAgent.indexOf("Android")!==-1)this.isAndroid = true;
                 if (navigator.userAgent.indexOf("Android")!==-1)this.isAndroid = true;
@@ -177,7 +181,13 @@
                     window.axios.post(url,{info:this.info})
                     window.axios.post(url,{info:this.info})
                         .then(res=>{
                         .then(res=>{
                             if (res.data.success){
                             if (res.data.success){
-                                window.location.href="{{url('store/handInStorage/receiveDetailPage')}}/" + res.data.data.asnno+'/'+ res.data.data.customerid;
+                                {{--window.location.href="{{url('store/handInStorage/receiveDetailPage')}}/" + res.data.data.asnno+'/'+ res.data.data.customerid;--}}
+                                    this.asnno=res.data.data.asnno;
+                                    this.customerid=res.data.data.customerid;
+                                    let _this=this;
+                                    setTimeout(function (){
+                                        _this.submitForm();
+                                    },10)
                             }else {
                             }else {
                                 window.tempTip.setDuration(2000);
                                 window.tempTip.setDuration(2000);
                                 window.tempTip.show(res.data.data);
                                 window.tempTip.show(res.data.data);
@@ -193,6 +203,9 @@
                         this.onfocus();
                         this.onfocus();
                     },100);
                     },100);
                 },
                 },
+                submitForm(){
+                    document.getElementById('submitForm').submit();
+                }
             },
             },
         });
         });
     </script>
     </script>

+ 5 - 0
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -195,6 +195,8 @@
                         .then(res=>{
                         .then(res=>{
                             if (res.data.success){
                             if (res.data.success){
                                 this.fillInfo(res.data.asnDetail);
                                 this.fillInfo(res.data.asnDetail);
+                                if (res.data.asnDetail.lotatt08) this.info.lotatt08=res.data.asnDetail.lotatt08;
+                                if (res.data.asnDetail.lotatt05) this.info.lotatt08=res.data.asnDetail.lotatt05;
                                 this.basSku=res.data.basSku;
                                 this.basSku=res.data.basSku;
                                 this.$forceUpdate()
                                 this.$forceUpdate()
                                 return;
                                 return;
@@ -214,6 +216,8 @@
                     window.axios.post(url,{asnno:this.asnno,customerid:this.customerid,sku:this.info.sku})
                     window.axios.post(url,{asnno:this.asnno,customerid:this.customerid,sku:this.info.sku})
                         .then(res=>{
                         .then(res=>{
                             if (res.data.success){
                             if (res.data.success){
+                                if (res.data.asnDetail.lotatt08) this.info.lotatt08=res.data.asnDetail.lotatt08;
+                                if (res.data.asnDetail.lotatt05) this.info.lotatt08=res.data.asnDetail.lotatt05;
                                 this.basSku=res.data.basSku;
                                 this.basSku=res.data.basSku;
                                 this.$forceUpdate()
                                 this.$forceUpdate()
                                 return;
                                 return;
@@ -287,6 +291,7 @@
                     this.info.asnno=this.asnno;
                     this.info.asnno=this.asnno;
                     // if (this.info.trackNumber==''||this.info.trackNumber==null||this.info.trackNumber==undefined)this.info.trackNumber='';
                     // 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='';
                     if (this.info.location==''||this.info.location==null||this.info.location==undefined)this.info.location='';
+                    if (this.info.lotatt02==''||this.info.lotatt02==null||this.info.lotatt02==undefined)this.info.lotatt02='';
                     if (Number(this.info.receivedqty)===Number(this.info.expectedqty)){
                     if (Number(this.info.receivedqty)===Number(this.info.expectedqty)){
                         window.tempTip.setDuration(2000); window.tempTip.show("收货已完成");
                         window.tempTip.setDuration(2000); window.tempTip.show("收货已完成");
                     }
                     }