Authored by wangnan

revert

... ... @@ -2,7 +2,6 @@ package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.base.ShopService;
import com.yoho.search.consumer.service.logic.ShopsLogicService;
import com.yoho.search.dal.model.Shops;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -16,8 +15,6 @@ import java.util.List;
public class ShopsIndexBuilder extends IIndexBuilder {
@Autowired
private ShopService shopService;
@Autowired
private ShopsLogicService shopsLogicService;
@Override
public int getTotalCount() throws Exception {
... ... @@ -26,7 +23,7 @@ public class ShopsIndexBuilder extends IIndexBuilder {
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return shopsLogicService.getShopsBOs(offset, limit);
return shopService.getshopPageLists(offset, limit);
}
@Override
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -9,13 +9,9 @@ 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.TblBrandService;
import com.yoho.search.consumer.service.bo.ShopsBO;
import com.yoho.search.consumer.service.logic.tbl.TblBrandLogicService;
import com.yoho.search.consumer.service.logic.tbl.TblShopsLogicService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblBrand;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -43,11 +39,7 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa
@Autowired
private TblBrandService tblBrandService;
@Autowired
private TblShopsLogicService tblShopsLogicService;
@Autowired
private IYohoIndexService indexService;
@Autowired
private TblBrandLogicService tblBrandLogicService;
protected ApplicationEventPublisher publisher;
... ... @@ -91,16 +83,6 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa
return;
}
tblBrandService.saveOrUpdate(tblBrand);
//修改shop索引
List<Integer> ids = new ArrayList<>();
ids.add(tblBrand.getBrandId());
List<ShopsBO> shopsBOS = tblShopsLogicService.getShopsBOs(ids);
if(CollectionUtils.isNotEmpty(shopsBOS)){
ShopsBO shopsBO = shopsBOS.get(0);
List<ESBluk> results = new ArrayList<ESBluk>();
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(shopsBO)), shopsBO.getShopsId().toString(), ISearchConstants.INDEX_NAME_SHOPS, ISearchConstants.INDEX_NAME_SHOPS, false));
indexService.bulk(results);
}
String idValue = data.get(idField).toString();
logger.info("[func=updateData][step=success][tableName=tblBrand][id={}][cost={}ms]", idValue, (System.currentTimeMillis() - begin));
}
... ... @@ -117,9 +99,5 @@ public class TblBrandMqListener extends AbstractMqListener implements ChannelAwa
logger.info("[func=deleteData][step=success][tableName=tblBrand][id={}][cost={}ms]", id, (System.currentTimeMillis() - begin));
}
private Map<String, Object> beanToMap(ShopsBO shopsBO) {
JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(shopsBO);
return josnoJsonObject;
}
}
... ...
... ... @@ -71,64 +71,6 @@
"shopIntro": {
"type": "string"
},
"brandName": {
"fields": {
"brandName": {
"type": "string",
"analyzer": "lowercase_standard",
"search_analyzer": "lowercase_standard"
},
"brandName_ansj": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
},
"brandName_pinyin": {
"type": "string",
"store": false,
"analyzer": "pinyin_analyzer",
"search_analyzer": "standard"
}
},
"type": "multi_field"
},
"brandNameCn": {
"fields": {
"brandNameCn": {
"type": "string",
"analyzer": "lowercase_standard",
"search_analyzer": "lowercase_standard"
},
"brandNameCn_ansj": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex"
},
"brandNameCn_pinyin": {
"type": "string",
"store": false,
"analyzer": "pinyin_analyzer",
"search_analyzer": "standard"
}
},
"type": "multi_field"
},
"brandNameEn": {
"type": "string",
"analyzer": "lowercase_standard",
"search_analyzer": "lowercase_standard"
},
"brandDomain": {
"type": "string",
"analyzer": "lowercase_standard",
"search_analyzer": "lowercase_standard"
},
"isGlobal": {
"type": "string",
"index": "not_analyzed"
},
"decoratorTemplateType": {
"type": "integer"
}
... ...
... ... @@ -182,7 +182,7 @@
<property key="refresh_interval" value="1s"/>
<property key="translog.flush_threshold_ops" value="5000"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder,com.yoho.search.consumer.index.fullbuild.TblShopsIndexBuilder</builderClass>
<builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder</builderClass>
<mappingFile>esmapping/shops.json</mappingFile>
</index>
... ...
... ... @@ -159,7 +159,7 @@
<property key="refresh_interval" value="${search.index.refresh_interval}"/>
<property key="translog.flush_threshold_ops" value="${search.index.translog.flush_threshold_ops}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder,com.yoho.search.consumer.index.fullbuild.TblShopsIndexBuilder</builderClass>
<builderClass>com.yoho.search.consumer.index.fullbuild.ShopsIndexBuilder</builderClass>
<mappingFile>esmapping/shops.json</mappingFile>
</index>
... ...