...
|
...
|
@@ -17,6 +17,7 @@ import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
import com.yoho.error.event.SearchEvent;
|
...
|
...
|
@@ -26,11 +27,14 @@ import com.yoho.search.base.utils.ISearchConstants; |
|
|
import com.yoho.search.consumer.common.CostStatistics;
|
|
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
|
|
import com.yoho.search.consumer.index.increment.bulks.StorageSkuIndexBulkService;
|
|
|
import com.yoho.search.consumer.service.base.GoodsService;
|
|
|
import com.yoho.search.consumer.service.base.Product15DaySalesNumService;
|
|
|
import com.yoho.search.consumer.service.base.ProductPoolDetailService;
|
|
|
import com.yoho.search.consumer.service.base.ProductService;
|
|
|
import com.yoho.search.consumer.service.base.StorageService;
|
|
|
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
|
|
|
import com.yoho.search.consumer.service.logic.ProductIndexLogicService;
|
|
|
import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
|
|
|
import com.yoho.search.consumer.service.logic.productIndex.StorageUpdateTimeLogicService;
|
|
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
import com.yoho.search.dal.model.Product;
|
...
|
...
|
@@ -57,6 +61,10 @@ public class StorageMqListener extends AbstractMqListener implements ChannelAwar |
|
|
private ProductIndexLogicService productIndexLogicService;
|
|
|
@Autowired
|
|
|
private StorageUpdateTimeLogicService storageUpdateTimeLogicService;
|
|
|
@Autowired
|
|
|
private GoodsService goodsService;
|
|
|
@Autowired
|
|
|
private ProductGoodsLogicService productGoodsLogicService;
|
|
|
|
|
|
@Override
|
|
|
public void onMessage(Message message, Channel channel) throws Exception {
|
...
|
...
|
@@ -181,7 +189,30 @@ public class StorageMqListener extends AbstractMqListener implements ChannelAwar |
|
|
StorageUpdateTime storageUpdateTime = storageUpdateTimes.get(0);
|
|
|
indexData.put("storageUpdateTime", storageUpdateTime.getStorageUpdateTime());
|
|
|
}
|
|
|
//更新color相关信息
|
|
|
fillColor(indexData,productId);
|
|
|
this.updateProductIndexWithDataMap(indexData, productId, key, begin);
|
|
|
}
|
|
|
|
|
|
private void fillColor(Map<String, Object> indexData,Integer productId){
|
|
|
Set<String> colorIdSet = new HashSet<String>();
|
|
|
Set<String> colorNameSet = new HashSet<String>();
|
|
|
// 第一步:获取goodsList
|
|
|
List<ProductGoodsBO> productGoodsBOList = goodsService.getProductGoodsByProductId(productId);
|
|
|
// 第二步、组装goods数据
|
|
|
if (productGoodsBOList != null && productGoodsBOList.size() == 1) {
|
|
|
ProductGoodsBO productGoodsBO = productGoodsBOList.get(0);
|
|
|
String goodsListJsonArrayStr = productGoodsBO.getGoodsList();
|
|
|
JSONArray goodsListJsonArray = JSONArray.parseArray(goodsListJsonArrayStr);
|
|
|
productGoodsLogicService.getColorSet(goodsListJsonArray, colorIdSet, colorNameSet);//获取有库存且状态正常的color
|
|
|
indexData.put("goodsList", goodsListJsonArray);
|
|
|
indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
|
|
|
indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
|
|
|
} else {
|
|
|
indexData.put("goodsList", "");
|
|
|
indexData.put("colorIds", "");
|
|
|
indexData.put("colorNames", "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|