gate("入库管理-手持入库-收货"); /** @var HandInStorageService $handInStorageService */ $handInStorageService=app('HandInStorageService'); $asnno= $request->input('asnno'); $asns =$handInStorageService->selectAsn($asnno); if (count($asns)>0){ foreach ($asns as $asn){ $asn->asnDetails=array(); } $this->success($asns); }else{ $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') $customerid=OracleDOCASNHeader::query()->where('asnno',$asnno)->value('customerid'); $qualityStatus=$handInStorageService->getQualityStatus(); $attributeLocations=$handInStorageService->getAttributeLocation(); $asnQty=$handInStorageService->getAsnQty($asnno); return view('store.handInStorage.receiveDetailPage') ->with(['asn_expectedqty'=>$asnQty->expectedqty,'asn_receivedqty'=>$asnQty->receivedqty, 'asnno'=>$asnno,'customerid'=>$customerid, 'qualityStatus'=>$qualityStatus,'attributeLocations'=>$attributeLocations]); } /** * @param Request $request * 查询富勒asn_detail(集合) */ public function selectAsnDetails(Request $request) { $this->gate("入库管理-手持入库-收货"); $asnno= $request->input('asnno'); $asnDetails =app('HandInStorageService')->selectAsnDetails($asnno); if (count($asnDetails)>0)$this->success($asnDetails); else $this->error('未查询到相应的asn明细'); } /** * @param Request $request * 查询富勒bas_sku 并关联 bas_lotid */ public function getBasSkuWithLot(Request $request): array { $customerid= $request->input('customerid'); $skuOrBarcode= $request->input('sku'); $asnno= $request->input('asnno'); $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'); $isReceivedqty=$info['receivedqty']??false; $isExpectedqty=$info['expectedqty']??false; $isSku=$info['sku']??false; if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期'); if (!$info['customerid']||$isSku===false||!$info['asnno']||$isReceivedqty===false||$isExpectedqty===false) $this->error('参数错误'); if ($info['amount'] + $info['receivedqty'] > $info['expectedqty']) $this->error('收货数大于预期数'); //九干仓禁止使用当前app收货 $res=$this->screenWarehouseAndContrast($info['customerid']); if ($res)$this->error('禁止使用当前app收货,请换用新版app收货!'); /** @var HandInStorageService $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 ($info['customerid']=='JIANSHANG'&&$handInStorageService->checkForwardingLoc($info)===1)$this->error('请维护拣货位'); $key = $info['asnno'] . '_' . $info['sku'] . '_' . Auth::id(); $ttl = 10; try { //缓存校验操作 if (Cache::has($key)){ $this->error('当前已操作'); }else{ Cache::put($key,true, $ttl); } //收货操作 $resultIn = $handInStorageService->fluxHandIn($info); if ($resultIn===1)$this->error("超收"); if ($resultIn){ $asnQty=$handInStorageService->getAsnQty($info['asnno']); $this->success($asnQty); } else $this->error("收货失败"); } catch (\Exception $e) { app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage()); } finally { Cache::forget($key); } } public function screenWarehouseAndContrast($ownerCode): bool { $owners=Owner::query() ->select('code') ->where('warehouse_id',3)//3 代表九干仓仓库id ->whereNull('deleted_at') ->get(); foreach ($owners as $owner){ if ($owner->code==$ownerCode){ return true; } } return false; } /** * @param Request $request * 根据商品条码和跟踪号 获取要上架的任务列表 */ public function getTsk(Request $request) { $this->gate("入库管理-手持入库-上架"); $barCode=$request->input('barCode'); $trackNumber=$request->input('trackNumber'); /** @var HandInStorageService $handInStorageService */ $handInStorageService=app('HandInStorageService'); $tasks=$handInStorageService->getTsk($trackNumber,$barCode); if (count($tasks)>0){ $invLots=$handInStorageService->getInvotlocid($barCode); $collect= collect(); foreach ($invLots as $invLot){ if ($invLot->locationid=='STAGEWH01'||$invLot->locationid=='STAGEWH02')continue; $collect->push($invLot); } return json_encode(["success"=>true,'data'=>$tasks,'inv'=>$collect]); } else $this->error("该商品暂无上架任务"); } /** * @param Request $request * 根据customerid,asnno,跟踪号 或空扫 获取待上架任务 */ public function getPaTaskByTraceInOrCustomerOrAsnOrNull(Request $request) { $this->gate("入库管理-手持入库-上架"); $trackNumber=$request->input('trackNumber'); $barCode=$request->input('barCode'); /** @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 (gettype($info['amount'])==='string')$info['amount']=(int)$info['amount']; if (!$info['location']||!$info['amount']||!$info['barCode'] || gettype($info['amount'])==='string') $this->error('参数错误'); if (count($request->input('checkData'))==0) $this->error('请勾选要上架任务'); $checkData=$request->input('checkData')[0]; //九干仓禁止使用当前app上架 $res=$this->screenWarehouseAndContrast($checkData['customerid']); if ($res)$this->error('禁止使用当前app上架,请换用新版app上架!'); /** @var HandInStorageService $handInStorageService */ $handInStorageService=app('HandInStorageService'); //判断当前库位是否能放该商品 $res=$handInStorageService->checkLocation($info,$checkData); if ($res===1)$this->error('库位不存在'); if ($res===2)$this->error('库位:产品和批次不可混放'); if ($res===3)$this->error('库位:不能混放批次'); if ($res===4)$this->error('库位:产品不能混放'); $key = $info['location'] . '_' . $info['barCode'] . '_' . Auth::id(); $ttl = 10; try { //缓存校验操作 if (Cache::has($key)){ $this->error('当前已操作'); }else{ Cache::put($key,true, $ttl); } $result = $handInStorageService->fluxHandPa($info, $checkData); if ($result===true){ if ($checkData['customerid']=="JIANSHANG"){ $asn=OracleDOCASNHeader::query() ->where('asnno',$checkData['docno']) ->where('asnstatus','99') ->whereIn('asntype',['F10','F21','F31','F32']) ->first(); if ($asn){$handInStorageService->verifyAsnStatusAndInsert($asn);} } $this->success("上架成功"); } if ($result===false) $this->error("上架失败"); if ($result===1)$this->error("拣货区找到效期更新的同样货品,不能上架至存储区"); } catch (\Exception $e) { $this->error($e->getMessage()); app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage()); }finally { Cache::forget($key); } } 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('未查询到库存信息'); } }