数据导入1.2,对数据进行检查

This commit is contained in:
Cool 2024-03-26 19:26:19 +08:00
parent 1c7cca09c9
commit 1526d304bc
1 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service;
import com.linuxense.javadbf.DBFReader;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.anno.AttributeName;
import org.jeecg.modules.entity.CET;
import org.jeecg.modules.mapper.CetMapper;
@ -17,6 +18,7 @@ import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
@Service
public class DBFImporter {
@ -48,8 +50,13 @@ public class DBFImporter {
field.set(cet, String.valueOf(value));
if (field.getName().equals("id")) {
// System.out.println(field.getName());
String s = String.valueOf(value);
cet.setEntrydate(s.substring(0, 4));
String entryDate = String.valueOf(value);
//对学生信息进行检查
int entry = Integer.parseInt(entryDate);
int year = DateUtils.getYear();
if (entry<2015||entry>year+1||Pattern.compile("[a-zA-Z]").matcher(entryDate).find()) continue;
cet.setEntrydate(entryDate.substring(0, 4));
}
} else if (fieldType == int.class || fieldType == Integer.class) {
Object value = rowValues[fieldIndex - 1];