Authored by unknown

listener

Showing 41 changed files with 139 additions and 131 deletions
package com.yoho.search.consumer.index.increment;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.bulks.CommonBulkService;
import com.yoho.search.core.es.model.ESBluk;
import org.springframework.messaging.handler.annotation.Payload;
public abstract class AbstractIndexMqListener extends AbstractMqListener {
protected abstract String getIndexName();
@Autowired
private CommonBulkService commonBulkService;
@Override
@RabbitHandler
public void onMessage(Message message, @Payload byte[] bytes) throws Exception {
// 必须指定索引的id_field
String idField = ISearchConstants.getKeyField(getIndexName());
if (StringUtils.isBlank(idField)) {
throw new Exception("idField is empty,indexName is " + getIndexName());
}
super.onMessage(message, bytes);
}
/**
* 增量更新PI索引的方法
*
* @param indexData
* @param productId
* @param key
* @param begin
*/
protected final void updateProductIndexWithDataMap(Map<String, Object> indexData, Integer productId) {
JSONObject jsonObject = new JSONObject(indexData);
commonBulkService.add(new ESBluk(jsonObject.toJSONString(), productId + "", ISearchConstants.INDEX_NAME_PRODUCT_INDEX, ISearchConstants.INDEX_NAME_PRODUCT_INDEX, false));
}
}
... ... @@ -5,10 +5,13 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.yoho.search.consumer.index.increment.bulks.CommonBulkService;
import com.yoho.search.core.es.model.ESBluk;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
... ... @@ -33,6 +36,9 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
private static final Map<String, PerformanceMonitor> performanceMonitors = new ConcurrentHashMap<String, PerformanceMonitor>();
@Autowired
private CommonBulkService commonBulkService;
protected ApplicationEventPublisher publisher;
@Override
... ... @@ -51,6 +57,10 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
// do nothing as default
}
protected String getIndexName(){
return "";
}
// 重试次数,子类可以重写覆盖
protected int getMaxRetryTime() {
return 5;
... ... @@ -67,11 +77,18 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
ignoreIncrease = false;
}
@RabbitHandler
public void onMessage(Message message, @Payload byte[] bytes) throws Exception {
if (ignoreIncrease) {
logger.warn("be ignoreIncreasing ,please close the flag after successed ");
return;
}
if (StringUtils.isNotEmpty(getIndexName())) {
String idField = ISearchConstants.getKeyField(getIndexName());
if (org.apache.commons.lang3.StringUtils.isBlank(idField)) {
throw new Exception("idField is empty,indexName is " + getIndexName());
}
}
try {
rebuildFlagService.waitingRebuildingIndex();
this.doBeforeConsume();
... ... @@ -220,4 +237,17 @@ public abstract class AbstractMqListener implements ApplicationEventPublisherAwa
logger.error(throwable.getMessage(), throwable);
}
}
/**
* 增量更新PI索引的方法
*
* @param indexData
* @param productId
*/
protected final void updateProductIndexWithDataMap(Map<String, Object> indexData, Integer productId) {
JSONObject jsonObject = new JSONObject(indexData);
commonBulkService.add(new ESBluk(jsonObject.toJSONString(), productId + "", ISearchConstants.INDEX_NAME_PRODUCT_INDEX, ISearchConstants.INDEX_NAME_PRODUCT_INDEX, false));
}
}
... ...
... ... @@ -7,6 +7,7 @@ import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.EsWordDefService;
import com.yoho.search.dal.model.EsWordDef;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -14,6 +15,7 @@ import java.util.HashSet;
import java.util.Set;
@Component
@RabbitListener(queues = "#{'${data_update_channel_esworddef}'}" )
public class EsWordDefMqListener extends AbstractMqListener {
private static final Set<Integer> validWordType = new HashSet<Integer>() {
... ...
... ... @@ -5,10 +5,11 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ActivityTagService;
import com.yoho.search.consumer.service.logicService.productIndex.ProductCustomizeTagBuilder;
import com.yoho.search.dal.model.ActivityTag;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -16,7 +17,8 @@ import org.springframework.stereotype.Component;
* Created by wangnan on 2017/9/11.
*/
@Component
public class ActivityTagMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_activitytag}'}" )
public class ActivityTagMqListener extends AbstractMqListener {
@Autowired
private ActivityTagService activityTagService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -10,12 +12,12 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.BrandService;
import com.yoho.search.dal.model.Brand;
@Component
public class BrandMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_brand}'}" )
public class BrandMqListener extends AbstractMqListener {
@Autowired
private BrandService brandService;
... ...
... ... @@ -3,6 +3,8 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import java.util.ArrayList;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -11,7 +13,6 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.HelperService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.dal.model.Helper;
... ... @@ -20,7 +21,8 @@ import com.yoho.search.dal.model.Helper;
* Created by wangnan on 2016/12/5.
*/
@Component
public class HelperMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_helper}'}" )
public class HelperMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -8,13 +10,13 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ProductColorService;
import com.yoho.search.consumer.service.logicService.ProductGoodsLogicService;
import com.yoho.search.dal.model.ProductColor;
@Component
public class ProductColorMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_productcolor}'}" )
public class ProductColorMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -8,13 +10,13 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ProductPricePlanService;
import com.yoho.search.consumer.service.logicService.VipPriceLogicService;
import com.yoho.search.dal.model.ProductPricePlan;
@Component
public class ProductPricePlanMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_productcolor}'}" )
public class ProductPricePlanMqListener extends AbstractMqListener {
@Autowired
private ProductPricePlanService productPricePlanService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -10,12 +11,11 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ProductSortService;
import com.yoho.search.dal.model.ProductSort;
@Component
public class ProductSortMqListener extends AbstractIndexMqListener {
public class ProductSortMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -14,7 +15,6 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.PromotionIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.PromotionProductFlagsService;
import com.yoho.search.dal.model.PromotionBO;
import com.yoho.search.dal.model.PromotionProductFlags;
... ... @@ -23,7 +23,7 @@ import com.yoho.search.dal.model.PromotionProductFlags;
* Created by wangnan on 2017/5/11.
*/
@Component
public class PromotionProductFlagsMqListener extends AbstractIndexMqListener {
public class PromotionProductFlagsMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(PromotionProductFlagsMqListener.class);
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -8,7 +9,6 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.RobotQuestionService;
import com.yoho.search.dal.model.RobotQuestion;
... ... @@ -16,7 +16,7 @@ import com.yoho.search.dal.model.RobotQuestion;
* Created by wangnan on 2016/11/28.
*/
@Component
public class RobotQuestionMqListener extends AbstractIndexMqListener {
public class RobotQuestionMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import java.util.ArrayList;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -12,7 +13,6 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ShopService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.dal.model.Shops;
... ... @@ -21,7 +21,7 @@ import com.yoho.search.dal.model.Shops;
* Created by wangnan on 2016/12/1.
*/
@Component
public class ShopsMqListener extends AbstractIndexMqListener {
public class ShopsMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -9,12 +11,12 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.SizeService;
import com.yoho.search.dal.model.Size;
@Component
public class SizeMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_size}'}" )
public class SizeMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -8,12 +10,12 @@ 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.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.StyleService;
import com.yoho.search.dal.model.Style;
@Component
public class StyleMqListener extends AbstractIndexMqListener {
@RabbitListener(queues = "#{'${data_update_channel_style}'}" )
public class StyleMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import java.util.HashMap;
import java.util.Map;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -14,7 +15,6 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.base.utils.MD5Util;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.SuggestConversionCustomService;
import com.yoho.search.consumer.service.daoService.SuggestConversionService;
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
... ... @@ -22,7 +22,7 @@ import com.yoho.search.dal.model.SuggestConversion;
import com.yoho.search.dal.model.SuggestConversionCustom;
@Component
public class SuggestConversionCustomMqListener extends AbstractIndexMqListener {
public class SuggestConversionCustomMqListener extends AbstractMqListener {
static final Logger logger = LoggerFactory.getLogger(SuggestConversionCustomMqListener.class);
... ...
... ... @@ -3,7 +3,7 @@ package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.*;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.SuggestWordCustomService;
import com.yoho.search.consumer.service.daoService.SuggestWordDefService;
import com.yoho.search.consumer.suggests.common.KeywordType;
... ... @@ -23,7 +23,7 @@ import java.util.Map;
* Created by gemingdan on 2017/3/15.
*/
@Component
public class SuggestWordCustomMqListener extends AbstractIndexMqListener {
public class SuggestWordCustomMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(SuggestWordCustomMqListener.class);
... ...
... ... @@ -6,7 +6,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ActivityProductService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.ActivityProduct;
... ... @@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
@Component
public class ActivityProductMqListener extends AbstractIndexMqListener {
public class ActivityProductMqListener extends AbstractMqListener {
@Autowired
private ActivityProductService activityProductService;
... ...
... ... @@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,7 +19,6 @@ 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.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.GoodsImagesService;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.logicService.SpecialDealLogicService;
... ... @@ -27,7 +27,7 @@ import com.yoho.search.consumer.service.logicService.productIndex.VideosBuilder;
import com.yoho.search.dal.model.GoodsImages;
@Component
public class GoodsImagesMqListener extends AbstractIndexMqListener {
public class GoodsImagesMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(GoodsImagesMqListener.class);
... ...
... ... @@ -6,15 +6,17 @@ 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.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractStorageRelatedMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.GoodsService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.consumer.service.logicService.StorageRelatedLogicService;
import com.yoho.search.dal.model.Goods;
import com.yoho.search.dal.model.Product;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -24,9 +26,13 @@ import java.util.List;
import java.util.Map;
@Component
public class GoodsMqListener extends AbstractStorageRelatedMqListener {
@RabbitListener(queues = "#{'${data_update_channel_goods}'}" )
public class GoodsMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(GoodsMqListener.class);
@Autowired
private StorageRelatedLogicService storageRelatedLogicService;
@Autowired
private GoodsService goodsService;
@Autowired
... ... @@ -92,10 +98,10 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener {
CostStatistics costStatistics = new CostStatistics();
Map<String, Object> indexData = new HashMap<String, Object>();
// 第一步:获取goodsList,组装goods数据
this.fillColor(indexData, productId);
storageRelatedLogicService.fillColor(indexData, productId);
logger.info("[func=updateProductIndex][step2(1/4)fillColor][productId={}][cost={}]", productId, costStatistics.getCost());
// 第二步、组装库存数据
this.fillStorageNumAndSizeInfo(productId, indexData);
storageRelatedLogicService.fillStorageNumAndSizeInfo(productId, indexData);
logger.info("[func=updateProductIndex][step2(2/4)fillStorageNumAndSizeInfo][productId={}][cost={}]", productId, costStatistics.getCost());
// 第三步,判断skn状态
this.checkSknStatus(productId, indexData);
... ...
... ... @@ -6,7 +6,7 @@ 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.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductActivitiesLinkService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.ProductActivitiesLink;
... ... @@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
@Component
public class ProductActivitiesLinkMqListener extends AbstractIndexMqListener {
public class ProductActivitiesLinkMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductActivitiesLinkMqListener.class);
... ...
... ... @@ -6,7 +6,7 @@ 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.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductAttributeService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.Product;
... ... @@ -19,7 +19,7 @@ import java.util.HashMap;
import java.util.Map;
@Component
public class ProductAttributePropertyValuesMqListener extends AbstractIndexMqListener {
public class ProductAttributePropertyValuesMqListener extends AbstractMqListener {
@Autowired
private ProductAttributeService productAttributeService;
... ...
... ... @@ -6,7 +6,7 @@ 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.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductExtService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.Product;
... ... @@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Map;
@Component
public class ProductExtMqListener extends AbstractIndexMqListener {
public class ProductExtMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductExtMqListener.class);
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.search.consumer.index.increment.productIndex;
import java.util.Arrays;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -17,12 +18,11 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService;
@Component
public class ProductIndexMqListener extends AbstractIndexMqListener {
public class ProductIndexMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductIndexMqListener.class);
... ...
... ... @@ -5,7 +5,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductKeywordsService;
import com.yoho.search.dal.model.ProductKeywords;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -21,7 +21,7 @@ import java.util.Map;
*/
@Component
public class ProductKeywordsMqListener extends AbstractIndexMqListener {
public class ProductKeywordsMqListener extends AbstractMqListener {
@Autowired
private ProductKeywordsService productKeywordsService;
... ...
... ... @@ -9,7 +9,7 @@ import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.ProductIndexIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.bo.ProductIBO;
import com.yoho.search.consumer.service.bo.ProductPriceBO;
import com.yoho.search.consumer.service.daoService.ProductService;
... ... @@ -30,7 +30,7 @@ import org.springframework.util.CollectionUtils;
@Component
@RabbitListener(queues = "#{'${data_update_channel_product}'.split(',')}" )
public class ProductMqListener extends AbstractIndexMqListener {
public class ProductMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductMqListener.class);
@Autowired
... ...
... ... @@ -7,7 +7,7 @@ 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.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductPoolDetailService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.ProductPoolDetail;
... ... @@ -22,7 +22,7 @@ import java.util.*;
* Created by wangnan on 2016/8/17.
*/
@Component
public class ProductPoolDetailMqListener extends AbstractIndexMqListener {
public class ProductPoolDetailMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductPoolDetailMqListener.class);
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.search.consumer.index.increment.productIndex;
import java.util.HashMap;
import java.util.Map;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -13,7 +14,6 @@ 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.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.ProductPriceService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.consumer.service.bo.ProductPriceBO;
... ... @@ -22,7 +22,7 @@ import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductPrice;
@Component
public class ProductPriceMqListener extends AbstractIndexMqListener {
public class ProductPriceMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductPriceMqListener.class);
@Autowired
... ...
... ... @@ -5,7 +5,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductSearchService;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.dal.model.ProductSearch;
... ... @@ -19,7 +19,7 @@ import java.util.HashMap;
import java.util.Map;
@Component
public class ProductSearchMqListener extends AbstractIndexMqListener {
public class ProductSearchMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductSearchMqListener.class);
@Autowired
... ...
... ... @@ -5,7 +5,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductStandardRelationService;
import com.yoho.search.dal.model.ProductStandardRelation;
import org.apache.commons.lang.StringUtils;
... ... @@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class ProductStandardRelationMqListener extends AbstractIndexMqListener {
public class ProductStandardRelationMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductStandardRelationMqListener.class);
@Autowired
... ...
... ... @@ -5,7 +5,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductStyleRelationService;
import com.yoho.search.dal.model.ProductStyleRelation;
import org.apache.commons.lang.StringUtils;
... ... @@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class ProductStyleRelationMqListener extends AbstractIndexMqListener{
public class ProductStyleRelationMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductStyleRelationMqListener.class);
@Autowired
... ...
... ... @@ -5,7 +5,7 @@ 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.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.consumer.service.daoService.ProductTimingService;
import com.yoho.search.consumer.service.logicService.StorageUpdateTimeLogicService;
... ... @@ -27,7 +27,7 @@ import java.util.Map;
* Created by wangnan on 2016/11/24.
*/
@Component
public class ProductTimingMqListener extends AbstractIndexMqListener {
public class ProductTimingMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ProductTimingMqListener.class);
... ...
... ... @@ -6,7 +6,7 @@ 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.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.consumer.service.daoService.ScoreSknRuleService;
import com.yoho.search.dal.model.Product;
... ... @@ -23,7 +23,7 @@ import java.util.Map;
* Created by gemingdan on 2017/6/19.
*/
@Component
public class ScoreSknRuleMqListener extends AbstractIndexMqListener {
public class ScoreSknRuleMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(ScoreSknRuleMqListener.class);
... ...
... ... @@ -3,6 +3,7 @@ package com.yoho.search.consumer.index.increment.productIndex;
import java.util.HashMap;
import java.util.Map;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -13,7 +14,6 @@ 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.ProductService;
import com.yoho.search.consumer.service.daoService.SknBlockService;
import com.yoho.search.dal.model.Product;
... ... @@ -23,7 +23,7 @@ import com.yoho.search.dal.model.SknBlock;
* Created by mingdan.ge on 2017/7/10.
*/
@Component
public class SknBlockMqListener extends AbstractIndexMqListener {
public class SknBlockMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(SknBlockMqListener.class);
... ...
... ... @@ -6,9 +6,10 @@ 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.common.CostStatistics;
import com.yoho.search.consumer.index.increment.AbstractStorageRelatedMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductService;
import com.yoho.search.consumer.service.daoService.StorageService;
import com.yoho.search.consumer.service.logicService.StorageRelatedLogicService;
import com.yoho.search.consumer.service.logicService.StorageUpdateTimeLogicService;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.Storage;
... ... @@ -26,10 +27,12 @@ import java.util.List;
import java.util.Map;
@Component
public class StorageMqListener extends AbstractStorageRelatedMqListener {
public class StorageMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(StorageMqListener.class);
@Autowired
private StorageRelatedLogicService storageRelatedLogicService;
@Autowired
private StorageService storageService;
@Autowired
private ProductService productService;
... ... @@ -92,9 +95,9 @@ public class StorageMqListener extends AbstractStorageRelatedMqListener {
Map<String, Object> indexData = new HashMap<String, Object>();
indexData.put(ProductIndexEsField.productId, productId);
// 更新库存和尺码信息
this.fillStorageNumAndSizeInfo(productId, indexData);
storageRelatedLogicService.fillStorageNumAndSizeInfo(productId, indexData);
// 更新color相关信息
this.fillColor(indexData, productId);
storageRelatedLogicService.fillColor(indexData, productId);
// 更新storageUpdateTime
this.updateStorageUpdateTime(indexData, productId);
// 更新商品索引
... ...
... ... @@ -6,7 +6,7 @@ import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.TblBrandService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.dal.model.TblBrand;
... ... @@ -22,7 +22,7 @@ import java.util.List;
* Created by wangnan on 2016/12/16.
*/
@Component
public class TblBrandMqListener extends AbstractIndexMqListener {
public class TblBrandMqListener extends AbstractMqListener {
private static final Logger logger = LoggerFactory.getLogger(TblBrandMqListener.class);
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -7,7 +8,6 @@ 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.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.daoService.TblProductService;
import com.yoho.search.dal.model.TblProduct;
... ... @@ -16,7 +16,7 @@ import com.yoho.search.dal.model.TblProduct;
* Created by wangnan on 2016/12/19.
*/
@Component
public class TblProductMqListener extends AbstractIndexMqListener {
public class TblProductMqListener extends AbstractMqListener {
@Autowired
private TblProductService tblProductService;
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -7,7 +8,6 @@ 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.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.daoService.TblProductSkcService;
import com.yoho.search.dal.model.TblProductSkc;
... ... @@ -16,7 +16,7 @@ import com.yoho.search.dal.model.TblProductSkc;
* Created by wangnan on 2016/12/19.
*/
@Component
public class TblProductSkcMqListener extends AbstractIndexMqListener {
public class TblProductSkcMqListener extends AbstractMqListener {
@Autowired
private TblProductSkcService tblProductSkcService;
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -7,7 +8,6 @@ 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.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.daoService.TblProductSkuService;
import com.yoho.search.dal.model.TblProductSku;
... ... @@ -16,7 +16,7 @@ import com.yoho.search.dal.model.TblProductSku;
* Created by wangnan on 2016/12/19.
*/
@Component
public class TblProductSkuMqListener extends AbstractIndexMqListener {
public class TblProductSkuMqListener extends AbstractMqListener {
@Autowired
private TblProductSkuService tblProductSkuService;
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.search.consumer.index.increment.tbl;
import java.util.List;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -10,7 +11,6 @@ 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.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.index.increment.bulks.GlobalIndexBulkService;
import com.yoho.search.consumer.service.daoService.TblProductService;
import com.yoho.search.consumer.service.daoService.TblSiteService;
... ... @@ -20,7 +20,7 @@ import com.yoho.search.dal.model.TblSite;
* Created by wangnan on 2016/12/16.
*/
@Component
public class TblSiteMqListener extends AbstractIndexMqListener {
public class TblSiteMqListener extends AbstractMqListener {
@Autowired
private TblSiteService tblSiteService;
... ...
package com.yoho.search.consumer.index.increment.tbl;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -8,7 +9,6 @@ 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.consumer.index.fullbuild.TblProductNewIndexBuilder;
import com.yoho.search.consumer.index.increment.AbstractIndexMqListener;
import com.yoho.search.consumer.service.daoService.TblSortService;
import com.yoho.search.dal.model.TblSort;
... ... @@ -16,7 +16,7 @@ import com.yoho.search.dal.model.TblSort;
* Created by wangnan on 2016/12/19.
*/
@Component
public class TblSortMqListener extends AbstractIndexMqListener {
public class TblSortMqListener extends AbstractMqListener {
@Autowired
private TblProductNewIndexBuilder tblProductNewIndexBuilder;
... ...
package com.yoho.search.consumer.index.increment;
package com.yoho.search.consumer.service.logicService;
import com.alibaba.fastjson.JSONArray;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.bo.ProductSizesBO;
import com.yoho.search.consumer.service.logicService.ProductGoodsLogicService;
import com.yoho.search.consumer.service.logicService.ProductSizesLogicService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* Created by ginozhang on 2017/2/8. 将库存相关的增量更新代码抽象到父类,被Storage和Goods的MqListener共用。
*/
public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqListener {
@Component
public class StorageRelatedLogicService {
@Autowired
private ProductGoodsLogicService productGoodsLogicService;
@Autowired
private ProductSizesLogicService productSizesLogicService;
protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
public void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
List<ProductSizesBO> productSizesBOList = productSizesLogicService.getProductSizeBOList(Arrays.asList(productId));
if (productSizesBOList == null || productSizesBOList.isEmpty()) {
indexData.put(ProductIndexEsField.storageNum, 0);
... ... @@ -43,7 +43,7 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractIndexMqLi
indexData.put(ProductIndexEsField.skuIds, productSizesBO.getSkuIds());
}
protected void fillColor(Map<String, Object> indexData, Integer productId) {
public void fillColor(Map<String, Object> indexData, Integer productId) {
Set<String> colorIdSet = new HashSet<String>();
Set<String> colorNameSet = new HashSet<String>();
// 1.获取goodsList
... ...