getIntersectPermitting(); $inventoryCompares=app('InventoryCompareService')->getInventoryCompare($request->all()); $param = $request->input(); return view('inventory.statement.inventoryCompare',compact('owners','inventoryCompares','param')); } function importExcel(Request $request){ if (!Gate::allows('库存管理-库存-库存对比')){return redirect(url('/')); } // $owner_id=$request->owner_id; // if(!$owner_id) return '

导入Excel失败

您还未选择相应货主!

'; $fileSuffix = $request->file()['file']->getClientOriginalExtension(); if (in_array($fileSuffix, ['xlsx', 'xlsm', 'xltx', 'xltm', 'xls', 'xlt', 'ods', 'ots', 'slk', 'xml', 'gnumeric', 'htm', 'html', 'csv', 'tsv'])) { ini_set('max_execution_time', 2100); ini_set('memory_limit', '512M'); $extension = $request->file()['file']->getClientOriginalExtension(); $extension[0] = strtoupper($extension[0]); Excel::import(new InventoryCompareImport(), $request->file('file')->path(), null, $extension); if (Cache::has('error')) { return '

导入Excel失败

' . Cache::pull('error') . '

'; } else { $exception = Cache::get('exception'); // if ($exception){ $a = ''; for ($i = 0; $i < count($exception); $i++) { $a .= implode(',', $exception[$i]) . ' '; }; app('LogService')->log(__METHOD__, __FUNCTION__, json_encode($request->toArray()), Auth::user()['id']); return '

导入Excel成功

'; // }else { // return '

导入Excel成功

'; // } } } else { return '

失败

不支持该文件类型

'; } } public function exportInventoryCompare(Request $request){ if (!Gate::allows('库存管理-库存-库存对比')){return redirect(url('/')); } if ($request->checkAllSign){ $params = $request->input(); unset($params['checkAllSign']); $sql=app('InventoryCompareService')->getSql($params); }else{ $sql=app('InventoryCompareService')->getSql(['id'=>$request->data]); } $e = new Export(); $e->setMysqlConnection(config('database.connections.mysql.host'), config('database.connections.mysql.port'),config('database.connections.mysql.database') ,config('database.connections.mysql.username'),config('database.connections.mysql.password')); $e->setFileName("库存对比记录"); return $e->sql($sql,[ "owner_name"=>"货主","mission_code"=>"任务号", "created_at"=>"生产时间","commodity_name"=>"商品名称", "commodity_sku"=>"商品编码","commodity_barcode_code"=>"商品条码", "custom_location"=>"属性仓","quality"=>"质量状态", "amount_in_sys"=>"宝时库存","amount_in_compare"=>"参考库存", "differ"=>"差值" ])->direct(); } }