|
@@ -179,7 +179,7 @@ public class ExcelUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ExcelImportTempleteVaild excelImportTempleteVaild = o.getClass().getDeclaredAnnotation(ExcelImportTempleteVaild.class);
|
|
ExcelImportTempleteVaild excelImportTempleteVaild = o.getClass().getDeclaredAnnotation(ExcelImportTempleteVaild.class);
|
|
- if (Objects.nonNull(excelImportTempleteVaild) && excelImportTempleteVaild.value() && (lastcell != fields.length || sheets != clazz.size())) {
|
|
|
|
|
|
+ if (y == 0 && i == 0 && Objects.nonNull(excelImportTempleteVaild) && excelImportTempleteVaild.value() && (lastcell != fields.length || sheets != clazz.size())) {
|
|
throw ExceptionResultEnum.ERROR.exception("导入文件和模版不一致,表头应包含【" + String.join(",", headList) + "】");
|
|
throw ExceptionResultEnum.ERROR.exception("导入文件和模版不一致,表头应包含【" + String.join(",", headList) + "】");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,7 +208,7 @@ public class ExcelUtil {
|
|
fields[j].set(o, obj);
|
|
fields[j].set(o, obj);
|
|
Annotation annotation = fields[j].getAnnotation(NotNull.class);
|
|
Annotation annotation = fields[j].getAnnotation(NotNull.class);
|
|
ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
|
|
ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
|
|
- if ((Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
|
|
|
|
|
|
+ if (note.require() && (Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
|
|
excelErrorList.add(y, new ExcelError(j + 1, "excel第" + (y + 1) + "个sheet第" + (j + 1) + "行[" + note.value() + "]为空"));
|
|
excelErrorList.add(y, new ExcelError(j + 1, "excel第" + (y + 1) + "个sheet第" + (j + 1) + "行[" + note.value() + "]为空"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -232,7 +232,7 @@ public class ExcelUtil {
|
|
fields[j].set(o, obj);
|
|
fields[j].set(o, obj);
|
|
Annotation annotation = fields[j].getAnnotation(NotNull.class);
|
|
Annotation annotation = fields[j].getAnnotation(NotNull.class);
|
|
ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
|
|
ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
|
|
- if ((Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
|
|
|
|
|
|
+ if (note.require() && (Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
|
|
excelErrorList.add(y, new ExcelError(i + 1, "excel第" + (y + 1) + "个sheet第" + (i + 1) + "行[" + note.value() + "]为空"));
|
|
excelErrorList.add(y, new ExcelError(i + 1, "excel第" + (y + 1) + "个sheet第" + (i + 1) + "行[" + note.value() + "]为空"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -341,7 +341,7 @@ public class ExcelUtil {
|
|
field.setAccessible(true);
|
|
field.setAccessible(true);
|
|
Annotation annotation = field.getAnnotation(NotNull.class);
|
|
Annotation annotation = field.getAnnotation(NotNull.class);
|
|
ExcelNote note = field.getAnnotation(ExcelNote.class);
|
|
ExcelNote note = field.getAnnotation(ExcelNote.class);
|
|
- if ((Objects.isNull(field.get(obj)) || Objects.equals("", field.get(obj))) && Objects.nonNull(annotation)) {
|
|
|
|
|
|
+ if (note.require() && (Objects.isNull(field.get(obj)) || Objects.equals("", field.get(obj))) && Objects.nonNull(annotation)) {
|
|
excelErrorList.add(new ExcelError(index + 1, "excel第" + (sheetIndex + 1) + "个sheet第" + (index + 1) + "行[" + note.value() + "]为空"));
|
|
excelErrorList.add(new ExcelError(index + 1, "excel第" + (sheetIndex + 1) + "个sheet第" + (index + 1) + "行[" + note.value() + "]为空"));
|
|
}
|
|
}
|
|
}
|
|
}
|