...
|
...
|
@@ -8,7 +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.ShopsBrandsService;
|
|
|
import com.yoho.search.core.es.model.ESBluk;
|
|
|
import com.yoho.search.core.es.utils.IgnoreSomeException;
|
|
|
import com.yoho.search.dal.model.ShopsBrands;
|
|
|
import org.apache.commons.lang.StringUtils;
|
...
|
...
|
@@ -18,7 +17,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;
|
...
|
...
|
@@ -34,8 +32,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel |
|
|
private IYohoIndexService indexService;
|
|
|
@Autowired
|
|
|
private ShopsBrandsService shopsBrandsService;
|
|
|
@Autowired
|
|
|
private ShopsLogicService shopsLogicService;
|
|
|
|
|
|
@Override
|
|
|
public void onMessage(Message message, Channel channel) throws Exception {
|
...
|
...
|
@@ -74,16 +70,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel |
|
|
String idValue = shopsBrands.getId().toString();
|
|
|
shopsBrandsService.saveOrUpdate(shopsBrands);
|
|
|
logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
ids.add(shopsBrands.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);
|
|
|
}
|
|
|
logger.info("[func=updateData][step=success][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
|
|
|
}
|
|
|
|
|
|
public void deleteData(final String id, final String indexName, final String idField) throws Exception {
|
...
|
...
|
@@ -96,18 +82,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel |
|
|
logger.info("[func=deleteData][step=deleteFromDb][indexName={}] [id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
ids.add(shopsBrands.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);
|
|
|
}
|
|
|
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);
|
|
|
return josnoJsonObject;
|
|
|
}
|
|
|
} |
...
|
...
|
|