List<Object> listobj= sListDao.excuteSqlQuery(sql);
//声明总数
int total_slcount = 0;
//保留几位小数
DecimalFormat df = new DecimalFormat("#.##");
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
if(listobj.size()>0){
for (Object obj : listobj) {
if(obj !=null){
//将object转成数组
Object[] objArr = (Object[]) obj;
Map<String, Object> map = new HashMap<String, Object>();
int index = 0;
map.put("sl", objArr[index++]);
String tqbjl = "";
Object tqbjlO = objArr[index++];
if (tqbjlO == null) {
tqbjl = "-";
} else {
tqbjl = df.format(tqbjlO) + "%";
}
map.put("tqbjl", tqbjl);
list.add(map);
//算总数
total_slcount += slcount;
}
}
}
Map<String, Object> bottomMap = new HashMap<String, Object>();
bottomMap.put("name", "合计");
bottomMap.put("sl", total_slcount);
list.add(bottomMap);
//返回类型
Map<String, Object> map = new HashMap<String, Object>();
map.put("rows", list);
map.put("total",list.size());
return map;
object 转成Object[] 数组
最新推荐文章于 2024-10-02 07:57:38 发布