From cc1e2961c602a1df60b636c000062c87ddb2d42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=E5=93=A5?= Date: Thu, 14 Oct 2021 14:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=87=E5=87=86=E5=88=86?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E5=92=8C=E4=B8=80=E9=94=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/controller/Tongji.php | 41 ++++++++++++ app/chengji/model/Chengji.php | 3 +- app/chengji/model/Tongji.php | 64 ++++++++++++++++++- app/chengji/route/chengji.php | 3 +- app/kaoshi/controller/Index.php | 5 ++ app/kaoshi/view/index/tongji.html | 49 ++++++++++++-- app/login/view/index/shangma_log.html | 2 + app/tools/model/OneStudentChengji.php | 13 ++-- .../migrations/20190430034853_chengji.php | 3 +- 9 files changed, 162 insertions(+), 21 deletions(-) diff --git a/app/chengji/controller/Tongji.php b/app/chengji/controller/Tongji.php index 48972dd1..75948554 100755 --- a/app/chengji/controller/Tongji.php +++ b/app/chengji/controller/Tongji.php @@ -67,4 +67,45 @@ class Tongji extends AdminBase // 渲染模板 return $this->view->fetch(); } + + + // 统计标准分 + public function biaoZhunFen() + { + // 获取参数 + $src = $this->request + ->only([ + 'kaoshi_id' => 0 + ,'ruxuenian' + ,'subject_id' + ], 'POST'); + + $tj = new TJ(); + if(isset($src['ruxuenian']) && isset($src['subject_id'])) + { + $data = $tj->biaoZhunFen($src); + }else{ + $ksset = new \app\kaoshi\model\KaoshiSet; + + // 重新计算得分率 + $nj = $ksset->srcGrade($src); # 获取参考年级 + $jg = 1; + foreach ($nj as $key => $value) { # 循环获取各年级参考学科 + $src['ruxuenian'] = $value['ruxuenian']; + $manfen = $ksset->srcSubject($src); # 获取本年级各学科满分 + // 循环取出当前学科成绩 + foreach ($manfen as $mf_k => $mf_v) { + $src['subject_id'] = $mf_v['id']; + $data = $tj->biaoZhunFen($src); + $jg = $jg * $data; + } + } + } + + $data ? $data = ['msg' => '完成', 'val' => 1] + : $data = ['msg' => '数据处理错误', 'val' => 0]; + + // 返回信息 + return json($data); + } } diff --git a/app/chengji/model/Chengji.php b/app/chengji/model/Chengji.php index 54675502..5a5cd689 100755 --- a/app/chengji/model/Chengji.php +++ b/app/chengji/model/Chengji.php @@ -22,7 +22,8 @@ class Chengji extends BaseModel ,'xpaixu' => 'int' ,'xweizhi' => 'decimal' ,'qpaixu' => 'int' - ,'qweizhi' =>' decimal' + ,'qweizhi' => 'decimal' + ,'biaozhunfen' => 'decimal' ,'create_time' =>'int' ,'update_time' => 'int' ,'delete_time' => 'int' diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index 861643a7..483c946e 100755 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -101,7 +101,6 @@ class Tongji extends BaseModel $temp['defenlv'] = round($temp['defenlv'] * 100, 2); $temp['canshilv'] = round($temp['chengji_cnt'] / $temp['stu_cnt'] * 100, 2); $temp['chashenglv'] = round(($temp['chengji_cnt'] - $temp['jige']) / $temp['chengji_cnt'] * 100, 2); - } $data['cj'][$value['lieming']] = $temp; } @@ -417,5 +416,68 @@ class Tongji extends BaseModel } + // 计算标准分 + public function biaoZhunFen($srcfrom) + { + $src = [ + 'kaoshi_id' => 0 + ,'ruxuenian' => 0 + ,'subject_id' => 0 + ]; + // 用新值替换初始值 + $src = array_cover($srcfrom, $src); + // $src = + $cj = new \app\chengji\model\Chengji; + $kh = new \app\kaohao\model\Kaohao; + $ksset = new \app\kaoshi\model\KaoshiSet; + $schTj = new \app\chengji\model\TongjiSch; + + // 查询考号 + $kaohaoid = $kh->where('kaoshi_id', $src['kaoshi_id']) + ->where('ruxuenian', $src['ruxuenian']) + ->column('id'); + // 查询成绩 + $cjList = $cj->where('kaohao_id', 'in', $kaohaoid) + ->where('subject_id', $src['subject_id']) + ->whereNotNull('defen') + ->field('id, defen, defenlv') + ->select(); + // 查询全区(所有学生)标准差和平均分 + $schJg = $schTj->where('kaoshi_id', $src['kaoshi_id']) + ->where('ruxuenian', $src['ruxuenian']) + ->where('subject_id', $src['subject_id']) + ->whereNotNull('avg&biaozhuncha') + ->field('avg, biaozhuncha') + ->find(); + + $data = array(); + if ($schJg) { + // $cha = $schJg->avg * 1 / $schJg->biaozhuncha * 1; # 平均分/标准分 + // $cha = round($cha, 2); + + // 循环写入新成绩 + foreach ($cjList as $cj_k => $cj_v) { + $bzf = ($cj_v->defen - $schJg->avg * 1) / ($schJg->biaozhuncha * 1); #计算标准分 + $bzf = round($bzf, 2); # 取两位小数 + $data[] = [ + 'id' => $cj_v->id + ,'biaozhunfen' => $bzf + ]; + } + } + + $cnt = count($data); + $data = $cj->saveAll($data)->count(); + if($cnt == $data) + { + $data = 1; + }else{ + $data = 0; + } + + return $data; + } + + } diff --git a/app/chengji/route/chengji.php b/app/chengji/route/chengji.php index d57ab380..fa068357 100755 --- a/app/chengji/route/chengji.php +++ b/app/chengji/route/chengji.php @@ -32,7 +32,8 @@ Route::group('index', function () { Route::group('tongji', function () { // Route::rule('editdfl/','Tongji/editDefenLv','get'); # 扫码界面 - Route::rule('editdfl','Tongji/updateDefenLv','post'); # 扫码界面 + Route::rule('editdfl','Tongji/updateDefenLv','post'); # 重新计算得分率 + Route::rule('biaozhunfen','Tongji/biaoZhunFen','post'); # 计算标准分 }); diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index 6d07c3d1..0ec5ff7d 100755 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -196,6 +196,11 @@ class Index extends AdminBase ,'url' => '/chengji/schtj/tongji' ,'checked' => ' checked' ] + ,[ + 'title' => '统计标准分' + ,'url' => '/chengji/tongji/biaozhunfen' + ,'checked' => ' checked' + ] ,[ 'title' => '重算得分率' ,'url' => '/chengji/tongji/editdfl' diff --git a/app/kaoshi/view/index/tongji.html b/app/kaoshi/view/index/tongji.html index be89998e..bc3aa461 100644 --- a/app/kaoshi/view/index/tongji.html +++ b/app/kaoshi/view/index/tongji.html @@ -44,14 +44,50 @@ function checkAll() { var inputs; inputs = $(":checked"); - inputs.each(function() { - var obj; - obj = $(this).parents("tr").children().last().find("a"); - tongji(obj); - }); + tongjiAll(inputs); return false; } +function tongjiAll(inputs, xiabiao=0) { + cnt = inputs.length - 1; + obj = inputs[xiabiao]; + obj = $(obj).parents("tr").children().last().find("a"); + var data; + data = { + 'kaoshi_id': "{$list.set.kaoshi_id}" + } + var url; + url = obj.attr('url'); + var val; + val = $(obj).attr('val'); + + // 到服务器去删除数据。 + $.ajax({ + url: url, + type: 'POST', + async: true, + data: data, + beforeSend: function() { + $('#showtd' + val).text('正在统计'); + $('#showtd' + val).append(""); + }, + complete: function() { + $('#showtd' + val).children("i").remove(); + }, + success: function(result) { + $('#showtd' + val).text(result.msg); + + if(xiabiao >= 0 && xiabiao < cnt) + { + tongjiAll(inputs, xiabiao + 1); + } + }, + error: function(result) { + $('#showtd' + val).text(result.msg); + }, + }); +} + function tongji(obj) { var data; data = { @@ -81,10 +117,9 @@ function tongji(obj) { error: function(result) { $('#showtd' + val).text(result.msg); }, - }); - } + {/block} \ No newline at end of file diff --git a/app/login/view/index/shangma_log.html b/app/login/view/index/shangma_log.html index ebf7a92b..cc88d3f5 100755 --- a/app/login/view/index/shangma_log.html +++ b/app/login/view/index/shangma_log.html @@ -50,6 +50,8 @@

