fetch(); } public function kq(){ set_time_limit(0); ini_set("memory_limit", -1); ob_flush();//清空缓存 flush();//刷新缓存 if(request()->file()) { $file = request()->file('file'); // 移动到框架应用根目录/uploads/ 目录下 $info = $file->validate([ 'size'=>500*1024*1024,'ext'=>'xls,xlsx' ]) ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'temp'); if(!$info){ exit('文件上传失败'); } $img = './uploads/temp/' . $info->getSaveName(); $filePath = str_replace('\\', '/', $img); $excelArray = ExcelUtil::read($filePath, ['val','val1','val2','val3','val4','val5','val6','val7','val8','val9','val10','val11','val13','val12'] ); // unset($excelArray[0]); if(empty($excelArray)){ exit('文件内容为空'); } $succ = []; foreach ($excelArray as $k => $v) { $name = $v['val']; $t = $v['val5']; $date = mb_substr($t,0,-11); $data = [ 'name'=>$name, 'st'=>$date, 'day'=>date('Y-m-d',strtotime($date)) ]; $ret = Db::name('shuaka')->insert($data); if($ret){ echo "第".($k+1)."行,导入成功
"; }else{ echo "第".($k+1)."行,导入失败
"; } } }else{ exit('请上传文件'); } } public function sava(){ $lists = Db::name('shuaka') ->group('name,day') ->order('id asc') ->select(); foreach ($lists as $k=>$v){ $count = Db::name('shuaka') ->where('name',$v['name']) ->where('day',$v['day']) ->count(); $st = Db::name('shuaka') ->where('name',$v['name']) ->where('day',$v['day']) ->order('st asc') ->value('st'); $et = Db::name('shuaka') ->where('name',$v['name']) ->where('day',$v['day']) ->order('st desc') ->value('st'); $data = [ 'name'=>$v['name'], 'st'=>$st, 'et'=>$count>1?$et:'', ]; $res = Db::name('shuaka_log')->insertGetId($data); if($res){ echo $res.'
';
            }

        }

    }

}