Prechádzať zdrojové kódy

Merge branch 'Haozi'

zhouzhendong 4 rokov pred
rodič
commit
ec1f43150d

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

@@ -3,8 +3,10 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\OracleBasLocation;
 use App\OracleDOCASNHeader;
 use App\Services\HandInStorageService;
+use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
 use Illuminate\Http\Request;
 
 class HandInStorageController extends Controller
@@ -15,22 +17,40 @@ class HandInStorageController extends Controller
      */
     public function selectAsn(Request $request)
     {
+        $this->gate("入库管理-手持入库-收货");
         /** @var HandInStorageService $handInStorageService  */
         $handInStorageService=app('HandInStorageService');
         $asnno= $request->input('asnno');
         $asns =$handInStorageService->selectAsn($asnno);
-        if ($asns->count()>0){
+        if (count($asns)>0){
+            foreach ($asns as $asn){
+                $asn->asnDetails=array();
+            }
             $this->success($asns);
         }else{
-            $this->error('未搜索到ASN单');
+            $this->error('无有效的ASN的订单');
         }
     }
+
+    public function checkAsnOperation(Request $request)
+    {
+        $this->gate("入库管理-手持入库-收货");
+        /** @var HandInStorageService $handInStorageService  */
+        $handInStorageService=app('HandInStorageService');
+        $info= $request->input('info');
+        $res=$handInStorageService->checkAsnOperation($info);
+        if ($res===1)$this->error('无有效的ASN的订单');
+        elseif ($res===2)$this->error('该asn无预约,暂不可收货');
+        else $this->success($res);
+    }
     /**
      * @param $asnno
      * 跳转到收货明细页面
      */
+
     public function receiveDetailPage($asnno,$customerid)
     {
+        $this->gate("入库管理-手持入库-收货");
         /** @var HandInStorageService $handInStorageService  */
         $handInStorageService=app('HandInStorageService');
         if (!$customerid||$customerid=='undefined')
@@ -47,11 +67,11 @@ class HandInStorageController extends Controller
      */
     public function selectAsnDetails(Request $request)
     {
+        $this->gate("入库管理-手持入库-收货");
         $asnno= $request->input('asnno');
         $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno);
-        if ($asnDetails->count()>0)$this->success($asnDetails);
-        else $this->error('未搜索到ASN详情单');
-
+        if (count($asnDetails)>0)$this->success($asnDetails);
+        else $this->error('未查询到相应的asn明细');
     }
     /**
      * @param Request $request
@@ -60,24 +80,86 @@ class HandInStorageController extends Controller
     public function getBasSkuWithLot(Request $request): array
     {
         $customerid= $request->input('customerid');
-        $sku= $request->input('sku');
+        $skuOrBarcode= $request->input('sku');
         $asnno= $request->input('asnno');
-        $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$sku);
-        $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$sku);
+        $asnDetail=app('HandInStorageService')->getAsnDetail($asnno,$skuOrBarcode);
+        if (!$asnDetail)$this->error('无效条码');
+        $basSku =app('HandInStorageService')->getBasSkuLotId($customerid,$asnDetail->sku);
         if (isset($basSku)&&isset($asnDetail))return ['success'=>true,'basSku'=>$basSku,'asnDetail'=>$asnDetail];
         else $this->error('无效条码');
     }
 
+    /**
+     * @throws \Throwable
+     * 收货
+     */
     public function fluxHandIn(Request $request)
     {
+        $this->gate("入库管理-手持入库-收货");
         $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'])
+//                ->where('status','OK')
+//                ->first();
+//            if (!$location)$this->error('目标库位不存在');
+//        }
         /** @var HandInStorageService $handInStorageService  */
         $handInStorageService=app('HandInStorageService');
-        $handInStorageService->fluxHandIn($info);
-//        dd($result,"111");
+        try {
+            $result = $handInStorageService->fluxHandIn($info);
+            if ($result)$this->success("收货成功");
+            else $this->error("收货失败");
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
+        }
+    }
+
+    /**
+     * @param Request $request
+     * 根据商品条码和跟踪号 获取要上架的任务列表
+     */
+    public function getTsk(Request $request)
+    {
+        $this->gate("入库管理-手持入库-上架");
+        $barCode=$request->input('barCode');
+        $trackNumber=$request->input('trackNumber');
+        if(!$barCode)$this->error('条码不能为空');
+        if(!$trackNumber)$this->error('容器号不能为空');
+        /** @var HandInStorageService $handInStorageService  */
+        $handInStorageService=app('HandInStorageService');
+        $tasks=$handInStorageService->getTsk($trackNumber,$barCode);
+        if (count($tasks)>0)$this->success($tasks);
+        else $this->error("该商品暂无上架任务");
+    }
+
+    /**
+     * @throws \Throwable
+     * 上架
+     */
+    public function handFluxPa(Request $request)
+    {
+        $this->gate("入库管理-手持入库-上架");
+        $info=$request->input('info');
+        if (!$info['location']||!$info['amount']||!$info['trackNumber']||!$info['barCode']) $this->error('参数错误');
+        if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务');
+        $checkData=$request->input('checkData')[0];
+        $location=OracleBasLocation::query()
+                ->where('locationid',$info['location'])
+                ->where('status','OK')
+                ->first();
+        if (!$location)$this->error('目标库位不存在');
+        /** @var HandInStorageService $handInStorageService  */
+        $handInStorageService=app('HandInStorageService');
+        try {
+            $result = $handInStorageService->fluxHandPa($info, $checkData);
+            if ($result)$this->success("上架成功");
+            else $this->error("上架失败");
+        } catch (\Exception $e) {
+            app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage());
+        }
     }
 
 

+ 2 - 3
app/Jobs/ProcurementCheckConfirmInform.php

