From ecfaad5f4882764739e2f3604bc8590d2d78b9a5 Mon Sep 17 00:00:00 2001 From: win7 Date: Wed, 25 Dec 2019 15:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=8F=B7=E4=B8=AD?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E6=8D=A2=E6=88=90=E5=B0=8F=E5=86=99=E5=AD=97?= =?UTF-8?q?=E6=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/renshi/common.php | 2 +- app/renshi/controller/Student.php | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/renshi/common.php b/app/renshi/common.php index 6e533c83..5f621351 100644 --- a/app/renshi/common.php +++ b/app/renshi/common.php @@ -97,7 +97,7 @@ function smDownload($url,$newname='') /** * 将“一年级一班”格式的班级名转换成入学年和班级排序 * $str是原文件格式 -* $data['ruxuenian'=>'',paixu=>''] +* 返回班级ID */ function strBjmArray($str,$school) { diff --git a/app/renshi/controller/Student.php b/app/renshi/controller/Student.php index c253afe0..1d80e974 100644 --- a/app/renshi/controller/Student.php +++ b/app/renshi/controller/Student.php @@ -459,11 +459,16 @@ class Student extends BaseController return $q[3] == $value; }); + $xlsStuList = array_column($myStuList, 2,0); $xlsStuList = array_map('strtolower', $xlsStuList); # 将大写字母转换成小写字母 $bjid = strBjmArray($value,$list['school']); + if($bjid == null) + { + continue; + } $serStulist = $stu::withTrashed() ->where('banji',$bjid) @@ -489,26 +494,33 @@ class Student extends BaseController } $add = array_diff($add, $add_temp); + // 针对不同数据进行不同操作 // 更新数据 foreach ($jiaoji as $key => $val) { $oneStu = $stu::withTrashed() ->where('shenfenzhenghao',$val) - ->field('id,xingming,banji,delete_time') + ->field('id,xingming,banji,school,delete_time') ->find(); + $oneStu->xingming = $myStuList[$key-1][1]; $oneStu->delete_time = null; + $oneStu->school = $list['school']; + $oneStu->banji = $bjid; $oneStu->save(); } + + + // 新增数据 $data = array(); foreach ($add as $key => $val) { intval(substr($myStuList[$key-1][2],16,1) )% 2 ? $sex = 1 :$sex = 0 ; $data[] = [ 'xingming'=>$myStuList[$key-1][1], - 'shenfenzhenghao'=>$myStuList[$key-1][2], + 'shenfenzhenghao'=>strtolower($myStuList[$key-1][2]), 'banji'=>$bjid, 'school'=>$list['school'], 'shengri' => substr($myStuList[$key-1][2],6,4).'-'.substr($myStuList[$key-1][2],10,2).'-'.substr($myStuList[$key-1][2],12,2), @@ -538,7 +550,6 @@ class Student extends BaseController $sch = $sch::where('id',$list['school'])->value('jiancheng'); - // 导出要删除的信息 // 创建表格 set_time_limit(0);