DetachedCriteria和Criteria的使用方法
DetachedCriteria和Criteria的使用方法
/*
* 下载统计
* @return
*/
public String downloadStatistics(){
logger.info("正在执行目录内容统计下载");
String type = getServletRequest().getParameter("type");
DetachedCriteria dc = DetachedCriteria.forClass(TbXymlb.class)
.add(Restrictions.and(Restrictions.isNotNull("sfsjtc"), Restrictions.isNotNull("mlnrb")))
.addOrder(Order.asc("diyu")).addOrder(Order.asc("cydw"));
logger.info("执行查询参数为:{}", type);
if(DOWNLOAD_TYPE_ZY.equals(type)){
dc.add(Restrictions.eq("diyu", "99"));
}else if(DOWNLOAD_TYPE_DF.equals(type)){
dc.add(Restrictions.ne("diyu", "99"));
}
// 执行查询
List<TbXymlb> xymls = xymlService.query(dc);
try{
downloadName = "mlnr_tj.xls";
downloadFile = buildXLSStream(xymls);
}catch(Exception error){
logger.error("下载出现错误", error);
}
return SUCCESS;
}
随后要加上自己的理解