bgp模块ip域配置提交

导出全部数据简单功能
This commit is contained in:
duandongmei
2018-06-13 09:30:03 +08:00
parent b6bfcdda1f
commit 611c9139cf
17 changed files with 1532 additions and 52 deletions

View File

@@ -9,6 +9,7 @@ import java.io.IOException;
import java.io.OutputStream;
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;
@@ -41,6 +42,7 @@ import com.google.common.collect.Lists;
import com.nis.util.DictUtils;
import com.nis.util.Encodes;
import com.nis.util.Reflections;
import com.nis.util.StringUtil;
/**
* 导出Excel文件导出“XLSX”格式支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion
@@ -76,6 +78,23 @@ public class ExportExcel {
*/
List<Object[]> annotationList = Lists.newArrayList();
/**
* //递归获取cls实体对象及父级对象的属性
* @param list
* @param cls
*/
public void getFields(List<Field> list,Class<?> cls) {
Field[] fields=cls.getDeclaredFields();
if(fields != null && fields.length > 0){
for (Field field : fields) {
list.add(field);
}
}
if(cls.getSuperclass() != null){
getFields(list,cls.getSuperclass());
}
}
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
@@ -84,7 +103,6 @@ public class ExportExcel {
public ExportExcel(String title, Class<?> cls){
this(title, cls, 1);
}
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
@@ -93,27 +111,31 @@ public class ExportExcel {
* @param groups 导入分组
*/
public ExportExcel(String title, Class<?> cls, int type, int... groups){
List<Field> list=new ArrayList<Field>();
// Get annotation field
Field[] fs = cls.getDeclaredFields();
for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
getFields(list, cls);
if(!StringUtil.isEmpty(list)){
for (Field f : list){
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, f});
}
}else{
annotationList.add(new Object[]{ef, f});
}
}
}
@@ -171,27 +193,32 @@ public class ExportExcel {
* @param groups 导入分组
*/
public ExportExcel(Properties msgProp,String title, Class<?> cls, int type, int... groups){
List<Field> list=new ArrayList<Field>();
// Get annotation field
Field[] fs = cls.getDeclaredFields();
for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
//递归获取cls实体对象及父级对象的属性
getFields(list, cls);
if(!StringUtil.isEmpty(list)){
for (Field f : list){
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, f});
}
}else{
annotationList.add(new Object[]{ef, f});
}
}
}