|
|
|
@ -76,8 +76,13 @@ public class BsonPackTool {
|
|
|
|
|
|
|
|
|
|
//查询
|
|
|
|
|
MongoCollection<Document> collection = mongoOperations.getCollection(tableName);
|
|
|
|
|
collection.find(bson).skip(skip).limit(limit).forEach(saveBlock);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
collection.count();
|
|
|
|
|
collection.find().skip(skip).limit(limit).forEach(saveBlock);
|
|
|
|
|
}else {
|
|
|
|
|
collection.count(bson);
|
|
|
|
|
collection.find(bson).skip(skip).limit(limit).forEach(saveBlock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return newLins;
|
|
|
|
|
}
|
|
|
|
@ -95,8 +100,9 @@ public class BsonPackTool {
|
|
|
|
|
List<Document> list = new ArrayList<>();
|
|
|
|
|
long count = mongoOperations.getCollection(tableName).count(bson);
|
|
|
|
|
int loops = (int)((count + pageSize - 1) / pageSize);
|
|
|
|
|
List<Document> newFinds = null;
|
|
|
|
|
for(int i = 0; i < loops; i++) {
|
|
|
|
|
List<Document> newFinds = query(mongoOperations, tableName, bson, i * pageSize, pageSize);
|
|
|
|
|
newFinds = query(mongoOperations, tableName, bson, i * pageSize, pageSize);
|
|
|
|
|
list.addAll(newFinds);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
@ -131,11 +137,18 @@ public class BsonPackTool {
|
|
|
|
|
if (isShowTime&& endDate.trim().length()<=11) {
|
|
|
|
|
endDate+= " 23:59:59";
|
|
|
|
|
}
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gte(columnName, startDate), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, endDate) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gte(columnName,startDate), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName,endDate) //小于等于结束日期
|
|
|
|
|
Filters.gte(columnName, startDate), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, endDate) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
@ -160,11 +173,16 @@ public class BsonPackTool {
|
|
|
|
|
String[] time = date.split(",");
|
|
|
|
|
if(time.length == 1){
|
|
|
|
|
//只有开始日期,没有结束日期
|
|
|
|
|
if(bson == null){
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.regex(columnName, "^" + time[0]) //like 日期%^
|
|
|
|
|
);
|
|
|
|
|
}else {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
//Filters.eq(columnName,time[0])
|
|
|
|
|
Filters.regex(columnName, "^"+time[0]) //like 日期%^
|
|
|
|
|
Filters.regex(columnName, "^" + time[0]) //like 日期%^
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}else if (time.length == 2 && ((time[0] != null && time[0].trim().length() > 0) || (time[1] != null & time[1].trim().length() > 0))) {
|
|
|
|
|
if (time[0] == null || time[0].trim().length() == 0) {
|
|
|
|
|
time[0] = "1900-01-01";
|
|
|
|
@ -182,30 +200,50 @@ public class BsonPackTool {
|
|
|
|
|
if (isShowTime&& time[1].trim().length()<=11) {
|
|
|
|
|
time[1]+= " 23:59:59";
|
|
|
|
|
}
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gte(columnName, time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1]) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gte(columnName,time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName,time[1]) //小于等于结束日期
|
|
|
|
|
Filters.gte(columnName, time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1]) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (showTaday) {
|
|
|
|
|
if (isShowTime) {
|
|
|
|
|
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gte(columnName, time[0] + " 00:00:00"), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1] + " 23:59:59") //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gte(columnName,time[0] + " 00:00:00"), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName,time[1] + " 23:59:59") //小于等于结束日期
|
|
|
|
|
Filters.gte(columnName, time[0] + " 00:00:00"), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1] + " 23:59:59") //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.gte(columnName, time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1]) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gte(columnName,time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName,time[1]) //小于等于结束日期
|
|
|
|
|
Filters.gte(columnName, time[0]), //大于等于开始日期
|
|
|
|
|
Filters.lte(columnName, time[1]) //小于等于结束日期
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -219,11 +257,17 @@ public class BsonPackTool {
|
|
|
|
|
if (str != null && str.trim().length() > 0) {
|
|
|
|
|
str = getSafeParam(str);
|
|
|
|
|
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.regex(columnName, str) //like
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.regex(columnName, str) //like
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
@ -238,6 +282,11 @@ public class BsonPackTool {
|
|
|
|
|
if (str != null && str.trim().length() > 0) {
|
|
|
|
|
str = getSafeParam(str);
|
|
|
|
|
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.or(
|
|
|
|
|
Filters.regex(columnName, str) //like
|
|
|
|
|
);
|
|
|
|
|
}else {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.or(
|
|
|
|
@ -245,6 +294,7 @@ public class BsonPackTool {
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -257,11 +307,17 @@ public class BsonPackTool {
|
|
|
|
|
public static Bson getStringRightLikerPack(String str,String columnName, Bson bson) {
|
|
|
|
|
if (str != null && str.trim().length() > 0) {
|
|
|
|
|
str = getSafeParam(str);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.regex(columnName, str + "^") //like
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.regex(columnName, str + "^") //like
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -274,11 +330,17 @@ public class BsonPackTool {
|
|
|
|
|
public static Bson getStringLeftLikerPack(String str,String columnName, Bson bson) {
|
|
|
|
|
if (str != null && str.trim().length() > 0) {
|
|
|
|
|
str = getSafeParam(str);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.regex(columnName, "^" + str) //like
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.regex(columnName, "^" + str) //like
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -290,11 +352,17 @@ public class BsonPackTool {
|
|
|
|
|
public static Bson getStringEqualPack(String data,String columnName, Bson bson) {
|
|
|
|
|
if(data != null && data.trim().length() > 0){
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -306,11 +374,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -322,11 +396,18 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -338,11 +419,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -354,11 +441,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gt(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -370,11 +463,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.lt(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -386,11 +485,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.gt(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -402,11 +507,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.lt(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -418,11 +529,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -434,11 +551,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -450,11 +573,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.eq(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -466,11 +595,17 @@ 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)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.ne(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -483,11 +618,17 @@ public class BsonPackTool {
|
|
|
|
|
public static Bson getInPack(String data,String columnName, Bson bson){
|
|
|
|
|
if (data!=null&&data.trim().length()>0) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.in(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.in(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -513,11 +654,17 @@ public class BsonPackTool {
|
|
|
|
|
data += "'" + dataArray[i] + "',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.in(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.in(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -543,11 +690,17 @@ public class BsonPackTool {
|
|
|
|
|
data += "'" + dataArray[i] + "',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.nin(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.nin(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -560,11 +713,17 @@ public class BsonPackTool {
|
|
|
|
|
public static Bson getNotInPack(String data,String columnName, Bson bson){
|
|
|
|
|
if (data!=null&&data.trim().length()>0) {
|
|
|
|
|
data = getSafeParam(data);
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
Filters.nin(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
bson = Filters.and(
|
|
|
|
|
bson,
|
|
|
|
|
Filters.nin(columnName, data)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bson;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|