Authored by hugufei

添加召回日志

1 package com.yoho.search.recall.config; 1 package com.yoho.search.recall.config;
2 2
  3 +import com.alibaba.fastjson.JSON;
3 import com.yoho.search.base.utils.CollectionUtils; 4 import com.yoho.search.base.utils.CollectionUtils;
4 import com.yoho.search.core.personalized.models.SortBrand; 5 import com.yoho.search.core.personalized.models.SortBrand;
5 import com.yoho.search.recall.beans.strategy.SortBrandType; 6 import com.yoho.search.recall.beans.strategy.SortBrandType;
6 import com.yoho.search.recall.beans.strategy.StrategyEnum; 7 import com.yoho.search.recall.beans.strategy.StrategyEnum;
7 import com.yoho.search.recall.models.personal.PagePersonalFactor; 8 import com.yoho.search.recall.models.personal.PagePersonalFactor;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
8 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
10 13
@@ -15,6 +18,8 @@ import java.util.Set; @@ -15,6 +18,8 @@ import java.util.Set;
15 18
16 @Service 19 @Service
17 public class RecallConfigService { 20 public class RecallConfigService {
  21 +
  22 + private static final Logger RECALL_LOGGE = LoggerFactory.getLogger("RECALL");
18 @Autowired 23 @Autowired
19 private RecallConfigProductService recallConfigProductService; 24 private RecallConfigProductService recallConfigProductService;
20 @Autowired 25 @Autowired
@@ -37,8 +42,10 @@ public class RecallConfigService { @@ -37,8 +42,10 @@ public class RecallConfigService {
37 */ 42 */
38 public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) { 43 public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) {
39 String configKey = getStrategyConfigKey(strategyEnum); 44 String configKey = getStrategyConfigKey(strategyEnum);
40 - int value = recallConfigCommonService.queryConfigSize(pageId, configKey, 0);  
41 - return this.legallValue(value, 0, 100); 45 + int size = recallConfigCommonService.queryConfigSize(pageId, configKey, 0);
  46 + size = this.legallValue(size, 0, 100);
  47 + RECALL_LOGGE.info("queryStrategyConfigSize,pageId is [{}],strategyEnum is [{}],size is[{}]", pageId, strategyEnum.name(), size);
  48 + return size;
42 } 49 }
43 50
44 /** 51 /**
@@ -51,7 +58,9 @@ public class RecallConfigService { @@ -51,7 +58,9 @@ public class RecallConfigService {
51 public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) { 58 public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) {
52 String configKey = getStrategyConfigKey(strategyEnum); 59 String configKey = getStrategyConfigKey(strategyEnum);
53 int interval = recallConfigCommonService.queryConfigInterval(pageId, configKey, 10); 60 int interval = recallConfigCommonService.queryConfigInterval(pageId, configKey, 10);
54 - return this.legallValue(interval, 2, 40); 61 + interval = this.legallValue(interval, 2, 40);
  62 + RECALL_LOGGE.info("queryStrategyConfigInterval,pageId is [{}],strategyEnum is [{}],interval is[{}]", pageId, strategyEnum.name(), interval);
  63 + return interval;
55 } 64 }
56 65
57 private String getStrategyConfigKey(StrategyEnum strategyEnum) { 66 private String getStrategyConfigKey(StrategyEnum strategyEnum) {
@@ -81,8 +90,10 @@ public class RecallConfigService { @@ -81,8 +90,10 @@ public class RecallConfigService {
81 */ 90 */
82 public int querySortBrandConfigCount(int pageId, SortBrandType sortBrandType, int defaultSize) { 91 public int querySortBrandConfigCount(int pageId, SortBrandType sortBrandType, int defaultSize) {
83 String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType); 92 String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType);
84 - int value = recallConfigCommonService.queryConfigSize(pageId, sortBrandConfigKey, defaultSize);  
85 - return this.legallValue(value, 0, 30); 93 + int size = recallConfigCommonService.queryConfigSize(pageId, sortBrandConfigKey, defaultSize);
  94 + size = this.legallValue(size, 0, 30);
  95 + RECALL_LOGGE.info("querySortBrandConfigCount,pageId is [{}],sortBrandType is [{}],size is[{}]", pageId, sortBrandType.name(), size);
  96 + return size;
86 } 97 }
87 98
88 /** 99 /**
@@ -96,6 +107,7 @@ public class RecallConfigService { @@ -96,6 +107,7 @@ public class RecallConfigService {
96 String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType); 107 String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType);
97 RecallSknCount recallSknCount = recallConfigProductService.queryRecallSknCount(pageId, sortBrandConfigKey, sortBrand); 108 RecallSknCount recallSknCount = recallConfigProductService.queryRecallSknCount(pageId, sortBrandConfigKey, sortBrand);
98 if (recallSknCount == null) { 109 if (recallSknCount == null) {
  110 + RECALL_LOGGE.info("queryRecallSknCount,pageId is [{}],sortBrandType is [{}],RecallSknCount is[{}]", pageId, sortBrandType.name(), "null");
99 return null; 111 return null;
100 } 112 }
101 recallSknCount.setNewShelve(this.legallValue(recallSknCount.getNewShelve(), 0, 20)); 113 recallSknCount.setNewShelve(this.legallValue(recallSknCount.getNewShelve(), 0, 20));
@@ -104,6 +116,7 @@ public class RecallConfigService { @@ -104,6 +116,7 @@ public class RecallConfigService {
104 recallSknCount.setHeatValue(this.legallValue(recallSknCount.getHeatValue(), 0, 20)); 116 recallSknCount.setHeatValue(this.legallValue(recallSknCount.getHeatValue(), 0, 20));
105 recallSknCount.setReducePrice(this.legallValue(recallSknCount.getReducePrice(), 0, 20)); 117 recallSknCount.setReducePrice(this.legallValue(recallSknCount.getReducePrice(), 0, 20));
106 recallSknCount.setRandom(this.legallValue(recallSknCount.getRandom(), 0, 20)); 118 recallSknCount.setRandom(this.legallValue(recallSknCount.getRandom(), 0, 20));
  119 + RECALL_LOGGE.info("queryRecallSknCount,pageId is [{}],sortBrandType is [{}],RecallSknCount is[{}]", pageId, sortBrandType.name(), JSON.toJSONString(recallSknCount));
107 return recallSknCount; 120 return recallSknCount;
108 } 121 }
109 122
@@ -125,15 +138,16 @@ public class RecallConfigService { @@ -125,15 +138,16 @@ public class RecallConfigService {
125 138
126 /** 139 /**
127 * 随机获取configSortBrandCount数量 140 * 随机获取configSortBrandCount数量
  141 + *
128 * @param pageFactor 142 * @param pageFactor
129 * @param filterSortBrandKeys 143 * @param filterSortBrandKeys
130 * @param configSortBrandCount 144 * @param configSortBrandCount
131 * @return 145 * @return
132 */ 146 */
133 public List<SortBrand> queryConfigSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, int configSortBrandCount) { 147 public List<SortBrand> queryConfigSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, int configSortBrandCount) {
134 - List<SortBrand> pageConfigSortBrands = recallConfigSortBrandService.queryConfigSortBrand(pageFactor,filterSortBrandKeys); 148 + List<SortBrand> pageConfigSortBrands = recallConfigSortBrandService.queryConfigSortBrand(pageFactor, filterSortBrandKeys);
135 Collections.shuffle(pageConfigSortBrands); 149 Collections.shuffle(pageConfigSortBrands);
136 - return CollectionUtils.safeSubList(pageConfigSortBrands,0,configSortBrandCount); 150 + return CollectionUtils.safeSubList(pageConfigSortBrands, 0, configSortBrandCount);
137 } 151 }
138 152
139 public static void main(String[] args) { 153 public static void main(String[] args) {