...
|
...
|
@@ -8,6 +8,7 @@ import com.yoho.search.base.utils.EventReportEnum; |
|
|
import com.yoho.search.base.utils.ISearchConstants;
|
|
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
|
|
import com.yoho.search.consumer.service.base.HelperService;
|
|
|
import com.yoho.search.core.es.model.ESBluk;
|
|
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
import com.yoho.search.dal.model.Helper;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -18,6 +19,8 @@ import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -65,27 +68,13 @@ public class HelperMqListener extends AbstractMqListener implements ChannelAware |
|
|
if (helper == null || helper.getId() == null) {
|
|
|
return;
|
|
|
}
|
|
|
//处理特殊枚举
|
|
|
if (data.get("isFaq").equals("1")) {
|
|
|
data.put("isFaq", "Y");
|
|
|
} else {
|
|
|
data.put("isFaq", "N");
|
|
|
}
|
|
|
if (data.get("isRobotQa").equals("1")) {
|
|
|
data.put("isRobotQa", "Y");
|
|
|
} else {
|
|
|
data.put("isRobotQa", "N");
|
|
|
}
|
|
|
if (data.get("isCustomerService").equals("1")) {
|
|
|
data.put("isCustomerService", "Y");
|
|
|
} else {
|
|
|
data.put("isCustomerService", "N");
|
|
|
}
|
|
|
|
|
|
helperService.saveOrUpdate(helper);
|
|
|
String idValue = helper.getId().toString();
|
|
|
indexService.updateIndexData(indexName, idValue, data);
|
|
|
logger.info("[func=updateData][step=success][indexName={}][id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
|
|
|
//查询出来更新到ES,为了获取正确的枚举值
|
|
|
Helper helper1 = helperService.getById(helper.getId());
|
|
|
List<ESBluk> results = new ArrayList<ESBluk>();
|
|
|
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(helper1)), helper1.getId().toString(), indexName, indexName, false));
|
|
|
indexService.bulk(results);
|
|
|
logger.info("[func=updateData][step=success][indexName={}][id={}][cost={}ms]", indexName, helper1.getId().toString(), (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
|
|
|
public void deleteData(final String id, final String indexName) throws Exception {
|
...
|
...
|
@@ -97,4 +86,9 @@ public class HelperMqListener extends AbstractMqListener implements ChannelAware |
|
|
indexService.deleteIndexData(indexName, id);
|
|
|
logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> beanToMap(Helper helper) {
|
|
|
JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(helper);
|
|
|
return josnoJsonObject;
|
|
|
}
|
|
|
} |
...
|
...
|
|