...
|
...
|
@@ -8,8 +8,6 @@ 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.ShopService;
|
|
|
import com.yoho.search.consumer.service.bo.ShopsBO;
|
|
|
import com.yoho.search.consumer.service.logic.ShopsLogicService;
|
|
|
import com.yoho.search.core.es.model.ESBluk;
|
|
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
import com.yoho.search.dal.model.Shops;
|
...
|
...
|
@@ -20,7 +18,6 @@ import org.springframework.amqp.core.Message; |
|
|
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
...
|
...
|
@@ -38,8 +35,6 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM |
|
|
private IYohoIndexService indexService;
|
|
|
@Autowired
|
|
|
private ShopService shopService;
|
|
|
@Autowired
|
|
|
private ShopsLogicService shopsLogicService;
|
|
|
|
|
|
@Override
|
|
|
public void onMessage(Message message, Channel channel) throws Exception {
|
...
|
...
|
@@ -78,15 +73,9 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM |
|
|
String idValue = shops.getShopsId().toString();
|
|
|
shopService.saveOrUpdate(shops);
|
|
|
logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
ids.add(shops.getShopsId());
|
|
|
List<ShopsBO> shopBOs = shopsLogicService.getShopsBOs(ids);
|
|
|
if(!CollectionUtils.isEmpty(shopBOs)){
|
|
|
ShopsBO shopsBO = shopBOs.get(0);
|
|
|
List<ESBluk> results = new ArrayList<ESBluk>();
|
|
|
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), indexName, indexName, false));
|
|
|
indexService.bulk(results);
|
|
|
}
|
|
|
List<ESBluk> results = new ArrayList<ESBluk>();
|
|
|
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shops)), shops.getShopsId().toString(), indexName, indexName, false));
|
|
|
indexService.bulk(results);
|
|
|
logger.info("[func=updateData][step=success][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -103,8 +92,8 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM |
|
|
logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> beanToMap(ShopsBO shopsBO) {
|
|
|
JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shopsBO);
|
|
|
private Map<String, Object> beanToMap(Shops shops) {
|
|
|
JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shops);
|
|
|
return josnoJsonObject;
|
|
|
}
|
|
|
} |
...
|
...
|
|