@@ -34,8 +34,8 @@ class ProcurementCheckConfirmInform implements ShouldQueue
     {
         if (empty($this->procurementTotalBills)) return;
         foreach ($this->procurementTotalBills as $procurementTotalBill){
-            foreach ($procurementTotalBill->supplier as $supplier) {
-                foreach ($supplier->user as $user){
+            if (!$procurementTotalBill->supplier||!$procurementTotalBill->supplier->user) return;
+                foreach ($procurementTotalBill->supplier->user as $user){
                    if($user->userDetail->procurement_wechat_open_id){
                        $param['touser'] =$user->userDetail->procurement_wechat_open_id;
                        $param['mp_template_msg'] =[
@@ -74,5 +74,4 @@ class ProcurementCheckConfirmInform implements ShouldQueue
 
         }
 
-    }
 }

+ 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";
+    //
+}

+ 12 - 0
app/Services/DeliveryAppointmentService.php

@@ -206,4 +206,16 @@ class DeliveryAppointmentService
         $total = $warehouse->production_capacity*DeliveryAppointment::HOUR[$period];
         return $total-$result->capacity;
     }
+
+    /**
+     * 检查可操作ASN
+     *
+     * @param string $asn
+     * @param string $customerid
+     * @return bool
+     */
+    public function checkOperableAsn(string $asn,string $customerid):bool
+    {
+        return true;
+    }
 }

+ 191 - 41
app/Services/HandInStorageService.php

@@ -2,6 +2,7 @@
 
 namespace App\Services;
 
+use App\CommodityBarcode;
 use App\OracleBasCode;
 use App\OracleBasSKU;
 use App\OracleDOCASNDetail;
@@ -10,6 +11,7 @@ use App\OracleInvLotAtt;
 use App\Traits\ServiceAppAop;
 use App\ValueStore;
 use Carbon\Carbon;
+use Doctrine\DBAL\Schema\AbstractAsset;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Database\Eloquent\Model;
@@ -21,27 +23,72 @@ class HandInStorageService
 {
     use ServiceAppAop;
 
+
+    public function checkAsnOperation(array $info)
+    {
+        if (!$info['customerid']||!$info['asntype']){
+            $asn=OracleDOCASNHeader::query()
+            ->select(['asnno','asnreference1','asnstatus','addtime','customerid','asntype'])
+            ->where('asnno',$info['asnno'])
+            ->whereIn('asnstatus',['00','30'])
+            ->first();
+            if (!$asn)return 1; //无效asn单号
+            return $this->whetherDeliver($asn);
+        }
+        return $this->whetherDeliver($info);
+    }
+
+    private function whetherDeliver($asn)
+    {
+        if ($asn['asntype']!='XNRK' && $asn['asntype']!='THRK' && $asn['asntype']!='F31'){
+            $res=app(DeliveryAppointmentService::class)->checkOperableAsn($asn['asnno'],$asn['customerid']);
+            if ($res) return $asn;
+            else return 2; //当前asn单号无预约记录
+        }
+        return $asn;
+    }
+
     /**
      * @param $asn
      * @return Builder[]|Collection
-     * 获取富勒asn_header
+     * 获取富勒asn_header  根据货主,asn,或者条码
      *
      */
     public function selectAsn($asn)
     {
-        if ($asn) return OracleDOCASNHeader::query()
-            ->with('asnStatus')
-            ->select(['asnno','asnreference1','asnstatus','addtime','customerid'])
-            ->where('asnno',$asn)
-            ->get();
-
-        return OracleDOCASNHeader::query()
-            ->select(['asnno','asnreference1','asnstatus','addtime','customerid'])
-            ->with('asnStatus')
+        if (!$asn) return OracleDOCASNHeader::query()
+            ->select(['asnno','asnreference1','asnstatus','addtime','customerid','asntype'])
             ->where('asnstatus','00')
             ->orderByDesc('addtime')
             ->limit(50)
             ->get();
+
+        if (strpos(strtoupper($asn),'ASN')!==false){
+            return OracleDOCASNHeader::query()
+                ->select(['asnno','asnreference1','asnstatus','addtime','customerid','asntype'])
+                ->where('asnno',$asn)
+                ->whereIn('asnstatus',['00','30'])
+                ->get();
+        }else {
+            $asns=OracleDOCASNHeader::query()
+                ->select(['asnno','asnreference1','asnstatus','addtime','customerid','asntype'])
+                ->where('customerid',strtoupper($asn))
+                ->whereIn('asnstatus',['00','30'])
+                ->get();
+            if ($asns->count()>0){
+                return $asns;
+            }else{
+                $sql = <<<SQL
+ SELECT DOC_ASN_HEADER.ASNNO,DOC_ASN_HEADER.addtime,DOC_ASN_HEADER.asnreference1,DOC_ASN_HEADER.customerid,DOC_ASN_HEADER.asnstatus,DOC_ASN_HEADER.asntype FROM DOC_ASN_HEADER
+                  LEFT JOIN DOC_ASN_DETAILS ON DOC_ASN_HEADER.ASNNO = DOC_ASN_DETAILS.ASNNO
+                  LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
+WHERE DOC_ASN_HEADER.ASNSTATUS in ('00','30') and (BAS_SKU.ALTERNATE_SKU1 = ? OR BAS_SKU.ALTERNATE_SKU2 = ?  OR BAS_SKU.ALTERNATE_SKU3 = ?)
+group by DOC_ASN_HEADER.ASNNO,DOC_ASN_HEADER.addtime,DOC_ASN_HEADER.asnreference1,DOC_ASN_HEADER.customerid,DOC_ASN_HEADER.asnstatus,DOC_ASN_HEADER.asntype
+SQL;
+                return DB::connection("oracle")->select(DB::raw($sql),[$asn,$asn,$asn]);
+            }
+        }
+
     }
 
     /**
@@ -51,24 +98,38 @@ class HandInStorageService
      */
     public function selectAsnDetails($asnno)
     {
-        return OracleDOCASNDetail::query()
-            ->select(['sku','expectedqty','skudescrc','asnlineno','asnno','receivedqty'])
-            ->where('asnno',$asnno)
-            ->get();
+        $sql = <<<sql
+ SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,DOC_ASN_DETAILS.asnlineno,DOC_ASN_DETAILS.asnno,
+       DOC_ASN_DETAILS.receivedqty,BAS_SKU.alternate_sku1
+FROM DOC_ASN_DETAILS 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')
+sql;
+        $asn_details = DB::connection("oracle")->select(DB::raw($sql),[$asnno]);
+        if (count($asn_details)>0)return $asn_details;
+        else return array();
     }
 
     /**
      * @param $asnno
-     * @param $sku
+     * @param $skuOrBarcode
      * @return Builder|Model|object|null
-     *
+     *根据sku 或者条码获取asn_detail
      */
-    public function getAsnDetail($asnno,$sku)
+    public function getAsnDetail($asnno,$skuOrBarcode)
     {
-        return OracleDOCASNDetail::query()
+        $sql = <<<sql
+SELECT DOC_ASN_DETAILS.sku,DOC_ASN_DETAILS.expectedqty,DOC_ASN_DETAILS.skudescrc,
+       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
+WHERE ASNNO = ? AND LINESTATUS IN ('00','30') AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ?  OR ALTERNATE_SKU3 = ?)
+sql;
+        $asn_detail = DB::connection("oracle")->selectOne(DB::raw($sql),[$asnno,$skuOrBarcode,$skuOrBarcode,$skuOrBarcode]);
+        if ($asn_detail)return $asn_detail;
+        else return OracleDOCASNDetail::query()
             ->select(['sku','expectedqty','skudescrc','asnlineno','asnno','receivedqty'])
             ->where('asnno',$asnno)
-            ->where('sku',$sku)
+            ->where('sku',$skuOrBarcode)
+            ->whereIn('linestatus',['00','30'])
             ->first();
     }
 
@@ -115,8 +176,87 @@ class HandInStorageService
         });
     }
 
