天天看點

SpringMVC 綜合查詢 easyui 架構

@SuppressWarnings("unchecked")
	@Override
	public List<Yz> search(int page,int rows,String blhxm, String cxysqz1,
			String zxsqxyz, String lsyzcx, String zxswcldyz, String start,
			String end,String blhcx ) {
		
		// TODO Auto-generated method stub
		StringBuffer hql;
		hql=new StringBuffer("from Yz ");
		hql.append(" where 1=1 and ");
		if(null!=blhxm&&!blhxm.equals("")){
			hql.append(""+blhcx+" = '"+blhxm+"' and ");
		}
		if(null!=zxsqxyz&&!zxsqxyz.equals("")){
			hql.append("qxyz='"+zxsqxyz+"' and ");
		}
		if(null!=cxysqz1&&!cxysqz1.equals("")){
			hql.append("yzys='"+cxysqz1+"' and ");
		}
		if(null!=lsyzcx&&!lsyzcx.equals("")){
			hql.append("lsyzbj='"+lsyzcx+"' and ");
		}
		if(null!=zxswcldyz&&!zxswcldyz.equals("")){
			hql.append("ysxg='"+zxswcldyz+"' and ");
		}
		if(null!=start&&!start.equals("")||null!=end&&!end.equals("")){
			hql.append(" "+blhcx+" between '"+start+"' and '"+end+"' and ");
		}
		 String finalHQL=hql.toString();
	     finalHQL=finalHQL.substring(0,finalHQL.lastIndexOf("and")>0? finalHQL.lastIndexOf("and"):finalHQL.indexOf("where"));
		System.out.println(finalHQL);
	     return super.createQuery(finalHQL).setFirstResult((page-1)*rows).setMaxResults(rows).list();
	}

           

繼續閱讀