Authored by hugufei

去除pi索引中的无效字段

... ... @@ -56,17 +56,9 @@ public class GeneralBuilder {
productIndexBO.setGenderS(tblProduct.getGender().replace('1', '男').replace('2', '女').replace("3", "男/女"));
}
productIndexBO.setIsSpecial("N");
productIndexBO.setIsHot("N");
productIndexBO.setIshot(2);
productIndexBO.setIspromotion(0);
productIndexBO.setIsAdvance("N");
productIndexBO.setIsadvance(2);
productIndexBO.setIsAuditing("N");
productIndexBO.setIsauditing(2);
productIndexBO.setAttribute(1);
productIndexBO.setIsDown("N");
productIndexBO.setIsdown(2);
productIndexBO.setIsrecommend(2);
productIndexBO.setIsOutlets(2);
if (null != tblProduct.getShelfTime()) {
productIndexBO.setShelveTime(tblProduct.getShelfTime());
... ...
... ... @@ -33,15 +33,12 @@ public class ShowStatusBuilder {
isShow = true;
}
productIndexBO.setStatus(isShow ? 1 : 0);
productIndexBO.setIsSales(productIndexBO.getStatus() == 1 ? "Y" : "N");
productIndexBO.setIssales(productIndexBO.getIsSales().equals("Y") ? 1 : 2);
productIndexBO.setIsSales(productIndexBO.getStatus() == 1 ? "Y" : "N");
// 判断库存状态
if (tblProduct.getStockStatus() != null) {
boolean hasStock = tblProduct.getStockStatus().equals("1") ? true : false;
productIndexBO.setStorageNum(isShow && hasStock ? new BigDecimal(100) : BigDecimal.ZERO);
productIndexBO.setIsSoonSoldOut("N");
productIndexBO.setIsSoldOut("N");
productIndexBO.setSoldOut(1);
}
return productIndexBO;
}
... ...
... ... @@ -30,8 +30,6 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqLi
if (productSizesBOList == null || productSizesBOList.isEmpty()) {
indexData.put("storageNum", 0);
indexData.put("isSoonSoldOut", "Y");
indexData.put("isSoldOut", "Y");
indexData.put("soldOut", 0);
indexData.put("sizeIds", "");
indexData.put("sizeNames", "");
indexData.put("breakSizePercent", 100);
... ... @@ -42,8 +40,6 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqLi
ProductSizesBO productSizesBO = productSizesBOList.get(0);
indexData.put("storageNum", productSizesBO.getStorageNum());
indexData.put("isSoonSoldOut", productSizesBO.getIsSoonSoldOut());
indexData.put("isSoldOut", productSizesBO.getIsSoldOut());
indexData.put("soldOut", productSizesBO.getSoldOut());
indexData.put("sizeIds", productSizesBO.getSizeIds());
indexData.put("sizeNames", productSizesBO.getSizeNames());
indexData.put("breakSizePercent", productSizesBO.getBreakSizePercent());
... ...
... ... @@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ProductSearchService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.ProductSearch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -87,20 +89,17 @@ public class ProductSearchMqListener extends AbstractIndexMqListener {
// 2、生成商品索引数据
Map<String, Object> indexData = new HashMap<String, Object>();
if (productSearch.getProjectId() == 1 && productSearch.getModelId() == 1) {
indexData.put("productId", productId);
indexData.put("brandWeight", productSearch.getIntValue());
// indexData.put("sortWeight", 0);
indexData.put(ProductIndexEsField.productId, productId);
indexData.put(ProductIndexEsField.brandWeight, productSearch.getIntValue());
// indexData.put("shopWeight", 0);
} else if (productSearch.getProjectId() == 4 && productSearch.getModelId() == 1) {
indexData.put("productId", productId);
indexData.put("sortWeight", productSearch.getIntValue());
indexData.put(ProductIndexEsField.productId, productId);
// indexData.put("brandWeight", 0);
// indexData.put("shopWeight", 0);
} else if (productSearch.getProjectId() == 5 && productSearch.getModelId() == 1) {
indexData.put("productId", productId);
indexData.put(ProductIndexEsField.productId, productId);
// indexData.put("brandWeight", 0);
// indexData.put("sortWeight", 0);
indexData.put("shopWeight", productSearch.getIntValue());
indexData.put(ProductIndexEsField.shopWeight, productSearch.getIntValue());
}
// 3、更新商品索引数据
... ...
... ... @@ -92,27 +92,12 @@
"islimited": {
"type": "keyword"
},
"ishot": {
"type": "long"
},
"isHot": {
"type": "keyword"
},
"isspecial": {
"type": "long"
},
"isSpecial": {
"type": "keyword"
},
"issales": {
"type": "long"
},
"isSales": {
"type": "keyword"
},
"isadvance": {
"type": "long"
},
"isAdvance": {
"type": "keyword"
},
... ... @@ -122,24 +107,12 @@
"isLimitbuy": {
"type": "keyword"
},
"isAuditing": {
"type": "keyword"
},
"isauditing": {
"type": "long"
},
"isrecommend": {
"type": "long"
},
"ispromotion": {
"type": "long"
},
"attribute": {
"type": "long"
},
"seasonsS": {
"type": "long"
},
"seasons": {
"type": "text",
"analyzer": "comma_spliter",
... ... @@ -160,12 +133,6 @@
"editTime": {
"type": "integer"
},
"isdown": {
"type": "long"
},
"isDown": {
"type": "keyword"
},
"status": {
"type": "long"
},
... ... @@ -324,11 +291,6 @@
"search_analyzer": "ik_complex_search",
"fielddata": "true"
},
"hotKeyword": {
"type": "text",
"analyzer": "ik_complex",
"search_analyzer": "ik_complex_search"
},
"countryId": {
"type": "long"
},
... ... @@ -353,9 +315,6 @@
}
}
},
"specialPrice": {
"type": "double"
},
"marketPrice": {
"type": "double"
},
... ... @@ -420,12 +379,6 @@
"isSoonSoldOut": {
"type": "keyword"
},
"isSoldOut": {
"type": "keyword"
},
"soldOut": {
"type": "long"
},
"colorIds": {
"type": "text",
"analyzer": "comma_spliter",
... ... @@ -478,9 +431,6 @@
"searchField_ansj"
]
},
"sortWeight": {
"type": "long"
},
"brandWeight": {
"type": "long"
},
... ... @@ -559,9 +509,6 @@
"discountScore": {
"type": "double"
},
"isForbiddenSortBrand": {
"type": "long"
},
"forbiddenPageIds": {
"type": "text",
"analyzer": "comma_spliter"
... ...
... ... @@ -29,29 +29,18 @@ public class ProductIBO implements Serializable {
private String style;
private String pattern;
private String islimited;
private Integer ishot;
private String isHot;
private String isSpecial;
private Integer isspecial;
private String isSales;
private Integer issales;
private String isAdvance;
private Integer isadvance;
private String isDepositAdvance;
private String isLimitbuy;
private String isAuditing;
private Integer isauditing;
private Integer isrecommend;
private Integer ispromotion;
private Integer attribute;
private String seasons;
private Integer seasonsS;
private Integer firstShelveTime;
private Integer shelveTime;
private String shelveDay;
private Integer editTime;
private String isDown;
private Integer isdown;
private Integer status;
private Integer isOutlets;
private Integer folderId;
... ... @@ -70,7 +59,6 @@ public class ProductIBO implements Serializable {
private String brandNameCn;
private String brandNameEn;
private String brandKeyword;
private String hotKeyword;
private String brandName;
private String brandDomain;
private String brandAlif;
... ... @@ -89,7 +77,6 @@ public class ProductIBO implements Serializable {
private String shopDomain;
private Integer shopCreateTime;
private Integer isForbiddenSortBrand;// 是否是品类+品牌的屏蔽字段
private String forbiddenPageIds;// 需要屏蔽的页面id
// from quanqiugou
... ... @@ -302,30 +289,6 @@ public class ProductIBO implements Serializable {
this.status = status;
}
public Integer getSeasonsS() {
return seasonsS;
}
public void setSeasonsS(Integer seasonsS) {
this.seasonsS = seasonsS;
}
public Integer getIsspecial() {
return isspecial;
}
public void setIsspecial(Integer isspecial) {
this.isspecial = isspecial;
}
public String getIsHot() {
return isHot;
}
public void setIsHot(String isHot) {
this.isHot = isHot == null ? null : isHot.trim();
}
public Integer getFolderId() {
return folderId;
}
... ... @@ -334,14 +297,6 @@ public class ProductIBO implements Serializable {
this.folderId = folderId;
}
public Integer getIshot() {
return ishot;
}
public void setIshot(Integer ishot) {
this.ishot = ishot;
}
public Integer getIspromotion() {
return ispromotion;
}
... ... @@ -366,14 +321,6 @@ public class ProductIBO implements Serializable {
this.isSales = isSales == null ? null : isSales.trim();
}
public Integer getIssales() {
return issales;
}
public void setIssales(Integer issales) {
this.issales = issales;
}
public String getIsAdvance() {
return isAdvance;
}
... ... @@ -382,30 +329,6 @@ public class ProductIBO implements Serializable {
this.isAdvance = isAdvance == null ? null : isAdvance.trim();
}
public Integer getIsadvance() {
return isadvance;
}
public void setIsadvance(Integer isadvance) {
this.isadvance = isadvance;
}
public String getIsAuditing() {
return isAuditing;
}
public void setIsAuditing(String isAuditing) {
this.isAuditing = isAuditing == null ? null : isAuditing.trim();
}
public Integer getIsauditing() {
return isauditing;
}
public void setIsauditing(Integer isauditing) {
this.isauditing = isauditing;
}
public Integer getAttribute() {
return attribute;
}
... ... @@ -422,30 +345,6 @@ public class ProductIBO implements Serializable {
this.seasons = seasons == null ? null : seasons.trim();
}
public String getIsDown() {
return isDown;
}
public void setIsDown(String isDown) {
this.isDown = isDown == null ? null : isDown.trim();
}
public Integer getIsdown() {
return isdown;
}
public void setIsdown(Integer isdown) {
this.isdown = isdown;
}
public Integer getIsrecommend() {
return isrecommend;
}
public void setIsrecommend(Integer isrecommend) {
this.isrecommend = isrecommend;
}
public Integer getIsOutlets() {
return isOutlets;
}
... ... @@ -502,14 +401,6 @@ public class ProductIBO implements Serializable {
this.brandKeyword = brandKeyword == null ? null : brandKeyword.trim();
}
public String getHotKeyword() {
return hotKeyword;
}
public void setHotKeyword(String hotKeyword) {
this.hotKeyword = hotKeyword == null ? null : hotKeyword.trim();
}
public String getBrandName() {
return brandName;
}
... ... @@ -630,14 +521,6 @@ public class ProductIBO implements Serializable {
this.isLimitbuy = isLimitbuy;
}
public Integer getIsForbiddenSortBrand() {
return isForbiddenSortBrand;
}
public void setIsForbiddenSortBrand(Integer isForbiddenSortBrand) {
this.isForbiddenSortBrand = isForbiddenSortBrand;
}
public String getForbiddenPageIds() {
return forbiddenPageIds;
}
... ...
... ... @@ -33,11 +33,8 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private String standardOnlyNames;
// from product_sizes
// private BigDecimal salesNum;
private BigDecimal storageNum;
private String isSoonSoldOut;
private String isSoldOut;
private Integer soldOut;
private String sizeIds;
private String sizeNames;
private double breakSizePercent;
... ... @@ -59,7 +56,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private String activities;
// from product_search
private Long sortWeight;
private Long brandWeight;
private Long shopWeight;
... ... @@ -260,14 +256,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
return isSoonSoldOut;
}
public String getIsSoldOut() {
return isSoldOut;
}
public Integer getSoldOut() {
return soldOut;
}
public String getSizeIds() {
return sizeIds;
}
... ... @@ -288,10 +276,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
return activities;
}
public Long getSortWeight() {
return sortWeight;
}
public Long getBrandWeight() {
return brandWeight;
}
... ... @@ -352,14 +336,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.isSoonSoldOut = isSoonSoldOut;
}
public void setIsSoldOut(String isSoldOut) {
this.isSoldOut = isSoldOut;
}
public void setSoldOut(Integer soldOut) {
this.soldOut = soldOut;
}
public void setSizeIds(String sizeIds) {
this.sizeIds = sizeIds == null ? null : sizeIds.trim();
}
... ... @@ -380,10 +356,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.activities = activities;
}
public void setSortWeight(Long sortWeight) {
this.sortWeight = sortWeight;
}
public void setBrandWeight(Long brandWeight) {
this.brandWeight = brandWeight;
}
... ...
... ... @@ -68,14 +68,6 @@ public class ProductSizesBO {
this.heatValue = heatValue;
}
public Integer getSoldOut() {
return storageNum == null || storageNum == 0 ? 0 : 1;
}
public String getIsSoldOut() {
return storageNum == null || storageNum == 0 ? "Y" : "N";
}
public String getIsSoonSoldOut() {
return storageNum == null || storageNum <= 2 ? "Y" : "N";
}
... ...
... ... @@ -79,45 +79,17 @@ public class ProductILogicService {
if ("Y".equals(p.getIsLimited())) {
productIBO.setIslimited("Y");
}
productIBO.setIsHot("N");
productIBO.setIshot(2);
if ("Y".equals(p.getIsHot())) {
productIBO.setIsHot("Y");
productIBO.setIshot(1);
}
productIBO.setIsSpecial("N");
productIBO.setIsspecial(2);
if ("Y".equals(p.getIsSpecial())) {
productIBO.setIsSpecial("Y");
productIBO.setIsspecial(1);
}
productIBO.setIsSales("Y");
productIBO.setIssales(1);
if ("N".equals(p.getIsSales())) {
productIBO.setIsSales("N");
productIBO.setIssales(2);
}
productIBO.setIsAdvance("N");
productIBO.setIsadvance(2);
if ("Y".equals(p.getIsAdvance())) {
productIBO.setIsAdvance("Y");
productIBO.setIsadvance(1);
}
productIBO.setIsAuditing("Y");
productIBO.setIsauditing(1);
if ("N".equals(p.getIsAuditing())) {
productIBO.setIsAuditing("N");
productIBO.setIsauditing(2);
}
productIBO.setIsrecommend(2);
if ("Y".equals(p.getIsRecommend())) {
productIBO.setIsrecommend(1);
}
productIBO.setIsdown(2);
productIBO.setIsDown("N");
if ("Y".equals(p.getIsDown())) {
productIBO.setIsdown(1);
productIBO.setIsDown("Y");
}
productIBO.setIsOutlets(2);
if ("Y".equals(p.getIsOutlets())) {
... ... @@ -142,21 +114,6 @@ public class ProductILogicService {
productIBO.setIspromotion(p.getIsPromotion());
productIBO.setAttribute(p.getAttribute());
productIBO.setSeasons(p.getSeasons());
if (p.getSeasons() != null) {
productIBO.setSeasonsS(4);
if (p.getSeasons().equals("spring") || p.getSeasons().equals("autumn") || p.getSeasons().equals("spring,autumn")) {
productIBO.setSeasonsS(1);
}
if (p.getSeasons().equals("summer")) {
productIBO.setSeasonsS(2);
}
if (p.getSeasons().equals("winter")) {
productIBO.setSeasonsS(3);
}
if (p.getSeasons().equals("spring,summer,autumn,winter") || p.getSeasons().equals("seasons")) {
productIBO.setSeasonsS(4);
}
}
productIBO.setFirstShelveTime(p.getFirstShelveTime());
productIBO.setShelveTime(p.getShelveTime());
String shelveDay = DateUtil.TimeStamp2DateWithFormat(Long.valueOf(p.getShelveTime()), "yyyy-MM-dd");
... ... @@ -198,7 +155,6 @@ public class ProductILogicService {
productIBO.setBrandNameCn(brand.getBrandNameCn());
productIBO.setBrandNameEn(brand.getBrandNameEn());
productIBO.setBrandKeyword(brand.getBrandKeyword());
productIBO.setHotKeyword(brand.getHotKeyword());
productIBO.setBrandName(brand.getBrandName());
productIBO.setBrandDomain(brand.getBrandDomain());
productIBO.setBrandAlif(brand.getBrandAlif());
... ... @@ -242,26 +198,4 @@ public class ProductILogicService {
}
}
/**
* 过滤product列表
*
* @deprecated
*/
public List<Product> filterProductList(List<Product> products, Map<Integer, ProductSort> ProductSortMap, Map<Integer, Brand> brandMap) {
List<Product> productsNew = new ArrayList<>();
for (Product p : products) {
if (ProductSortMap.containsKey(p.getMaxSortId())) {
if (ProductSortMap.containsKey(p.getMiddleSortId())) {
if (ProductSortMap.containsKey(p.getSmallSortId())) {
if (brandMap.containsKey(p.getBrandId())) {
productsNew.add(p);
}
}
}
}
}
return productsNew;
}
}
... ...
... ... @@ -33,7 +33,6 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.brandNameCn, productIndexBO.getBrandNameCn());
map.put(ProductIndexEsField.brandNameEn, productIndexBO.getBrandNameEn());
map.put(ProductIndexEsField.brandKeyword, productIndexBO.getBrandKeyword());
map.put(ProductIndexEsField.hotKeyword, productIndexBO.getHotKeyword());
map.put(ProductIndexEsField.brandName, productIndexBO.getBrandName());
map.put(ProductIndexEsField.style, productIndexBO.getStyle());
map.put(ProductIndexEsField.salesPhrase, productIndexBO.getSalesPhrase());
... ... @@ -47,26 +46,15 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.brandId, productIndexBO.getBrandId());
map.put(ProductIndexEsField.isSpecial, productIndexBO.getIsSpecial());
map.put(ProductIndexEsField.status, productIndexBO.getStatus());
map.put(ProductIndexEsField.seasonsS, productIndexBO.getSeasonsS());
map.put(ProductIndexEsField.isspecial, productIndexBO.getIsspecial());
map.put(ProductIndexEsField.isHot, productIndexBO.getIsHot());
map.put(ProductIndexEsField.folderId, productIndexBO.getFolderId());
map.put(ProductIndexEsField.ishot, productIndexBO.getIshot());
map.put(ProductIndexEsField.ispromotion, productIndexBO.getIspromotion());
map.put(ProductIndexEsField.seriesId, productIndexBO.getSeriesId());
map.put(ProductIndexEsField.isSales, productIndexBO.getIsSales());
map.put(ProductIndexEsField.issales, productIndexBO.getIssales());
map.put(ProductIndexEsField.isAdvance, productIndexBO.getIsAdvance());
map.put(ProductIndexEsField.isadvance, productIndexBO.getIsadvance());
map.put(ProductIndexEsField.isDepositAdvance, productIndexBO.getIsDepositAdvance());
map.put(ProductIndexEsField.isLimitbuy, productIndexBO.getIsLimitbuy());
map.put(ProductIndexEsField.isAuditing, productIndexBO.getIsAuditing());
map.put(ProductIndexEsField.isauditing, productIndexBO.getIsauditing());
map.put(ProductIndexEsField.attribute, productIndexBO.getAttribute());
map.put(ProductIndexEsField.seasons, productIndexBO.getSeasons());
map.put(ProductIndexEsField.isDown, productIndexBO.getIsDown());
map.put(ProductIndexEsField.isdown, productIndexBO.getIsdown());
map.put(ProductIndexEsField.isrecommend, productIndexBO.getIsrecommend());
map.put(ProductIndexEsField.isOutlets, productIndexBO.getIsOutlets());
map.put(ProductIndexEsField.firstShelveTime, productIndexBO.getFirstShelveTime());
... ... @@ -121,9 +109,6 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.brandAlif, productIndexBO.getBrandAlif());
map.put(ProductIndexEsField.editTime, productIndexBO.getEditTime());
map.put(ProductIndexEsField.isSoonSoldOut, productIndexBO.getIsSoonSoldOut());
map.put(ProductIndexEsField.isSoldOut, productIndexBO.getIsSoldOut());
map.put(ProductIndexEsField.soldOut, productIndexBO.getSoldOut());
map.put(ProductIndexEsField.sortWeight, productIndexBO.getSortWeight());
map.put(ProductIndexEsField.brandWeight, productIndexBO.getBrandWeight());
map.put(ProductIndexEsField.shopWeight, productIndexBO.getShopWeight());
map.put(ProductIndexEsField.yohoodId, productIndexBO.getYohoodId());
... ... @@ -166,7 +151,6 @@ public class ProductIndexBOToMapService {
logger.error("[id={}} [activitiesStr={}] [e={}]", productIndexBO.getId(), activitiesStr, e.getMessage());
}
}
map.put(ProductIndexEsField.isForbiddenSortBrand, productIndexBO.getIsForbiddenSortBrand());
map.put(ProductIndexEsField.forbiddenPageIds, productIndexBO.getForbiddenPageIds());
map.put(ProductIndexEsField.productFeatureFactor, productIndexBO.getProductFeatureFactor());
map.put(ProductIndexEsField.productFeatureFactorExist, productIndexBO.getProductFeatureFactorExist());
... ...
package com.yoho.search.consumer.service.logicService.productIndex;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.ProductSearchSortWeightBO;
import com.yoho.search.consumer.service.logicService.productIndex.IndexFieldBuilder;
import com.yoho.search.dal.ProductSearchMapper;
import com.yoho.search.dal.ProductSearchSortMapper;
import com.yoho.search.dal.model.ProductSearch;
import com.yoho.search.dal.model.ProductSearchSort;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Created by wangnan on 2017/1/9.
*/
@Component
public class ProductSearchSortWeightBuilder implements IndexFieldBuilder {
@Autowired
private ProductSearchMapper productSearchMapper;
@Autowired
private ProductSearchSortMapper productSearchSortMapper;
@Override
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
List<ProductSearchSortWeightBO> productSearchSortWeightBOs = this.getData(sknList);
if (CollectionUtils.isEmpty(productSearchSortWeightBOs)) {
return;
}
Map<Integer, ProductSearchSortWeightBO> productSearchSortWeightsMap = productSearchSortWeightBOs.stream().collect(Collectors.toMap(ProductSearchSortWeightBO::getProductSkn, (p) -> p));
productIndexBOs.stream().forEach(productIndexBO -> productIndexBO.setSortWeight(Optional.ofNullable(productSearchSortWeightsMap.get(productIndexBO.getProductSkn()))
.map(ProductSearchSortWeightBO::getSortWeight)
.orElse(Long.valueOf(0))));
}
@Autowired
private ProductSearchMapper productSearchMapper;
@Autowired
private ProductSearchSortMapper productSearchSortMapper;
@Override
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
// List<ProductSearchSortWeightBO> productSearchSortWeightBOs = this.getData(sknList);
// if (CollectionUtils.isEmpty(productSearchSortWeightBOs)) {
// return;
// }
// Map<Integer, ProductSearchSortWeightBO> productSearchSortWeightsMap =
// productSearchSortWeightBOs.stream().collect(Collectors.toMap(ProductSearchSortWeightBO::getProductSkn, (p) -> p));
// productIndexBOs.stream().forEach(productIndexBO ->
// productIndexBO.setSortWeight(Optional.ofNullable(productSearchSortWeightsMap.get(productIndexBO.getProductSkn()))
// .map(ProductSearchSortWeightBO::getSortWeight)
// .orElse(Long.valueOf(0))));
}
public List<ProductSearchSortWeightBO> getData(List<Integer> productSknList) {
List<ProductSearchSort> productSearchSorts = productSearchSortMapper.selectProductSearchSort(productSknList);
List<ProductSearch> productSearches = productSearchMapper.selectByIds(productSknList);
Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue));
List<ProductSearchSort> productSearchSortsNew = new ArrayList<>();
for (ProductSearchSort p : productSearchSorts) {
if (productSearchesMap.containsKey(p.getSortWeightId())) {
productSearchSortsNew.add(p);
}
}
List<ProductSearchSortWeightBO> productSearchSortWeightBOs = new ArrayList<>();
for (ProductSearchSort p : productSearchSortsNew) {
ProductSearchSortWeightBO productSearchSortWeightBO = new ProductSearchSortWeightBO();
productSearchSortWeightBO.setProductSkn(p.getProductSkn());
productSearchSortWeightBO.setSortWeightId(p.getSortWeightId());
productSearchSortWeightBO.setSortWeight(productSearchesMap.get(p.getSortWeightId()));
productSearchSortWeightBOs.add(productSearchSortWeightBO);
}
return productSearchSortWeightBOs;
}
public List<ProductSearchSortWeightBO> getData(List<Integer> productSknList) {
List<ProductSearchSort> productSearchSorts = productSearchSortMapper.selectProductSearchSort(productSknList);
List<ProductSearch> productSearches = productSearchMapper.selectByIds(productSknList);
Map<Integer, Long> productSearchesMap = productSearches.stream().collect(Collectors.toMap(ProductSearch::getId, ProductSearch::getIntValue));
List<ProductSearchSort> productSearchSortsNew = new ArrayList<>();
for (ProductSearchSort p : productSearchSorts) {
if (productSearchesMap.containsKey(p.getSortWeightId())) {
productSearchSortsNew.add(p);
}
}
List<ProductSearchSortWeightBO> productSearchSortWeightBOs = new ArrayList<>();
for (ProductSearchSort p : productSearchSortsNew) {
ProductSearchSortWeightBO productSearchSortWeightBO = new ProductSearchSortWeightBO();
productSearchSortWeightBO.setProductSkn(p.getProductSkn());
productSearchSortWeightBO.setSortWeightId(p.getSortWeightId());
productSearchSortWeightBO.setSortWeight(productSearchesMap.get(p.getSortWeightId()));
productSearchSortWeightBOs.add(productSearchSortWeightBO);
}
return productSearchSortWeightBOs;
}
}
... ...
package com.yoho.search.consumer.service.logicService.productIndex;
import com.yoho.search.consumer.service.logicService.productIndex.IndexFieldBuilder;
import com.yoho.search.consumer.service.logicService.ProductSizesLogicService;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.ProductSizesBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.ProductSizesBO;
import com.yoho.search.consumer.service.logicService.ProductSizesLogicService;
/**
* Created by wangnan on 2017/1/6.
*/
... ... @@ -29,8 +29,6 @@ public class ProductSizesBuilder implements IndexFieldBuilder {
// 设置默认值
productIndexBO.setStorageNum(BigDecimal.valueOf(0));
productIndexBO.setIsSoonSoldOut("Y");
productIndexBO.setIsSoldOut("Y");
productIndexBO.setSoldOut(1);
productIndexBO.setSizeIds("");
productIndexBO.setSizeNames("");
productIndexBO.setBreakSizePercent(100);
... ... @@ -40,8 +38,6 @@ public class ProductSizesBuilder implements IndexFieldBuilder {
if (productSizesBO != null) {
productIndexBO.setStorageNum(BigDecimal.valueOf(productSizesBO.getStorageNum()));
productIndexBO.setIsSoonSoldOut(productSizesBO.getIsSoonSoldOut());
productIndexBO.setIsSoldOut(productSizesBO.getIsSoldOut());
productIndexBO.setSoldOut(productSizesBO.getSoldOut());
productIndexBO.setSizeIds(productSizesBO.getSizeIds());
productIndexBO.setSizeNames(productSizesBO.getSizeNames());
productIndexBO.setBreakSizePercent(productSizesBO.getBreakSizePercent());
... ...