本帖最后由 xuchunlin2011 于 2013-09-26 10:05:53 编辑

解决方案 »

  1.   

    这是我的动态评价方法,没有问题 :
    public String createHql(Map<String,String> map){
    String hql="";
    if(!"".equals(map.get("year")) && map.get("year") != null){
     hql += " and reportyear ="+map.get("year");
    }
    if(!"".equals(map.get("month")) && map.get("month") != null){
     hql += " and to_number(reportmonth) ="+map.get("month");
    }
    if(!"".equals(map.get("leimonth")) && map.get("leimonth") != null){
     hql += " and to_number(reportmonth) >="+map.get("leimonth");
    }
    if(!"".equals(map.get("reporttype")) && map.get("reporttype") != null){
     hql += " and reporttype ="+map.get("reporttype");
    }
    if(!"".equals(map.get("isreport")) && map.get("isreport") != null){
     hql += " and isreport ="+map.get("isreport");
    }
    if(!"".equals(map.get("reportstatus")) && map.get("reportstatus") != null){
     hql += " and reportstatus ="+map.get("reportstatus");//是否存盘或者上报
    }
    if(!"".equals(map.get("checkisreport")) && map.get("checkisreport") != null){
     hql += " and reportstatus  >=0 ";//是否存盘或者上报
    }
    if(!"".equals(map.get("userid")) && map.get("userid") != null){
     hql += " and UUsrUser36.userid ="+map.get("userid");
    }
    if(!"".equals(map.get("departmentid")) && map.get("departmentid") != null){
     hql += " and QCmnDepartment23.departmentid ="+map.get("departmentid");
    }
    if(!"".equals(map.get("operpointid")) && map.get("operpointid") != null){
     hql += " and QCmnOperatepoint20.operatepointid ="+map.get("operpointid");
    }
    if(!"".equals(map.get("notJuoperpointid")) && map.get("notJuoperpointid") != null){
     hql += " and QCmnOperatepoint20.operatepointid != 153 ";
    }
    if(!"".equals(map.get("isaggregateblock")) && map.get("isaggregateblock") != null){
     hql += " and isaggregateblock="+map.get("isaggregateblock");
    }
    if(!"".equals(map.get("reportDateStart")) && map.get("reportDateStart") != null){
         hql += " and reportdate>=to_date('"+map.get("reportDateStart")+"','yyyy-mm-dd')";
    }
    if(!"".equals(map.get("reportDateStop")) && map.get("reportDateStop") != null){
         hql += " and reportdate<=to_date('"+map.get("reportDateStop")+"','yyyy-mm-dd')";
    }
    if(!"".equals(map.get("order")) && map.get("order") != null){
    hql+=" order by reportdate desc";
    }
    if(!"".equals(map.get("monthOrder")) && map.get("monthOrder") != null){
    hql+=" order by to_number(reportmonth) desc";
    }
    return hql;
    }