Showing
6 changed files
with
6 additions
and
100 deletions
@@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.fullbuild; | @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.fullbuild; | ||
2 | 2 | ||
3 | import com.yoho.search.consumer.index.common.IIndexBuilder; | 3 | import com.yoho.search.consumer.index.common.IIndexBuilder; |
4 | import com.yoho.search.consumer.service.base.ShopService; | 4 | import com.yoho.search.consumer.service.base.ShopService; |
5 | -import com.yoho.search.consumer.service.logic.ShopsLogicService; | ||
6 | import com.yoho.search.dal.model.Shops; | 5 | import com.yoho.search.dal.model.Shops; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
@@ -16,8 +15,6 @@ import java.util.List; | @@ -16,8 +15,6 @@ import java.util.List; | ||
16 | public class ShopsIndexBuilder extends IIndexBuilder { | 15 | public class ShopsIndexBuilder extends IIndexBuilder { |
17 | @Autowired | 16 | @Autowired |
18 | private ShopService shopService; | 17 | private ShopService shopService; |
19 | - @Autowired | ||
20 | - private ShopsLogicService shopsLogicService; | ||
21 | 18 | ||
22 | @Override | 19 | @Override |
23 | public int getTotalCount() throws Exception { | 20 | public int getTotalCount() throws Exception { |
@@ -26,7 +23,7 @@ public class ShopsIndexBuilder extends IIndexBuilder { | @@ -26,7 +23,7 @@ public class ShopsIndexBuilder extends IIndexBuilder { | ||
26 | 23 | ||
27 | @Override | 24 | @Override |
28 | public List<?> getPageLists(int offset, int limit) throws Exception { | 25 | public List<?> getPageLists(int offset, int limit) throws Exception { |
29 | - return shopsLogicService.getShopsBOs(offset, limit); | 26 | + return shopService.getshopPageLists(offset, limit); |
30 | } | 27 | } |
31 | 28 | ||
32 | @Override | 29 | @Override |
@@ -8,8 +8,6 @@ import com.yoho.search.base.utils.EventReportEnum; | @@ -8,8 +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.ShopService; | 10 | import com.yoho.search.consumer.service.base.ShopService; |
11 | -import com.yoho.search.consumer.service.bo.ShopsBO; | ||
12 | -import com.yoho.search.consumer.service.logic.ShopsLogicService; | ||
13 | import com.yoho.search.core.es.model.ESBluk; | 11 | import com.yoho.search.core.es.model.ESBluk; |
14 | import com.yoho.search.core.es.utils.IgnoreSomeException; | 12 | import com.yoho.search.core.es.utils.IgnoreSomeException; |
15 | import com.yoho.search.dal.model.Shops; | 13 | import com.yoho.search.dal.model.Shops; |
@@ -20,7 +18,6 @@ import org.springframework.amqp.core.Message; | @@ -20,7 +18,6 @@ import org.springframework.amqp.core.Message; | ||
20 | import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; | 18 | import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
22 | import org.springframework.stereotype.Component; | 20 | import org.springframework.stereotype.Component; |
23 | -import org.springframework.util.CollectionUtils; | ||
24 | 21 | ||
25 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
26 | import java.util.List; | 23 | import java.util.List; |
@@ -38,8 +35,6 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | @@ -38,8 +35,6 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | ||
38 | private IYohoIndexService indexService; | 35 | private IYohoIndexService indexService; |
39 | @Autowired | 36 | @Autowired |
40 | private ShopService shopService; | 37 | private ShopService shopService; |
41 | - @Autowired | ||
42 | - private ShopsLogicService shopsLogicService; | ||
43 | 38 | ||
44 | @Override | 39 | @Override |
45 | public void onMessage(Message message, Channel channel) throws Exception { | 40 | public void onMessage(Message message, Channel channel) throws Exception { |
@@ -78,15 +73,9 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | @@ -78,15 +73,9 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | ||
78 | String idValue = shops.getShopsId().toString(); | 73 | String idValue = shops.getShopsId().toString(); |
79 | shopService.saveOrUpdate(shops); | 74 | shopService.saveOrUpdate(shops); |
80 | logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin)); | 75 | logger.info("[func=updateData][step=saveToDb][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin)); |
81 | - List<Integer> ids = new ArrayList<>(); | ||
82 | - ids.add(shops.getShopsId()); | ||
83 | - List<ShopsBO> shopBOs = shopsLogicService.getShopsBOs(ids); | ||
84 | - if(!CollectionUtils.isEmpty(shopBOs)){ | ||
85 | - ShopsBO shopsBO = shopBOs.get(0); | ||
86 | List<ESBluk> results = new ArrayList<ESBluk>(); | 76 | List<ESBluk> results = new ArrayList<ESBluk>(); |
87 | - results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), indexName, indexName, false)); | 77 | + results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shops)), shops.getShopsId().toString(), indexName, indexName, false)); |
88 | indexService.bulk(results); | 78 | indexService.bulk(results); |
89 | - } | ||
90 | logger.info("[func=updateData][step=success][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin)); | 79 | logger.info("[func=updateData][step=success][indexName={}] [id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin)); |
91 | } | 80 | } |
92 | 81 | ||
@@ -103,8 +92,8 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | @@ -103,8 +92,8 @@ public class ShopsMqListener extends AbstractMqListener implements ChannelAwareM | ||
103 | logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin)); | 92 | logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin)); |
104 | } | 93 | } |
105 | 94 | ||
106 | - private Map<String, Object> beanToMap(ShopsBO shopsBO) { | ||
107 | - JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shopsBO); | 95 | + private Map<String, Object> beanToMap(Shops shops) { |
96 | + JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shops); | ||
108 | return josnoJsonObject; | 97 | return josnoJsonObject; |
109 | } | 98 | } |
110 | } | 99 | } |
@@ -9,13 +9,9 @@ import com.yoho.search.base.utils.EventReportEnum; | @@ -9,13 +9,9 @@ import com.yoho.search.base.utils.EventReportEnum; | ||
9 | import com.yoho.search.base.utils.ISearchConstants; | 9 | import com.yoho.search.base.utils.ISearchConstants; |
10 | import com.yoho.search.consumer.index.common.IYohoIndexService; | 10 | import com.yoho.search.consumer.index.common.IYohoIndexService; |
11 | import com.yoho.search.consumer.service.base.TblBrandService; | 11 | import com.yoho.search.consumer.service.base.TblBrandService; |
12 | -import com.yoho.search.consumer.service.bo.ShopsBO; | ||
13 | -import com.yoho.search.consumer.service.logic.tbl.TblBrandLogicService; | ||
14 | -import com.yoho.search.consumer.service.logic.tbl.TblShopsLogicService; | ||
15 | import com.yoho.search.core.es.model.ESBluk; | 12 | import com.yoho.search.core.es.model.ESBluk; |
16 | import com.yoho.search.core.es.utils.IgnoreSomeException; | 13 | import com.yoho.search.core.es.utils.IgnoreSomeException; |
17 | import com.yoho.search.dal.model.TblBrand; | 14 | import com.yoho.search.dal.model.TblBrand; |
18 | -import org.apache.commons.collections.CollectionUtils; | ||
19 | import org.apache.commons.lang.StringUtils; | 15 | import org.apache.commons.lang.StringUtils; |
20 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
21 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
@@ -43,11 +39,7 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | @@ -43,11 +39,7 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | ||
43 | @Autowired | 39 | @Autowired |
44 | private TblBrandService tblBrandService; | 40 | private TblBrandService tblBrandService; |
45 | @Autowired | 41 | @Autowired |
46 | - private TblShopsLogicService tblShopsLogicService; | ||
47 | - @Autowired | ||
48 | private IYohoIndexService indexService; | 42 | private IYohoIndexService indexService; |
49 | - @Autowired | ||
50 | - private TblBrandLogicService tblBrandLogicService; | ||
51 | 43 | ||
52 | 44 | ||
53 | protected ApplicationEventPublisher publisher; | 45 | protected ApplicationEventPublisher publisher; |
@@ -91,16 +83,6 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | @@ -91,16 +83,6 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | ||
91 | return; | 83 | return; |
92 | } | 84 | } |
93 | tblBrandService.saveOrUpdate(tblBrand); | 85 | tblBrandService.saveOrUpdate(tblBrand); |
94 | - //修改shop索引 | ||
95 | - List<Integer> ids = new ArrayList<>(); | ||
96 | - ids.add(tblBrand.getBrandId()); | ||
97 | - List<ShopsBO> shopsBOS = tblShopsLogicService.getShopsBOs(ids); | ||
98 | - if(CollectionUtils.isNotEmpty(shopsBOS)){ | ||
99 | - ShopsBO shopsBO = shopsBOS.get(0); | ||
100 | - List<ESBluk> results = new ArrayList<ESBluk>(); | ||
101 | - results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), ISearchConstants.INDEX_NAME_SHOPS, ISearchConstants.INDEX_NAME_SHOPS, false)); | ||
102 | - indexService.bulk(results); | ||
103 | - } | ||
104 | String idValue = data.get(idField).toString(); | 86 | String idValue = data.get(idField).toString(); |
105 | logger.info("[func=updateData][step=success][tableName=tblBrand][id={}][cost={}ms]", idValue, (System.currentTimeMillis() - begin)); | 87 | logger.info("[func=updateData][step=success][tableName=tblBrand][id={}][cost={}ms]", idValue, (System.currentTimeMillis() - begin)); |
106 | } | 88 | } |
@@ -117,9 +99,5 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | @@ -117,9 +99,5 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa | ||
117 | logger.info("[func=deleteData][step=success][tableName=tblBrand][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin)); | 99 | logger.info("[func=deleteData][step=success][tableName=tblBrand][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin)); |
118 | } | 100 | } |
119 | 101 | ||
120 | - private Map<String, Object> beanToMap(ShopsBO shopsBO) { | ||
121 | - JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shopsBO); | ||
122 | - return josnoJsonObject; | ||
123 | - } | ||
124 | 102 | ||
125 | } | 103 | } |
@@ -71,64 +71,6 @@ | @@ -71,64 +71,6 @@ | ||
71 | "shopIntro": { | 71 | "shopIntro": { |
72 | "type": "string" | 72 | "type": "string" |
73 | }, | 73 | }, |
74 | - "brandName": { | ||
75 | - "fields": { | ||
76 | - "brandName": { | ||
77 | - "type": "string", | ||
78 | - "analyzer": "lowercase_standard", | ||
79 | - "search_analyzer": "lowercase_standard" | ||
80 | - }, | ||
81 | - "brandName_ansj": { | ||
82 | - "type": "string", | ||
83 | - "store": false, | ||
84 | - "analyzer": "ik_complex", | ||
85 | - "search_analyzer": "ik_complex" | ||
86 | - }, | ||
87 | - "brandName_pinyin": { | ||
88 | - "type": "string", | ||
89 | - "store": false, | ||
90 | - "analyzer": "pinyin_analyzer", | ||
91 | - "search_analyzer": "standard" | ||
92 | - } | ||
93 | - }, | ||
94 | - "type": "multi_field" | ||
95 | - }, | ||
96 | - "brandNameCn": { | ||
97 | - "fields": { | ||
98 | - "brandNameCn": { | ||
99 | - "type": "string", | ||
100 | - "analyzer": "lowercase_standard", | ||
101 | - "search_analyzer": "lowercase_standard" | ||
102 | - }, | ||
103 | - "brandNameCn_ansj": { | ||
104 | - "type": "string", | ||
105 | - "store": false, | ||
106 | - "analyzer": "ik_complex", | ||
107 | - "search_analyzer": "ik_complex" | ||
108 | - }, | ||
109 | - "brandNameCn_pinyin": { | ||
110 | - "type": "string", | ||
111 | - "store": false, | ||
112 | - "analyzer": "pinyin_analyzer", | ||
113 | - "search_analyzer": "standard" | ||
114 | - } | ||
115 | - }, | ||
116 | - "type": "multi_field" | ||
117 | - }, | ||
118 | - "brandNameEn": { | ||
119 | - "type": "string", | ||
120 | - "analyzer": "lowercase_standard", | ||
121 | - "search_analyzer": "lowercase_standard" | ||
122 | - }, | ||
123 | - "brandDomain": { | ||
124 | - "type": "string", | ||
125 | - "analyzer": "lowercase_standard", | ||
126 | - "search_analyzer": "lowercase_standard" | ||
127 | - }, | ||
128 | - "isGlobal": { | ||
129 | - "type": "string", | ||
130 | - "index": "not_analyzed" | ||
131 | - }, | ||
132 | "decoratorTemplateType": { | 74 | "decoratorTemplateType": { |
133 | "type": "integer" | 75 | "type": "integer" |
134 | } | 76 | } |
@@ -182,7 +182,7 @@ | @@ -182,7 +182,7 @@ | ||
182 | <property key="refresh_interval" value="1s"/> | 182 | <property key="refresh_interval" value="1s"/> |
183 | <property key="translog.flush_threshold_ops" value="5000"/> | 183 | <property key="translog.flush_threshold_ops" value="5000"/> |
184 | </properties> | 184 | </properties> |
185 | - <builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder,com.yoho.search.consumer.index.fullbuild.TblShopsIndexBuilder</builderClass> | 185 | + <builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder</builderClass> |
186 | <mappingFile>esmapping/shops.json</mappingFile> | 186 | <mappingFile>esmapping/shops.json</mappingFile> |
187 | </index> | 187 | </index> |
188 | 188 |
@@ -159,7 +159,7 @@ | @@ -159,7 +159,7 @@ | ||
159 | <property key="refresh_interval" value="${search.index.refresh_interval}"/> | 159 | <property key="refresh_interval" value="${search.index.refresh_interval}"/> |
160 | <property key="translog.flush_threshold_ops" value="${search.index.translog.flush_threshold_ops}"/> | 160 | <property key="translog.flush_threshold_ops" value="${search.index.translog.flush_threshold_ops}"/> |
161 | </properties> | 161 | </properties> |
162 | - <builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder,com.yoho.search.consumer.index.fullbuild.TblShopsIndexBuilder</builderClass> | 162 | + <builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder</builderClass> |
163 | <mappingFile>esmapping/shops.json</mappingFile> | 163 | <mappingFile>esmapping/shops.json</mappingFile> |
164 | </index> | 164 | </index> |
165 | 165 |
-
Please register or login to post a comment