Authored by hugufei

代码优化

... ... @@ -61,75 +61,6 @@ public class ExtendFilterHelper {
return null;
}
/**
* 品牌新品
* @return
*/
public static QueryBuilder brandNewFilter (List<Integer> brandIds){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
//must
filter.must(brandIdsFilter(brandIds));
filter.must(newFilter());
//must not
filter.mustNot(forbiddenFlowFilter());
filter.mustNot(latestReducePriceFilter());
filter.mustNot(isGlobalFilter());
filter.mustNot(breakSizeFilter());
return filter;
}
/**
* 品牌新降价
* @return
*/
public static QueryBuilder brandReducePrice (List<Integer> brandIds){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
//must
filter.must(brandIdsFilter(brandIds));
filter.must(latestReducePriceFilter());
//must not
filter.mustNot(forbiddenFlowFilter());
filter.mustNot(newFilter());
filter.mustNot(isGlobalFilter());
filter.mustNot(breakSizeFilter());
return filter;
}
/**
* 品牌人气
* @return
*/
public static QueryBuilder brandHeatValue (List<Integer> brandIds){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
//must
filter.must(brandIdsFilter(brandIds));
//must not
filter.mustNot(forbiddenFlowFilter());
filter.mustNot(newFilter());
filter.mustNot(latestReducePriceFilter());
filter.mustNot(isGlobalFilter());
filter.mustNot(breakSizeFilter());
return filter;
}
/**
* 品牌新开促销
* @return
*/
public static QueryBuilder brandPromotion (List<Integer> brandIds){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
//must
filter.must(brandIdsFilter(brandIds));
filter.must(isNewPromotionFilter());
//must not
filter.mustNot(forbiddenFlowFilter());
filter.mustNot(newFilter());
filter.mustNot(latestReducePriceFilter());
filter.mustNot(isGlobalFilter());
filter.mustNot(breakSizeFilter());
return filter;
}
/**
* 【品类+品牌】新品
... ... @@ -216,14 +147,6 @@ public class ExtendFilterHelper {
return QueryBuilders.rangeQuery(ProductIndexEsField.breakSizePercent).gt(50);
}
private static QueryBuilder brandIdsFilter (List<Integer> brandIds){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
if (brandIds != null && !brandIds.isEmpty()) {
filter.must(QueryBuilders.termsQuery(ProductIndexEsField.brandId, brandIds));
}
return filter;
}
private static QueryBuilder sortBrandIdFilter (SortBrand sortBrand){
BoolQueryBuilder filter = QueryBuilders.boolQuery();
filter.must(QueryBuilders.termQuery(ProductIndexEsField.brandId, sortBrand.getBrandId()));
... ...
... ... @@ -52,7 +52,7 @@ public class QueryUserPersionalFactorBean {
//3、join获取最终的结果
begin = System.currentTimeMillis();
List<SortBrand> sortBrandList = this.getSortBrandListWithSort(pageFactor, userFactorNew);
List<SortPriceAreas> sortPriceAreasList = userFactorNew.getSortPriceAreasList();
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactorNew);
//4、构造UserPersonalFactorRspNew
UserPersonalFactor userPersonalFactor = new UserPersonalFactor(sortBrandList, sortPriceAreasList,userFactorNew.getVector());
if(userRecallRequest.getUid()==13420925){
... ... @@ -95,4 +95,18 @@ public class QueryUserPersionalFactorBean {
return results;
}
/**
* 【品类+价格带】
* @param pageFactor
* @param userFactorNew
* @return
*/
private List<SortPriceAreas> getSortPriceAreasListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew){
List<SortPriceAreas> sortPriceAreas = userFactorNew.getSortPriceAreasList();
if(sortPriceAreas==null|| sortPriceAreas.isEmpty()){
return new ArrayList<>();
}
return sortPriceAreas;
}
}
... ...
... ... @@ -33,29 +33,6 @@ class UserPersionalFactorComponent {
* @param udid
* @return
*/
public UserPersonalFactorRsp queryUserPersionalFactor(int uid, String udid) {
try {
UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid);
JSONObject result = serviceCaller.call(SERVICE_NAME, userPersionalFactorReq, JSONObject.class, timeOut);
JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
UserPersonalFactorRsp rsp = JSON.toJavaObject(userPersonalFactorRspJSon, UserPersonalFactorRsp.class);
if (rsp == null || rsp.getBrandIds() == null || rsp.getSortPriceAreas() == null) {
return new UserPersonalFactorRsp();
}
return rsp;
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
return new UserPersonalFactorRsp();
}
}
/**
* 获取用户的个性化因子
*
* @param uid
* @param udid
* @return
*/
public UserPersonalFactorRspNew queryUserPersionalFactorNew(int uid, String udid, PagePersonalFactor pageFactor) {
try {
UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid, udid);
... ...
... ... @@ -7,30 +7,16 @@ import java.util.List;
public class UserPersonalFactor {
private List<Integer> brandIds;
private List<SortBrand> sortBrandList;
private List<SortPriceAreas> sortPriceAreasList;
private String vector;
public UserPersonalFactor(List<Integer> brandIds, String vector) {
this.brandIds = brandIds;
this.vector = vector;
}
public UserPersonalFactor(List<SortBrand> sortBrandList, List<SortPriceAreas> sortPriceAreasList, String vector) {
this.sortBrandList = sortBrandList;
this.sortPriceAreasList = sortPriceAreasList;
this.vector = vector;
}
public List<Integer> getBrandIds() {
return brandIds;
}
public void setBrandIds(List<Integer> brandIds) {
this.brandIds = brandIds;
}
public List<SortBrand> getSortBrandList() {
return sortBrandList;
}
... ...