Authored by wangnan9279

ufo 自定义标签 fix

1 package com.yoho.search.consumer.index.fullbuild.ufo; 1 package com.yoho.search.consumer.index.fullbuild.ufo;
2 2
  3 +import com.alibaba.fastjson.JSONArray;
3 import com.yoho.search.consumer.index.fullbuild.IIndexBuilder; 4 import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
4 import com.yoho.search.consumer.service.bo.CutdownPriceInfoBO; 5 import com.yoho.search.consumer.service.bo.CutdownPriceInfoBO;
5 import com.yoho.search.consumer.service.bo.ProductIndexBO; 6 import com.yoho.search.consumer.service.bo.ProductIndexBO;
  7 +import com.yoho.search.consumer.service.bo.UfoProductPoolBO;
6 import com.yoho.search.consumer.service.logicService.CutdownPriceLogicService; 8 import com.yoho.search.consumer.service.logicService.CutdownPriceLogicService;
7 import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService; 9 import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService;
8 import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService; 10 import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService;
9 import com.yoho.search.consumer.service.logicService.cache.UfoBasicDataCacheService; 11 import com.yoho.search.consumer.service.logicService.cache.UfoBasicDataCacheService;
10 import com.yoho.search.consumer.service.logicService.tbl.util.StringUtils; 12 import com.yoho.search.consumer.service.logicService.tbl.util.StringUtils;
  13 +import com.yoho.search.consumer.service.logicService.ufo.UfoProductPoolDetailFieldBuilder;
11 import com.yoho.search.consumer.service.logicService.ufo.ufo2yoho.*; 14 import com.yoho.search.consumer.service.logicService.ufo.ufo2yoho.*;
12 import com.yoho.search.consumer.service.utils.IdCheckUtils; 15 import com.yoho.search.consumer.service.utils.IdCheckUtils;
13 import com.yoho.search.dal.*; 16 import com.yoho.search.dal.*;
@@ -69,6 +72,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -69,6 +72,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
69 private BigdataUfoSalesMoneyMapper bigdataUfoSalesMoneyMapper; 72 private BigdataUfoSalesMoneyMapper bigdataUfoSalesMoneyMapper;
70 @Autowired 73 @Autowired
71 private CutdownPriceLogicService cutdownPriceLogicService; 74 private CutdownPriceLogicService cutdownPriceLogicService;
  75 + @Autowired
  76 + private UfoProductPoolDetailFieldBuilder ufoProductPoolDetailFieldBuilder;
