1.手动分页切割
List<ZLBDistrictAndCountyStatisticsVo> result = statisticsService.findAll(javaBean,begin,end,pp);
List<ZLBDistrictAndCountyStatisticsVo> dataList ;
int tempNum = result.size()/pp.getPageMaxSize();
int maxPageNum = result.size()%pp.getPageMaxSize() > 0 ? tempNum+1 : tempNum;
if(pp.getPageMaxSize() > result.size()){
dataList = result;
}else
if(pp.getCurrentPageNumber() == maxPageNum){
dataList = result.subList((pp.getCurrentPageNumber()-1)*pp.getPageMaxSize(),result.size());
}else
{
dataList = result.subList((pp.getCurrentPageNumber()-1)*pp.getPageMaxSize(),pp.getCurrentPageNumber()*pp.getPageMaxSize());
}
Page<ZLBDistrictAndCountyStatisticsVo> page = new Page(pp.getCurrentPageNumber(),pp.getPageMaxSize(),dataList,result.size(),pp.getPageDiv());
2.反射实体类转化为map
List<ZLBStatisticsEverydayVo> result = statisticsService.findAll(statisticsEveryday,begin,end,pp);
List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
for (ZLBStatisticsEverydayVo vo : result) {
Map<String, Object> stringObjectMap = objectToMap01(vo);
resultList.add(stringObjectMap);
}
public static Map<String, Object> objectToMap01(Object obj) throws Exception {
if (obj == null) {
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
Field[] declaredFields = obj.getClass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
if ("wyht".equals(field.getName()) && null!=field.getName() && -1 == (Integer) field.get(obj)){
map.put(field.getName(),"-");
}else {
map.put(field.getName(),field.get(obj));
}
}
Field[] declaredFields1 = obj.getClass().getSuperclass().getDeclaredFields();
for (Field field : declaredFields1) {
field.setAccessible(true);
if ("wyht".equals(field.getName()) && null!=field.getName() && -1 == (Integer) field.get(obj)){
map.put(field.getName(),"-");
}else {
map.put(field.getName(),field.get(obj));
}
}
return map;
}