(1)ip导入调整,子类的同名字段覆盖父类的,用于某些字段的注解重写
(2)新建package template,将IP的template入 (3)IP复用策略配置导入模板调整,由于界面只有IP,端口,所以模板的注解进行了响应调整 (4)配置文件加入了IP和端口的默认值设置 (5)导入IP加入了IP复用策略和限速比例的验证
This commit is contained in:
@@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -211,7 +212,69 @@ public class ImportExcel {
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* //递归获取cls实体对象及父级对象的属性
|
||||
* wx:修改,子类覆盖父类的同名方法
|
||||
* @param list
|
||||
* @param cls
|
||||
*/
|
||||
public void getFields(List<Field> list,Class<?> cls) {
|
||||
Field[] fields=cls.getDeclaredFields();
|
||||
if(fields != null && fields.length > 0){
|
||||
List<Field> tempList=new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
if(list.size()==0) {
|
||||
tempList.add(field);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Field checkF:list) {
|
||||
if(checkF.getName().equals(field.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getFields(list,cls.getSuperclass());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* //递归获取cls实体对象及父级对象的method
|
||||
* @param list
|
||||
* @param cls
|
||||
*/
|
||||
public void getMethods(List<Method> list,Class<?> cls) {
|
||||
Method[] methods=cls.getDeclaredMethods();
|
||||
if(methods != null && methods.length > 0){
|
||||
List<Method> tempList=new ArrayList<>();
|
||||
for (Method method : methods) {
|
||||
if(list.size()==0) {
|
||||
tempList.add(method);
|
||||
}else {
|
||||
boolean has=false;
|
||||
for(Method checkM:list) {
|
||||
if(checkM.getName().equals(method.getName())) {
|
||||
has=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
tempList.add(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.addAll(tempList);
|
||||
}
|
||||
if(cls.getSuperclass() != null){
|
||||
getMethods(list,cls.getSuperclass());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取导入数据列表
|
||||
* @param cls 导入对象类型
|
||||
@@ -220,7 +283,11 @@ public class ImportExcel {
|
||||
public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
|
||||
List<Object[]> annotationList = Lists.newArrayList();
|
||||
// Get annotation field
|
||||
Field[] fs = cls.getDeclaredFields();
|
||||
// Field[] fs = cls.getDeclaredFields();
|
||||
List<Field> fs=new ArrayList<Field>();
|
||||
// Get annotation field
|
||||
//递归获取cls实体对象及父级对象的属性
|
||||
getFields(fs, cls);
|
||||
for (Field f : fs){
|
||||
ExcelField ef = f.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
@@ -244,7 +311,11 @@ public class ImportExcel {
|
||||
}
|
||||
}
|
||||
// Get annotation method
|
||||
Method[] ms = cls.getDeclaredMethods();
|
||||
// Method[] ms = cls.getDeclaredMethods();
|
||||
List<Method> ms=new ArrayList<Method>();
|
||||
// Get annotation method
|
||||
//递归获取cls实体对象及父级对象的属性
|
||||
getMethods(ms, cls);
|
||||
for (Method m : ms){
|
||||
ExcelField ef = m.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
|
||||
Reference in New Issue
Block a user