From 2254f4e2b6c4811ef4fb4511892ac8211b28a7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Wed, 16 Dec 2020 21:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=98=E7=A7=80=E7=8E=87?= =?UTF-8?q?=E3=80=81=E5=8F=8A=E6=A0=BC=E7=8E=87=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/controller/Bjtongji.php | 6 +-- app/chengji/controller/Index.php | 26 ++++++++++-- app/chengji/controller/Njtongji.php | 6 +-- app/chengji/model/Tongji.php | 16 ++++---- app/chengji/model/TongjiBj.php | 37 +++++++++++++++-- app/chengji/model/TongjiNj.php | 40 ++++++++++++++++--- app/chengji/model/TongjiSch.php | 39 ++++++++++++++++-- app/chengji/view/bjtongji/biaoge.html | 8 ++-- app/chengji/view/njtongji/biaoge.html | 4 +- app/chengji/view/schtongji/biaoge.html | 4 +- .../view/index/index.html | 2 +- app/teach/model/Xueqi.php | 4 +- .../view/index/index.html | 4 +- .../migrations/20200106012240_tongji_nj.php | 4 +- .../migrations/20200106013922_tongji_bj.php | 4 +- .../migrations/20200107045207_tongji_sch.php | 4 +- database/seeds/Rule.php | 6 +-- 17 files changed, 160 insertions(+), 54 deletions(-) diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index f83167d8..33727a75 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -176,8 +176,8 @@ class Bjtongji extends AdminBase $sbjcol = [ 'cjCnt' => '人数' ,'avg' => '平均分' - ,'jige' => '及格率%' - ,'youxiu' => '优秀率%' + ,'jigelv' => '及格率%' + ,'youxiulv' => '优秀率%' ]; $sbjcolcnt = count($sbjcol); $colname = excelColumnName(); @@ -228,7 +228,7 @@ class Bjtongji extends AdminBase $col++; } } - $sheet->setCellValue($colname[$col].$row, $value['quanke']['jige']); + $sheet->setCellValue($colname[$col].$row, $value['quanke']['jigelv']); $col++; $sheet->setCellValue($colname[$col].$row, $value['quanke']['avg']); $row++; diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php index 39e55293..0aabdc47 100644 --- a/app/chengji/controller/Index.php +++ b/app/chengji/controller/Index.php @@ -366,10 +366,20 @@ class Index extends AdminBase $colBiankuang = $colcnt; // 循环写出统计结果 foreach ($subject_id as $key => $value) { + $xkcnt = $temp['cj'][$value['lieming']]['xkcnt']; + if ($xkcnt > 0 ) { + $youxiulv = round($temp['cj'][$value['lieming']]['youxiu'] / $xkcnt * 100, 2); + $jigelv = round($temp['cj'][$value['lieming']]['jige'] / $xkcnt * 100, 2); + } else { + $youxiulv = 0; + $jigelv = 0; + } + $sheet->setCellValue($colname[$colcnt] . '4', $temp['cj'][$value['lieming']]['xkcnt']); $sheet->setCellValue($colname[$colcnt] . '5', $temp['cj'][$value['lieming']]['avg']); - $sheet->setCellValue($colname[$colcnt] . '6', $temp['cj'][$value['lieming']]['youxiu']); - $sheet->setCellValue($colname[$colcnt] . '7', $temp['cj'][$value['lieming']]['jige']); + + $sheet->setCellValue($colname[$colcnt] . '6', $youxiulv); + $sheet->setCellValue($colname[$colcnt] . '7', $jigelv); $sheet->setCellValue($colname[$colcnt] . '8', $temp['cj'][$value['lieming']]['biaozhuncha']); $sheet->setCellValue($colname[$colcnt] . '9', $temp['cj'][$value['lieming']]['zhongweishu']); $sheet->setCellValue($colname[$colcnt] . '10', $temp['cj'][$value['lieming']]['zhongshu']); @@ -555,11 +565,19 @@ class Index extends AdminBase // 写入成绩 foreach ($subject_id as $k => $val) { + $xkcnt = $njtj['cj'][$val['lieming']]['xkcnt']; + if ($xkcnt > 0 ) { + $youxiulv = round($njtj['cj'][$val['lieming']]['youxiu'] / $xkcnt * 100, 2); + $jigelv = round($njtj['cj'][$val['lieming']]['jige'] / $xkcnt * 100, 2); + } else { + $youxiulv = 0; + $jigelv = 0; + } $sheet->setCellValue('D' . ($row + $k), $val['title']); $sheet->setCellValue('E' . ($row + $k), $value[$val['lieming']]); # 得分 $sheet->setCellValue('F' . ($row + $k), $njtj['cj'][$val['lieming']]['avg']); - $sheet->setCellValue('G' . ($row + $k), $njtj['cj'][$val['lieming']]['youxiu']); - $sheet->setCellValue('H' . ($row + $k), $njtj['cj'][$val['lieming']]['jige']); + $sheet->setCellValue('G' . ($row + $k), $youxiulv); + $sheet->setCellValue('H' . ($row + $k), $jigelv); $sheet->setCellValue('I' . ($row + $k), $njtj['cj'][$val['lieming']]['max']); $sheet->setCellValue('J' . ($row + $k), $njtj['cj'][$val['lieming']]['sifenwei'][0]); $sheet->setCellValue('K' . ($row + $k), $njtj['cj'][$val['lieming']]['sifenwei'][1]); diff --git a/app/chengji/controller/Njtongji.php b/app/chengji/controller/Njtongji.php index 9c81f332..99c798b8 100644 --- a/app/chengji/controller/Njtongji.php +++ b/app/chengji/controller/Njtongji.php @@ -151,8 +151,8 @@ class Njtongji extends AdminBase $sbjcol = [ 'cjCnt' => '人数' ,'avg' => '平均分' - ,'jige' => '及格率%' - ,'youxiu' => '优秀率%' + ,'jigelv' => '及格率%' + ,'youxiulv' => '优秀率%' ]; $sbjcolcnt = count($sbjcol); $colname = excelColumnName(); @@ -196,7 +196,7 @@ class Njtongji extends AdminBase $col ++; } } - $sheet->setCellValue($colname[$col] . $row, $value['quanke']['jige']); + $sheet->setCellValue($colname[$col] . $row, $value['quanke']['jigelv']); $col ++; $sheet->setCellValue($colname[$col] . $row, $value['quanke']['avg']); $row ++; diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index 43dd2196..6dcbdad4 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -120,7 +120,7 @@ class Tongji extends BaseModel } - // 统计优秀、及格率 + // 统计优秀、及格率人数 public function rate($cj = array(), $fenshuxian) { $cnt = 0; @@ -129,11 +129,7 @@ class Tongji extends BaseModel $cnt ++; } } - if (count($cj) > 0) { - return round($cnt / count($cj) * 100, 2); - } else { - return '0'; - } + return $cnt; } @@ -163,8 +159,8 @@ class Tongji extends BaseModel $temjige == $sbjcnt && $temjige > 0 ? $jige ++ : $jige ; } - $row > 0 ? $rate = round($jige / count($cj) * 100, 2) : $rate = ''; - return $rate; + // $row > 0 ? $rate = round($jige / count($cj) * 100, 2) : $rate = ''; + return $jige; } @@ -248,7 +244,9 @@ class Tongji extends BaseModel $cnt = count($arr); if ($cnt === 1) { $zws = $arr[0]; - }elseif ($cnt > 1) { + } elseif ($cnt == 2) { + $zws = ($arr[0] + $arr[1]) / 2; + } elseif ($cnt > 2) { $mod = $cnt % 2; if ($mod === 0) { $i = $cnt / 2; diff --git a/app/chengji/model/TongjiBj.php b/app/chengji/model/TongjiBj.php index 858752f6..0167b8bf 100644 --- a/app/chengji/model/TongjiBj.php +++ b/app/chengji/model/TongjiBj.php @@ -235,8 +235,8 @@ class TongjiBj extends BaseModel if($val->subject_id > 0){ $data[$value->banji_id]['chengji'][$val->bjSubject->lieming] = [ 'avg' => $val->avg * 1 - ,'youxiu' => $val->youxiu * 1 - ,'jige' => $val->jige * 1 + ,'youxiulv' => $val->youxiulv + ,'jigelv' => $val->jigelv ,'cjCnt' => $val->chengji_cnt ,'title' => $val->bjSubject->title ,'jiancheng' => $val->bjSubject->jiancheng @@ -252,7 +252,7 @@ class TongjiBj extends BaseModel }else{ $data[$value->banji_id]['quanke'] = [ 'avg' => $val->avg - ,'jige' => $val->jige + ,'jigelv' => $val->jigelv ]; } } @@ -626,7 +626,8 @@ class TongjiBj extends BaseModel { $ksid = $this->getAttr('kaoshi_id'); return $this->hasMany('\app\chengji\model\TongjiBj', 'banji_id', 'banji_id') - ->where('kaoshi_id', $ksid); + ->where('kaoshi_id', $ksid) + ->append(['youxiulv', 'jigelv']); } @@ -679,4 +680,32 @@ class TongjiBj extends BaseModel return $title; } + + + // 获取优秀率 + public function getYouxiulvAttr() + { + $youxiu = 0; + $ycnt = $this->youxiu; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $youxiu = round($ycnt / $cjcnt * 100, 2); + } + + return $youxiu; + } + + + // 获取优秀率 + public function getJigelvAttr() + { + $jige = 0; + $jcnt = $this->jige; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $jige = round($jcnt / $cjcnt * 100, 2); + } + + return $jige; + } } diff --git a/app/chengji/model/TongjiNj.php b/app/chengji/model/TongjiNj.php index 7df2cc24..6915ae04 100644 --- a/app/chengji/model/TongjiNj.php +++ b/app/chengji/model/TongjiNj.php @@ -168,8 +168,8 @@ class TongjiNj extends BaseModel if($val->subject_id > 0){ $data[$value->school_id]['chengji'][$val->njSubject->lieming] = [ 'avg' => $val->avg * 1 - ,'youxiu' => $val->youxiu * 1 - ,'jige' => $val->jige * 1 + ,'youxiulv' => $val->youxiulv + ,'jigelv' => $val->jigelv ,'cjCnt' => $val->chengji_cnt ,'title' => $val->njSubject->title ,'jiancheng' => $val->njSubject->jiancheng @@ -185,7 +185,7 @@ class TongjiNj extends BaseModel }else{ $data[$value->school_id]['quanke'] = [ 'avg' => $val->avg - ,'jige' => $val->jige + ,'jigelv' => $val->jigelv ]; } @@ -264,9 +264,39 @@ class TongjiNj extends BaseModel { $ruxuenian = $this->getAttr('ruxuenian'); $kaoshi = $this->getAttr('kaoshi_id'); - return $this->hasMany('\app\chengji\model\TongjiNj', 'school_id', 'school_id') + $data = $this->hasMany('\app\chengji\model\TongjiNj', 'school_id', 'school_id') ->where('ruxuenian', $ruxuenian) - ->where('kaoshi_id', $kaoshi); + ->where('kaoshi_id', $kaoshi) + ->append(['youxiulv', 'jigelv']); + return $data; + } + + + // 获取优秀率 + public function getYouxiulvAttr() + { + $youxiu = 0; + $ycnt = $this->youxiu; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $youxiu = round($ycnt / $cjcnt * 100, 2); + } + + return $youxiu; + } + + + // 获取优秀率 + public function getJigelvAttr() + { + $jige = 0; + $jcnt = $this->jige; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $jige = round($jcnt / $cjcnt * 100, 2); + } + + return $jige; } } diff --git a/app/chengji/model/TongjiSch.php b/app/chengji/model/TongjiSch.php index 8adcb5b7..49887a3f 100644 --- a/app/chengji/model/TongjiSch.php +++ b/app/chengji/model/TongjiSch.php @@ -132,14 +132,14 @@ class TongjiSch extends BaseModel if ($val->subject_id > 0) { $data['all']['chengji'][$val->schSubject->lieming] = [ 'avg' => $val->avg - ,'youxiu' => $val->youxiu - ,'jige' => $val->jige + ,'youxiulv' => $val->youxiulv + ,'jigelv' => $val->jigelv ,'cjCnt' => $val->chengji_cnt ]; }else{ $data['all']['quanke'] = [ 'avg' => $val->avg - ,'jige' => $val->jige + ,'jigelv' => $val->jigelv ]; } } @@ -198,6 +198,37 @@ class TongjiSch extends BaseModel // 成绩统计结果关联 public function schJieguo() { - return $this->hasMany('\app\chengji\model\TongjiSch', 'ruxuenian', 'ruxuenian'); + $data = $this->hasMany('\app\chengji\model\TongjiSch', 'ruxuenian', 'ruxuenian') + ->append(['youxiulv', 'jigelv']); + return $data; } + + + // 获取优秀率 + public function getYouxiulvAttr() + { + $youxiu = 0; + $ycnt = $this->youxiu; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $youxiu = round($ycnt / $cjcnt * 100, 2); + } + + return $youxiu; + } + + + // 获取优秀率 + public function getJigelvAttr() + { + $jige = 0; + $jcnt = $this->jige; + $cjcnt = $this->chengji_cnt; + if ($cjcnt > 0) { + $jige = round($jcnt / $cjcnt * 100, 2); + } + + return $jige; + } + } diff --git a/app/chengji/view/bjtongji/biaoge.html b/app/chengji/view/bjtongji/biaoge.html index b4b0d041..608258c8 100644 --- a/app/chengji/view/bjtongji/biaoge.html +++ b/app/chengji/view/bjtongji/biaoge.html @@ -82,7 +82,7 @@ // 获取学科 var xk = ''; xk = eval(decodeURIComponent(xk)); - var xiangmu = {cjCnt:'人数',avg:'平均分',jige:'及格率%',youxiu:'优秀率%'}; // 要显示哪些统计结果 + var xiangmu = {cjCnt:'人数',avg:'平均分',jigelv:'及格率%',youxiulv:'优秀率%'}; // 要显示哪些统计结果 $.each(xk,function(index,value){ options.cols[0].push({title: xk[index].title+'('+xk[index].fenshuxian.manfen+')',colspan:4,align:'center'}); @@ -107,7 +107,7 @@ }); }); options.cols[0].push({title: '全科及格率%',minWidth:100,rowspan:2,templet:function(d){ - var str = d.quanke.jige; + var str = d.quanke.jigelv; return str; }}); options.cols[0].push({ title: '总平均分',minWidth:100,rowspan:2,templet:function(d){ @@ -224,7 +224,7 @@ var id = 'myJige'; var url = '/chengji/bjtj/myavg'; var val = form.val('search'); - val.xiangmu = 'jige'; + val.xiangmu = 'jigelv'; var title = '及格率'; createTiaoxing(id, url, val, title); } @@ -234,7 +234,7 @@ var id = 'myYouxiu'; var url = '/chengji/bjtj/myavg'; var val = form.val('search'); - val.xiangmu = 'youxiu'; + val.xiangmu = 'youxiulv'; var title = '优秀率'; createTiaoxing(id, url, val, title); } diff --git a/app/chengji/view/njtongji/biaoge.html b/app/chengji/view/njtongji/biaoge.html index 0403ea9a..134ffb90 100644 --- a/app/chengji/view/njtongji/biaoge.html +++ b/app/chengji/view/njtongji/biaoge.html @@ -65,7 +65,7 @@ // 获取学科 var xk = ''; xk = eval(decodeURIComponent(xk)); - var xiangmu = {cjCnt:'参考人数',avg:'平均分',jige:'及格率%',youxiu:'优秀率%'}; // 要显示哪些统计结果 + var xiangmu = {cjCnt:'参考人数',avg:'平均分',jigelv:'及格率%',youxiulv:'优秀率%'}; // 要显示哪些统计结果 $.each(xk,function(index,value){ options.cols[0].push({title: xk[index].title+'('+xk[index].fenshuxian.manfen+')',colspan:4,align:'center'}); @@ -92,7 +92,7 @@ }); }); options.cols[0].push({title: '全科及格率%',minWidth:120,rowspan:2,templet:function(d){ - var str = d.quanke.jige; + var str = d.quanke.jigelv; return str; }}); options.cols[0].push({ title: '总平均分',minWidth:100,rowspan:2,templet:function(d){ diff --git a/app/chengji/view/schtongji/biaoge.html b/app/chengji/view/schtongji/biaoge.html index d2c82001..c94ba737 100644 --- a/app/chengji/view/schtongji/biaoge.html +++ b/app/chengji/view/schtongji/biaoge.html @@ -56,7 +56,7 @@ // 获取学科 var xk = ''; xk = eval(decodeURIComponent(xk)); - var xiangmu = {cj_cnt:'参考人数',avg:'平均分',jige:'及格率%',youxiu:'优秀率%'}; // 要显示哪些统计结果 + var xiangmu = {cj_cnt:'参考人数',avg:'平均分',jigelv:'及格率%',youxiulv:'优秀率%'}; // 要显示哪些统计结果 $.each(xk,function(index,value){ options.cols[0].push({title: xk[index].subjectName.title+'('+xk[index].manfen+')',colspan:4,align:'center'}); @@ -80,7 +80,7 @@ }); }); options.cols[0].push({title: '全科及格率%',minWidth:120,rowspan:2,templet:function(d){ - var str = d.quanke.jige; + var str = d.quanke.jigelv; return str; }}); options.cols[0].push({ title: '总平均分',minWidth:100,rowspan:2,templet:function(d){ diff --git a/app/studentSearchChengji/view/index/index.html b/app/studentSearchChengji/view/index/index.html index fb92c27d..5bd41d2e 100644 --- a/app/studentSearchChengji/view/index/index.html +++ b/app/studentSearchChengji/view/index/index.html @@ -44,7 +44,7 @@
+ {$list['webtitle']}