Authored by wangnan9279

ufo 自定义标签 fix

package com.yoho.search.consumer.index.fullbuild.ufo;
import com.alibaba.fastjson.JSONArray;
import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
import com.yoho.search.consumer.service.bo.CutdownPriceInfoBO;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.bo.UfoProductPoolBO;
import com.yoho.search.consumer.service.logicService.CutdownPriceLogicService;
import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService;
import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService;
import com.yoho.search.consumer.service.logicService.cache.UfoBasicDataCacheService;
import com.yoho.search.consumer.service.logicService.tbl.util.StringUtils;
import com.yoho.search.consumer.service.logicService.ufo.UfoProductPoolDetailFieldBuilder;
import com.yoho.search.consumer.service.logicService.ufo.ufo2yoho.*;
import com.yoho.search.consumer.service.utils.IdCheckUtils;
import com.yoho.search.dal.*;
... ... @@ -69,6 +72,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
private BigdataUfoSalesMoneyMapper bigdataUfoSalesMoneyMapper;
@Autowired
private CutdownPriceLogicService cutdownPriceLogicService;
@Autowired
private UfoProductPoolDetailFieldBuilder ufoProductPoolDetailFieldBuilder;
@Override
public int getTotalCount() throws Exception {
... ... @@ -165,6 +170,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
Map<Integer, BigDecimal> productSevendayMoneyMap = this.queryProductSevendayMoney(ufoProductIdList);
//去查这一批ufo商品的砍价购【cutdown_price_product】
Map<Integer, CutdownPriceInfoBO> cutdownPriceInfoBOMap = cutdownPriceLogicService.selectCutdownPriceInfoBOMap(ufoProductIdList);
//去查这一批ufo商品的商品池信息【product_pool_detail】
Map<Integer, UfoProductPoolBO> ufoProductPoolBOMap = ufoProductPoolDetailFieldBuilder.buildUfoProductPoolBOMap(ufoProductIdList);
//构造ProductIndexBO
for (Product product : productList) {
... ... @@ -175,7 +182,6 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
// 构建ProductIndexBO并加入结果集
ProductIndexBO productIndexBO = new ProductIndexBO();
productIndexBOList.add(productIndexBO);
// 一般字段
ufoToYohoGeneralService.build(productIndexBO, product, ufoBrandSeriesMap);
// 品牌
... ... @@ -200,6 +206,15 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
productIndexBO.setCutdownPriceActivityIds(StringUtils.join(cutdownPriceInfoBO.getActivityIds(), ","));
productIndexBO.setCutdownPriceOrder(cutdownPriceInfoBO.getOrder());
}
//商品池
UfoProductPoolBO ufoProductPoolBO = ufoProductPoolBOMap.get(productIndexBO.getProductSkn());
if (ufoProductPoolBO == null) {
productIndexBO.setPoolIds("");
productIndexBO.setPools(new JSONArray());
} else {
productIndexBO.setPoolIds(ufoProductPoolBO.getPoolIds());
productIndexBO.setPools(ufoProductPoolBO.getPools());
}
}
return productIndexBOList;
} catch (Exception e) {
... ...
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.index.mix.Ufo2YohoIndexUpdateHelper;
import com.yoho.search.consumer.index.mix.UfoIndexUpdateHelper;
import com.yoho.search.consumer.service.daoService.ufo.UfoProductPoolDetailService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
... ... @@ -16,13 +17,15 @@ import org.springframework.stereotype.Component;
* @version 2018/9/11
*/
@Component
@SearchMqConsumerListerner(dbName = "ufo_product",tableName = "product_pool_detail")
@SearchMqConsumerListerner(dbName = "ufo_product", tableName = "product_pool_detail")
public class UfoProductPoolDetailMqListener extends AbstractMqListener {
@Autowired
private UfoProductPoolDetailService ufoProductPoolDetailService;
@Autowired
private UfoIndexUpdateHelper ufoIndexUpdateHelper;
@Autowired
private Ufo2YohoIndexUpdateHelper ufo2YohoIndexUpdateHelper;
@Override
public String getIndexName() {
... ... @@ -35,6 +38,7 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener {
ufoProductPoolDetailService.delete(Integer.valueOf(id));
if (productPoolDetail != null) {
ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId());
ufo2YohoIndexUpdateHelper.updateYohoIndex(productPoolDetail.getProductId());
}
}
... ... @@ -46,5 +50,6 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener {
}
ufoProductPoolDetailService.saveOrUpdate(productPoolDetail);
ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId());
ufo2YohoIndexUpdateHelper.updateYohoIndex(productPoolDetail.getProductId());
}
}
... ...
... ... @@ -42,6 +42,18 @@ public class UfoProductPoolDetailFieldBuilder implements UfoIndexFieldBuilder {
}
}
/**
* 用于ufo融入有货
*/
public Map<Integer, UfoProductPoolBO> buildUfoProductPoolBOMap(List<Integer> idList) {
List<UfoProductPoolBO> ufoProductPoolBOList = buildUfoProductPoolBOList(idList);
Map<Integer, UfoProductPoolBO> ufoProductPoolBOMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(ufoProductPoolBOList)) {
ufoProductPoolBOMap = ufoProductPoolBOList.stream().collect(Collectors.toMap(UfoProductPoolBO::getProductId, p -> p));
}
return ufoProductPoolBOMap;
}
private List<UfoProductPoolBO> buildUfoProductPoolBOList(List<Integer> idList) {
List<UfoProductPoolBO> ufoProductPoolBOList = new ArrayList<>();
for (Integer id : idList) {
... ...