public Object queryProgressAllCnd(NutMap map) throws BusinessException {
System.out.println(map);
Map returnMap = new NutMap();
SysUser user = (SysUser)Mvcs.getHttpSession().getAttribute(Globals.SESSION_USER_CODE);
//分页开始
int pageNumber = map.getInt("pageNumber");
int pageSize = map.getInt("pageSize");
Pager pager = new Pager();
pager.setPageNumber(pageNumber);
pager.setPageSize(pageSize);
List<ProjectProgressV> list = new ArrayList<ProjectProgressV>();
String sqlstr2 = " select * from V_PROGRESS_TJ a where 1=1 ";
//提取条件
String cndProgress_user = map.getString("cndProgress_user").trim();
String cndProgress_projectId = map.getString("cndProgress_projectId").trim();
String cndProgress_tripId = map.getString("cndProgress_tripId").trim();
if(cndProgress_user!=null && !"".equals(cndProgress_user)){
sqlstr2 = sqlstr2 + " and a.userId = '"+cndProgress_user+"' ";
}
if(cndProgress_projectId!=null && !"".equals(cndProgress_projectId)){
sqlstr2 = sqlstr2 + " and a.projectId = '"+cndProgress_projectId+"' ";
}
if(cndProgress_tripId!=null && !"".equals(cndProgress_tripId)){
int temp = Integer.valueOf(cndProgress_tripId);
sqlstr2 = sqlstr2 + " and a.tripId like '%"+temp+"%' ";
}
long total = Daos.queryCount(dao,sqlstr2);
sqlstr2 = sqlstr2 + " order by a.tripId desc,a.workDate asc";
Sql sql2 = Sqls.create(sqlstr2);
//分页
sql2.setPager(pager);
sql2.setCallback(Sqls.callback.entities());
sql2.setEntity(dao.getEntity(ProjectProgressV.class));
dao.execute(sql2);
//设置总记录数
pager.setRecordCount((int)total);
list = sql2.getList(ProjectProgressV.class);
//return list;
returnMap.put("total", pager.getRecordCount());
returnMap.put("rows", list);
return returnMap;
}
其中pager中参数:size: 20, total: 0, page: 1/0
最后结果:
returnMap.put("rows", list);
中的list有22条记录,都出来了,没有按20条一页来查
之前也是自定义SQL + pager分页,因为是数据库表,一直OK,这次用视图,才出现的,咋弄啊?