专业,班级,学生,教师的批量导入
parent
402cb1b071
commit
c9f092e060
@ -0,0 +1,45 @@
|
|||||||
|
package yuxingshi.sms.server.domain.dto.major;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import yuxingshi.sms.common.core.utils.ExcelImportUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专业Excel读取监听器 - 使用工具类基类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class MajorReadListener extends ExcelImportUtil.BaseReadListener<MajorExcelDTO> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldSkip(MajorExcelDTO data, int rowNo) {
|
||||||
|
if (data == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 如果所有主要字段都为空则跳过
|
||||||
|
if (StringUtils.isAllBlank(data.getMajorCode(), data.getMajorName(), data.getDescription())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 如果首行看起来像是表头,忽略这行
|
||||||
|
if (rowNo == 1) {
|
||||||
|
if ("专业代码".equalsIgnoreCase(data.getMajorCode())
|
||||||
|
|| "专业名称".equalsIgnoreCase(data.getMajorName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preProcess(MajorExcelDTO data) {
|
||||||
|
// 去除首尾空格
|
||||||
|
if (data.getMajorCode() != null) {
|
||||||
|
data.setMajorCode(data.getMajorCode().trim());
|
||||||
|
}
|
||||||
|
if (data.getMajorName() != null) {
|
||||||
|
data.setMajorName(data.getMajorName().trim());
|
||||||
|
}
|
||||||
|
if (data.getDescription() != null) {
|
||||||
|
data.setDescription(data.getDescription().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package yuxingshi.sms.server.domain.dto.stu;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import yuxingshi.sms.common.core.utils.ExcelImportUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学生Excel读取监听器 - 使用工具类基类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class StudentReadListener extends ExcelImportUtil.BaseReadListener<StudentExcelDTO> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldSkip(StudentExcelDTO data, int rowNo) {
|
||||||
|
if (data == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 如果所有主要字段都为空则跳过
|
||||||
|
if (StringUtils.isAllBlank(data.getStudentNo(), data.getRealName(), data.getClassCode())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 如果首行看起来像是表头,忽略这行
|
||||||
|
if (rowNo == 1) {
|
||||||
|
if ("学号".equalsIgnoreCase(data.getStudentNo())
|
||||||
|
|| "真实姓名".equalsIgnoreCase(data.getRealName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preProcess(StudentExcelDTO data) {
|
||||||
|
// 去除首尾空格
|
||||||
|
if (data.getStudentNo() != null) {
|
||||||
|
data.setStudentNo(data.getStudentNo().trim());
|
||||||
|
}
|
||||||
|
if (data.getRealName() != null) {
|
||||||
|
data.setRealName(data.getRealName().trim());
|
||||||
|
}
|
||||||
|
if (data.getClassCode() != null) {
|
||||||
|
data.setClassCode(data.getClassCode().trim());
|
||||||
|
}
|
||||||
|
if (data.getGender() != null) {
|
||||||
|
data.setGender(data.getGender().trim());
|
||||||
|
}
|
||||||
|
if (data.getPhone() != null) {
|
||||||
|
data.setPhone(data.getPhone().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue