|
|
|
@ -30,9 +30,6 @@ public class HqlPack {
|
|
|
|
|
* @param isShowTime 是否包含时分秒
|
|
|
|
|
*/
|
|
|
|
|
public static void timeBuilder( String startDate,String endDate, String columnName, StringBuffer result, boolean isShowTime) {
|
|
|
|
|
startDate = getSafeParam(startDate);
|
|
|
|
|
endDate = getSafeParam(endDate);
|
|
|
|
|
|
|
|
|
|
if (startDate == null || startDate.trim().length() == 0) {
|
|
|
|
|
startDate = "1900-01-01";
|
|
|
|
|
} else {
|
|
|
|
@ -49,6 +46,9 @@ public class HqlPack {
|
|
|
|
|
if (isShowTime&& endDate.trim().length()<=11) {
|
|
|
|
|
endDate+= " 23:59:59";
|
|
|
|
|
}
|
|
|
|
|
startDate = getSafeParam(startDate);
|
|
|
|
|
endDate = getSafeParam(endDate);
|
|
|
|
|
|
|
|
|
|
result.append(" and model." + columnName + " between '" + startDate + "' and '" + endDate + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -61,14 +61,15 @@ public class HqlPack {
|
|
|
|
|
* @param isShowTime 是否包含时分秒
|
|
|
|
|
*/
|
|
|
|
|
public static void timeBuilder( String date, String columnName, StringBuffer result, Boolean showTaday,boolean isShowTime) {
|
|
|
|
|
date = getSafeParam(date);
|
|
|
|
|
|
|
|
|
|
String today = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date());
|
|
|
|
|
if(date != null && date.trim().length() > 0 && (date.length() == 1 || ",".equals(date))){
|
|
|
|
|
//只有一个逗号
|
|
|
|
|
date = "";
|
|
|
|
|
}
|
|
|
|
|
if(date != null && date.trim().length() > 0){
|
|
|
|
|
date = getSafeParam(date);
|
|
|
|
|
|
|
|
|
|
String today = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date());
|
|
|
|
|
if(date != null && date.trim().length() > 0 && (date.length() == 1 || ",".equals(date))){
|
|
|
|
|
//只有一个逗号
|
|
|
|
|
date = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] time = date.split(",");
|
|
|
|
|
if(time.length == 1){
|
|
|
|
|
//只有开始日期,没有结束日期
|
|
|
|
@ -410,4 +411,56 @@ public class HqlPack {
|
|
|
|
|
result.append(" and dbo.CheckStrInArr('"+data+"',model."+columnName+")>0 ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封装long或者int的整数对象成like语句
|
|
|
|
|
* @param data 对象值
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param result
|
|
|
|
|
*/
|
|
|
|
|
public static void getNumLikerPack(Object data,String columnName, StringBuffer result) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
result.append(" and model."+columnName+" like '%" + data + "%'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封装String对象成like语句
|
|
|
|
|
* @param data 对象值
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param result
|
|
|
|
|
*/
|
|
|
|
|
public static void getNumLikerPackOr(Object data,String columnName, StringBuffer result) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
result.append(" or model."+columnName+" like '%" + data + "%'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封装String对象成like语句(右侧模糊)
|
|
|
|
|
* @param data 对象值
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param result
|
|
|
|
|
*/
|
|
|
|
|
public static void getNumRightLikerPack(Object data,String columnName, StringBuffer result) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
result.append(" and model."+columnName+" like '" + data + "%'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封装String对象成like语句(左侧模糊)
|
|
|
|
|
* @param data 对象值
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param result
|
|
|
|
|
*/
|
|
|
|
|
public static void getNumLeftLikerPack(Object data,String columnName, StringBuffer result) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
result.append(" and model."+columnName+" like '%" + data + "'");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|