|
@@ -2,6 +2,7 @@ package com.qmth.themis.business.util;
|
|
|
|
|
|
import com.qmth.themis.business.annotation.ExcelNotNull;
|
|
|
import com.qmth.themis.business.annotation.ExcelNote;
|
|
|
+import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
@@ -16,9 +17,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.lang.annotation.Annotation;
|
|
|
import java.lang.reflect.Field;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: excel util
|
|
@@ -68,6 +67,7 @@ public class ExcelUtil {
|
|
|
int lastcell = row.getLastCellNum();
|
|
|
o = clazz.get(y).newInstance();
|
|
|
Field[] fields = o.getClass().getDeclaredFields();
|
|
|
+ Map map = null;
|
|
|
for (int j = firstcell; j < lastcell; j++) {
|
|
|
//获取第j列
|
|
|
Cell cell = row.getCell(j);
|
|
@@ -76,8 +76,25 @@ public class ExcelUtil {
|
|
|
} else {
|
|
|
if (Objects.nonNull(cell)) {
|
|
|
Object obj = convert(cell);
|
|
|
- fields[j].setAccessible(true);
|
|
|
- fields[j].set(o, obj);
|
|
|
+ if (Objects.isNull(map)) {
|
|
|
+ fields[j].setAccessible(true);
|
|
|
+ String string = fields[j].getGenericType().getTypeName();
|
|
|
+ if (string.contains(SystemConstant.MAP)) {
|
|
|
+ map = (Map) fields[j].get(o);
|
|
|
+ if (Objects.isNull(map)) {
|
|
|
+ map = new LinkedHashMap<>();
|
|
|
+ }
|
|
|
+ map.put(columnNameList.get(y).get(j), obj);
|
|
|
+ fields[j].set(o, map);
|
|
|
+ } else {
|
|
|
+ fields[j].set(o, obj);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Field field = o.getClass().getDeclaredField(SystemConstant.EXTEND_COLUMN);
|
|
|
+ field.setAccessible(true);
|
|
|
+ map.put(columnNameList.get(y).get(j), obj);
|
|
|
+ field.set(o, map);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|