Authored by 胡古飞

BUG

... ... @@ -8,12 +8,14 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.bulks.CommonBulkService;
import com.yoho.search.consumer.index.increment.bulks.ProductPoolIndexBulkService;
import com.yoho.search.consumer.index.rebuild.RebuildFlagService;
import com.yoho.search.consumer.service.base.ProductIndexService;
import com.yoho.search.consumer.service.base.ProductPoolDetailService;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.logic.TblLogicService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.ProductPoolDetail;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -41,6 +43,8 @@ public class AbstractMqListener implements ApplicationEventPublisherAware {
private ProductPoolDetailService productPoolDetailService;
@Autowired
private TblLogicService tblLogicService;
@Autowired
private ProductIndexService productIndexService;
protected ApplicationEventPublisher publisher;
... ... @@ -71,20 +75,17 @@ public class AbstractMqListener implements ApplicationEventPublisherAware {
commonBulkService.add(new ESBluk(jsonString, productId + "", ISearchConstants.INDEX_NAME_PRODUCT_INDEX, ISearchConstants.INDEX_NAME_PRODUCT_INDEX, false));
}
public void updateProductPoolIndexWithDataMap(String jsonString, Integer id, String key, long begin) {
commonBulkService.add(new ESBluk(jsonString, id + "", ISearchConstants.INDEX_NAME_PRODUCT_POOL, ISearchConstants.INDEX_NAME_PRODUCT_POOL, false));
}
public void updateTblProductIndexWithJsonString(String jsonString, Integer productId, String key, long begin) {
commonBulkService.add(new ESBluk(jsonString, productId + "", ISearchConstants.INDEX_NAME_GLOBAL, ISearchConstants.INDEX_NAME_GLOBAL, false));
}
public void updateProductIndexWithDataMap(Map<String, Object> indexData, Integer productId, String key, long begin) {
this.updateProductIndexWithJsonString(JSON.toJSONString(indexData), productId, key, begin);
}
public void updateProductPoolIndexWithDataMap(Map<String, Object> indexData, Integer id, String key, long begin) {
this.updateProductPoolIndexWithDataMap(JSON.toJSONString(indexData), id, key, begin);
String jsonString = JSON.toJSONString(indexData);
commonBulkService.add(new ESBluk(jsonString, id + "", ISearchConstants.INDEX_NAME_PRODUCT_POOL, ISearchConstants.INDEX_NAME_PRODUCT_POOL, false));
}
/**
... ... @@ -121,7 +122,8 @@ public class AbstractMqListener implements ApplicationEventPublisherAware {
return;
}
for (ProductIndexBO productIndexBO : productIndexBOS) {
String jsonString = JSON.toJSONString(productIndexBO);
Map<String, Object> object = productIndexService.beanToMap(productIndexBO);
String jsonString = JSON.toJSONString(object);
this.updateTblProductIndexWithJsonString(jsonString, productIndexBO.getId(), key, System.currentTimeMillis());
logger.info("[updateToEs success][key={}][id={}][cost={}ms][json={}]", key, productIndexBO.getId(), (System.currentTimeMillis() - begin), jsonString);
}
... ...