+    /**
+     * @param string $barCode
+     * @return array
+     * 根据商品条码  获取完全收货状态  部分收货状态的 PA任务
+     */
+    public function getTsk(string $trackNumber,string $barCode): array
+    {
+        $sql = <<<sql
+SELECT TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC,sum(TSK_TASKLISTS.PlanToQty) AS QTY
+FROM DOC_ASN_DETAILS
+         LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND
+                                    DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
+WHERE
+      ASNNO in (SELECT asnno FROM DOC_ASN_DETAILS
+                                      LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
+                WHERE LINESTATUS in ('30','40') and (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ?  OR ALTERNATE_SKU3 = ?))
+  AND TSK_TASKLISTS.TASKPROCESS = '00'
+  AND TSK_TASKLISTS.TASKTYPE = 'PA'
+  AND TSK_TASKLISTS.PlanToID= ?
+  group by TSK_TASKLISTS.CustomerID,TSK_TASKLISTS.Sku,TSK_TASKLISTS.PlanToLotNum,TSK_TASKLISTS.PlanToID,DOC_ASN_DETAILS.SKUDESCRC
+sql;
+        $tasks = DB::connection("oracle")->select(DB::raw($sql),[$barCode,$barCode,$barCode,$trackNumber]);
+        if (!$tasks)return [];
+        else return $tasks;
+    }
+
+    /**
+     * @throws \Throwable
+     * flux手持端 上架
+     */
+    public function fluxHandPa(array $info, array $taskParam): bool
+    {
+        $tasks=$this->selectFluxTask($taskParam,$info['amount']);
+        if (!$tasks)return false; //获取任务失败
+        return DB::connection("oracle")->transaction(function ()use($tasks,$info){ //单体嵌套事务 回滚FLUX失败任务
+            foreach ($tasks as $task){
+                if (!app("StorageService")->fluxPA($task,$info['location'])){
+                    DB::connection("oracle")->rollBack();
+                    return false; //上架失败
+                }
+            }
+            return true; //上架成功
+        });
+    }
+
+    /**
+     * @param $taskParam
+     * @param $amount
+     * @return array
+     * 根据跟踪号,货主,sku,批次 获取任务列表   再通过数量 进行任务的重组(拆分或选定)
+     */
+    public function selectFluxTask($taskParam,$amount): array
+    {
+        /** @var StorageService $storageService  */
+        $storageService=app('StorageService');
+        $sql = <<<sql
+select * from TSK_TASKLISTS where customerid = ? AND sku = ? AND plantoid = ? AND plantolotnum = ? AND TASKPROCESS = '00' AND TASKTYPE = 'PA'
+sql;
+        $tasks = DB::connection("oracle")->select(DB::raw($sql),[$taskParam['customerid'],$taskParam['sku'],$taskParam['plantoid'],$taskParam['plantolotnum']]);
+        if (!$tasks)return [];
+        $nums = [];
+        $sum = 0;
+        $maxIndex = null;
+        foreach ($tasks as $i => $task){
+            if ((int)$task->fmqty == $amount)return [$task];
+            $nums[] = (int)$task->fmqty;
+            $sum += (int)$task->fmqty;
+            if ((int)$task->fmqty>$amount)$maxIndex = $i;
+        }
+        if ($sum<$amount)return []; //上架数大于入库数
+        $result = $storageService->getMatch($nums,$amount);
+        if (!$result)return $storageService->splitTask($tasks,$maxIndex,$amount);
+        $arr = [];
+        foreach ($result as $index)$arr[] = $tasks[$index];
+        return $arr;
+    }
+
+
     /**
      * @throws \Throwable
+     * fulx 手持收货
      */
     public function fluxHandIn(array $info)
     {
@@ -132,22 +272,26 @@ 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){
+                DB::connection("oracle")->rollBack();
+                return false;
+            }
             //flux 创建入库事务
