|
|
@ -106,6 +106,32 @@ public class HqlPack {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 封装日期
|
|
|
|
|
|
|
|
* @param date 日期,需要和时间字段的值格式相同
|
|
|
|
|
|
|
|
* @param startColumnName HQL里对应的开始时间字段
|
|
|
|
|
|
|
|
* @param endColumnName HQL里对应的结束时间字段
|
|
|
|
|
|
|
|
* @param result 封装的HQL
|
|
|
|
|
|
|
|
* @param isShowTime 是否包含时分秒
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static void getTimeBetweenCol(String date, String startColumnName, String endColumnName, StringBuffer result,boolean isShowTime) {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
if(date != null && date.trim().length() > 0) {
|
|
|
|
|
|
|
|
date = getSafeParam(date);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
date = sdf.format(new Date());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!isShowTime) {
|
|
|
|
|
|
|
|
date = date.substring(0,10);
|
|
|
|
|
|
|
|
result.append(" and '"+date+"' between substring(model." + startColumnName + ",1,10) and substring(model." + endColumnName + ",1,10)");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}else if(date.trim().length()<=11){
|
|
|
|
|
|
|
|
date+= " 00:00:00";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.append(" and '"+date+"' between model." + startColumnName + " and model." + endColumnName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 封装String对象成order by排序
|
|
|
|
* 封装String对象成order by排序
|
|
|
|
* @param columnName 列名
|
|
|
|
* @param columnName 列名
|
|
|
|