From f6bc03f76bcd5032d711f2ec6c73d658a5c3d5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Wed, 16 Oct 2019 09:30:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=90=E7=BB=A9=E7=BB=9F=E8=AE=A1=E5=88=86?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/chengji/controller/Bjtongji.php | 213 ++++++++++ application/chengji/controller/Njtongji.php | 204 +++++++++ application/chengji/controller/Tongji.php | 395 ------------------ application/chengji/model/Bjtongji.php | 63 +++ application/chengji/model/Njtongji.php | 55 +++ application/chengji/model/Tongji.php | 99 +---- .../tj_banji.html => bjtongji/biaoge.html} | 5 +- .../view/{tongji => bjtongji}/dw_banji.html | 0 .../tj_nianji.html => njtongji/biaoge.html} | 5 +- .../view/{tongji => njtongji}/dw_nianji.html | 0 .../kaoshi/view/index/more_action.html | 4 +- config/database.php | 4 +- public/.htaccess | 2 +- route/chengji.php | 40 +- 14 files changed, 572 insertions(+), 517 deletions(-) create mode 100644 application/chengji/controller/Bjtongji.php create mode 100644 application/chengji/controller/Njtongji.php create mode 100644 application/chengji/model/Bjtongji.php create mode 100644 application/chengji/model/Njtongji.php rename application/chengji/view/{tongji/tj_banji.html => bjtongji/biaoge.html} (97%) rename application/chengji/view/{tongji => bjtongji}/dw_banji.html (100%) rename application/chengji/view/{tongji/tj_nianji.html => njtongji/biaoge.html} (96%) rename application/chengji/view/{tongji => njtongji}/dw_nianji.html (100%) diff --git a/application/chengji/controller/Bjtongji.php b/application/chengji/controller/Bjtongji.php new file mode 100644 index 00000000..509e6dbb --- /dev/null +++ b/application/chengji/controller/Bjtongji.php @@ -0,0 +1,213 @@ +where('id',$kaoshi) + ->with([ + 'KsNianji' + ,'ksSubject'=>function($query){ + $query->field('kaoshiid,subjectid,manfen') + ->with(['subjectName'=>function($q){ + $q->field('id,title,lieming'); + }] + ); + } + ]) + ->field('id,title') + ->find(); + + if(count($ksinfo->ks_nianji)>0) + { + $list['nianji'] = $ksinfo->ks_nianji[0]->nianji; + }else{ + $list['nianji'] = "一年级"; + } + $list['subject'] = $ksinfo->ks_subject->toArray(); + // 设置要给模板赋值的信息 + $list['webtitle'] = '各年级的班级成绩列表'; + $list['kaoshi'] = $kaoshi; + $list['kaoshititle'] = $ksinfo->title; + + + // 模板赋值 + $this->assign('list',$list); + + // 渲染模板 + return $this->fetch(); + } + + + // 获取年级成绩统计结果 + public function ajaxBianji() + { + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'kaoshi'=>'', + 'nianji'=>'', + 'school'=>array(), + 'paixu'=>array(), + ],'POST'); + + // 统计成绩 + $btj = new BTJ; + + $data = $btj->tjBanji($src['kaoshi'],$src['nianji'],$src['school'],$src['paixu']); + + + // 获取记录总数 + $cnt = count($data); + // 截取当前页数据 + $data = array_slice($data,($src['page']-1)*$src['limit'],$src['limit']); + + // 重组返回内容 + $data = [ + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, //获取到的数据结果 + ]; + + return json($data); + } + + // 年级、班级学生成绩统计结果下载界面 + public function dwBanji($kaoshi) + { + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'各班级成绩汇总表下载', + 'butname'=>'下载', + 'formpost'=>'POST', + 'url'=>'/bjtongji/dwBanji', + 'kaoshi'=>$kaoshi + ); + + // 模板赋值 + $this->assign('list',$list); + // 渲染 + return $this->fetch(); + + } + + + // 年级、班级学生成绩统计下载表格 + public function dwBanjixls($kaoshi) + { + // 获取表单参数 + $src = $this->request + ->only([ + 'kaoshi'=>'', + 'nianji'=>'一年级', + 'school'=>array(), + ],'POST'); + + $schools = [$src['school']]; + + + // 统计成绩 + $btj = new BTJ; + $data = $btj->tjBanji($src['kaoshi'],$src['nianji'],$schools,array()); + + + // 获取参考学科 + $ks = new \app\kaoshi\model\Kaoshi; + $ksinfo = $ks->where('id',$src['kaoshi']) + ->field('id,title') + ->with([ + 'ksSubject'=>function($query){ + $query->field('kaoshiid,subjectid,manfen') + ->with(['subjectName'=>function($q){ + $q->field('id,title,lieming'); + }] + ); + } + ]) + ->find(); + $xk = $ksinfo->ks_subject; + + + // 获取要下载成绩的学校和年级信息 + $school = new \app\system\model\School; + $schoolname = $school->where('id',$src['school'])->value('jiancheng'); + $tabletitle = $ksinfo->title.' '.$schoolname.' '.$src['nianji'].'各班级成绩汇总'; + + // 创建表格 + $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; + $sheet = $spreadsheet->getActiveSheet(); + + $sbjcol = ['xkcnt'=>'人数','avg'=>'平均分','jige'=>'及格率%','youxiu'=>'优秀率%']; + $sbjcolcnt = count($sbjcol); + $colname = excelLieming(); + $colcnt = $sbjcolcnt*count($xk)+3; + + + // 设置表头信息 + $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); + $sheet->setCellValue('A1', $tabletitle); + $sheet->mergeCells('A3:A4'); + $sheet->setCellValue('A3', '序号'); + $sheet->mergeCells('B3:B4'); + $sheet->setCellValue('B3', '班级'); + $col = 2; + foreach ($xk as $key => $value) { + $colend = $col + $sbjcolcnt - 1; + $sheet->mergeCells($colname[$col].'3:'.$colname[$colend].'3'); + $sheet->setCellValue($colname[$col].'3', $value->subject_name->title.' ('.$value->manfen.')'); + foreach ($sbjcol as $k => $val) { + $sheet->setCellValue($colname[$col].'4', $val); + $col++; + } + } + $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); + $sheet->setCellValue($colname[$col].'3', '全科及格率%'); + $col++; + $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); + $sheet->setCellValue($colname[$col].'3', '全科平均'); + + $row = 5; + foreach ($data as $key => $value) { + $col = 2; + $sheet->setCellValue('A'.$row, $row-4); + $sheet->setCellValue('B'.$row, $value['banji']); + foreach ($xk as $ke => $val) { + foreach ($sbjcol as $k => $v) { + $sheet->setCellValue($colname[$col].$row, $value['chengji'][$val->subject_name->lieming][$k]); + $col++; + } + } + $sheet->setCellValue($colname[$col].$row, $value['chengji']['rate']); + $col++; + $sheet->setCellValue($colname[$col].$row, $value['chengji']['avg']); + $row++; + } + + + // 保存文件 + $filename = $tabletitle.date('ymdHis').'.xlsx'; + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment;filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); + $writer->save('php://output'); + ob_flush(); + flush(); + + } + + + +} diff --git a/application/chengji/controller/Njtongji.php b/application/chengji/controller/Njtongji.php new file mode 100644 index 00000000..bd548272 --- /dev/null +++ b/application/chengji/controller/Njtongji.php @@ -0,0 +1,204 @@ +where('id',$kaoshi) + ->with([ + 'KsNianji' + ,'ksSubject'=>function($query){ + $query->field('kaoshiid,subjectid,manfen') + ->with(['subjectName'=>function($q){ + $q->field('id,title,lieming'); + }] + ); + } + ]) + ->field('id,title') + ->find(); + + if(count($ksinfo->ks_nianji)>0) + { + $list['nianji'] = $ksinfo->ks_nianji[0]->nianji; + }else{ + $list['nianji'] = "一年级"; + } + + $list['subject'] = $ksinfo->ks_subject; + // 设置要给模板赋值的信息 + $list['webtitle'] = '各学校的年级成绩统计表'; + $list['kaoshi'] = $kaoshi; + $list['kaoshititle'] = $ksinfo->title; + + + // 模板赋值 + $this->assign('list',$list); + + // 渲染模板 + return $this->fetch(); + } + + + // 获取年级成绩统计结果 + public function ajaxNianji() + { + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'kaoshi'=>'', + 'nianji'=>'一年级', + ],'POST'); + // 统计成绩 + $ntj = new NTJ; + $data = $ntj->tjNianji($kaoshi=$src['kaoshi'],$nianji=$src['nianji']); + // 获取记录数 + $cnt = count($data); + // 截取当前页数据 + $data = array_slice($data,($src['page']-1)*$src['limit'],$src['limit']); + + // 重组返回内容 + $data = [ + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, //获取到的数据结果 + ]; + + + return json($data); + } + + + + // 年级、班级学生成绩统计结果下载界面 + public function dwNianji($kaoshi) + { + + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'各年级成绩汇总表下载', + 'butname'=>'下载', + 'formpost'=>'POST', + 'url'=>'/njtongji/dwNanji', + 'kaoshi'=>$kaoshi + ); + + // 模板赋值 + $this->assign('list',$list); + // 渲染 + return $this->fetch(); + + } + + + // 年级、班级学生成绩统计下载表格 + public function dwNianjixls($kaoshi) + { + + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'kaoshi'=>'', + 'nianji'=>'一年级', + ],'POST'); + + // 统计成绩 + $ntj = new NTJ; + $data = $ntj->tjNianji($kaoshi=$src['kaoshi'],$nianji=$src['nianji']); + + // 获取参考学科 + $ks = new \app\kaoshi\model\Kaoshi; + $ksinfo = $ks->where('id',$src['kaoshi']) + ->field('id,title') + ->with([ + 'ksSubject'=>function($query){ + $query->field('kaoshiid,subjectid,manfen') + ->with(['subjectName'=>function($q){ + $q->field('id,title,lieming'); + }] + ); + } + ]) + ->find(); + $xk = $ksinfo->ks_subject; + + // 获取要下载成绩的学校和年级信息 + $tabletitle = $ksinfo->title.' '.$src['nianji'].'各学校成绩汇总'; + + + // 创建表格 + $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; + $sheet = $spreadsheet->getActiveSheet(); + + $sbjcol = ['xkcnt'=>'人数','avg'=>'平均分','jige'=>'及格率%','youxiu'=>'优秀率%']; + $sbjcolcnt = count($sbjcol); + $colname = excelLieming(); + $colcnt = $sbjcolcnt*count($xk)+3; + + + // 设置表头信息 + $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); + $sheet->setCellValue('A1', $tabletitle); + $sheet->mergeCells('A3:A4'); + $sheet->setCellValue('A3', '序号'); + $sheet->mergeCells('B3:B4'); + $sheet->setCellValue('B3', '班级'); + $col = 2; + foreach ($xk as $key => $value) { + $colend = $col + $sbjcolcnt - 1; + $sheet->mergeCells($colname[$col].'3:'.$colname[$colend].'3'); + $sheet->setCellValue($colname[$col].'3', $value->subject_name->title.' ('.$value->manfen.')'); + foreach ($sbjcol as $k => $val) { + $sheet->setCellValue($colname[$col].'4', $val); + $col++; + } + } + $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); + $sheet->setCellValue($colname[$col].'3', '全科及格率%'); + $col++; + $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); + $sheet->setCellValue($colname[$col].'3', '总平均分'); + + $row = 5; + foreach ($data as $key => $value) { + $col = 2; + $sheet->setCellValue('A'.$row, $row-4); + $sheet->setCellValue('B'.$row, $value['school']); + foreach ($xk as $ke => $val) { + foreach ($sbjcol as $k => $v) { + $sheet->setCellValue($colname[$col].$row, $value['chengji'][$val->subject_name->lieming][$k]); + $col++; + } + } + $sheet->setCellValue($colname[$col].$row, $value['chengji']['rate']); + $col++; + $sheet->setCellValue($colname[$col].$row, $value['chengji']['avg']); + $row++; + } + + // 保存文件 + $filename = $tabletitle.date('ymdHis').'.xlsx'; + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment;filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); + $writer->save('php://output'); + ob_flush(); + flush(); + } +} diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index 8d6e9a93..0d3af2db 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -9,401 +9,6 @@ use app\chengji\model\Tongji as TJ; class Tongji extends Base { - // 年级成绩汇总 - public function tjBanji($kaoshi) - { - $ks = new \app\kaoshi\model\Kaoshi; - $ksinfo = $ks->where('id',$kaoshi) - ->with([ - 'KsNianji' - ,'ksSubject'=>function($query){ - $query->field('kaoshiid,subjectid,manfen') - ->with(['subjectName'=>function($q){ - $q->field('id,title,lieming'); - }] - ); - } - ]) - ->field('id,title') - ->find(); - - if(count($ksinfo->ks_nianji)>0) - { - $list['nianji'] = $ksinfo->ks_nianji[0]->nianji; - }else{ - $list['nianji'] = "一年级"; - } - $list['subject'] = $ksinfo->ks_subject->toArray(); - // 设置要给模板赋值的信息 - $list['webtitle'] = '各年级的班级成绩列表'; - $list['kaoshi'] = $kaoshi; - $list['kaoshititle'] = $ksinfo->title; - - - // 模板赋值 - $this->assign('list',$list); - - // 渲染模板 - return $this->fetch(); - } - - - // 获取年级成绩统计结果 - public function ajaxBianji() - { - // 获取参数 - $src = $this->request - ->only([ - 'page'=>'1', - 'limit'=>'10', - 'kaoshi'=>'', - 'nianji'=>'', - 'school'=>array(), - 'paixu'=>array(), - ],'POST'); - - // 统计成绩 - $tj = new TJ; - - $data = $tj->tjBanji($src['kaoshi'],$src['nianji'],$src['school'],$src['paixu']); - - - // 获取记录总数 - $cnt = count($data); - // 截取当前页数据 - $data = array_slice($data,($src['page']-1)*$src['limit'],$src['limit']); - - // 重组返回内容 - $data = [ - 'code'=> 0 , // ajax请求次数,作为标识符 - 'msg'=>"", // 获取到的结果数(每页显示数量) - 'count'=>$cnt, // 符合条件的总数据量 - 'data'=>$data, //获取到的数据结果 - ]; - - return json($data); - } - - - // 年级、班级学生成绩统计结果下载界面 - public function dwBanji($kaoshi) - { - // 设置页面标题 - $list['set'] = array( - 'webtitle'=>'各班级成绩汇总表下载', - 'butname'=>'下载', - 'formpost'=>'POST', - 'url'=>'/cjtongji/dwBanji', - 'kaoshi'=>$kaoshi - ); - - // 模板赋值 - $this->assign('list',$list); - // 渲染 - return $this->fetch(); - - } - - - // 年级、班级学生成绩统计下载表格 - public function dwBanjixls($kaoshi) - { - // 获取表单参数 - $src = $this->request - ->only([ - 'kaoshi'=>'', - 'nianji'=>'一年级', - 'school'=>array(), - ],'POST'); - - $schools = [$src['school']]; - - - // 统计成绩 - $tj = new TJ; - $data = $tj->tjBanji($src['kaoshi'],$src['nianji'],$schools,array()); - - - // 获取参考学科 - $ks = new \app\kaoshi\model\Kaoshi; - $ksinfo = $ks->where('id',$src['kaoshi']) - ->field('id,title') - ->with([ - 'ksSubject'=>function($query){ - $query->field('kaoshiid,subjectid,manfen') - ->with(['subjectName'=>function($q){ - $q->field('id,title,lieming'); - }] - ); - } - ]) - ->find(); - $xk = $ksinfo->ks_subject; - - - // 获取要下载成绩的学校和年级信息 - $school = new \app\system\model\School; - $schoolname = $school->where('id',$src['school'])->value('jiancheng'); - $tabletitle = $ksinfo->title.' '.$schoolname.' '.$src['nianji'].'各班级成绩汇总'; - - // 创建表格 - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; - $sheet = $spreadsheet->getActiveSheet(); - - $sbjcol = ['xkcnt'=>'人数','avg'=>'平均分','jige'=>'及格率%','youxiu'=>'优秀率%']; - $sbjcolcnt = count($sbjcol); - $colname = excelLieming(); - $colcnt = $sbjcolcnt*count($xk)+3; - - - // 设置表头信息 - $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); - $sheet->setCellValue('A1', $tabletitle); - $sheet->mergeCells('A3:A4'); - $sheet->setCellValue('A3', '序号'); - $sheet->mergeCells('B3:B4'); - $sheet->setCellValue('B3', '班级'); - $col = 2; - foreach ($xk as $key => $value) { - $colend = $col + $sbjcolcnt - 1; - $sheet->mergeCells($colname[$col].'3:'.$colname[$colend].'3'); - $sheet->setCellValue($colname[$col].'3', $value->subject_name->title.' ('.$value->manfen.')'); - foreach ($sbjcol as $k => $val) { - $sheet->setCellValue($colname[$col].'4', $val); - $col++; - } - } - $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); - $sheet->setCellValue($colname[$col].'3', '全科及格率%'); - $col++; - $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); - $sheet->setCellValue($colname[$col].'3', '全科平均'); - - $row = 5; - foreach ($data as $key => $value) { - $col = 2; - $sheet->setCellValue('A'.$row, $row-4); - $sheet->setCellValue('B'.$row, $value['banji']); - foreach ($xk as $ke => $val) { - foreach ($sbjcol as $k => $v) { - $sheet->setCellValue($colname[$col].$row, $value['chengji'][$val->subject_name->lieming][$k]); - $col++; - } - } - $sheet->setCellValue($colname[$col].$row, $value['chengji']['rate']); - $col++; - $sheet->setCellValue($colname[$col].$row, $value['chengji']['avg']); - $row++; - } - - - // 保存文件 - $filename = $tabletitle.date('ymdHis').'.xlsx'; - header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - header('Content-Disposition: attachment;filename="' . $filename . '"'); - header('Cache-Control: max-age=0'); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); - $writer->save('php://output'); - ob_flush(); - flush(); - - } - - - - // 获取各学校、各年级考试成绩 - public function tjNianji($kaoshi) - { - - $ks = new \app\kaoshi\model\Kaoshi; - $ksinfo = $ks->where('id',$kaoshi) - ->with([ - 'KsNianji' - ,'ksSubject'=>function($query){ - $query->field('kaoshiid,subjectid,manfen') - ->with(['subjectName'=>function($q){ - $q->field('id,title,lieming'); - }] - ); - } - ]) - ->field('id,title') - ->find(); - - if(count($ksinfo->ks_nianji)>0) - { - $list['nianji'] = $ksinfo->ks_nianji[0]->nianji; - }else{ - $list['nianji'] = "一年级"; - } - - $list['subject'] = $ksinfo->ks_subject; - // 设置要给模板赋值的信息 - $list['webtitle'] = '各学校的年级成绩统计表'; - $list['kaoshi'] = $kaoshi; - $list['kaoshititle'] = $ksinfo->title; - - - // 模板赋值 - $this->assign('list',$list); - - // 渲染模板 - return $this->fetch(); - } - - - // 获取年级成绩统计结果 - public function ajaxNianji() - { - // 获取参数 - $src = $this->request - ->only([ - 'page'=>'1', - 'limit'=>'10', - 'kaoshi'=>'', - 'nianji'=>'一年级', - ],'POST'); - // 统计成绩 - $tj = new TJ; - $data = $tj->tjNianji($kaoshi=$src['kaoshi'],$nianji=$src['nianji']); - // 获取记录数 - $cnt = count($data); - // 截取当前页数据 - $data = array_slice($data,($src['page']-1)*$src['limit'],$src['limit']); - - // 重组返回内容 - $data = [ - 'code'=> 0 , // ajax请求次数,作为标识符 - 'msg'=>"", // 获取到的结果数(每页显示数量) - 'count'=>$cnt, // 符合条件的总数据量 - 'data'=>$data, //获取到的数据结果 - ]; - - - return json($data); - } - - - - // 年级、班级学生成绩统计结果下载界面 - public function dwNianji($kaoshi) - { - - // 设置页面标题 - $list['set'] = array( - 'webtitle'=>'各年级成绩汇总表下载', - 'butname'=>'下载', - 'formpost'=>'POST', - 'url'=>'/cjtongji/dwNanji', - 'kaoshi'=>$kaoshi - ); - - // 模板赋值 - $this->assign('list',$list); - // 渲染 - return $this->fetch(); - - } - - - // 年级、班级学生成绩统计下载表格 - public function dwNianjixls($kaoshi) - { - - // 获取参数 - $src = $this->request - ->only([ - 'page'=>'1', - 'limit'=>'10', - 'kaoshi'=>'', - 'nianji'=>'一年级', - ],'POST'); - - // 统计成绩 - $tj = new TJ; - $data = $tj->tjNianji($kaoshi=$src['kaoshi'],$nianji=$src['nianji']); - - // 获取参考学科 - $ks = new \app\kaoshi\model\Kaoshi; - $ksinfo = $ks->where('id',$src['kaoshi']) - ->field('id,title') - ->with([ - 'ksSubject'=>function($query){ - $query->field('kaoshiid,subjectid,manfen') - ->with(['subjectName'=>function($q){ - $q->field('id,title,lieming'); - }] - ); - } - ]) - ->find(); - $xk = $ksinfo->ks_subject; - - // 获取要下载成绩的学校和年级信息 - $tabletitle = $ksinfo->title.' '.$src['nianji'].'各学校成绩汇总'; - - - // 创建表格 - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet; - $sheet = $spreadsheet->getActiveSheet(); - - $sbjcol = ['xkcnt'=>'人数','avg'=>'平均分','jige'=>'及格率%','youxiu'=>'优秀率%']; - $sbjcolcnt = count($sbjcol); - $colname = excelLieming(); - $colcnt = $sbjcolcnt*count($xk)+3; - - - // 设置表头信息 - $sheet->mergeCells('A1:'.$colname[$colcnt].'1'); - $sheet->setCellValue('A1', $tabletitle); - $sheet->mergeCells('A3:A4'); - $sheet->setCellValue('A3', '序号'); - $sheet->mergeCells('B3:B4'); - $sheet->setCellValue('B3', '班级'); - $col = 2; - foreach ($xk as $key => $value) { - $colend = $col + $sbjcolcnt - 1; - $sheet->mergeCells($colname[$col].'3:'.$colname[$colend].'3'); - $sheet->setCellValue($colname[$col].'3', $value->subject_name->title.' ('.$value->manfen.')'); - foreach ($sbjcol as $k => $val) { - $sheet->setCellValue($colname[$col].'4', $val); - $col++; - } - } - $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); - $sheet->setCellValue($colname[$col].'3', '全科及格率%'); - $col++; - $sheet->mergeCells($colname[$col].'3:'.$colname[$col].'4'); - $sheet->setCellValue($colname[$col].'3', '总平均分'); - - $row = 5; - foreach ($data as $key => $value) { - $col = 2; - $sheet->setCellValue('A'.$row, $row-4); - $sheet->setCellValue('B'.$row, $value['school']); - foreach ($xk as $ke => $val) { - foreach ($sbjcol as $k => $v) { - $sheet->setCellValue($colname[$col].$row, $value['chengji'][$val->subject_name->lieming][$k]); - $col++; - } - } - $sheet->setCellValue($colname[$col].$row, $value['chengji']['rate']); - $col++; - $sheet->setCellValue($colname[$col].$row, $value['chengji']['avg']); - $row++; - } - - // 保存文件 - $filename = $tabletitle.date('ymdHis').'.xlsx'; - header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - header('Content-Disposition: attachment;filename="' . $filename . '"'); - header('Cache-Control: max-age=0'); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); - $writer->save('php://output'); - ob_flush(); - flush(); - } - // 统计已经录入成绩数量 public function yiluCnt($kaoshi) diff --git a/application/chengji/model/Bjtongji.php b/application/chengji/model/Bjtongji.php new file mode 100644 index 00000000..6942f00f --- /dev/null +++ b/application/chengji/model/Bjtongji.php @@ -0,0 +1,63 @@ +cyBanji($kaoshi=$kaoshi,$ruxuenian=$nianji,$school=$school,$paixu=$paixu); + + $data = array(); + if($bj->isEmpty()){ + return $data; + } + + // 实例化学生成绩统计类 + $tj = new TJ; + + // 获取并统计各班级成绩 + $data = array(); + $bjs = array(); + foreach ($bj as $key => $value) { + $bjs[] = $value->banji; + $banji=[$value->banji]; + $temp = $tj->srcChengji($kaoshi=$kaoshi,$banji=$banji,$nianji=$nianji,$school=array()); + $temp = $tj->tongji($temp,$kaoshi); + $data[] = [ + 'banji'=>$value->cj_banji->banjiTitle, + 'school'=>$value->cj_school->jiancheng, + 'chengji'=>$temp + ]; + + } + + + // 获取年级成绩 + $allcj = $tj->srcChengji($kaoshi=$kaoshi,$banji=$bjs,$nianji=$nianji,$school=array()); + $temp = $tj->tongji($allcj,$kaoshi); + $data[] = [ + 'banji'=>'合计', + 'school'=>'', + 'chengji'=>$temp + ]; + + + return $data; + } +} diff --git a/application/chengji/model/Njtongji.php b/application/chengji/model/Njtongji.php new file mode 100644 index 00000000..3c7fb764 --- /dev/null +++ b/application/chengji/model/Njtongji.php @@ -0,0 +1,55 @@ +cySchool($kaoshi=$kaoshi,$ruxuenian=$nianji); + + $data = array(); + if($school->isEmpty()){ + return $data; + } + + // 实例化学生成绩统计类 + $tj = new TJ; + + // 获取并统计各班级成绩 + $data = array(); + foreach ($school as $key => $value) { + $schools=[$value->cj_school->id]; + $temp = $tj->srcChengji($kaoshi=$kaoshi,$banji=array(),$nianji=$nianji,$schools=$schools); + $temp = $tj->tongji($temp,$kaoshi); + $data[] = [ + 'school'=>$value->cj_school->jiancheng, + 'chengji'=>$temp + ]; + } + + // 获取年级成绩 + $allcj = $tj->srcChengji($kaoshi=$kaoshi,$banji=array(),$nianji=$nianji,$school=array()); + $temp = $tj->tongji($allcj,$kaoshi); + $data[] = [ + 'school'=>'合计', + 'chengji'=>$temp + ]; + return $data; + } +} diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php index cfe84878..32a08fde 100644 --- a/application/chengji/model/Tongji.php +++ b/application/chengji/model/Tongji.php @@ -2,9 +2,10 @@ namespace app\chengji\model; -use think\Model; +// 引用基类 +use app\common\model\Base; -class Tongji extends Model +class Tongji extends Base { /** @@ -229,97 +230,5 @@ class Tongji extends Model return $result; } - - - /** - * 统计各学校的指定个年级的成绩 - * 统计项目参考tongji方法 - * @access public - * @param number $kaoshi 考试id - * @param number $ruxuenian 入学年 - * @return array 返回类型 - */ - public function tjNianji($kaoshi,$nianji) - { - // 查询要统计成绩的学校 - $kh = new \app\kaoshi\model\Kaohao; - $school = $kh->cySchool($kaoshi=$kaoshi,$ruxuenian=$nianji); - - $data = array(); - if($school->isEmpty()){ - return $data; - } - - // 获取并统计各班级成绩 - $data = array(); - foreach ($school as $key => $value) { - $schools=[$value->cj_school->id]; - $temp = $this->srcChengji($kaoshi=$kaoshi,$banji=array(),$nianji=$nianji,$schools=$schools); - $temp = $this->tongji($temp,$kaoshi); - $data[] = [ - 'school'=>$value->cj_school->jiancheng, - 'chengji'=>$temp - ]; - } - - // 获取年级成绩 - $allcj = $this->srcChengji($kaoshi=$kaoshi,$banji=array(),$nianji=$nianji,$school=array()); - $temp = $this->tongji($allcj,$kaoshi); - $data[] = [ - 'school'=>'合计', - 'chengji'=>$temp - ]; - return $data; - } - - - /** - * 统计指定个年级的各班级成绩 - * 统计项目参考tongji方法 - * @access public - * @param number $kaoshi 考试id - * @param number $ruxuenian 入学年 - * @return array 返回类型 - */ - public function tjBanji($kaoshi,$nianji,$school=array(),$paixu=array()) - { - // 查询要统计成绩的班级 - $kh = new \app\kaoshi\model\Kaohao; - $bj = $kh->cyBanji($kaoshi=$kaoshi,$ruxuenian=$nianji,$school=$school,$paixu=$paixu); - - $data = array(); - if($bj->isEmpty()){ - return $data; - } - - // 获取并统计各班级成绩 - $data = array(); - $bjs = array(); - foreach ($bj as $key => $value) { - $bjs[] = $value->banji; - $banji=[$value->banji]; - $temp = $this->srcChengji($kaoshi=$kaoshi,$banji=$banji,$nianji=$nianji,$school=array()); - $temp = $this->tongji($temp,$kaoshi); - $data[] = [ - 'banji'=>$value->cj_banji->banjiTitle, - 'school'=>$value->cj_school->jiancheng, - 'chengji'=>$temp - ]; - - } - - - // 获取年级成绩 - $allcj = $this->srcChengji($kaoshi=$kaoshi,$banji=$bjs,$nianji=$nianji,$school=array()); - $temp = $this->tongji($allcj,$kaoshi); - $data[] = [ - 'banji'=>'合计', - 'school'=>'', - 'chengji'=>$temp - ]; - - - return $data; - } - + } diff --git a/application/chengji/view/tongji/tj_banji.html b/application/chengji/view/bjtongji/biaoge.html similarity index 97% rename from application/chengji/view/tongji/tj_banji.html rename to application/chengji/view/bjtongji/biaoge.html index 5b693304..4421b988 100644 --- a/application/chengji/view/tongji/tj_banji.html +++ b/application/chengji/view/bjtongji/biaoge.html @@ -66,9 +66,6 @@ - @@ -149,7 +146,7 @@ cjgl.add('添加单位','/school/create','650','500'); break; case 'download': - cjgl.add('下载成绩','/cjtongji/{$list.kaoshi}/dwBanji','650','300'); + cjgl.add('下载成绩','/bjtongji/{$list.kaoshi}/dwBanji','650','300'); break; }; }); diff --git a/application/chengji/view/tongji/dw_banji.html b/application/chengji/view/bjtongji/dw_banji.html similarity index 100% rename from application/chengji/view/tongji/dw_banji.html rename to application/chengji/view/bjtongji/dw_banji.html diff --git a/application/chengji/view/tongji/tj_nianji.html b/application/chengji/view/njtongji/biaoge.html similarity index 96% rename from application/chengji/view/tongji/tj_nianji.html rename to application/chengji/view/njtongji/biaoge.html index 2baf5aed..bcb5612a 100644 --- a/application/chengji/view/tongji/tj_nianji.html +++ b/application/chengji/view/njtongji/biaoge.html @@ -41,9 +41,6 @@ - @@ -123,7 +120,7 @@ cjgl.add('添加单位','/school/create','650','500'); break; case 'download': - cjgl.add('下载成绩','/cjtongji/{$list.kaoshi}/dwNianji','650','300'); + cjgl.add('下载成绩','/njtongji/{$list.kaoshi}/dwNianji','650','300'); break; }; }); diff --git a/application/chengji/view/tongji/dw_nianji.html b/application/chengji/view/njtongji/dw_nianji.html similarity index 100% rename from application/chengji/view/tongji/dw_nianji.html rename to application/chengji/view/njtongji/dw_nianji.html diff --git a/application/kaoshi/view/index/more_action.html b/application/kaoshi/view/index/more_action.html index cf5dd63b..c06f0140 100644 --- a/application/kaoshi/view/index/more_action.html +++ b/application/kaoshi/view/index/more_action.html @@ -98,7 +98,7 @@
- +
各年级的班级成绩统计表
@@ -111,7 +111,7 @@
- +
各学校的年级成绩统计表
diff --git a/config/database.php b/config/database.php index b558421f..1cba7d7a 100644 --- a/config/database.php +++ b/config/database.php @@ -17,9 +17,9 @@ return [ // 数据库名 'database' => 'chengji', // 用户名 - 'username' => 'root', + 'username' => 'jkp', // 密码 - 'password' => '', + 'password' => '123456', // 端口 'hostport' => '', // 连接dsn diff --git a/public/.htaccess b/public/.htaccess index cbc78689..d9ee23c9 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -4,5 +4,5 @@ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] + RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] diff --git a/route/chengji.php b/route/chengji.php index ed01e263..7e14c44b 100644 --- a/route/chengji.php +++ b/route/chengji.php @@ -20,31 +20,43 @@ Route::post('chengji/read','chengji/Index/read'); // 表格录入成绩 Route::get('chengji/biaolu','chengji/Index/biaolu'); Route::post('chengji/biaolu','chengji/Index/saveAll'); +// 已录成绩统计 +Route::get('cjtongji/:kaoshi/yilucnt','chengji/Tongji/yiluCnt'); # 年级成绩统计列表 + + // 获取学生成绩列表 Route::get('chengji/:kaoshi/stuChengjilist','chengji/Index/index'); // Route::delete('chengji/:kaoshi/cj','chengji/Index/delete'); # 删除考试成绩 Route::get('readcjadd/:kaohao','chengji/Index/readAdd'); # 查看录入成绩人信息 - -// 成绩统计表 -Route::get('cjtongji/:kaoshi/banji','chengji/Tongji/tjBanji'); # 班级成绩统计列表 -Route::get('cjtongji/:kaoshi/nianji','chengji/Tongji/tjNianji'); # 年级成绩统计列表 -Route::get('cjtongji/:kaoshi/yilucnt','chengji/Tongji/yiluCnt'); # 年级成绩统计列表 - // 下载学生成绩 Route::get('chengji/:kaoshi/dwChengji','chengji/Index/dwChengji'); Route::post('chengji/dwChengji','chengji/Index/dwchengjixls'); - // 批量删除学生成绩 Route::get('deletecjs/:kaoshi','chengji/Index/deletecjs'); Route::post('deletecjmore','chengji/Index/deletecjmore'); + + + +// 班级成绩统计表格 +Route::get('bjtongji/:kaoshi/biaoge','chengji/Bjtongji/Biaoge'); # 班级成绩统计列表 +// 下载班级成绩统计表格 +Route::get('bjtongji/:kaoshi/dwBanji','chengji/Bjtongji/dwBanji'); +Route::post('bjtongji/dwBanji','chengji/Bjtongji/dwBanjixls'); + + + +// 年级成绩统计表格 +Route::get('njtongji/:kaoshi/biaoge','chengji/Njtongji/Biaoge'); # 年级成绩统计列表 +// 下载年级成绩统计表格 +Route::get('njtongji/:kaoshi/dwNianji','chengji/Njtongji/dwNianji'); +Route::post('njtongji/dwNanji','chengji/Njtongji/dwNianjixls'); + + + -// 下载班级成绩统计表 -Route::get('cjtongji/:kaoshi/dwBanji','chengji/Tongji/dwBanji'); -Route::post('cjtongji/dwBanji','chengji/Tongji/dwBanjixls'); - -// 下载年级成绩统计表 -Route::get('cjtongji/:kaoshi/dwNianji','chengji/Tongji/dwNianji'); -Route::post('cjtongji/dwNanji','chengji/Tongji/dwNianjixls'); + + +