...
|
...
|
@@ -9,7 +9,10 @@ import com.yoho.search.base.utils.ISearchConstants; |
|
|
import com.yoho.search.base.utils.MD5Util;
|
|
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
|
|
import com.yoho.search.consumer.service.base.SuggestConversionCustomService;
|
|
|
import com.yoho.search.consumer.service.base.SuggestConversionService;
|
|
|
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
|
|
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
import com.yoho.search.dal.model.SuggestConversion;
|
|
|
import com.yoho.search.dal.model.SuggestConversionCustom;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -31,6 +34,9 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
|
|
private SuggestConversionCustomService suggestConversionCustomService;
|
|
|
|
|
|
@Autowired
|
|
|
private SuggestConversionService suggestConversionService;
|
|
|
|
|
|
@Autowired
|
|
|
private IYohoIndexService indexService;
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -85,8 +91,27 @@ public class SuggestConversionCustomMqListener extends AbstractMqListener implem |
|
|
return;
|
|
|
}
|
|
|
long begin = System.currentTimeMillis();
|
|
|
// 删除数据 NOTE:界面没有删除操作 如有删除 则等到全量索引里再处理
|
|
|
suggestConversionCustomService.delete(Integer.valueOf(id));
|
|
|
logger.info("[func=deleteData][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
|
|
|
SuggestConversionCustom sourceData = suggestConversionCustomService.selectByPrimaryKey(Integer.valueOf(id));
|
|
|
SuggestConversion suggestConversion;
|
|
|
if (sourceData != null) {
|
|
|
// 删除数据
|
|
|
suggestConversionCustomService.delete(Integer.valueOf(id));
|
|
|
logger.info("[func=deleteData][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
|
|
|
if ((suggestConversion = suggestConversionService.selectBySource(sourceData.getSource())) != null) {
|
|
|
// 还原成自动爬虫生成的数据
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
dataMap.put("source", suggestConversion.getSource());
|
|
|
dataMap.put("dest", suggestConversion.getDest());
|
|
|
dataMap.put("updateTime", suggestConversion.getUpdateTime());
|
|
|
dataMap.put("status", SuggestionConstants.VALID_STATUS);
|
|
|
indexService.updateIndexData(ISearchConstants.INDEX_NAME_CONVERSION, MD5Util.string2MD5(sourceData.getSource().trim().toLowerCase()), dataMap);
|
|
|
logger.info("[func=updateDataToES][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
} else {
|
|
|
indexService.deleteIndexData(ISearchConstants.INDEX_NAME_CONVERSION, MD5Util.string2MD5(sourceData.getSource().trim().toLowerCase()));
|
|
|
logger.info("[func=deleteDataFromES][step=success][tableName={}][id={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|