diff --git a/app/chengji/common.php b/app/chengji/common.php index efe12f6e..1af12857 100644 --- a/app/chengji/common.php +++ b/app/chengji/common.php @@ -1,14 +1,9 @@ where('id',$kaohaoid)->value('kaoshi'); - - // 根据考试号和学科名获取满分 $KSXK = new app\kaoshi\model\KaoshiSubject; $manfen = $KSXK->where('kaoshiid',$kaoshiid)->where('subjectid',$subjectid)->value('manfen'); diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php index 9719e290..bf7349b2 100644 --- a/app/chengji/controller/Index.php +++ b/app/chengji/controller/Index.php @@ -204,10 +204,11 @@ class Index extends BaseController // 实例化操作表格类 $excel = new \app\renshi\controller\Myexcel; - // 读取表格数据 // 读取表格数据 $cjinfo = $excel->readXls(public_path().'public\\uploads\\'.$url); + $kaoshiid = $cjinfo[1][0]; #获取考号 + // 删除空单元格得到学科列名数组 array_splice($cjinfo[1],0,4); $xk = $cjinfo[1]; @@ -217,48 +218,58 @@ class Index extends BaseController // 查询考试信息 $kh = new Kaohao; - $ks = new \app\kaoshi\model\Kaoshi; + // $ks = new \app\kaoshi\model\Kaoshi; - $user_id = session('userid'); - // 重新组合成绩信息 - foreach ($cjinfo as $key => $value) { - foreach ($xk as $k => $val) { + $user_id = session('userid'); # 获取用户id + $data = array(); - // $thissbj = $val; # 当前学科 - $defen = $value[$k+4]; # 当前学科 + $cj = new Chengji; #实例化成绩数据模型 + + // 重新组合数组 + foreach ($xk as $key => $value) { + // 获取成绩满分 + $manfen = getmanfen($kaoshiid,$value); + # code... + foreach ($cjinfo as $k => $val) { + $defen = $val[$key+4]; # 当前学生当前学科成绩 // 如果不存在值,跳过这次循环 if($defen === null){ continue; } - - // 成绩验证 - $manfen = getmanfen($value[1],$val); + // 验证成绩格式,如果不对则跳过 $mfyz = manfenvalidate($defen,$manfen); if($mfyz['val'] == 0) { continue; } - - // 查询是否存在这个成绩 - $cj = Chengji::withTrashed() - ->where('kaohao_id',$value[1]) - ->where('subject_id',$val) - ->find(); - - // 如果存在则删除 - if($cj){ - $cj->force()->delete(); + // 添加或更新数据 + $cjone = $cj::withTrashed() + ->where('kaohao_id',$val[1]) + ->where('subject_id',$value) + ->find(); + // 判断成绩是否存在 + if($cjone) + { + // 如果存在则更新记录 + if($cj->defen != $defen) + { + $cjone->defen = $defen; + $cjone->delete_time = null; + $cjone->save(); + } + }else{ + // 如果不存在则新增记录 + $data = [ + 'kaohao_id'=>$val[1], + 'subject_id'=>$value, + 'user_id'=>$user_id, + 'defen'=>$defen + ]; + $cj::create($data); } - - $data = Chengji::create([ - 'kaohao_id'=>$value[1], - 'subject_id'=>$val, - 'user_id'=>$user_id, - 'defen'=>$defen - ]); } } diff --git a/app/kaoshi/controller/Kaohao.php b/app/kaoshi/controller/Kaohao.php index bd17c812..13660a38 100644 --- a/app/kaoshi/controller/Kaohao.php +++ b/app/kaoshi/controller/Kaohao.php @@ -524,6 +524,7 @@ class Kaohao extends BaseController // 设置表格标题与表头信息 $sheet->setCellValue('A1',$kslist->title.' 成绩采集表'); + $sheet->setCellValue('A2', $kaoshi); $sheet->setCellValue('A3', '序号'); $sheet->setCellValue('B3', '考号'); $sheet->setCellValue('C3', '班级'); diff --git a/app/kaoshi/view/index/index.html b/app/kaoshi/view/index/index.html index 29ffed2a..f2bdc93c 100644 --- a/app/kaoshi/view/index/index.html +++ b/app/kaoshi/view/index/index.html @@ -39,7 +39,6 @@ @@ -49,7 +48,7 @@ // 设置列 options.cols=[[ //表头 {type:'checkbox', fixed: 'left'}, - {field: 'id', title: '操作',toolbar: '#barDemo',minWidth:130}, + {field: 'id', title: '操作',toolbar: '#barDemo',minWidth:80}, {field: 'title', title: '考试名称',sort: true, minWidth:240}, // {field: 'category', title: '考试分类', minWidth:100,sort: true,templet:function(d){ // var str=''; @@ -128,9 +127,9 @@ case 'edit':// 编辑 cjgl.add('编辑考试','index/edit/'+obj.data.id,'','',true); break; - case 'set':// 编辑 - cjgl.add('设置考试','index/set/'+obj.data.id,'','',true); - break; + // case 'set':// 编辑 + // cjgl.add('设置考试','index/set/'+obj.data.id,'','',true); + // break; case 'more':// 状态 parent.xadmin.add_tab(obj.data.title + ' 操作','/kaoshi/index/more/'+obj.data.id,true); break; diff --git a/app/kaoshi/view/index/more_action.html b/app/kaoshi/view/index/more_action.html index af7b7f28..26efcbbb 100644 --- a/app/kaoshi/view/index/more_action.html +++ b/app/kaoshi/view/index/more_action.html @@ -45,6 +45,13 @@
+ +
+ +
考试设置
+
+