2021-05-24 09:25:57 +08:00
|
|
|
|
package cn.com.tenlion.util;
|
|
|
|
|
|
|
|
|
|
import cn.com.tenlion.dao.excel.IExcelDao;
|
2021-06-01 19:17:13 +08:00
|
|
|
|
import cn.com.tenlion.pojo.model.ApplyStudentsModel;
|
2021-05-24 09:25:57 +08:00
|
|
|
|
import cn.com.tenlion.service.handleimportexcel.IHandleImportExcelService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入excel数据的校验类
|
|
|
|
|
* @author renpc
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
public class ImportExcelHelper {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IHandleImportExcelService handleImportExcelService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* excelDao
|
|
|
|
|
*/
|
|
|
|
|
private static IExcelDao excelDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
public void init(IExcelDao excelDao) {
|
|
|
|
|
ImportExcelHelper.excelDao = excelDao;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static <T> String checkDataValid(T obj) {
|
|
|
|
|
if(null == obj) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String returnStr = isMustInput(obj);
|
|
|
|
|
return returnStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查数据是否必填项缺失
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param <T>
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static <T> String isMustInput(T obj) {
|
|
|
|
|
// 出租房
|
|
|
|
|
if(obj instanceof ApplyStudentsModel) {
|
|
|
|
|
Object temp = obj;
|
|
|
|
|
ApplyStudentsModel rentalHousingModel = (ApplyStudentsModel) temp;
|
|
|
|
|
return checkApplyStudentsData(rentalHousingModel);
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从数据库比对数据,并转换为数据库数据
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param <T>
|
|
|
|
|
*/
|
|
|
|
|
public static <T> void checkDataFromDatabase(T obj) {
|
|
|
|
|
// 出租房
|
|
|
|
|
if(obj instanceof ApplyStudentsModel) {
|
|
|
|
|
Object temp = obj;
|
|
|
|
|
ApplyStudentsModel applyStudentsModel = (ApplyStudentsModel) temp;
|
|
|
|
|
applyStudentsCheck(applyStudentsModel);
|
|
|
|
|
temp = applyStudentsModel;
|
|
|
|
|
obj = (T) temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查数据是否必填项缺失(考生成绩)
|
|
|
|
|
* @param applyStudentsModel
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static String checkApplyStudentsData(ApplyStudentsModel applyStudentsModel) {
|
|
|
|
|
if(StringUtils.isEmpty(applyStudentsModel.getPlanNumber())) {
|
|
|
|
|
return "班号必填";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isEmpty(applyStudentsModel.getUserName())) {
|
|
|
|
|
return "考生姓名必填";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isEmpty(applyStudentsModel.getCardNumber())) {
|
|
|
|
|
return "考生身份证号码必填";
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isEmpty(applyStudentsModel.getScore())) {
|
|
|
|
|
return "考生成绩必填";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从数据库比对数据,并转换为数据库数据(考生成绩)
|
|
|
|
|
* @param applyStudentsModel
|
|
|
|
|
*/
|
|
|
|
|
private static void applyStudentsCheck(ApplyStudentsModel applyStudentsModel) {
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|