-//            $actTransactionLog=$this->setFluxActTransactionLog($info,$lotNum,$who,$time);
-//            if (!$actTransactionLog)return false;
+            $actTransactionLog=$this->setFluxActTransactionLog($info,$lotNum,$who,$time);
+            if (!$actTransactionLog){
+                DB::connection("oracle")->rollBack();
+                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,26 +315,32 @@ 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'],
-                        $invlotatt['lotatt05'],$invlotatt['lotatt06'],$invlotatt['lotatt07'],$invlotatt['lotatt08'],$info['asnno']]);
+                $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 = ? and asnlineno = ?"),
+                    [(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'],$info['asnlineno']]);
                 //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'],
-                        $invlotatt['lotatt05'],$invlotatt['lotatt06'],$invlotatt['lotatt07'],$invlotatt['lotatt08'],$info['asnno']]);
+                $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 = ? and asnlineno = ?"),
+                    [(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'],$info['asnlineno']]);
                 //当asn_detail 所有状态都为完全收货是  asn_header 状态修改为 完全收货(asnstatus=40)
                 if (OracleDOCASNDetail::query()->where('asnno',$info['asnno'])->where('linestatus',40)->count()==$asn->asn_details_count){
                     $db->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '40',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
                         [$time,$who,$info['asnno']]);
+                }else {
+                    //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']]);
                 }
             }
             return true;
@@ -348,7 +498,7 @@ sql;
      * 获取批次号
      * @return array
      */
