Authored by wangnan

fix

@@ -8,7 +8,6 @@ import com.yoho.search.base.utils.EventReportEnum; @@ -8,7 +8,6 @@ import com.yoho.search.base.utils.EventReportEnum;
8 import com.yoho.search.base.utils.ISearchConstants; 8 import com.yoho.search.base.utils.ISearchConstants;
9 import com.yoho.search.consumer.index.common.IYohoIndexService; 9 import com.yoho.search.consumer.index.common.IYohoIndexService;
10 import com.yoho.search.consumer.service.base.ShopsBrandsService; 10 import com.yoho.search.consumer.service.base.ShopsBrandsService;
11 -import com.yoho.search.core.es.model.ESBluk;  
12 import com.yoho.search.core.es.utils.IgnoreSomeException; 11 import com.yoho.search.core.es.utils.IgnoreSomeException;
13 import com.yoho.search.dal.model.ShopsBrands; 12 import com.yoho.search.dal.model.ShopsBrands;
14 import org.apache.commons.lang.StringUtils; 13 import org.apache.commons.lang.StringUtils;
@@ -18,7 +17,6 @@ import org.springframework.amqp.core.Message; @@ -18,7 +17,6 @@ import org.springframework.amqp.core.Message;
18 import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; 17 import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
19 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Component; 19 import org.springframework.stereotype.Component;
21 -import org.springframework.util.CollectionUtils;  
22 20
23 import java.util.ArrayList; 21 import java.util.ArrayList;
24 import java.util.List; 22 import java.util.List;
@@ -34,8 +32,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel @@ -34,8 +32,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
34 private IYohoIndexService indexService; 32 private IYohoIndexService indexService;
35 @Autowired 33 @Autowired
36 private ShopsBrandsService shopsBrandsService; 34 private ShopsBrandsService shopsBrandsService;
37 - @Autowired  
38 - private ShopsLogicService shopsLogicService;  
39 35
40 @Override 36 @Override
41 public void onMessage(Message message, Channel channel) throws Exception { 37 public void onMessage(Message message, Channel channel) throws Exception {
@@ -74,16 +70,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel @@ -74,16 +70,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
74 String idValue = shopsBrands.getId().toString(); 70 String idValue = shopsBrands.getId().toString();
75 shopsBrandsService.saveOrUpdate(shopsBrands); 71 shopsBrandsService.saveOrUpdate(shopsBrands);
76 logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin)); 72 logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
77 - List<Integer> ids = new ArrayList<>();  
78 - ids.add(shopsBrands.getShopsId());  
79 - List<ShopsBO> shopBOs = shopsLogicService.getShopsBOs(ids);  
80 - if (!CollectionUtils.isEmpty(shopBOs)) {  
81 - ShopsBO shopsBO = shopBOs.get(0);  
82 - List<ESBluk> results = new ArrayList<ESBluk>();  
83 - results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), indexName, indexName, false));  
84 - indexService.bulk(results);  
85 - }  
86 - logger.info("[func=updateData][step=success][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));  
87 } 73 }
88 74
89 public void deleteData(final String id, final String indexName, final String idField) throws Exception { 75 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 @@ -96,18 +82,6 @@ public class ShopsBrandsMqListener extends AbstractMqListener implements Channel
96 logger.info("[func=deleteData][step=deleteFromDb][indexName={}] [id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin)); 82 logger.info("[func=deleteData][step=deleteFromDb][indexName={}] [id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
97 List<Integer> ids = new ArrayList<>(); 83 List<Integer> ids = new ArrayList<>();
98 ids.add(shopsBrands.getShopsId()); 84 ids.add(shopsBrands.getShopsId());
99 - List<ShopsBO> shopBOs = shopsLogicService.getShopsBOs(ids);  
100 - if (!CollectionUtils.isEmpty(shopBOs)) {  
101 - ShopsBO shopsBO = shopBOs.get(0);  
102 - List<ESBluk> results = new ArrayList<ESBluk>();  
103 - results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), indexName, indexName, false));  
104 - indexService.bulk(results);  
105 - }  
106 - logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));  
107 } 85 }
108 86
109 - private Map<String, Object> beanToMap(ShopsBO shopsBO) {  
110 - JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shopsBO);  
111 - return josnoJsonObject;  
112 - }  
113 } 87 }