V1.3.9 Beta 2021-7-25

升级框架ThinkPHP V6.0.9
+ 修改一键统计、增加标准分计算
+ 修改数据查询条件,增加模型对应数据表字段及类型

diff --git a/app/tools/model/OneStudentChengji.php b/app/tools/model/OneStudentChengji.php index 909daca8..102bfb10 100755 --- a/app/tools/model/OneStudentChengji.php +++ b/app/tools/model/OneStudentChengji.php @@ -209,11 +209,6 @@ class OneStudentChengji extends BaseModel ->find(); $stuCj = $khInfo->ksChengji; # 拿出学生成绩 - // dump($khInfo->toArray()); - - // 参加考试学科 - // $sbj = new \app\teach\model\Subject; - // $subject = subjectKaoshiList(); // 获取参加考试学科满分 $src['kaoshi_id'] = $khInfo->kaoshi_id; $src['ruxuenian'] = $khInfo->ruxuenian; @@ -337,8 +332,8 @@ class OneStudentChengji extends BaseModel $src['banji_id'] = $khInfo->banji_id; $src['auth']['check'] = false; $data = $cj->search($src); - $data = sortArrByManyField($data, 'sum', SORT_DESC); - $data = array_column($data, 'sum', 'id'); + $data =array_column($data, 'sum', 'id'); + asort($data); $rank = \app\facade\Tools::paiwei($data, $src['kaohao_id']); $paixu['ban']['paixu'] = $rank['rank']; $paixu['ban']['weizhi'] = $rank['weizhi']; @@ -346,8 +341,8 @@ class OneStudentChengji extends BaseModel $cy = new \app\kaohao\model\SearchCanYu; $src['banji_id'] = array_column($cy->class($src), 'id'); $data = $cj->search($src); - $data = sortArrByManyField($data, 'sum', SORT_DESC); $data = array_column($data, 'sum', 'id'); + asort($data); $rank = \app\facade\Tools::paiwei($data, $src['kaohao_id']); $paixu['qu']['paixu'] = $rank['rank']; $paixu['qu']['weizhi'] = $rank['weizhi']; @@ -355,8 +350,8 @@ class OneStudentChengji extends BaseModel $src['school_id'] = $khInfo->school_id; $src['banji_id'] = array_column($cy->class($src), 'id'); $data = $cj->search($src); - $data = sortArrByManyField($data, 'sum', SORT_DESC); $data = array_column($data, 'sum', 'id'); + asort($data); $rank = \app\facade\Tools::paiwei($data, $src['kaohao_id']); $paixu['xiao']['paixu'] = $rank['rank']; $paixu['xiao']['weizhi'] = $rank['weizhi']; diff --git a/database/migrations/20190430034853_chengji.php b/database/migrations/20190430034853_chengji.php index beda0c20..8ebb02c9 100755 --- a/database/migrations/20190430034853_chengji.php +++ b/database/migrations/20190430034853_chengji.php @@ -47,8 +47,7 @@ class Chengji extends Migrator // 区排序和位置 ->addColumn('qpaixu','integer',['limit'=>4,'null'=>true,'comment'=>'区排序']) ->addColumn('qweizhi','decimal',['precision'=>6,'scale'=>2,'null'=>true,'comment'=>'区位置']) - - + ->addColumn('biaozhunfen','decimal',['precision'=>6,'scale'=>2,'default'=>Null,'null'=>false,'comment'=>'标准分']) ->addColumn('create_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'default'=>'1539158918','null'=>false,'comment'=>'更新时间']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间'])