Authored by wangnan

优化mqlinster代码结构,减少重复代码

@@ -65,9 +65,9 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene @@ -65,9 +65,9 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
65 indexData.put("colorIds", StringUtils.join(colorIdSet, ",")); 65 indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
66 indexData.put("colorNames", StringUtils.join(colorNameSet, ",")); 66 indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
67 } else { 67 } else {
68 - indexData.put("goodsList", "");  
69 - indexData.put("colorIds", "");  
70 - indexData.put("colorNames", ""); 68 + indexData.put("goodsList", new JSONArray());
  69 + indexData.put("colorIds", " ");
  70 + indexData.put("colorNames", " ");
71 } 71 }
72 } 72 }
73 } 73 }
@@ -63,13 +63,13 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements @@ -63,13 +63,13 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements
63 if (productId == null) { 63 if (productId == null) {
64 return; 64 return;
65 } 65 }
66 - logger.info("[func=updateData][step1/3=covertFromMap][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost()); 66 + logger.info("[func=updateData][step(1/3)=covertFromMap][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
67 // 2.保存到数据库 67 // 2.保存到数据库
68 goodsService.saveOrUpdate(goods); 68 goodsService.saveOrUpdate(goods);
69 - logger.info("[func=updateData][step2/3=saveToBb][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost()); 69 + logger.info("[func=updateData][step(2/3)=saveToBb][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
70 // 3.更新到ES 70 // 3.更新到ES
71 updateProductIndex(productId, System.currentTimeMillis(), key); 71 updateProductIndex(productId, System.currentTimeMillis(), key);
72 - logger.info("[func=updateData][step3/4=updateProductIndex][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost()); 72 + logger.info("[func=updateData][step(3/4)=updateProductIndex][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
73 logger.info("[func=updateData][goodId={}][totalCost={}ms][costStatistics={}]", goods.getId(), costStatistics.getTotalCost(), 73 logger.info("[func=updateData][goodId={}][totalCost={}ms][costStatistics={}]", goods.getId(), costStatistics.getTotalCost(),
74 costStatistics.getCostStatisticsString()); 74 costStatistics.getCostStatisticsString());
75 } 75 }
@@ -103,17 +103,17 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements @@ -103,17 +103,17 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements
103 CostStatistics costStatistics = new CostStatistics(); 103 CostStatistics costStatistics = new CostStatistics();
104 Map<String, Object> indexData = new HashMap<String, Object>(); 104 Map<String, Object> indexData = new HashMap<String, Object>();
105 // 第一步:获取goodsList,组装goods数据 105 // 第一步:获取goodsList,组装goods数据
106 - fillColor(indexData, productId);  
107 - logger.info(" [func=updateProductIndex][step(1/4)fillColor][productId={}][cost={}]", productId, costStatistics.getCost()); 106 + this.fillColor(indexData, productId);
  107 + logger.info("[func=updateProductIndex][step(1/4)fillColor][productId={}][cost={}]", productId, costStatistics.getCost());
108 // 第二步、组装库存数据 108 // 第二步、组装库存数据
109 this.fillStorageNumAndSizeInfo(productId, indexData); 109 this.fillStorageNumAndSizeInfo(productId, indexData);
110 - logger.info(" [func=updateProductIndex][step(2/4)fillStorageNumAndSizeInfo][productId={}][cost={}]", productId, costStatistics.getCost()); 110 + logger.info("[func=updateProductIndex][step(2/4)fillStorageNumAndSizeInfo][productId={}][cost={}]", productId, costStatistics.getCost());
111 // 第三步,判断skn状态 111 // 第三步,判断skn状态
112 this.checkSknStatus(productId, indexData); 112 this.checkSknStatus(productId, indexData);
113 - logger.info(" [func=updateProductIndex][step(3/4)checkSknStatus][productId={}][cost={}]", productId, costStatistics.getCost()); 113 + logger.info("[func=updateProductIndex][step(3/4)checkSknStatus][productId={}][cost={}]", productId, costStatistics.getCost());
114 // 第四步:更新索引 114 // 第四步:更新索引
115 this.updateProductIndexWithDataMap(indexData, productId, key, begin); 115 this.updateProductIndexWithDataMap(indexData, productId, key, begin);
116 - logger.info(" [func=updateProductIndex][step(4/4)updateProductIndexWithDataMap][productId={}][cost={}]", productId, costStatistics.getCost()); 116 + logger.info("[func=updateProductIndex][step(4/4)updateProductIndexWithDataMap][productId={}][cost={}]", productId, costStatistics.getCost());
117 } 117 }
118 118
119 /** 119 /**