|
@@ -10,10 +10,7 @@ import com.uas.search.constant.model.SPage;
|
|
|
import com.uas.search.exception.SearchException;
|
|
import com.uas.search.exception.SearchException;
|
|
|
import com.uas.search.grouping.DistinctGroupCollector;
|
|
import com.uas.search.grouping.DistinctGroupCollector;
|
|
|
import com.uas.search.grouping.GoodsGroupCollector;
|
|
import com.uas.search.grouping.GoodsGroupCollector;
|
|
|
-import com.uas.search.model.Brand;
|
|
|
|
|
-import com.uas.search.model.Component;
|
|
|
|
|
-import com.uas.search.model.Goods;
|
|
|
|
|
-import com.uas.search.model.Kind;
|
|
|
|
|
|
|
+import com.uas.search.model.*;
|
|
|
import com.uas.search.service.SearchService;
|
|
import com.uas.search.service.SearchService;
|
|
|
import com.uas.search.sort.StringFieldComparatorSource;
|
|
import com.uas.search.sort.StringFieldComparatorSource;
|
|
|
import com.uas.search.util.CollectionUtils;
|
|
import com.uas.search.util.CollectionUtils;
|
|
@@ -875,7 +872,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
throw new SearchException("排序字段不可为空:" + s);
|
|
throw new SearchException("排序字段不可为空:" + s);
|
|
|
}
|
|
}
|
|
|
switch (s.getField()) {
|
|
switch (s.getField()) {
|
|
|
- // 价格
|
|
|
|
|
|
|
+ // 库存
|
|
|
case GO_RESERVE:
|
|
case GO_RESERVE:
|
|
|
sortFieldList.add(new SortField(SearchConstants.GOODS_GO_RESERVE_FIELD, Type.DOUBLE,
|
|
sortFieldList.add(new SortField(SearchConstants.GOODS_GO_RESERVE_FIELD, Type.DOUBLE,
|
|
|
s.isReverse()));
|
|
s.isReverse()));
|
|
@@ -964,6 +961,28 @@ public class SearchServiceImpl implements SearchService {
|
|
|
* @param query 原查询
|
|
* @param query 原查询
|
|
|
*/
|
|
*/
|
|
|
private void setGoodsFilter(Map<FilterField, Object> filters, BooleanQuery query) {
|
|
private void setGoodsFilter(Map<FilterField, Object> filters, BooleanQuery query) {
|
|
|
|
|
+ Object status;
|
|
|
|
|
+ // 筛选状态
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(filters) && !StringUtils.isEmpty(filters.get(FilterField.GOODS_STATUS))) {
|
|
|
|
|
+ status = filters.get(FilterField.GOODS_STATUS);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ status = Arrays.asList(TradeGoods.VALID_STATUS);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 批次 id 不为空时,对状态过滤
|
|
|
|
|
+ Query goIdNotNullQuery = SearchUtils.getNotNullQuery(SearchConstants.GOODS_GO_ID_FIELD);
|
|
|
|
|
+ BooleanQuery q1 = new BooleanQuery();
|
|
|
|
|
+ q1.add(goIdNotNullQuery, Occur.MUST);
|
|
|
|
|
+ filter(status, SearchConstants.GOODS_GO_STATUS_FIELD, q1);
|
|
|
|
|
+ // 或者批次 id 为空(此时是器件)
|
|
|
|
|
+ BooleanQuery q2 = new BooleanQuery();
|
|
|
|
|
+ q2.add(SearchUtils.getNotNullQuery(SearchConstants.GOODS_CMP_ID_FIELD), Occur.SHOULD);
|
|
|
|
|
+ q2.add(goIdNotNullQuery, Occur.MUST_NOT);
|
|
|
|
|
+
|
|
|
|
|
+ BooleanQuery booleanQuery = new BooleanQuery();
|
|
|
|
|
+ booleanQuery.add(q1, Occur.SHOULD);
|
|
|
|
|
+ booleanQuery.add(q2, Occur.SHOULD);
|
|
|
|
|
+ query.add(booleanQuery, Occur.FILTER);
|
|
|
|
|
+
|
|
|
if (CollectionUtils.isEmpty(filters)) {
|
|
if (CollectionUtils.isEmpty(filters)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -987,24 +1006,6 @@ public class SearchServiceImpl implements SearchService {
|
|
|
filter(filters.get(FilterField.GOODS_CRNAME), SearchConstants.GOODS_CRNAME_FIELD, query);
|
|
filter(filters.get(FilterField.GOODS_CRNAME), SearchConstants.GOODS_CRNAME_FIELD, query);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 筛选状态
|
|
|
|
|
- if (!StringUtils.isEmpty(filters.get(FilterField.GOODS_STATUS))) {
|
|
|
|
|
- // 批次 id 不为空时,对状态过滤
|
|
|
|
|
- Query goIdNotNullQuery = SearchUtils.getNotNullQuery(SearchConstants.GOODS_GO_ID_FIELD);
|
|
|
|
|
- BooleanQuery q1 = new BooleanQuery();
|
|
|
|
|
- q1.add(goIdNotNullQuery, Occur.MUST);
|
|
|
|
|
- filter(filters.get(FilterField.GOODS_STATUS), SearchConstants.GOODS_GO_STATUS_FIELD, q1);
|
|
|
|
|
- // 或者批次 id 为空(此时是器件)
|
|
|
|
|
- BooleanQuery q2 = new BooleanQuery();
|
|
|
|
|
- q2.add(SearchUtils.getNotNullQuery(SearchConstants.GOODS_CMP_ID_FIELD), Occur.SHOULD);
|
|
|
|
|
- q2.add(goIdNotNullQuery, Occur.MUST_NOT);
|
|
|
|
|
-
|
|
|
|
|
- BooleanQuery booleanQuery = new BooleanQuery();
|
|
|
|
|
- booleanQuery.add(q1, Occur.SHOULD);
|
|
|
|
|
- booleanQuery.add(q2, Occur.SHOULD);
|
|
|
|
|
- query.add(booleanQuery, Occur.FILTER);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 价格筛选
|
|
// 价格筛选
|
|
|
Object minPriceRmb = filters.get(FilterField.GOODS_MINPRICERMB);
|
|
Object minPriceRmb = filters.get(FilterField.GOODS_MINPRICERMB);
|
|
|
Object maxPriceRmb = filters.get(FilterField.GOODS_MAXPRICERMB);
|
|
Object maxPriceRmb = filters.get(FilterField.GOODS_MAXPRICERMB);
|