getQualityStatus(); $attributeLocations=$handInStorageService->getAttributeLocation(); return view('store.countGoodsAndReceive.index', compact('qualityStatus','attributeLocations')); } public function excel() { $excels=InventoryBlindReceiveExcel::query() ->where('name','like','清点%') ->orderByDesc('id')->get(); return view('store.countGoodsAndReceive.excel',['excels'=>$excels]); } public function createExcel(Request $request): array { $goodses=$request->input('goodses')??''; $excelFileName=$request->input('filename')??''; if(!$goodses||!is_array($goodses)||count($goodses)==0){ return ['result'=>'failure','fail_info'=>'没有数据提交!']; } $goodsExcelArray=[['条码','数量','箱号']]; foreach ($goodses as $goods){ array_push($goodsExcelArray,[$goods['barcode'],$goods['amount'],$goods['cast_number']]); } $fileName=Carbon::now()->toDateTimeLocalString().'.xlsx'; $fileName = str_replace( ':', '_',$fileName); $goodsNeateningExcel = new InventoryBlindReceiveExcel(['file' => $fileName, 'goods_amount' => count($goodses), 'name'=>'清点_'.$excelFileName]); $goodsNeateningExcel->save(); Excel::store(new InventoryBlindReceiveExcelExport($goodsExcelArray),$fileName,'public'); $this->removeExpiredExcel(); return ['result'=>'success']; } private function removeExpiredExcel(){ $excels=InventoryBlindReceiveExcel::query()->where('created_at','<',Carbon::now()->subDays(100)->toDateTimeString())->get(); $excels->each( /** @throws \Exception */ function(InventoryBlindReceiveExcel $excel){ $excel->delete(); }); } public function getReceiveTaskByAsnNoAndBarcodes(Request $request) { $asnno=$request->input('asnno'); $goods=$request->input('goods'); $asnDetails=OracleDOCASNDetail::query() ->select('asnno','asnlineno','customerid','sku','expectedqty','receivedqty_each', 'lotatt01','lotatt02','lotatt03','lotatt04','lotatt05','lotatt08') ->with('basSku.lotId') ->where('asnno',$asnno) ->whereIn('linestatus', ['00', '30']) ->get(); $status=false; foreach ($goods as &$good){ foreach ($asnDetails as $asnDetail){ if (!$asnDetail['basSku']??false)continue; if ($good['sku']==$asnDetail['basSku']['alternate_sku1'] ||$good['sku']==$asnDetail['basSku']['alternate_sku2'] ||$good['sku']==$asnDetail['basSku']['alternate_sku3']){ $good['basSku']=$asnDetail['basSku']; $good['customerid']=$asnDetail['customerid']; $good['asn_amount']=($asnDetail['expectedqty']-$asnDetail['receivedqty_each']); $good['diff_val']=($good['asn_amount']-$good['amount']); $good['receiveStatus']=true; $status=true; $good['asnlineno']=$asnDetail['asnlineno']; $good['lotatt01']=$asnDetail['lotatt01']; $good['lotatt02']=$asnDetail['lotatt02']; $good['lotatt03']=$asnDetail['lotatt03']; $good['lotatt04']=$asnDetail['lotatt04']; $good['lotatt05']=$asnDetail['lotatt05']; $good['lotatt08']=$asnDetail['lotatt08']; } } } if ($status)$this->success($goods); else $this->error('当前ASN单号未查询到下述商品信息!'); } public function fluxReceive(Request $request) { $info=$request->input('good'); $isSku=$info['sku']??false; if ($info['lotatt02']&&Carbon::now()->gt($info['lotatt02']))$this->error('失效日期超过入库效期'); if (!$info['customerid']||$isSku===false||!$info['asnno']) $this->error('参数错误'); /** @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){ $this->success('收货成功'); } else $this->error("收货失败"); } catch (\Exception $e) { app('LogService')->log(__METHOD__,'error_'.__FUNCTION__,json_encode($info).'|catch:'.$e->getMessage()); } finally { Cache::forget($key); } } }