From 48763b7e53c2d9f470c6d317943835fc0a888fe8 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Thu, 8 Nov 2018 20:10:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=89=B9=E4=BC=A0=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/renshi/common.php | 1 + application/renshi/controller/Student.php | 62 +++++++++++++++++-- application/renshi/model/Student.php | 10 +-- application/renshi/validate/Student.php | 2 +- application/renshi/view/student/create.html | 6 +- .../renshi/view/student/create_all.html | 10 ++- application/renshi/view/student/edit.html | 8 +-- .../20181030072733_kaoshi_subject.php | 3 + 8 files changed, 79 insertions(+), 23 deletions(-) diff --git a/application/renshi/common.php b/application/renshi/common.php index b3d9bbc7..a4abe2da 100644 --- a/application/renshi/common.php +++ b/application/renshi/common.php @@ -1 +1,2 @@ only(['danwei','url'],'post'); + $list = request()->only(['school','url'],'post'); // 实例化操作表格类 $excel = new Myexcel(); // 读取表格数据 $stuinfo = $excel->readXls($list['url']); + // 删除标题行 + array_splice($stuinfo,0,3); + // $upcnt = count($stuinfo); - dump($stuinfo); + // 实例化班级数据模型 + $banji = new \app\teach\model\Banji; + $njlist = nianjilist(); + $bjlist = banjinamelist(); + + + $i = 0; + $bfbanji = ''; + $bj = ''; + $students = array(); + // 重新计算组合数据,如果存在数据则更新数据 + foreach ($stuinfo as $key => $value) { + // 判断本行班级与上行班级数据是否相等,如果不相等则从数据库查询班级ID + if($bfbanji != $value[3]) + { + // 获取入学年与排序 + $paixu = array_search(substr($value[3],9),$bjlist); + $ruxuenian = array_search(substr($value[3],0,9),$njlist); + // 查询班级ID + $bj = $banji::where('school',$list['school']) + ->where('ruxuenian',$ruxuenian) + ->where('paixu',$paixu) + ->value('id'); + } + $bfbanji = $value[3]; + // 如果班级ID为空,删除数据并跳出当前循环 + if($bj == null || $bj =='' ) + { + continue; + } + + + $students[$i]['banji'] = $bj; + $students[$i]['xingming'] = $value[1]; + $students[$i]['shenfenzhenghao'] = $value[2]; + substr($value[2],16,17)%2 == 1 ? $students[$i]['sex']=1 :$students[$i]['sex']=0; + $students[$i]['shengri'] = substr($value[2],6,4).'-'.substr($value[2],10,2).'-'.substr($value[2],12,2); + + $students[$i]['school'] = $list['school']; + $stuid = STU::where('shenfenzhenghao',$value[2])->value('id'); + $stuid > 1 ? $students[$i]['id'] = $stuid : true; + // 销毁无用变量 + $i++; + } + + + // 实例化学生信息数据模型 + $student = new STU(); + + // 保存或更新信息 + $data = $student->saveAll($students); + // $cnt = $data->count(); + + $data ? $data = ['msg'=>'数据同步成功','val'=>true] : ['msg'=>'数据同步失败','val'=>false]; diff --git a/application/renshi/model/Student.php b/application/renshi/model/Student.php index f0ba8be0..fd04b3ac 100644 --- a/application/renshi/model/Student.php +++ b/application/renshi/model/Student.php @@ -46,13 +46,5 @@ class Student extends Base return $sex[$value]; } - // 性别获取器 - public function setSexAttr($value) - { - $sex = array('0'=>'女','1'=>'男','2'=>'保密'); - $val = array_search($value,$sex); - return $val; - } - - + } diff --git a/application/renshi/validate/Student.php b/application/renshi/validate/Student.php index 485d26f4..ed6c5440 100644 --- a/application/renshi/validate/Student.php +++ b/application/renshi/validate/Student.php @@ -14,7 +14,7 @@ class Student extends Validate */ protected $rule = [ 'xingming|姓名' => 'require|chs|length:2,8', - 'sex|性别' => 'require|chs|max:2', + 'sex|性别' => 'require|number', 'shengri|出生日期' => 'date', 'shenfenzhenghao|身份证号' => "require|idCard", 'school|学校' => 'require|number', diff --git a/application/renshi/view/student/create.html b/application/renshi/view/student/create.html index fe3e9764..208e6758 100644 --- a/application/renshi/view/student/create.html +++ b/application/renshi/view/student/create.html @@ -17,15 +17,15 @@
- +
- +
- +
diff --git a/application/renshi/view/student/create_all.html b/application/renshi/view/student/create_all.html index d137dbbe..216ac207 100644 --- a/application/renshi/view/student/create_all.html +++ b/application/renshi/view/student/create_all.html @@ -4,6 +4,12 @@ {/block} {block name="formaa"}
+
+ +
+ 批传是以本地数据为准同步服务器数据:如果服务器不存在本地数据会创建新数据,如果服务器存在本地数据,则会更新服务器数据,不支持删除。 +
+
@@ -29,7 +35,7 @@
- +
{php} @@ -39,7 +45,7 @@ ->field('id,title') ->all(); {/php} - {volist name="danwei" id="vo" key="k"} diff --git a/application/renshi/view/student/edit.html b/application/renshi/view/student/edit.html index 0820e243..03814a8f 100644 --- a/application/renshi/view/student/edit.html +++ b/application/renshi/view/student/edit.html @@ -17,15 +17,15 @@
- - + +
- +
- +
diff --git a/database/migrations/20181030072733_kaoshi_subject.php b/database/migrations/20181030072733_kaoshi_subject.php index 2e787656..edebb8e7 100644 --- a/database/migrations/20181030072733_kaoshi_subject.php +++ b/database/migrations/20181030072733_kaoshi_subject.php @@ -35,6 +35,9 @@ class KaoshiSubject extends Migrator $table ->addColumn('kaoshiid','integer',['limit'=>11,'null'=>false,'comment'=>'考试id']) ->addColumn('subjectid','integer',['limit'=>170,'null'=>false,'comment'=>'年级']) + ->addColumn('manfen','integer',['limit'=>3,'null'=>false,'comment'=>'满分']) + ->addColumn('youxiu','integer',['limit'=>3,'null'=>false,'comment'=>'优秀']) + ->addColumn('jige','integer',['limit'=>3,'null'=>false,'comment'=>'及格']) ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) ->create(); }