-    private function getLtNum()
+    private function getLtNum(): array
     {
         $val = ValueStore::query()->select("value")->where("name","flux_lt_number")->lockForUpdate()->first();
         if (!$val)$val = ValueStore::query()->create(["name"=>"flux_lt_number","value"=>'0']);
@@ -371,7 +521,7 @@ sql;
      * 获取批次号
      * @return array
      */
-    private function getTsNum()
+    private function getTsNum(): array
     {
         $val = ValueStore::query()->select("value")->where("name","flux_ts_number")->lockForUpdate()->first();
         if (!$val)$val = ValueStore::query()->create(["name"=>"flux_ts_number","value"=>'0']);

+ 2 - 2
app/Services/StorageService.php

@@ -332,7 +332,7 @@ SQL;
      * @return array
      * @throws
      */
-    private function splitTask($tasks,$maxIndex,$amount):array
+    public function splitTask($tasks, $maxIndex, $amount):array
     {
         $result = [];
         if ($maxIndex===null){
@@ -414,7 +414,7 @@ sql;
      * @param Integer $target
      * @return Integer[]|null
      */
-    protected function getMatch(array $nums,int $target) :?array
+    public function getMatch(array $nums, int $target) :?array
     {
         $map=[];
         foreach ($nums as $index=>$val){

+ 4 - 4
bashupMysql.sh

@@ -1,11 +1,11 @@
 #!/bin/bash
 #设置mysql的备份保存目录
-folder=/etc/bashupMysql
-cd $folder
+#folder=/etc/bashupMysql
+#cd $folder
 #当前日期
 time_now=$(date  "+%Y-%m-%d")
 #当前时间的前30天 %H:%M:%S
-time_30day_ago=$(date -d"25 day ago" "+%Y-%m-%d 00:00:00")
+time_30day_ago=$(date -d"20 day ago" "+%Y-%m-%d 00:00:00")
 #数据库服务器ip
 host="was.baoshi56.com"
 test_host="101.133.135.193"
@@ -19,7 +19,7 @@ test_password="123456"
 db="bswas"
 test_db="bswas_test"
 #执行备份语句 --single-transaction 是在导出数据时不锁表
-mysqldump -h$host -u$user -p$password --single-transaction $db --ignore-table=$db.orders --ignore-table=$db.stores --ignore-table=$db.packages --ignore-table=$db.store_items --ignore-table=$db.commodities --ignore-table=$db.commodity_barcodes --ignore-table=$db.logs --ignore-table=$db.order_commodities --ignore-table=$db.order_bins --ignore-table=$db.w_m_s_waybill_orders --ignore-table=$db.rejected_bills --ignore-table=$db.rejected_bill_items --ignore-table=$db.w_m_s_reflect_packages --ignore-table=$db.w_m_s_reflect_receive_skus --ignore-table=$db.w_m_s_reflect_receives --ignore-table=$db.order_counting_records --ignore-table=$db.order_package_commodities --ignore-table=$db.order_packages --ignore-table=$db.packages> $time_nowall.sql
+mysqldump -h$host -u$user -p$password --single-transaction $db --ignore-table=$db.orders --ignore-table=$db.failed_jobs --ignore-table=$db.stores --ignore-table=$db.packages --ignore-table=$db.store_items --ignore-table=$db.commodities --ignore-table=$db.commodity_barcodes --ignore-table=$db.logs --ignore-table=$db.order_commodities --ignore-table=$db.order_bins --ignore-table=$db.w_m_s_waybill_orders --ignore-table=$db.rejected_bills --ignore-table=$db.rejected_bill_items --ignore-table=$db.w_m_s_reflect_packages --ignore-table=$db.w_m_s_reflect_receive_skus --ignore-table=$db.w_m_s_reflect_receives --ignore-table=$db.order_counting_records --ignore-table=$db.order_package_commodities --ignore-table=$db.order_packages --ignore-table=$db.packages> $time_nowall.sql
 mysql  -u$test_user -p$test_password  $test_db< $time_nowall.sql
 mysqldump -h$host -u$user -p$password --single-transaction -q -e $db orders --where="created_at>='$time_30day_ago'" > $time_noworders.sql
 mysql  -u$test_user -p$test_password  $test_db< $time_noworders.sql

+ 2 - 2
resources/views/store/handInStorage/androidIndex.blade.php

@@ -19,8 +19,8 @@
     <div class="text-center h-75">
         <div class="w-100 center h-75 row align-items-center justify-content-center">
             <div class="w-100">
-                <a href="{{url('')}}"><button class="btn btn-info w-75 text-white" style="height: 60px"><h4>收货</h4></button></a>
-                <a href="{{url('')}}"><button class="btn btn-info w-75 mt-3 text-white" style="height: 60px"><h4>上架</h4></button></a>
+                <a  href="{{url('store/handInStorage/receive')}}"><button class="btn btn-info w-75 text-white" style="height: 60px"><h4>收货</h4></button></a>
+                <a  href="{{url('store/handInStorage/putaway')}}"><button class="btn btn-info w-75 mt-3 text-white" style="height: 60px"><h4>上架</h4></button></a>
             </div>
         </div>
     </div>

+ 262 - 0
resources/views/store/handInStorage/putaway.blade.php

@@ -0,0 +1,262 @@
+@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 mt-2 bg-transparent" id="header_title">
+                <span class="font-weight-bold h4">上架</span>
+            </div>
+            <div class="card-body">
+                <div class="form-group row m-1">
+                        <span class="text-right">
+                            <label for="trackNumber" class="text-right font-weight-bold">容器号:</label>
+                        </span>
+                    <input type="text" class="form-control form-control-sm col-8" id="trackNumber" autocomplete="off"
+                           :class="errors.trackNumber ? 'is-invalid' : ''" @keydown.enter="enterVal($event)"
+                           v-model="info.trackNumber">
+                    <span class="invalid-feedback offset-3" role="alert" v-if="errors.trackNumber">
+                            <strong>@{{ errors.trackNumber[0] }}</strong>
+                    </span>
+                </div>
+                <div class="form-group row m-1">
+                        <span class="text-right">
+                            <label for="barCode" class="text-right font-weight-bold">商品条码:</label>
+                        </span>
+                    <input type="text" class="form-control form-control-sm col-8" id="barCode" autocomplete="off"
+                           :class="errors.barCode ? 'is-invalid' : ''" @keydown.enter="enterVal($event)"
+                           v-model="info.barCode" @blur="getTsk()">
+                    <span class="invalid-feedback offset-3" role="alert" v-if="errors.barCode">
+                            <strong>@{{ errors.barCode[0] }}</strong>
+                    </span>
+                </div>
+                <div class="card border-bottom-0">
+                    <div class="card-body">
+                        <div class="form-group row m-1">
+                            <label for="name" class="text-right">商品品名:</label>
+                            <span id="name">@{{ info.name }}</span>
+                        </div>
+                        <div class="form-group row m-1">
+                            <label for="amount" class="text-right">上架总数:</label>
+                            <input type="text" class="form-control form-control-sm col-4" style="width: 10px"
+                                   id="amount" autocomplete="off"
+                                   :class="errors.amount ? 'is-invalid' : ''"
+                                   @keydown.enter="enterVal($event)" v-model="info.amount"><span id="paTotal"
+                                                                                                 v-if="info.paTotal">&nbsp;&nbsp;/&nbsp;&nbsp;@{{ info.paTotal }}</span>
+                            <span class="invalid-feedback offset-3" role="alert" v-if="errors.amount">
+                            <strong>@{{ errors.amount[0] }}</strong>
+                    </span>
+                        </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"
+                                   autocomplete="off"
+                                   :class="errors.location ? 'is-invalid' : ''"
+                                   @keydown.enter="enterVal($event)" v-model="info.location">
+                            <span class="invalid-feedback offset-3" role="alert" v-if="errors.location">
+                            <strong>@{{ errors.location[0] }}</strong>
+                    </span>
+                        </div>
+                    </div>
+                </div>
+                <div style="overflow: auto;overflow-x: hidden" id="cardTable" v-if="tasks.length>0">
+                    <table class="table-sm table-striped table-bordered table-hover mb-3"
+                           style="background: rgb(255, 255, 255);">
+                        <tr v-for="(task,i) in tasks">
+                            <td style="filter:grayscale(30%);">
+                                <div>
+                                    <div style="transform:scale(1)" class="pl-0">
+                                        <span><span class="text-black">货主:</span><span
+                                                class="text-black font-weight-bold">@{{ task.customerid }}</span></span>
+                                        <span><span class="text-black">批次:</span><span
+                                                class="text-danger">@{{ task.plantolotnum }}</span></span>
+                                        <span class="text-right float-right">选中:<input type="checkbox" :id="'task_'+i"
+                                                                                       @click="checked($event,task)"></span>
+                                        <br>
+                                        <span><span>容器号:</span><span class="">@{{ task.plantoid }} </span></span>
+                                        <span><span class="text-lowercase">数量:</span><span
+                                                class="text-lowercase">@{{ task.qty }} </span></span>
+                                        <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                        <span><span class="text-black">商品名:</span><span class="text-black">@{{ task.skudescrc }}</span></span>
+                                    </div>
+                                </div>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+
+                <div class="card-footer bg-transparent">
+                    <button type="button" id="confirm" class="btn btn-sm btn-outline-success float-right"
+                            @click="ensure()">确定
+                    </button>
+                    <button type="button" id="cancel" class="btn btn-sm btn-outline-info float-left" @click="cancel()">
+                        取消
+                    </button>
+                </div>
+            </div>
+        </div>
+        @stop
+
+        @section('lastScript')
+            <script type="text/javascript">
+                new Vue({
+                    el: "#container",
+                    data: {
+                        height: 0,//屏幕高度
+                        info: {},
+                        errors: {},
+                        tasks: [],
+                        checkData: [],
+                        selectTr: '',
+                        isAndroid: false,
+                        element: [
+                            "trackNumber","barCode", "amount", "location",
+                        ],
+                    },
+                    mounted() {
+                        if (navigator.userAgent.indexOf("Android") !== -1) this.isAndroid = true;
+                        this.pageInit();
+                        $("#container").removeClass("d-none");
+                        document.getElementById("trackNumber").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();
+                        },
+                        checked(e, task, element = undefined) {
+                            if (!element)element = e.target;
+                            let _this = this;
+                            if (element.checked) {
+                                if (_this.checkData.length === 0) {
+                                    _this.checkData.push(task);
+                                    _this.fillInfo(task);
+                                } else if (_this.checkData.length > 0) {
+                                    this.checkData.some(function (item, i) {
+                                        if (item.customerid == task.customerid
+                                            && item.plantolotnum == task.plantolotnum
+                                            && item.sku == task.sku) {
+                                            _this.checkData.push(task)
+                                            _this.fillInfo(task);
+                                            return true;
+                                        } else {
+                                            $('#'+element.id).prop('checked', false);
+                                            window.tempTip.setDuration(2000);
+                                            window.tempTip.show('货主,批次不同,不可同时上架');
+                                        }
+                                    });
+                                }
+                            }else {
+                                _this.checkData.some(function (item, i) {
+                                    if (item.taskid == task.taskid
+                                    && item.taskid_sequence == task.taskid_sequence) {
+                                        _this.checkData.splice(i, 1);
+                                        _this.updateInfo(task);
+                                        return true;
+                                    }
+                                });
+                            }
+                            _this.$forceUpdate();
+                        },
+                        fillInfo(task){
+                            this.info.name=task.skudescrc;
+                            if (this.info.paTotal==''||this.info.paTotal==null||this.info.paTotal==undefined){this.info.paTotal=0;}
+                            this.info.paTotal+=Number(task.qty);
+                            // this.info.location=task.plantolocation;
+                        },
+                        updateInfo(task){
+                            this.info.name=task.skudescrc;
+                            this.info.paTotal-=Number(task.qty);
+                            // this.info.location=task.plantolocation;
+                        },
+                        getTsk() {
+                            let _this=this;
+                            _this.clearChecked();
+                            if (!this.info.barCode)return;
+                            let url = '{{url('store/handInStorage/getTsk')}}';
+                            window.axios.post(url, {trackNumber:this.info.trackNumber,barCode: this.info.barCode})
+                                .then(res => {
+                                    if (res.data.success) {
+                                        this.tasks = res.data.data;
+                                        this.$forceUpdate();
+                                        setTimeout(function () {
+                                            document.getElementById("task_0").checked=true;
+                                            let element={};
+                                            element.checked=true;
+                                            _this.checked(1,_this.tasks[0],element)
+                                        }, 100);
+                                        return;
+                                    }
+                                    window.tempTip.setDuration(2000);
+                                    window.tempTip.show(res.data.data);
+                                }).catch(err => {
+                                window.tempTip.setDuration(2000);
+                                window.tempTip.show("网络错误:" + err);
+                            })
+                        },
+                        clearChecked(){
+                            this.checkData=[];
+                            this.info.paTotal=0;//设置上架总数
+                            $('input[type=checkbox]').each(function() {
+                                let self = $(this);
+                                self.prop('checked', false);
+                            });
+                        },
+                        ensure() {
+                            this.errors={};//初始errors状态
+                            this.verifyInfoAndCheckData();
+                            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(2000);
+                                        window.tempTip.showSuccess(res.data.data);
+                                        this.info={};
+                                        this.checkData=[];
+                                        this.tasks=[];
+                                        this.$forceUpdate()
+                                        document.getElementById("trackNumber").focus();
+                                        return;
+                                    }
+                                    window.tempTip.setDuration(2000);
+                                    window.tempTip.show(res.data.data);
+                                }).catch(err=>{
+                                window.tempTip.setDuration(2000);
+                                window.tempTip.show("网络错误:"+err);
+                            })
+
+                        },
+                        cancel() {
+                            setTimeout(function () {
+                                window.location.reload();
+                                document.getElementById("trackNumber").focus();
+                            }, 100);
+                        },
+                        enterVal(e) {
+                            let index = this.element.indexOf(e.target.id) + 1;
+                            let element = document.getElementById(this.element[index]);
+                            if (element) element.focus();
+                            e.preventDefault();
+                            return false;
+                        },
+                        verifyInfoAndCheckData(){
+                            let error = {};
+                            if (!this.info.trackNumber) error.trackNumber = ["容器号必填"];
+                            if (!this.info.barCode) error.barCode = ["条码必填"];
+                            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;}
+                        },
+                    },
+                });
+            </script>
+@stop

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

@@ -8,17 +8,18 @@
                 <span class="font-weight-bold h4">收货</span>
             </div>
             <div class="card-body" >
-                <div class="offset-2">
-                    <span class="font-weight-bold">ASN号:</span>
+                <div class="offset-1">
+                    <span class="font-weight-bold">ASN号:</span><br>
+                    <p class="small font-weight-light">可输入条码,ASN号,货主编号(如:YOUWU)_搜索</p>
                     <div class="form-group row mt-2">
                         <label for="asn"></label>
-                        <input type="text" class="form-control col-8" id="asn"
-                               :class="errors.asn ? 'is-invalid' : ''" @keydown.enter="selectCustomerid($event)" v-model="info.asn">
+                        <input type="text" class="form-control col-8" id="asn" autocomplete="off"
+                               :class="errors.asnno ? 'is-invalid' : ''" v-model="info.asnno">
                         <span class="ml-2">
                              <button type="button" id="select" class="btn btn-info" @click="selectAsn()">搜索</button>
                         </span>
-                        <span class="invalid-feedback" role="alert" v-if="errors.asn">
-                            <strong>@{{ errors.asn[0] }}</strong>
+                        <span class="invalid-feedback" role="alert" v-if="errors.asnno">
+                            <strong>@{{ errors.asnno[0] }}</strong>
                         </span>
                     </div>
                 </div>
@@ -29,10 +30,31 @@
                             <td style="filter:grayscale(30%);">
                                 <div>
                                     <div style="transform:scale(1)" class="pl-0">
-                                        <span><span class="text-danger font-weight-bold">ASN编号:</span><span class="text-black">@{{ asn.asnno }}</span></span>
-                                        <span><span class="font-weight-bold">交接状态:</span><span class="text-lowercase" v-if="asn.asn_status">@{{ asn.asn_status.codename_c }}</span></span>
+                                        <span><span class="text-danger">ASN编号:</span><span class="text-black font-weight-bold">@{{ asn.asnno }}</span></span><br>
+                                        <span>
+                                            <span >状态:</span>
+                                            <span class="text-lowercase small" v-if="asn.asnstatus==='00'">订单创建</span>
+                                            <span class="text-lowercase small" v-if="asn.asnstatus==='30'">部分收货</span>
+                                        </span>
+                                        <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                        <span><span>货主:</span><span class="text-black font-weight-bold small">@{{ asn.customerid }}</span></span><br>
                                         <span><span class="text-lowercase">客户订单号1:</span><span class="text-lowercase">@{{ asn.asnreference1 }} </span></span>
                                         <span><span class="text-black">创建时间:</span><span class="text-black-50">@{{ asn.addtime }}</span></span>
+                                        <span>
+                                            <span class="btn btn-success btn-sm" v-if="!asn.up"  @click.stop="getAsnDetails(asn)">明细</span>
+                                            <span class="btn btn-secondary btn-sm" v-if="asn.up" @click.stop="closeDetail(asn)">收起</span>
+                                        </span>
+                                        <table class="table-sm table-borderless" v-if="asns.length>0 && asn.asnDetails && asn.up">
+                                            <tr  v-for="(asnDetail,i) in asn.asnDetails">
+                                                <td>
+                                                    <span><span class="small">产品:</span><span class="text-black small">@{{ asnDetail.sku }}</span></span>
+                                                    <span><span class="small">条码:</span><span class="text-black font-weight-bold small">@{{ asnDetail.alternate_sku1 }}</span></span>
+                                                    <span><span class="small">品名:</span><span class="text-black small">@{{ asnDetail.skudescrc }}</span></span>
+                                                    <span><span class="small">预期数量:</span><span class="text-black font-weight-bold small">@{{ asnDetail.expectedqty }}</span></span>
+                                                    <span><span class="small">已收数量:</span><span class="text-black font-weight-bold small">@{{ asnDetail.receivedqty }}</span></span>
+                                                <td/>
+                                            </tr>
+                                        </table>
                                     </div>
                                 </div>
                             </td>
@@ -66,7 +88,8 @@
                 this.pageInit();
                 $("#container").removeClass("d-none");
                 this.height=window.screen.availHeight;
-                document.getElementById('cardTable').style.height=this.height*0.50+'px';
+                document.getElementById('cardTable').style.height=this.height*0.35+'px';
+                document.getElementById("asn").focus();
             },
             methods:{
                 //页面初始化
@@ -82,8 +105,9 @@
                     if (e2)e2.remove();
                 },
                 selectAsn(){
+                    this.selectTr='';
                     let url = '{{url('store/handInStorage/selectAsn')}}';
-                    window.axios.post(url,{asnno:this.info.asn})
+                    window.axios.post(url,{asnno:this.info.asnno})
                         .then(res=>{
                             if (res.data.success){
                                 this.asns=res.data.data;
@@ -97,25 +121,76 @@
                         window.tempTip.show("网络错误:"+err);
                     })
                 },
+                getAsnDetails(asn){
+                    if (!asn)return;
+                    let url = '{{url('store/handInStorage/selectAsnDetails')}}';
+                    window.axios.post(url,{asnno:asn.asnno})
+                        .then(res=>{
+                            if (res.data.success){
+                                this.asns.forEach(function (Asn){
+                                    if (Asn.asnno==asn.asnno){
+                                        Asn.up=true;
+                                        Asn.asnDetails=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);
+                    })
+                },
+                closeDetail(asn){
+                    this.asns.forEach(function (Asn){
+                        if (Asn.asnno==asn.asnno){
+                            Asn.up=false;
+                        }
+                    })
+                    this.$forceUpdate()
+                },
                 selectTrOne(i,asn){
                     if (this.selectTr===i+1){
                         this.selectTr=0
                     }else {
                         this.selectTr=i+1;
-                        this.info.asn=asn.asnno;
+                        this.info.asnno=asn.asnno;
                         this.info.customerid=asn.customerid;
+                        this.info.asntype=asn.asntype;
                     }
                 },
+                onfocus(){
+                    document.getElementById("asn").focus();
+                },
                 ensure(){
                     let error = {};
-                    if (!this.info.asn)error.asn = ["ASN号必填"];
-                    if (this.info.asn && this.info.asn.length!==13)error.asn = ["无效ASN号"];
+                    if (!this.info.asnno)error.asnno = ["ASN号必填"];
+                    if (this.info.asnno && this.info.asnno.length!==13)error.asnno = ["无效ASN号"];
                     if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
-                    window.location.href="{{url('store/handInStorage/receiveDetailPage')}}/" + this.info.asn+'/'+ this.info.customerid;
+                    if (!this.info.customerid||!this.info.asntype){this.info.customerid='';this.info.asntype='';}
+                    this.checkAsnOperation();
+                },
+                checkAsnOperation(){
+                    let url = '{{url('store/handInStorage/checkAsnOperation')}}';
+                    window.axios.post(url,{info:this.info})
+                        .then(res=>{
+                            if (res.data.success){
+                                window.location.href="{{url('store/handInStorage/receiveDetailPage')}}/" + res.data.data.asnno+'/'+ res.data.data.customerid;
+                            }else {
+                                window.tempTip.setDuration(2000);
+                                window.tempTip.show(res.data.data);
+                            }
+                        }).catch(err=>{
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.show("网络错误:"+err);
+                    })
                 },
                 cancel(){
                     setTimeout(function () {
                         window.location.reload();
+                        this.onfocus();
                     },100);
                 },
             },

+ 40 - 30
resources/views/store/handInStorage/receiveDetailPage.blade.php

@@ -11,9 +11,9 @@
                 <div class="form-group row m-1">
                         <span class="text-right">
                             <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>
+                            <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" placeholder="输入商品sku或商品条码"
                            :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,21 +31,24 @@
                     </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>
                         </span>
                     </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" autocomplete="off"--}}
+{{--                               @keydown.enter="enterVal($event)" v-model="info.location">--}}
+{{--                    </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"
-                               @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"
-                               @keydown.enter="enterVal($event)" v-model="info.trackNumber">
+                        <label for="trackNumber" class="text-right text-danger font-weight-bold">容器号:</label>
+                        <input type="text" class="form-control form-control-sm col-8" id="trackNumber" autocomplete="off"
+                               @keydown.enter="enterVal($event)" :class="errors.trackNumber ? 'is-invalid' : ''" v-model="info.trackNumber">
+                        <span class="invalid-feedback offset-3" role="alert" v-if="errors.trackNumber">
+                            <strong>@{{ errors.trackNumber[0] }}</strong>
+                        </span>
                     </div>
                 </div>
                 <div style="overflow: auto;overflow-x: hidden" id="cardTable" v-if="!isInit">
@@ -55,11 +58,12 @@
                             <td style="filter:grayscale(30%);">
                                 <div>
                                     <div style="transform:scale(1)" class="pl-0">
-                                        <span><span class="text-danger font-weight-bold">条码:</span><span class="text-black">@{{ asnDetail.sku }}</span></span>
+                                        <span><span class="text-danger font-weight-bold">产品:</span><span class="text-black">@{{ asnDetail.sku }}</span></span>
                                         <span><span class="font-weight-bold">行号:</span><span class="text-lowercase" >@{{ asnDetail.asnlineno }}</span></span>
                                         <span class="text-right float-right">选中:<input type="checkbox" @click="checked(asnDetail)"></span>
                                         <span><span class="text-lowercase">品名:</span><span class="text-lowercase">@{{ asnDetail.skudescrc }} </span></span>
                                         <span><span class="text-black">预期数量:</span><span class="text-black-50">@{{ asnDetail.expectedqty }}</span></span>
+                                        <span><span class="text-black">已收数量:</span><span class="text-black-50">@{{ asnDetail.receivedqty }}</span></span>
                                     </div>
                                 </div>
                             </td>
@@ -89,7 +93,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>
@@ -154,15 +158,15 @@
                 isAndroid:false,
                 isInit:true,
                 element:[
-                    "sku","amount","location","trackNumber"
+                    "sku","amount",/*"location",*/"trackNumber"
                 ],
                 selectTr:'',
             },
             mounted(){
                 if (navigator.userAgent.indexOf("Android")!==-1)this.isAndroid = true;
-                this.codeFocus();
                 this.pageInit();
                 $("#container").removeClass("d-none");
+                document.getElementById("sku").focus();
             },
             methods:{
                 //页面初始化
@@ -182,10 +186,10 @@
                         this.selectTr=0
                     }else {
                         this.selectTr=i+1;
-                        // this.info.sku=sku;
                     }
                 },
                 checkedSku(){
+                    if (!this.info.sku)return;
                     let url = '{{url('store/handInStorage/getBasSkuWithLot')}}';
                     window.axios.post(url,{asnno:this.asnno,customerid:this.customerid,sku:this.info.sku})
                         .then(res=>{
@@ -232,16 +236,14 @@
                     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;
                 },
-                //聚焦 白名单
-                codeFocus(){
-                    document.getElementById("sku").focus();
-                },
                 checkInfo(){
                     let error = {};
                     if (!this.info.sku)error.sku = ["条码必填"];
                     if (!this.info.amount)error.amount = ["实收数量必填"];
+                    if (!this.info.trackNumber)error.trackNumber = ["容器号必填"];
                     if (this.info.amount && ((Number(this.info.amount)+Number(this.info.receivedqty))>Number(this.info.expectedqty)))error.amount = ["总数不能超过预期数"];
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey01==='Y' && !this.info.lotatt01) error.lotatt01=["生产日期为选"];
                     if (this.basSku.lot_id && this.basSku.lot_id.lotkey02==='Y' && !this.info.lotatt02) error.lotatt02=["失效日期为选"];
@@ -249,8 +251,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 +279,24 @@
                     })
                 },
                 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.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();
+                                document.getElementById("sku").focus();
                                 return;
                             }
                             window.tempTip.setDuration(2000);
@@ -302,6 +306,12 @@
                         window.tempTip.show("网络错误:"+err);
                     })
                 },
