list=listEFormat(list, "Class_type", "611");//list查询数据库得到的结果Class_type
/**
* @Title: listEFormat
* @Description: 实体类 list fid
* @param @param list 查询出来的结果
* @param @param name
* @param @param fid
* @param @return
* @return List<Object>
* @throws
*/
public List<Object> listEFormat(List<Object> list,String name,String fid) {
//取得所在类
if(null==list ||list.size()==0) {
return list;
}
Class c=list.get(0).getClass();
try {
//取得get/set
Method gm =c.getMethod("get"+name, null);
Method sm =c.getMethod("set"+name, String.class);
//循环处理list
for(int i =0;i<list.size();i++) {
Object o = list .get(i);
String allin=(String) gm.invoke(o, null);
System.out.println("输入量="+allin);
String out="";
//循环处理具体量
if (null!=allin&&!"".equals(allin)) {
String[] ins=allin.split(",");
for(int j =0;j<ins.length;j++) {
String in =ins[j];
if (!"".equals(in)) {
Map para=new HashMap();
para.put("fid", fid);
para.put("id", ins[j]);
Map res=userDao.getNameByFidId(para);
if (null==res) {
out=in;
}else {
out = out+res.get("name")+" ";
}}
}
System.out.println("输出量="+out);
sm.invoke(o, out);
list.remove(i);
list.add(i, o);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}