72 77
73 @Override 78 @Override
74 public int getTotalCount() throws Exception { 79 public int getTotalCount() throws Exception {
@@ -165,6 +170,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -165,6 +170,8 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
165 Map<Integer, BigDecimal> productSevendayMoneyMap = this.queryProductSevendayMoney(ufoProductIdList); 170 Map<Integer, BigDecimal> productSevendayMoneyMap = this.queryProductSevendayMoney(ufoProductIdList);
166 //去查这一批ufo商品的砍价购【cutdown_price_product】 171 //去查这一批ufo商品的砍价购【cutdown_price_product】
167 Map<Integer, CutdownPriceInfoBO> cutdownPriceInfoBOMap = cutdownPriceLogicService.selectCutdownPriceInfoBOMap(ufoProductIdList); 172 Map<Integer, CutdownPriceInfoBO> cutdownPriceInfoBOMap = cutdownPriceLogicService.selectCutdownPriceInfoBOMap(ufoProductIdList);
  173 + //去查这一批ufo商品的商品池信息【product_pool_detail】
  174 + Map<Integer, UfoProductPoolBO> ufoProductPoolBOMap = ufoProductPoolDetailFieldBuilder.buildUfoProductPoolBOMap(ufoProductIdList);
168 175
169 //构造ProductIndexBO 176 //构造ProductIndexBO
170 for (Product product : productList) { 177 for (Product product : productList) {
@@ -175,7 +182,6 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -175,7 +182,6 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
175 // 构建ProductIndexBO并加入结果集 182 // 构建ProductIndexBO并加入结果集
176 ProductIndexBO productIndexBO = new ProductIndexBO(); 183 ProductIndexBO productIndexBO = new ProductIndexBO();
177 productIndexBOList.add(productIndexBO); 184 productIndexBOList.add(productIndexBO);
178 -  
179 // 一般字段 185 // 一般字段
180 ufoToYohoGeneralService.build(productIndexBO, product, ufoBrandSeriesMap); 186 ufoToYohoGeneralService.build(productIndexBO, product, ufoBrandSeriesMap);
181 // 品牌 187 // 品牌
@@ -200,6 +206,15 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { @@ -200,6 +206,15 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder {
200 productIndexBO.setCutdownPriceActivityIds(StringUtils.join(cutdownPriceInfoBO.getActivityIds(), ",")); 206 productIndexBO.setCutdownPriceActivityIds(StringUtils.join(cutdownPriceInfoBO.getActivityIds(), ","));
201 productIndexBO.setCutdownPriceOrder(cutdownPriceInfoBO.getOrder()); 207 productIndexBO.setCutdownPriceOrder(cutdownPriceInfoBO.getOrder());
202 } 208 }
  209 + //商品池
  210 + UfoProductPoolBO ufoProductPoolBO = ufoProductPoolBOMap.get(productIndexBO.getProductSkn());
  211 + if (ufoProductPoolBO == null) {
  212 + productIndexBO.setPoolIds("");
  213 + productIndexBO.setPools(new JSONArray());
  214 + } else {
  215 + productIndexBO.setPoolIds(ufoProductPoolBO.getPoolIds());
  216 + productIndexBO.setPools(ufoProductPoolBO.getPools());
  217 + }
203 } 218 }
204 return productIndexBOList; 219 return productIndexBOList;
205 } catch (Exception e) { 220 } catch (Exception e) {
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
4 import com.yoho.search.base.utils.ConvertUtils; 4 import com.yoho.search.base.utils.ConvertUtils;
5 import com.yoho.search.base.utils.ISearchConstants; 5 import com.yoho.search.base.utils.ISearchConstants;
6 import com.yoho.search.consumer.index.increment.AbstractMqListener; 6 import com.yoho.search.consumer.index.increment.AbstractMqListener;
  7 +import com.yoho.search.consumer.index.mix.Ufo2YohoIndexUpdateHelper;
7 import com.yoho.search.consumer.index.mix.UfoIndexUpdateHelper; 8 import com.yoho.search.consumer.index.mix.UfoIndexUpdateHelper;
8 import com.yoho.search.consumer.service.daoService.ufo.UfoProductPoolDetailService; 9 import com.yoho.search.consumer.service.daoService.ufo.UfoProductPoolDetailService;
9 import com.yoho.search.core.message.beans.SearchMqConsumerListerner; 10 import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
@@ -16,13 +17,15 @@ import org.springframework.stereotype.Component; @@ -16,13 +17,15 @@ import org.springframework.stereotype.Component;
16 * @version 2018/9/11 17 * @version 2018/9/11
17 */ 18 */
18 @Component 19 @Component
19 -@SearchMqConsumerListerner(dbName = "ufo_product",tableName = "product_pool_detail") 20 +@SearchMqConsumerListerner(dbName = "ufo_product", tableName = "product_pool_detail")
20 public class UfoProductPoolDetailMqListener extends AbstractMqListener { 21 public class UfoProductPoolDetailMqListener extends AbstractMqListener {
21 22
22 @Autowired 23 @Autowired
23 private UfoProductPoolDetailService ufoProductPoolDetailService; 24 private UfoProductPoolDetailService ufoProductPoolDetailService;
24 @Autowired 25 @Autowired
25 private UfoIndexUpdateHelper ufoIndexUpdateHelper; 26 private UfoIndexUpdateHelper ufoIndexUpdateHelper;
  27 + @Autowired
  28 + private Ufo2YohoIndexUpdateHelper ufo2YohoIndexUpdateHelper;
26 29
27 @Override 30 @Override
28 public String getIndexName() { 31 public String getIndexName() {
@@ -35,6 +38,7 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener { @@ -35,6 +38,7 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener {
35 ufoProductPoolDetailService.delete(Integer.valueOf(id)); 38 ufoProductPoolDetailService.delete(Integer.valueOf(id));
36 if (productPoolDetail != null) { 39 if (productPoolDetail != null) {
37 ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId()); 40 ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId());
  41 + ufo2YohoIndexUpdateHelper.updateYohoIndex(productPoolDetail.getProductId());
38 } 42 }
39 } 43 }
40 44
@@ -46,5 +50,6 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener { @@ -46,5 +50,6 @@ public class UfoProductPoolDetailMqListener extends AbstractMqListener {
46 } 50 }
47 ufoProductPoolDetailService.saveOrUpdate(productPoolDetail); 51 ufoProductPoolDetailService.saveOrUpdate(productPoolDetail);
48 ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId()); 52 ufoIndexUpdateHelper.updateUfoIndexByUfoProductId(productPoolDetail.getProductId());
  53 + ufo2YohoIndexUpdateHelper.updateYohoIndex(productPoolDetail.getProductId());
49 } 54 }
50 } 55 }
@@ -42,6 +42,18 @@ public class UfoProductPoolDetailFieldBuilder implements UfoIndexFieldBuilder { @@ -42,6 +42,18 @@ public class UfoProductPoolDetailFieldBuilder implements UfoIndexFieldBuilder {
42 } 42 }
43 } 43 }
44 44
  45 + /**
  46 + * 用于ufo融入有货
  47 + */
  48 + public Map<Integer, UfoProductPoolBO> buildUfoProductPoolBOMap(List<Integer> idList) {
  49 + List<UfoProductPoolBO> ufoProductPoolBOList = buildUfoProductPoolBOList(idList);
  50 + Map<Integer, UfoProductPoolBO> ufoProductPoolBOMap = new HashMap<>();
  51 + if (CollectionUtils.isNotEmpty(ufoProductPoolBOList)) {
  52 + ufoProductPoolBOMap = ufoProductPoolBOList.stream().collect(Collectors.toMap(UfoProductPoolBO::getProductId, p -> p));
  53 + }
  54 + return ufoProductPoolBOMap;
  55 + }
  56 +
45 private List<UfoProductPoolBO> buildUfoProductPoolBOList(List<Integer> idList) { 57 private List<UfoProductPoolBO> buildUfoProductPoolBOList(List<Integer> idList) {
46 List<UfoProductPoolBO> ufoProductPoolBOList = new ArrayList<>(); 58 List<UfoProductPoolBO> ufoProductPoolBOList = new ArrayList<>();
47 for (Integer id : idList) { 59 for (Integer id : idList) {