海工商新版后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

138 lines
4.4 KiB

<?php
namespace App\Admin\Extensions\Exporter;
use Dcat\Admin\Grid\Exporters\AbstractExporter;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class ImportStudentExporter extends AbstractExporter implements WithMapping, WithHeadings, FromCollection
{
use Exportable;
protected $fileName = '导入学生名单';
protected $titles = [];
public function __construct()
{
$this->fileName = $this->fileName.'_'.time().'.xlsx';//拼接下载文件名称
$this->titles = [
'mobile' => '手机号' ,
'name'=>'姓名',
'idCard'=>'身份证',
'sex' => "性别",
"admission_code" => "录取编码(学号)",
"admission_college" => "二级学院",
"admitted_major" => "录取专业",
"status" => "状态",
"is_register" => "是否已注册",
"annual_session" => "年份",
"is_test" => "测试账号",
"nj" => "年级",
"xydm" => "学院代码",
"zydm" => "专业代码",
"bjdm" => "班级代码",
"xz" => "学制代码",
"xslbdm" => "学生类别代码",
"xjztdm" => "学籍状态代码",
"sfzx" => "是否在校代码",
"is_push" => "是否已推送",
"is_five_year" => "是否为五年制一贯制",
"is_equivalent" => "考生类型",
"is_four_type" => "考生分类",
"province" => "招生省份",
"is_new_student" => "是否为新生",
"old_student_bed_info" => "老生床位信息",
"day_student" => "是否为走读生",
"create_time" => "导入时间",
];
parent::__construct();
}
public function export()
{
// TODO: Implement export() method.
$this->download($this->fileName)->prepare(request())->send();
exit;
}
public function collection()
{
// TODO: Implement collection() method.
return collect($this->buildData());
}
public function headings(): array
{
// TODO: Implement headings() method.
return $this->titles();
}
public function map($row): array
{
$sex = "";
if($row['sex'] == 1) $sex = "";
$status = "正常";
if($row['status'] == 2) $status = "禁用";
$is_register = "未注册";
if($row['is_register'] == 2) $status = "已注册";
$is_test = "";
if($row['is_test'] == 2) $status = "";
$sfzx = "";
if($row['sfzx'] == 1) $sfzx = "";
$is_push = "未推送";
if($row['is_push'] == 2) $is_push = "已推送";
$is_five_year = "";
if($row['is_five_year'] == 2) $is_five_year = "";
$is_equivalent = "统招生";
if($row['is_equivalent'] == 2) $is_equivalent = "单招生";
$is_four_type = "";
if($row['is_four_type'] == 1) $is_four_type = "高职本科3+2";
if($row['is_four_type'] == 2) $is_four_type = "四类人员";
if($row['is_four_type'] == 3) $is_four_type = "普通考生";
if($row['is_four_type'] == 4) $is_four_type = "中职3+2";
$is_new_student = "新生";
if($row['is_new_student'] == 2) $is_new_student = "老生";
$day_student = "";
if($row['day_student'] == 2) $day_student = "";
// TODO: Implement map() method.
return [
$row['mobile'],
$row['name'],
"'".$row['idCard'].'',
$sex,
$row['admission_code'],
$row['admission_college'],
$row['admitted_major'],
$status,
$is_register,
$row['annual_session'],
$is_test,
$row['nj'],
$row['xydm'],
$row['zydm'],
$row['bjdm'],
$row['xz'],
$row['xslbdm'],
$row['xjztdm'],
$sfzx,
$is_push,
$is_five_year,
$is_equivalent,
$is_four_type,
$row['province'],
$is_new_student,
$row['old_student_bed_info'],
$day_student,
date("Y-m-d H:i:s", $row['create_time']),
];
}
}