+                cancel(){
+                    setTimeout(function () {
+                        window.location.reload();
+                        document.getElementById("sku").focus();
+                    },100);
+                },
             },
         });
     </script>

+ 4 - 1
routes/web.php

@@ -495,9 +495,12 @@ Route::group(['middleware'=>'auth'],function ($route){
             Route::get('putaway',function (){return view('store.handInStorage.putaway');});//上架页面
             Route::get('android.index',function (){return view('store.handInStorage.androidIndex');});
             Route::post('selectAsn','HandInStorageController@selectAsn');
+            Route::post('checkAsnOperation','HandInStorageController@checkAsnOperation');
             Route::post('selectAsnDetails','HandInStorageController@selectAsnDetails');
             Route::post('getBasSkuWithLot','HandInStorageController@getBasSkuWithLot');
-            Route::post('fluxHandIn','HandInStorageController@fluxHandIn');
+            Route::any('fluxHandIn','HandInStorageController@fluxHandIn');
+            Route::post('getTsk','HandInStorageController@getTsk');
+            Route::post('handFluxPa','HandInStorageController@handFluxPa');
             Route::get('receiveDetailPage/{asnno}/{customerid}','HandInStorageController@receiveDetailPage');
         });
         Route::group(['prefix'=>'fast'],function() {

+ 1 - 1
syncProject.sh

@@ -3,7 +3,7 @@ Ip="was.baoshi56.com"
 username="haozi"
 password="haozi"
 files=("app" "config" "database" "public" "resources" "routes" "webpack.mix.js" "composer.json" "tests")
-src=/var/www/bswas_test_
+src=/var/www/bswas_test
 dsc=/var/www/was
 cd $src
 for i in ${files[*]}

+ 5 - 0
yarn.lock

@@ -4351,6 +4351,11 @@ map-visit@^1.0.0:
   dependencies:
     object-visit "^1.0.0"
 
+marked@^2.1.3:
+  version "2.1.3"
+  resolved "https://registry.yarnpkg.com/marked/-/marked-2.1.3.tgz#bd017cef6431724fd4b27e0657f5ceb14bff3753"
+  integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==
+
 md5.js@^1.3.4:
   version "1.3.5"
   resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"