private final String SEARCH_HQL = "select new com.linghui.doimf.proprietor.priceback.formbean.ParentpayfeeForm"
+"(pay.id,pay.month,pay.parentid,pay.parentname,pay.banknumber,pay.nowmonthpayfee,pay.nopayfee,pay.changefee, "
+"pay.nextmonthpayfee, pay.nowpayfee, pay.paystate, "
+"pay.remark) "
+" from Parentpayfee pay where 1=1 ";
private final String ORDER_BY = "order by pay.id desc";
private String getHql1(ParentpayfeeForm model, String parentname) {
String year=model.getMonth();
String months=model.getMonth();
String paystate=model.getPaystate();
String parentid=model.getParentid();
StringBuffer hqlBuf=new StringBuffer(SEARCH_HQL);
if(null != parentname && !"".equals(parentname.trim())){
hqlBuf.append("and pay.parentname like '%"+parentname+"%' " );
}
if(null != year && null != parentid && !"".equals(parentid.trim())){
hqlBuf.append("and pay.parentid=:parentid " );
}
if(null != year && !"9999".equals(year) && null != months && !"13".equals(months)){
hqlBuf.append("and pay.month=:month " );
}
else if(null!=year&&!"9999".equals(year)){hqlBuf.append("and substr(pay.month,1,4)=:month " ); //java: yearmonth=20090424,yearmonth.substring(0,5);最后一位不现实的,结果是2009
} //SQL: substr(yearmonth,1,4) 结果是2009
if(null != paystate && !"3".equals(paystate) && "0".equals(paystate)){
hqlBuf.append("and pay.paystate='0' ");
}
else if(null != paystate&& ! "3".equals(paystate) && "1".equals(paystate)){
hqlBuf.append("and pay.paystate='1' ");
}
else if(null != paystate&& ! "3".equals(paystate) && "2".equals(paystate)){
hqlBuf.append("and pay.paystate='2' ");
}
hqlBuf.append(ORDER_BY);
return hqlBuf.toString();
}
private Map getParamMap(ParentpayfeeForm model) {
String year=model.getYear();
String month=model.getMonth();
String pid=model.getParentid();
String ym ;
Map paramMap = new HashMap();
if(null !=pid && !"".equals(pid.trim())){
paramMap.put("parentid", pid);
}
if(!"9999".equals(year) && null != year && null != month && !"13".equals(month)){
ym=year+month;
paramMap.put("month", ym);
}
else if(null!=year&&!"9999".equals(year)){
paramMap.put("month", year);
}
return paramMap;
}
public List searchParentpayfeeParentname(ParentpayfeeForm model,PageSortModel pageModel, String parentname, Logger logger,boolean isAll) throws ApplicationException {
String hqlString=this.getHql1(model,parentname);
Map paramMap = this.getParamMap(model);
AllEntityNumber allnumber=new AllEntityNumber();
List result=null;
if(isAll){
result=this.searchObjectByHQL(hqlString, paramMap, -1, -1, allnumber,logger, null);
}else{
result=this.searchObjectByHQL(hqlString, paramMap, pageModel.getPageSize(), pageModel.getPageSize(), allnumber, logger, null);
}
pageModel.setTotalRows(allnumber.getAllRow());
return result;
}