|
@@ -9,7 +9,10 @@ import com.yoho.search.base.utils.ISearchConstants; |
|
@@ -9,7 +9,10 @@ import com.yoho.search.base.utils.ISearchConstants; |
9
|
import com.yoho.search.base.utils.MD5Util;
|
9
|
import com.yoho.search.base.utils.MD5Util;
|
10
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
10
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
11
|
import com.yoho.search.consumer.service.base.SuggestConversionCustomService;
|
11
|
import com.yoho.search.consumer.service.base.SuggestConversionCustomService;
|
|
|
12
|
+import com.yoho.search.consumer.service.base.SuggestConversionService;
|
|
|
13
|
+import com.yoho.search.consumer.suggests.common.SuggestionConstants;
|
12
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
14
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
15
|
+import com.yoho.search.dal.model.SuggestConversion;
|
13
|
import com.yoho.search.dal.model.SuggestConversionCustom;
|
16
|
import com.yoho.search.dal.model.SuggestConversionCustom;
|
14
|
import org.apache.commons.lang3.StringUtils;
|
17
|
import org.apache.commons.lang3.StringUtils;
|
15
|
import org.slf4j.Logger;
|
18
|
import org.slf4j.Logger;
|
|
@@ -31,6 +34,9 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
|
@@ -31,6 +34,9 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
31
|
private SuggestConversionCustomService suggestConversionCustomService;
|
34
|
private SuggestConversionCustomService suggestConversionCustomService;
|
32
|
|
35
|
|
33
|
@Autowired
|
36
|
@Autowired
|
|
|
37
|
+ private SuggestConversionService suggestConversionService;
|
|
|
38
|
+
|
|
|
39
|
+ @Autowired
|
34
|
private IYohoIndexService indexService;
|
40
|
private IYohoIndexService indexService;
|
35
|
|
41
|
|
36
|
@Override
|
42
|
@Override
|
|
@@ -85,8 +91,27 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
|
@@ -85,8 +91,27 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
85
|
return;
|
91
|
return;
|
86
|
}
|
92
|
}
|
87
|
long begin = System.currentTimeMillis();
|
93
|
long begin = System.currentTimeMillis();
|
88
|
- // 删除数据 NOTE:界面没有删除操作 如有删除 则等到全量索引里再处理
|
94
|
+
|
|
|
95
|
+ SuggestConversionCustom sourceData = suggestConversionCustomService.selectByPrimaryKey(Integer.valueOf(id));
|
|
|
96
|
+ SuggestConversion suggestConversion;
|
|
|
97
|
+ if (sourceData != null) {
|
|
|
98
|
+ // 删除数据
|
89
|
suggestConversionCustomService.delete(Integer.valueOf(id));
|
99
|
suggestConversionCustomService.delete(Integer.valueOf(id));
|
90
|
logger.info("[func=deleteData][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
100
|
logger.info("[func=deleteData][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
101
|
+
|
|
|
102
|
+ if ((suggestConversion = suggestConversionService.selectBySource(sourceData.getSource())) != null) {
|
|
|
103
|
+ // 还原成自动爬虫生成的数据
|
|
|
104
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
105
|
+ dataMap.put("source", suggestConversion.getSource());
|
|
|
106
|
+ dataMap.put("dest", suggestConversion.getDest());
|
|
|
107
|
+ dataMap.put("updateTime", suggestConversion.getUpdateTime());
|
|
|
108
|
+ dataMap.put("status", SuggestionConstants.VALID_STATUS);
|
|
|
109
|
+ indexService.updateIndexData(ISearchConstants.INDEX_NAME_CONVERSION, MD5Util.string2MD5(sourceData.getSource().trim().toLowerCase()), dataMap);
|
|
|
110
|
+ logger.info("[func=updateDataToES][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
111
|
+ } else {
|
|
|
112
|
+ indexService.deleteIndexData(ISearchConstants.INDEX_NAME_CONVERSION, MD5Util.string2MD5(sourceData.getSource().trim().toLowerCase()));
|
|
|
113
|
+ logger.info("[func=deleteDataFromES][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
114
|
+ }
|
|
|
115
|
+ }
|
91
|
}
|
116
|
}
|
92
|
} |
117
|
} |