List<ProjectProgress> list = new ArrayList<ProjectProgress>();
String sqlstr2 = "select a.*,"
+ "(select b.codename from CODEMNG b where b.CODETYPE = 'PROGRESSSTEP' and b.CODE = a.PROGRESSSTEP) PROGRESSSTEPTEXT,"
+ "(select b.DISPLAYNAME from SYSUSER b where b.userid = a.userid) username,"
+ "(select b.codename from CODEMNG b where b.CODETYPE = 'PROGRESSPLACE' and b.CODE = a.PROGRESSPLACE) PROGRESSPLACETEXT "
+ "from V_PROJECTPROGRESS_TJ a where tripId = '"+tripList.get(0).getTripId()+"' and userId = '"+user.getUserId()+"' ";
long total = Daos.queryCount(dao,sqlstr2);
sqlstr2 = sqlstr2 + " order by a.workDate desc";
Sql sql2 = Sqls.create(sqlstr2);
//分页
sql2.setPager(pager);
sql2.setParam("userId", user.getUserId());
sql2.setParam("tripId", tripList.get(0).getTripId());
sql2.setCallback(Sqls.callback.entities());
sql2.setEntity(dao.getEntity(ProjectProgress.class));
dao.execute(sql2);
//设置总记录数
pager.setRecordCount((int)total);
list = sql2.getList(ProjectProgress.class);
//return list;
returnMap.put("total", pager.getRecordCount());
returnMap.put("rows", list);
return returnMap;
关键点:
一、要能够自定义SQL
二、是查询数据库视图
三、要能够分页