Authored by wangnan

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

... ... @@ -65,9 +65,9 @@ public abstract class AbstractStorageRelatedMqListener extends AbstractMqListene
indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
} else {
indexData.put("goodsList", "");
indexData.put("colorIds", "");
indexData.put("colorNames", "");
indexData.put("goodsList", new JSONArray());
indexData.put("colorIds", " ");
indexData.put("colorNames", " ");
}
}
}
\ No newline at end of file
... ...
... ... @@ -63,13 +63,13 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements
if (productId == null) {
return;
}
logger.info("[func=updateData][step1/3=covertFromMap][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
logger.info("[func=updateData][step(1/3)=covertFromMap][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
// 2.保存到数据库
goodsService.saveOrUpdate(goods);
logger.info("[func=updateData][step2/3=saveToBb][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
logger.info("[func=updateData][step(2/3)=saveToBb][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
// 3.更新到ES
updateProductIndex(productId, System.currentTimeMillis(), key);
logger.info("[func=updateData][step3/4=updateProductIndex][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
logger.info("[func=updateData][step(3/4)=updateProductIndex][goodId={}][cost={}ms]", goods.getId(), costStatistics.getCost());
logger.info("[func=updateData][goodId={}][totalCost={}ms][costStatistics={}]", goods.getId(), costStatistics.getTotalCost(),
costStatistics.getCostStatisticsString());
}
... ... @@ -103,17 +103,17 @@ public class GoodsMqListener extends AbstractStorageRelatedMqListener implements
CostStatistics costStatistics = new CostStatistics();
Map<String, Object> indexData = new HashMap<String, Object>();
// 第一步:获取goodsList,组装goods数据
fillColor(indexData, productId);
logger.info(" [func=updateProductIndex][step(1/4)fillColor][productId={}][cost={}]", productId, costStatistics.getCost());
this.fillColor(indexData, productId);
logger.info("[func=updateProductIndex][step(1/4)fillColor][productId={}][cost={}]", productId, costStatistics.getCost());
// 第二步、组装库存数据
this.fillStorageNumAndSizeInfo(productId, indexData);
logger.info(" [func=updateProductIndex][step(2/4)fillStorageNumAndSizeInfo][productId={}][cost={}]", productId, costStatistics.getCost());
logger.info("[func=updateProductIndex][step(2/4)fillStorageNumAndSizeInfo][productId={}][cost={}]", productId, costStatistics.getCost());
// 第三步,判断skn状态
this.checkSknStatus(productId, indexData);
logger.info(" [func=updateProductIndex][step(3/4)checkSknStatus][productId={}][cost={}]", productId, costStatistics.getCost());
logger.info("[func=updateProductIndex][step(3/4)checkSknStatus][productId={}][cost={}]", productId, costStatistics.getCost());
// 第四步:更新索引
this.updateProductIndexWithDataMap(indexData, productId, key, begin);
logger.info(" [func=updateProductIndex][step(4/4)updateProductIndexWithDataMap][productId={}][cost={}]", productId, costStatistics.getCost());
logger.info("[func=updateProductIndex][step(4/4)updateProductIndexWithDataMap][productId={}][cost={}]", productId, costStatistics.getCost());
}
/**
... ...