1.修改mongodb查询参数拼接规则

master
x_z 3 years ago
parent d4069455dc
commit 83cf4129ba

@ -32,7 +32,7 @@ public class CodesDao implements MongoBaseDao<WarehouseEntity, FilterWarehouseRe
if (null == query && null != filterWarehouseRequest) {
query = buildQuery(filterWarehouseRequest);
}
return mongoPageHelper.pageQuery(query, WarehouseEntity.class, page, size, MongoDBName.NAME_CODE);
return mongoPageHelper.pageQuery(query, WarehouseEntity.class, size, page, MongoDBName.NAME_CODE);
}
@Override

@ -31,7 +31,7 @@ public class CodesTempDao implements MongoBaseDao<WarehousetempEntity, FilterWar
if (null == query && null != filterWarehouseRequest) {
query = buildQuery(filterWarehouseRequest);
}
return mongoPageHelper.pageQuery(query, WarehousetempEntity.class, page, size, MongoDBName.NAME_CODE_TEMP);
return mongoPageHelper.pageQuery(query, WarehousetempEntity.class, size, page, MongoDBName.NAME_CODE_TEMP);
}
@Override

@ -33,7 +33,7 @@ public class InvProductDao implements MongoBaseDao<InvProductEntity, FilterInvPr
if (null == query && null != filterInvProductRequest) {
query = buildQuery(filterInvProductRequest);
}
return mongoPageHelper.pageQuery(query, InvProductEntity.class, page, size, MongoDBName.NAME_INV_PRODUCT);
return mongoPageHelper.pageQuery(query, InvProductEntity.class, size, page, MongoDBName.NAME_INV_PRODUCT);
}
@Override

@ -32,7 +32,7 @@ public class InvProductDetailDao implements MongoBaseDao<InvProductDetailEntity,
if (null == query && null != filterInvProductDetailRequest) {
query = buildQuery(filterInvProductDetailRequest);
}
return mongoPageHelper.pageQuery(query, InvProductDetailEntity.class, page, size, MongoDBName.NAME_INV_PRODUCT_DETAIL);
return mongoPageHelper.pageQuery(query, InvProductDetailEntity.class, size, page, MongoDBName.NAME_INV_PRODUCT_DETAIL);
}
@Override

@ -2,6 +2,7 @@ package com.glxp.udi.admin.mongo.dao;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.mongo.dao.base.MongoBaseDao;
@ -35,7 +36,7 @@ public class OrderDao implements MongoBaseDao<OrderMdEntity, OrderFilterRequest>
if (null == query && orderFilterRequest != null) {
query = buildQuery(orderFilterRequest);
}
return mongoPageHelper.pageQuery(query, OrderMdEntity.class, page, size, MongoDBName.NAME_ORDER);
return mongoPageHelper.pageQuery(query, OrderMdEntity.class, size, page, MongoDBName.NAME_ORDER);
}
@Override
@ -101,22 +102,36 @@ public class OrderDao implements MongoBaseDao<OrderMdEntity, OrderFilterRequest>
Query query = new Query();
Field[] fields = ReflectUtil.getFields(OrderFilterRequest.class);
for (Field field : fields) {
if (field.getName() != "page" && field.getName() != "limit") {
Object fieldValue = ReflectUtil.getFieldValue(orderFilterRequest, field);
if (ObjectUtil.isNotNull(fieldValue)) {
if (ObjectUtil.isNotEmpty(fieldValue) && StrUtil.isNotBlank(String.valueOf(fieldValue))) {
if ("id".equals(field.getName())) {
query.addCriteria(Criteria.where("orderId").is(fieldValue));
} else if ("invCodes".equals(field.getName())) {
query.addCriteria(Criteria.where("locStorageCode").in(fieldValue));
List invCodes = (List) fieldValue;
query.addCriteria(Criteria.where("locStorageCode").in(invCodes.toArray()));
} else if ("actDate".equals(field.getName())) {
query.addCriteria(Criteria.where("actDate").gte(fieldValue + " 00:00:00").andOperator(Criteria.where("actDate").lte(fieldValue + " 23:59:59")));
} else if ("isError".equals(field.getName())) {
query.addCriteria(Criteria.where("status").ne(fieldValue));
} else if ("receiveStatus".equals(field.getName())) {
break;
} else if ("checkReceiveStatus".equals(field.getName())) {
if ("true".equals(String.valueOf(fieldValue))) {
Object receiveStatus = ReflectUtil.getFieldValue(orderFilterRequest, "receiveStatus");
if (null != receiveStatus) {
query.addCriteria(Criteria.where("receiveStatus").is(fieldValue));
} else {
query.addCriteria(Criteria.where("receiveStatus").ne(0));
}
}
} else {
query.addCriteria(Criteria.where(field.getName()).is(fieldValue));
}
} else {
if ("receiveStatus".equals(field.getName())) {
query.addCriteria(Criteria.where("receiveStatus").ne(0));
if ("action".equals(field.getName())) {
query.addCriteria(Criteria.where("action").ne("StockCheck"));
}
}
}
}
@ -134,7 +149,7 @@ public class OrderDao implements MongoBaseDao<OrderMdEntity, OrderFilterRequest>
Field[] fields = ReflectUtil.getFields(OrderMdEntity.class);
for (Field field : fields) {
Object fieldValue = ReflectUtil.getFieldValue(orderMdEntity, field);
if (ObjectUtil.isNotEmpty(fieldValue)) {
if (ObjectUtil.isNotEmpty(fieldValue) && StrUtil.isNotBlank(String.valueOf(fieldValue))) {
if ("id".equals(field.getName())) {
query.addCriteria(Criteria.where("_id").is(fieldValue));
}
@ -154,7 +169,7 @@ public class OrderDao implements MongoBaseDao<OrderMdEntity, OrderFilterRequest>
Field[] fields = ReflectUtil.getFields(OrderMdEntity.class);
for (Field field : fields) {
Object fieldValue = ReflectUtil.getFieldValue(orderMdEntity, field);
if (ObjectUtil.isNotEmpty(fieldValue)) {
if (ObjectUtil.isNotEmpty(fieldValue) && StrUtil.isNotBlank(String.valueOf(fieldValue))) {
if (!field.getName().equals("id") && !field.getName().equals("orderId")) {
update.set(field.getName(), fieldValue);
}

@ -33,7 +33,7 @@ public class OrderDetailDao implements MongoBaseDao<ErpOrderEntity, FilterErpOrd
if (null == query && null != filterErpOrderRequest) {
query = buildQuery(filterErpOrderRequest);
}
return mongoPageHelper.pageQuery(query, ErpOrderEntity.class, page, size, MongoDBName.NAME_ORDER_DETAIL);
return mongoPageHelper.pageQuery(query, ErpOrderEntity.class, size, page, MongoDBName.NAME_ORDER_DETAIL);
}
@Override

Loading…
Cancel
Save