ibatis 里查询select语句写法带分页

startDate  endDate  传如为日期类型

 


 
 

 

前台方法

 

 

 public ModelAndView queryProcedures(HttpServletRequest request, HttpServletResponse response) throws Exception{
    ModelAndView modelAndView = new ModelAndView("his/medicalManagement/ProcedureStatistic/queryProcedures");
    try {
   String isUpper = request.getParameter("ISUPPER");//是否上级
   String forgid = request.getParameter("forgid");
   String frcode = request.getParameter("frcode");
   String organizeName = request.getParameter("organizeName");
   if(frcode.length() > 6)//截取县区编码
   {
     frcode = frcode.substring(0, 6);
   }
   if(!PageMonitor.storeOperCheck(request, modelAndView, getApplicationContext(), GlobalConstant.OFFICE_TYPE_YK)){
     return modelAndView; 
   }
  
  HashMap hashMap = new HashMap();
  
  //用做分页
  int pageIndex = request.getParameter("pageIndex") == null?1:Integer.parseInt(request.getParameter("pageIndex"));
  int pageSize = request.getParameter("pageSize") == null?7:Integer.parseInt(request.getParameter("pageSize"));
  int start = (pageIndex - 1)*pageSize+1;
  int end = pageIndex * pageSize;
  hashMap.put("start",new Integer(start));
  hashMap.put("end",new Integer(end));
  
  //获取当月的第一天和最后一天
  Date date = getCommonImpl().getDBDate();
  Date startDate = Convert.getFirstDayByMonth(date);
  Date endDate = Convert.getLastDayByMonth(date);
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     String firstDateStr = sdf.format(startDate).concat(" 00:00:00");
     startDate = Convert.toParseDate(firstDateStr);
     String lastDateStr = sdf.format(endDate).concat(" 23:59:59");
     endDate = Convert.toParseDate(lastDateStr);
   //县编码
   hashMap.put("FRCODE", frcode);
   //医院编码
   hashMap.put("FORGID", forgid);
   hashMap.put("startDate", startDate);
   hashMap.put("endDate", endDate);
   if(isUpper==null){
   hashMap.put("RETU", 0);
   }
   int totalRows = getProcedureStatisticImpl().queryProcedureTopCount(hashMap);
   List list = getProcedureStatisticImpl().queryProceduresTop(hashMap);

   modelAndView.addObject("list", list);
   modelAndView.addObject("totalRows", totalRows);
   modelAndView.addObject("start", start);
   modelAndView.addObject("end", end);
   modelAndView.addObject("frcode", frcode);
   modelAndView.addObject("forgid", forgid);
   modelAndView.addObject("organizeName", organizeName);

   modelAndView.addObject("startDate", startDate);
   modelAndView.addObject("endDate", endDate);
   modelAndView.addObject("ISUPPER", isUpper);
   modelAndView.addObject("retu", 0);
  } catch (Exception e) {
   //e.printStackTrace();
   AjaxException.MyException(response, e);
  }
   return modelAndView;
  }

 

 

 

 

 

 

你可能感兴趣的:(ibatis)