|
|
|
@ -14,6 +14,7 @@ import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
@ -118,12 +119,10 @@ public class BsonPackTool {
|
|
|
|
|
* @param isShowTime 是否包含时分秒
|
|
|
|
|
*/
|
|
|
|
|
public static Bson timeBuilder( String startDate,String endDate, String columnName, Bson bson, boolean isShowTime) {
|
|
|
|
|
startDate = getSafeParam(startDate);
|
|
|
|
|
endDate = getSafeParam(endDate);
|
|
|
|
|
|
|
|
|
|
if (startDate == null || startDate.trim().length() == 0) {
|
|
|
|
|
startDate = "1900-01-01";
|
|
|
|
|
} else {
|
|
|
|
|
startDate = getSafeParam(startDate);
|
|
|
|
|
startDate = startDate.trim();
|
|
|
|
|
}
|
|
|
|
|
if (isShowTime && startDate.trim().length()<=11) {
|
|
|
|
@ -132,6 +131,7 @@ public class BsonPackTool {
|
|
|
|
|
if (endDate == null || endDate.trim().length() == 0) {
|
|
|
|
|
endDate = "2100-01-01";
|
|
|
|
|
} else {
|
|
|
|
|
endDate = getSafeParam(endDate);
|
|
|
|
|
endDate = endDate.trim();
|
|
|
|
|
}
|
|
|
|
|
if (isShowTime&& endDate.trim().length()<=11) {
|
|
|
|
@ -158,18 +158,19 @@ public class BsonPackTool {
|
|
|
|
|
* @param date 开始日期和结束日期,以逗号分隔(分为开始时间和结束时间)
|
|
|
|
|
* @param columnName HQL里对应的时间字段
|
|
|
|
|
* @param bson 封装的bson
|
|
|
|
|
* @param showTaday 如果没有开始时间和结束时间,是否查询当天时间,还是查询所有时间。true:查询当天时间,false:查询所有
|
|
|
|
|
* @param showToday 如果没有开始时间和结束时间,是否查询当天时间,还是查询所有时间。true:查询当天时间,false:查询所有
|
|
|
|
|
* @param isShowTime 是否包含时分秒
|
|
|
|
|
*/
|
|
|
|
|
public static Bson timeBuilder( String date, String columnName, Bson bson, Boolean showTaday,boolean isShowTime) {
|
|
|
|
|
public static Bson timeBuilder( String date, String columnName, Bson bson, Boolean showToday,boolean isShowTime) {
|
|
|
|
|
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))){
|
|
|
|
|
if(date.length() == 1 || ",".equals(date)){
|
|
|
|
|
//只有一个逗号
|
|
|
|
|
date = "";
|
|
|
|
|
}
|
|
|
|
|
if(date != null && date.trim().length() > 0){
|
|
|
|
|
|
|
|
|
|
String[] time = date.split(",");
|
|
|
|
|
if(time.length == 1){
|
|
|
|
|
//只有开始日期,没有结束日期
|
|
|
|
@ -213,7 +214,7 @@ public class BsonPackTool {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (showTaday) {
|
|
|
|
|
if (showToday) {
|
|
|
|
|
if (isShowTime) {
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
@ -373,7 +374,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumEqualPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -395,8 +395,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumEqualPackForZero(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) >= 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -418,7 +416,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumWithZeroEqualPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) >= 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -440,7 +437,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumBiggerPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gt(columnName, data)
|
|
|
|
@ -462,7 +458,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumSmallerPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.lt(columnName, data)
|
|
|
|
@ -484,7 +479,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getDoubleBiggerPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Double.parseDouble(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gt(columnName, data)
|
|
|
|
@ -506,7 +500,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getDoubleSmallerPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Double.parseDouble(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.lt(columnName, data)
|
|
|
|
@ -528,7 +521,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumEqualPack(Object data,String columnName, Bson bson,Integer expvalue) {
|
|
|
|
|
if(data!=null&&Long.parseLong(data.toString()) > (long)expvalue){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -550,7 +542,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumEqualPackDouble(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null&&Double.parseDouble(data.toString()) > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -572,7 +563,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumEqualPackDouble(Object data,String columnName, Bson bson,Integer expvalue) {
|
|
|
|
|
if(data!=null&&Double.parseDouble(data.toString()) > (double)expvalue){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
@ -594,7 +584,6 @@ public class BsonPackTool {
|
|
|
|
|
*/
|
|
|
|
|
public static Bson getNumNOEqualPack(Object data,String columnName, Bson bson) {
|
|
|
|
|
if(data!=null){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.ne(columnName, data)
|
|
|
|
|