Authored by wangnan

Merge branch 'master' into wn_add_marketphrase

# Conflicts:
#	index/src/main/resources/esmapping/productindex.json
#	service/src/main/java/com/yoho/search/consumer/service/base/ProductIndexService.java
#	service/src/main/java/com/yoho/search/consumer/service/bo/ProductIBO.java
#	service/src/main/java/com/yoho/search/consumer/service/logic/productIndex/ProductILogicService.java
Showing 38 changed files with 1873 additions and 1306 deletions

Too many changes to show.

To preserve performance only 38 of 38+ files are displayed.

package com.yoho.search.dal;
import java.util.List;
import com.yoho.search.dal.model.SalesCategory;
public interface SalesCategoryMapper {
int deleteByPrimaryKey(Integer categoryId);
int insert(SalesCategory record);
int insertSelective(SalesCategory record);
SalesCategory selectByPrimaryKey(Integer categoryId);
List<SalesCategory> selectAll();
int updateByPrimaryKeySelective(SalesCategory record);
int updateByPrimaryKey(SalesCategory record);
}
\ No newline at end of file
... ...
... ... @@ -6,22 +6,24 @@ import java.io.Serializable;
* Created by wangnan on 2016/6/30.
*/
public class BrokenCode implements Serializable {
private Integer productSkn;
private Double breakingRate;
public Integer getProductSkn() {
return productSkn;
}
private static final long serialVersionUID = -5187295436950928862L;
private Integer productSkn;
private Double breakingRate;
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public Integer getProductSkn() {
return productSkn;
}
public Double getBreakingRate() {
return breakingRate;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public void setBreakingRate(Double breakingRate) {
this.breakingRate = breakingRate;
}
public Double getBreakingRate() {
return breakingRate;
}
public void setBreakingRate(Double breakingRate) {
this.breakingRate = breakingRate;
}
}
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class GoodsCoverImage implements Serializable {
private Integer id;
public class GoodsCoverImage{
private Integer id;
private Integer goodsId;
private String cover_1;
private String cover_2;
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductActivity implements Serializable {
private Integer productSkn;
public class ProductActivity{
private Integer productSkn;
private String activity;
public Integer getProductSkn() {
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/29.
*/
public class ProductColors implements Serializable {
public class ProductColors {
private Integer productId;
private String colorIds;
private String colorNames;
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductDefaultImage implements Serializable {
public class ProductDefaultImage{
private Integer productId;
private String defaultImage;
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductSearchBrand implements Serializable {
public class ProductSearchBrand {
private Integer productSkn;
private Integer brandWeightId;
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
public class ProductSearchShop {
private Integer productSkn;
private Integer shopWeightId;
public class ProductSearchShop implements Serializable {
private Integer productSkn;
private Integer shopWeightId;
public Integer getProductSkn() {
return productSkn;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public Integer getShopWeightId() {
return shopWeightId;
}
public void setShopWeightId(Integer shopWeightId) {
this.shopWeightId = shopWeightId;
}
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductSearchSort implements Serializable {
private Integer productSkn;
public class ProductSearchSort {
private Integer productSkn;
private Integer sortWeightId;
public Integer getProductSkn() {
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductSizes implements Serializable {
public class ProductSizes {
private Integer productId;
private String sizeIds;
private String sizeNames;
//private Integer salesNum;
private Integer storageNum;
public Integer getProductId() {
... ...
package com.yoho.search.dal.model;
import java.io.Serializable;
/**
* Created by wangnan on 2016/6/30.
*/
public class ProductStyles implements Serializable {
public class ProductStyles{
private Integer productId;
private String styleIds;
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.SalesCategoryMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.SalesCategory">
<id column="category_id" property="categoryId" jdbcType="INTEGER" />
<result column="category_name" property="categoryName" jdbcType="VARCHAR" />
<result column="relation_parameter" property="relationParameter" jdbcType="VARCHAR" />
<result column="relation_url" property="relationUrl" jdbcType="VARCHAR" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="order_by" property="orderBy" jdbcType="INTEGER" />
<result column="icon" property="icon" jdbcType="VARCHAR" />
<result column="category_code" property="categoryCode" jdbcType="VARCHAR" />
<result column="state" property="state" jdbcType="INTEGER" />
<result column="level_number" property="levelNumber" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="app_type" property="appType" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
category_id, category_name, relation_parameter,
relation_url, parent_id, order_by,
icon, category_code, state,
level_number, create_time, app_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from sales_category
where category_id = #{categoryId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from
sales_category
where category_id = #{categoryId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.SalesCategory">
insert into sales_category
(category_id, category_name,
relation_parameter,
relation_url,
parent_id, order_by,
icon, category_code, state,
level_number,
create_time, app_type
)
values (#{categoryId,jdbcType=INTEGER},
#{categoryName,jdbcType=VARCHAR},
#{relationParameter,jdbcType=VARCHAR},
#{relationUrl,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
#{orderBy,jdbcType=INTEGER},
#{icon,jdbcType=VARCHAR},
#{categoryCode,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER},
#{levelNumber,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER},
#{appType,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.SalesCategory">
insert into sales_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="categoryId != null">
category_id,
</if>
<if test="categoryName != null">
category_name,
</if>
<if test="relationParameter != null">
relation_parameter,
</if>
<if test="relationUrl != null">
relation_url,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="orderBy != null">
order_by,
</if>
<if test="icon != null">
icon,
</if>
<if test="categoryCode != null">
category_code,
</if>
<if test="state != null">
state,
</if>
<if test="levelNumber != null">
level_number,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="appType != null">
app_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryId != null">
#{categoryId,jdbcType=INTEGER},
</if>
<if test="categoryName != null">
#{categoryName,jdbcType=VARCHAR},
</if>
<if test="relationParameter != null">
#{relationParameter,jdbcType=VARCHAR},
</if>
<if test="relationUrl != null">
#{relationUrl,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=INTEGER},
</if>
<if test="orderBy != null">
#{orderBy,jdbcType=INTEGER},
</if>
<if test="icon != null">
#{icon,jdbcType=VARCHAR},
</if>
<if test="categoryCode != null">
#{categoryCode,jdbcType=VARCHAR},
</if>
<if test="state != null">
#{state,jdbcType=INTEGER},
</if>
<if test="levelNumber != null">
#{levelNumber,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="appType != null">
#{appType,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.SalesCategory">
update sales_category
<set>
<if test="categoryName != null">
category_name = #{categoryName,jdbcType=VARCHAR},
</if>
<if test="relationParameter != null">
relation_parameter =
#{relationParameter,jdbcType=VARCHAR},
</if>
<if test="relationUrl != null">
relation_url = #{relationUrl,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="orderBy != null">
order_by = #{orderBy,jdbcType=INTEGER},
</if>
<if test="icon != null">
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="categoryCode != null">
category_code = #{categoryCode,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=INTEGER},
</if>
<if test="levelNumber != null">
level_number = #{levelNumber,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="appType != null">
app_type = #{appType,jdbcType=TINYINT},
</if>
</set>
where category_id = #{categoryId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SalesCategory">
update
sales_category
set category_name = #{categoryName,jdbcType=VARCHAR},
relation_parameter = #{relationParameter,jdbcType=VARCHAR},
relation_url = #{relationUrl,jdbcType=VARCHAR},
parent_id =
#{parentId,jdbcType=INTEGER},
order_by = #{orderBy,jdbcType=INTEGER},
icon = #{icon,jdbcType=VARCHAR},
category_code =
#{categoryCode,jdbcType=VARCHAR},
state = #{state,jdbcType=INTEGER},
level_number = #{levelNumber,jdbcType=INTEGER},
create_time =
#{createTime,jdbcType=INTEGER},
app_type = #{appType,jdbcType=TINYINT}
where category_id = #{categoryId,jdbcType=INTEGER}
</update>
<select id="selectAll" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List" />
from sales_category
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.common.impl;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import javax.annotation.PostConstruct;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import com.yoho.search.base.utils.FileUtils;
import com.yoho.search.base.utils.JaxbBinder;
import com.yoho.search.consumer.index.common.IIndexBuilder;
... ... @@ -17,28 +40,6 @@ import com.yoho.search.core.es.impl.YohoIndexHelper;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
@Component
public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEventPublisherAware {
... ... @@ -55,8 +56,9 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
private IYohoIndexDataLoader yohoIndexDataLoader;
@Autowired
private IndexRebuildListenerMgr indexRebuildListenerMgr;
ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
... ... @@ -105,7 +107,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
throw new RuntimeException("初始化索引服务失败,Exception: ", e);
}
}
@Override
public ClusterHealthStatus getClusterHealthStatus(String yohoIndexName) {
IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
... ... @@ -115,7 +117,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
IElasticsearchClient client = index.getIndexClient();
return client.getClusterHealthStatus(yohoIndexName);
}
@Override
public IYohoIndex getIndex(String yohoIndexName) {
return this.nameToIndexMap.get(yohoIndexName);
... ... @@ -129,16 +131,21 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
}
IElasticsearchClient client = index.getIndexClient();
// 获取真实的索引名
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return false;
}
if (realIndexNames.size() != 1) {
client.deleteIndexs(realIndexNames);
return false;
}
return client.indexExists(realIndexName);
return client.indexExists(realIndexNames.get(0));
}
@Override
public String createIndex(final String yohoIndexName, final boolean force) throws Exception {
return this.createIndex(yohoIndexName, yohoIndexName, force);
String yohoIndexAliasName = yohoIndexName;
return this.createIndex(yohoIndexName, yohoIndexAliasName, force);
}
@Override
... ... @@ -149,8 +156,8 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
}
IElasticsearchClient client = index.getIndexClient();
// 1、判断旧索引是否存在,如果存在且不是强制更新,则直接返回
String oldRealIndexName = yohoIndexHelper.getRealIndexName(alias, client);
if (StringUtils.isNotBlank(oldRealIndexName) && !force) {
List<String> oldRealIndexNames = yohoIndexHelper.getRealIndexNames(alias, client.getRealNameToAliasesMap());
if (oldRealIndexNames != null && oldRealIndexNames.size() == 1 && !force) {
return null;
}
// 2、生成真实索引名称
... ... @@ -160,14 +167,17 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
final String mappingContent = index.getMappingContent();
client.createIndex(newRealIndexName, yohoIndexName, settings, mappingContent);
// 4、删除旧索引别名
if (oldRealIndexName != null) {
client.removeAlias(oldRealIndexName, alias);
if (oldRealIndexNames != null && !oldRealIndexNames.isEmpty()) {
client.removeAlias(oldRealIndexNames, alias);
}
// 5、添加新索引别名
client.addAlias(alias, newRealIndexName);
// 6、删除旧索引
if (oldRealIndexName != null) {
client.deleteIndex(oldRealIndexName);
// 5、添加新索引别名【如果存在一个名字为alias的真实索引,则直接删除】
if (client.indexExists(alias)) {
client.deleteIndex(alias);
}
client.addAlias(newRealIndexName, alias);
// 7、删除旧索引
if (oldRealIndexNames != null && !oldRealIndexNames.isEmpty()) {
client.deleteIndexs(oldRealIndexNames);
}
return newRealIndexName;
}
... ... @@ -179,11 +189,11 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.deleteIndex(realIndexName);
client.deleteIndexs(realIndexNames);
}
@Override
... ... @@ -193,32 +203,38 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
// 1、获取真实索引的正则规则
String regEx = yohoIndexHelper.getTemplateIndexNamePattern(yohoIndexName);
String regEx = yohoIndexHelper.getRealIndexNamePattern(yohoIndexName);
Pattern p = Pattern.compile(regEx);
// 2、获取ES集群中真实索引名称对临时索引名称
Map<String, List<String>> realNameToAliasesMap = client.getRealNameToAliasesMap();
// 3、删除realIndexName对应的索引
// 3、找出yohoIndexName对应的非法索引
List<String> tempRealIndexNames = new ArrayList<String>();
for (Map.Entry<String, List<String>> entry : realNameToAliasesMap.entrySet()) {
String realIndexName = entry.getKey();
if (!p.matcher(realIndexName).find()) {
// 1)如果真实索引名称和yohoIndexName相同,则可能是增量创建的索引,视为非法
if (realIndexName.equals(yohoIndexName)) {
tempRealIndexNames.add(realIndexName);
continue;
}
boolean validate = false;
for (String alias : entry.getValue()) {
if (yohoIndexName.equals(alias)) {
validate = true;
break;
}
// 2)如果真实索引名称非法,则无视
if (!p.matcher(realIndexName).find()) {
continue;
}
if (!validate) {
client.deleteIndex(realIndexName);
INDEX_REBUILD_LOG.info("[client={}] 删除遗留的临时索引:[id={}]", client.getName(), realIndexName);
// 3)如果别名中不包含yohoIndexName,则视为失败的临时索引
List<String> aliasNames = entry.getValue();
if (aliasNames == null || !aliasNames.contains(yohoIndexName)) {
tempRealIndexNames.add(realIndexName);
continue;
}
}
// 4、删除yohoIndexName对应的非法索引
if (tempRealIndexNames != null && !tempRealIndexNames.isEmpty()) {
client.deleteIndexs(tempRealIndexNames);
INDEX_REBUILD_LOG.info("[client={}] 删除遗留的临时索引:[tempRealIndexNames={}]", client.getName(), tempRealIndexNames);
}
}
@Override
... ... @@ -228,11 +244,13 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.refreshIndex(realIndexName);
for (String realIndexName : realIndexNames) {
client.refreshIndex(realIndexName);
}
}
@Override
... ... @@ -242,11 +260,13 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.closeIndex(realIndexName);
for (String realIndexName : realIndexNames) {
client.closeIndex(realIndexName);
}
}
@Override
... ... @@ -256,11 +276,13 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.flushIndex(realIndexName);
for (String realIndexName : realIndexNames) {
client.flushIndex(realIndexName);
}
}
@Override
... ... @@ -274,32 +296,38 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
// 1、获取真实索引名与别名的对应关系
Map<String, List<String>> realNameToAliasesMap = client.getRealNameToAliasesMap();
// 2、获取真实的索引名称
String oldIndexId = yohoIndexHelper.getRealIndexName(yohoIndexName, realNameToAliasesMap);
String newIndexId = yohoIndexHelper.getRealIndexName(yohoTemplateIndexName, realNameToAliasesMap);
if (newIndexId == null) {
// 2、获取新的索引名称[考虑一个别名有多个索引的情况]
List<String> newIndexRealNames = yohoIndexHelper.getRealIndexNames(yohoTemplateIndexName, realNameToAliasesMap);
if (newIndexRealNames == null || newIndexRealNames.isEmpty()) {
return;
}
// 4. 把老索引的索引名先删除
if (oldIndexId != null) {
client.removeAlias(oldIndexId, yohoIndexName);
if (newIndexRealNames.size() != 1) {
client.deleteIndexs(newIndexRealNames);
return;
}
// 5. 把新索引的别名全部删除
List<String> yohoTemplateIndexNameAlias = realNameToAliasesMap.get(newIndexId);
for (String alias : yohoTemplateIndexNameAlias) {
client.removeAlias(newIndexId, alias);
// 3、获取老的索引名称列表
List<String> oldIndexRealNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, realNameToAliasesMap);
// 4. 把全部老索引的别名全部删除
String yohoIndexAliasName = yohoIndexName;
if (oldIndexRealNames != null && !oldIndexRealNames.isEmpty()) {
client.removeAlias(oldIndexRealNames, yohoIndexAliasName);
}
// 6. 把老索引的索引名加到新索引上面
client.addAlias(yohoIndexName, newIndexId);
// 5. 把唯一的一个新索引的别名全部删除
String newIndexRealName = newIndexRealNames.get(0);
List<String> aliasList = realNameToAliasesMap.get(newIndexRealName);
String[] aliases = aliasList.toArray(new String[aliasList.size()]);
client.removeAlias(newIndexRealName, aliases);
// 6. 把别名加到新索引上面
client.addAlias(newIndexRealName, yohoIndexAliasName);
// 7. 删除老索引
if (oldIndexId != null) {
client.deleteIndex(oldIndexId);
if (oldIndexRealNames != null && !oldIndexRealNames.isEmpty()) {
client.deleteIndexs(oldIndexRealNames);
}
}
@Override
... ... @@ -309,11 +337,13 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.optimize(realIndexName);
for (String realIndexName : realIndexNames) {
client.optimize(realIndexName);
}
}
/**
... ... @@ -406,27 +436,15 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.addIndexData(realIndexName, yohoIndexName, id, data);
for (String realIndexName : realIndexNames) {
client.addIndexData(realIndexName, yohoIndexName, id, data);
}
}
// @Override
// public void addIndexData(final String yohoIndexName, final List<Map<String, Object>> dataList) throws Exception {
// IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
// if (index == null) {
// return;
// }
// IElasticsearchClient client = index.getIndexClient();
// String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
// if (StringUtils.isBlank(realIndexName)) {
// return;
// }
// client.addIndexData(realIndexName, yohoIndexName, dataList);
// }
@Override
public void deleteIndexData(final String yohoIndexName, final String id) throws Exception {
IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
... ... @@ -434,27 +452,15 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
client.deleteIndexData(realIndexName, yohoIndexName, id);
for (String realIndexName : realIndexNames) {
client.deleteIndexData(realIndexName, yohoIndexName, id);
}
}
// @Override
// public void deleteIndexDataByQuery(final String yohoIndexName, final String query) throws Exception {
// IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
// if (index == null) {
// return;
// }
// IElasticsearchClient client = index.getIndexClient();
// String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
// if (StringUtils.isBlank(realIndexName)) {
// return;
// }
// client.deleteIndexDataByQuery(realIndexName, yohoIndexName, query);
// }
@Override
public void updateIndexData(final String yohoIndexName, final String id, final Object data) throws Exception {
IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
... ... @@ -462,7 +468,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
List<String> realIndexNames = yohoIndexHelper.getRelatedIndexs(yohoIndexName, client);
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
... ... @@ -478,7 +484,7 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return;
}
IElasticsearchClient client = index.getIndexClient();
List<String> realIndexNames = yohoIndexHelper.getRelatedIndexs(yohoIndexName, client);
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return;
}
... ... @@ -514,13 +520,13 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return null;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return null;
}
return client.get(realIndexName, yohoIndexName, id);
return client.get(realIndexNames.get(0), yohoIndexName, id);
}
@Override
public MultiGetResponse multiGet(String yohoIndexName, Set<String> idList, List<String> fields) {
IYohoIndex index = this.nameToIndexMap.get(yohoIndexName);
... ... @@ -528,11 +534,11 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return null;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return null;
}
return client.multiGet(realIndexName, yohoIndexName, idList, fields);
return client.multiGet(realIndexNames.get(0), yohoIndexName, idList, fields);
}
@Override
... ... @@ -542,8 +548,8 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
return null;
}
IElasticsearchClient client = index.getIndexClient();
String realIndexName = yohoIndexHelper.getRealIndexName(yohoIndexName, client);
if (StringUtils.isBlank(realIndexName)) {
List<String> realIndexNames = yohoIndexHelper.getRealIndexNames(yohoIndexName, client);
if (realIndexNames == null || realIndexNames.isEmpty()) {
return new ArrayList<AnalyzeToken>();
}
AnalyzeResponse analyzeResponse = client.getAnalyzeResponse(yohoIndexName, text, analyzer);
... ... @@ -551,19 +557,20 @@ public class YohoIndexServiceImpl implements IYohoIndexService, ApplicationEvent
}
@Override
public BulkResponse bulk(List<ESBluk> esBluks){
public BulkResponse bulk(List<ESBluk> esBluks) {
IYohoIndex index = this.nameToIndexMap.get(esBluks.get(0).getIndexName());
if (index == null) {
return null;
}
rebuildFlagService.waitingRebuildingIndex();
IElasticsearchClient client = index.getIndexClient();
BulkResponse bulkResponse = client.bulk(esBluks);
if(bulkResponse.hasFailures()){
logger.warn("bulk failure",bulkResponse.buildFailureMessage());
}
BulkResponse bulkResponse = client.bulk(esBluks);
if (bulkResponse.hasFailures()) {
logger.warn("bulk failure", bulkResponse.buildFailureMessage());
}
return bulkResponse;
}
@Override
public boolean checkHealth(String indexName) {
IYohoIndex index = this.nameToIndexMap.get(indexName);
... ...
... ... @@ -2,10 +2,8 @@ package com.yoho.search.consumer.index.increment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
... ... @@ -16,7 +14,6 @@ import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
... ... @@ -24,37 +21,24 @@ import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.bulks.StorageSkuIndexBulkService;
import com.yoho.search.consumer.index.increment.rule.AbstractStorageRelatedMqListener;
import com.yoho.search.consumer.service.base.GoodsService;
import com.yoho.search.consumer.service.base.Product15DaySalesNumService;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.bo.StorageSkuBO;
import com.yoho.search.consumer.service.logic.StorageSkuLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Goods;
import com.yoho.search.dal.model.Storage;
@Component
public class GoodsMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
public class GoodsMqListener extends AbstractStorageRelatedMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(GoodsMqListener.class);
@Autowired
private IYohoIndexService indexService;
@Autowired
private GoodsService goodsService;
@Autowired
private StorageService storageService;
@Autowired
private StorageSkuIndexBulkService storageSkuIndexService;
@Autowired
private Product15DaySalesNumService product15DaySalesNumService;
@Autowired
private StorageSkuLogicService storageSkuLogicService;
@Autowired
private ProductService productService;
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -144,79 +128,18 @@ public class GoodsMqListener extends AbstractMqListener implements ChannelAwareM
private void updateIndexNew(Integer productId, long begin, final String key) {
CostStatistics costStatistics = new CostStatistics();
Set<String> colorIdSet = new HashSet<String>();
Set<String> colorNameSet = new HashSet<String>();
Map<String, Object> indexData = new HashMap<String, Object>();
// 第一步:获取goodsList
List<ProductGoodsBO> productGoodsBOList = goodsService.getProductGoodsByProductId(productId);
logger.info("[model=GoodsMqListener_UpdateIndexNew][step=getGoodsListByProductId][productId={}][cost={}]", productId, costStatistics.getCost());
// 第二步、组装goods数据
if (productGoodsBOList != null && productGoodsBOList.size() == 1) {
ProductGoodsBO productGoodsBO = productGoodsBOList.get(0);
String goodsListJsonArrayStr = productGoodsBO.getGoodsList();
JSONArray goodsListJsonArray = JSONArray.parseArray(goodsListJsonArrayStr);
for (int i = 0; i < goodsListJsonArray.size(); i++) {
JSONObject jsonObject = goodsListJsonArray.getJSONObject(i);
if (jsonObject.containsKey("color_id")) {
colorIdSet.add(jsonObject.get("color_id").toString());
}
if (jsonObject.containsKey("color_name")) {
colorNameSet.add(jsonObject.get("color_name").toString());
}
}
indexData.put("goodsList", goodsListJsonArray);
indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
} else {
indexData.put("goodsList", "");
indexData.put("colorIds", "");
indexData.put("colorNames", "");
}
//第一步:获取goodsList,组装goods数据
fillColor(indexData,productId);
logger.info("[model=GoodsMqListener_UpdateIndexNew][step=genGoodsList][productId={}][cost={}]", productId, costStatistics.getCost());
// 第三步、组装库存数据
this.fillProductStorage(productId, indexData);
// 第二步、组装库存数据
this.fillStorageNumAndSizeInfo(productId, indexData);
logger.info("[model=GoodsMqListener_UpdateIndexNew][step=fillProductStorage][productId={}][cost={}]", productId, costStatistics.getCost());
// 第步:更新索引
// 第步:更新索引
this.updateProductIndexWithDataMap(indexData, productId, key, begin);
logger.info("[model=GoodsMqListener_UpdateIndexNew][step=updateProductIndexWithDataMap][productId={}][cost={}]", productId, costStatistics.getCost());
}
/**
* 更新库存
*
* @param productId
* @param indexData
*/
private void fillProductStorage(Integer productId, Map<String, Object> indexData) {
// 第三步、更新库存
List<Storage> storageList = storageService.getStoragesByProductId(productId);
if (storageList.isEmpty()) {
indexData.put("storageNum", null);
indexData.put("isSoonSoldOut", null);
indexData.put("isSoldOut", null);
indexData.put("soldOut", null);
indexData.put("sizeIds", null);
} else {
int storageNum = 0;
Set<String> sizeSet = new HashSet<String>();
for (Storage stor : storageList) {
storageNum += stor.getStorageNum();
if (stor.getGoodsDimensionId() != null) {
sizeSet.add(stor.getGoodsDimensionId() + "");
}
}
indexData.put("storageNum", storageNum);
indexData.put("isSoonSoldOut", storageNum <= 2 ? "Y" : "N");
indexData.put("isSoldOut", storageNum == 0 ? "Y" : "N");
indexData.put("soldOut", storageNum == 0 ? 0 : 1);
if (!sizeSet.isEmpty()) {
indexData.put("sizeIds", StringUtils.join(sizeSet, ","));
}
}
}
}
... ...
... ... @@ -8,6 +8,7 @@ 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.HelperService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Helper;
import org.apache.commons.lang3.StringUtils;
... ... @@ -18,6 +19,8 @@ import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
... ... @@ -65,27 +68,13 @@ public class HelperMqListener extends AbstractMqListener implements ChannelAware
if (helper == null || helper.getId() == null) {
return;
}
//处理特殊枚举
if (data.get("isFaq").equals("1")) {
data.put("isFaq", "Y");
} else {
data.put("isFaq", "N");
}
if (data.get("isRobotQa").equals("1")) {
data.put("isRobotQa", "Y");
} else {
data.put("isRobotQa", "N");
}
if (data.get("isCustomerService").equals("1")) {
data.put("isCustomerService", "Y");
} else {
data.put("isCustomerService", "N");
}
helperService.saveOrUpdate(helper);
String idValue = helper.getId().toString();
indexService.updateIndexData(indexName, idValue, data);
logger.info("[func=updateData][step=success][indexName={}][id={}][cost={}ms]", indexName, idValue, (System.currentTimeMillis() - begin));
//查询出来更新到ES,为了获取正确的枚举值
Helper helper1 = helperService.getById(helper.getId());
List<ESBluk> results = new ArrayList<ESBluk>();
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(helper1)), helper1.getId().toString(), indexName, indexName, false));
indexService.bulk(results);
logger.info("[func=updateData][step=success][indexName={}][id={}][cost={}ms]", indexName, helper1.getId().toString(), (System.currentTimeMillis() - begin));
}
public void deleteData(final String id, final String indexName) throws Exception {
... ... @@ -97,4 +86,9 @@ public class HelperMqListener extends AbstractMqListener implements ChannelAware
indexService.deleteIndexData(indexName, id);
logger.info("[func=deleteData][step=success][indexName={}][id={}][cost={}ms]", indexName, id, (System.currentTimeMillis() - begin));
}
private Map<String, Object> beanToMap(Helper helper) {
JSONObject josnoJsonObject = (JSONObject) JSONObject.toJSON(helper);
return josnoJsonObject;
}
}
... ...
package com.yoho.search.consumer.index.increment;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.ConvertUtils;
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.logic.SalesCategoryLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.SalesCategory;
@Component
public class SalesCategoryMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(RobotQuestionMqListener.class);
@Autowired
private IYohoIndexService indexService;
@Autowired
private SalesCategoryLogicService salesCategoryLogicService;
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
String messageStr = new String(message.getBody(), "UTF-8");
logger.info("[model=SalesCategoryMqListener] [message={}]", messageStr);
// 如果在重建索引等待
this.waitingRebuildingIndex();
JSONObject json = JSONObject.parseObject(messageStr);
if (ISearchConstants.ACTION_DELETE.equals(json.getString("action"))) {
deleteData(json.getString("data"));
} else if (ISearchConstants.ACTION_UPDATE.equals(json.getString("action"))) {
updateData(json.getObject("data", Map.class));
} else {
updateData(json.getObject("data", Map.class));
}
} catch (Exception e) {
publisher.publishEvent(new SearchEvent(EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE
.getFunctionName(), EventReportEnum.ROBOTQUESTION_MQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null));
Thread.sleep(1000);
throw e;
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void updateData(final Map data) throws Exception {
SalesCategory salesCategory = new SalesCategory();
salesCategory = (SalesCategory) ConvertUtils.toJavaBean(salesCategory, data);
if (salesCategory == null || salesCategory.getCategoryId() == null) {
return;
}
salesCategoryLogicService.saveOrUpdate(salesCategory);
salesCategoryLogicService.doReload();
}
public void deleteData(final String id) throws Exception {
if (StringUtils.isBlank(id)) {
return;
}
salesCategoryLogicService.deleteById(Integer.valueOf(id));
salesCategoryLogicService.doReload();
}
}
... ...
... ... @@ -2,10 +2,8 @@ package com.yoho.search.consumer.index.increment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -24,13 +22,10 @@ import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.bulks.StorageSkuIndexBulkService;
import com.yoho.search.consumer.service.base.Product15DaySalesNumService;
import com.yoho.search.consumer.service.base.ProductPoolDetailService;
import com.yoho.search.consumer.index.increment.rule.AbstractStorageRelatedMqListener;
import com.yoho.search.consumer.service.base.ProductService;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.logic.ProductIndexLogicService;
import com.yoho.search.consumer.service.logic.productIndex.StorageUpdateTimeLogicService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.Product;
... ... @@ -38,24 +33,16 @@ import com.yoho.search.dal.model.Storage;
import com.yoho.search.dal.model.StorageUpdateTime;
@Component
public class StorageMqListener extends AbstractMqListener implements ChannelAwareMessageListener {
public class StorageMqListener extends AbstractStorageRelatedMqListener implements ChannelAwareMessageListener {
private static final Logger logger = LoggerFactory.getLogger(StorageMqListener.class);
@Autowired
private IYohoIndexService indexService;
@Autowired
private StorageService storageService;
@Autowired
private StorageSkuIndexBulkService storageSkuIndexService;
@Autowired
private ProductPoolDetailService productPoolDetailService;
@Autowired
private ProductService productService;
@Autowired
private Product15DaySalesNumService product15DaySalesNumService;
@Autowired
private ProductIndexLogicService productIndexLogicService;
@Autowired
private StorageUpdateTimeLogicService storageUpdateTimeLogicService;
@Override
... ... @@ -147,30 +134,10 @@ public class StorageMqListener extends AbstractMqListener implements ChannelAwar
private void updateProductIndex(Integer productId, Integer productSkn, long begin, final String key) {
Map<String, Object> indexData = new HashMap<String, Object>();
indexData.put("productId", productId);
List<Storage> storageList = storageService.getStoragesByProductId(productId);
if (storageList.isEmpty()) {
indexData.put("storageNum", null);
indexData.put("isSoonSoldOut", null);
indexData.put("isSoldOut", null);
indexData.put("soldOut", null);
indexData.put("sizeIds", null);
} else {
int storageNum = 0;
Set<String> sizeSet = new HashSet<String>();
for (Storage stor : storageList) {
storageNum += stor.getStorageNum();
if (stor.getGoodsDimensionId() != null) {
sizeSet.add(stor.getGoodsDimensionId() + "");
}
}
indexData.put("storageNum", storageNum);
indexData.put("isSoonSoldOut", storageNum <= 2 ? "Y" : "N");
indexData.put("isSoldOut", storageNum == 0 ? "Y" : "N");
indexData.put("soldOut", storageNum == 0 ? 0 : 1);
if (!sizeSet.isEmpty()) {
indexData.put("sizeIds", StringUtils.join(sizeSet, ","));
}
}
// 设置库存和尺码信息
fillStorageNumAndSizeInfo(productId, indexData);
// 获取storageUpdateTime
List<Integer> productIds = new ArrayList<>();
List<Integer> skns = new ArrayList<>();
... ... @@ -181,7 +148,11 @@ public class StorageMqListener extends AbstractMqListener implements ChannelAwar
StorageUpdateTime storageUpdateTime = storageUpdateTimes.get(0);
indexData.put("storageUpdateTime", storageUpdateTime.getStorageUpdateTime());
}
//更新color相关信息
fillColor(indexData,productId);
this.updateProductIndexWithDataMap(indexData, productId, key, begin);
}
}
... ...
package com.yoho.search.consumer.index.increment;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
... ... @@ -14,20 +29,6 @@ import com.yoho.search.consumer.service.logic.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;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Created by wangnan on 2016/12/16.
... ...
package com.yoho.search.consumer.index.increment;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
... ... @@ -11,17 +23,6 @@ import com.yoho.search.consumer.index.increment.bulks.GlobalndexBulkService;
import com.yoho.search.consumer.service.base.TblProductSkcService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblProductSkc;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.UUID;
/**
* Created by wangnan on 2016/12/19.
... ...
package com.yoho.search.consumer.index.increment;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.yoho.error.event.SearchEvent;
... ... @@ -11,17 +23,6 @@ import com.yoho.search.consumer.index.increment.bulks.GlobalndexBulkService;
import com.yoho.search.consumer.service.base.TblProductSkuService;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import com.yoho.search.dal.model.TblProductSku;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.UUID;
/**
* Created by wangnan on 2016/12/19.
... ...
... ... @@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ...
package com.yoho.search.consumer.index.increment.bulks;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.yoho.error.event.SearchEvent;
import com.yoho.search.base.utils.EventReportEnum;
... ... @@ -7,24 +23,10 @@ import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.common.CostStatistics;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.service.bo.StorageSkuBO;
import com.yoho.search.consumer.service.logic.tools.SpecialDealLogicService;
import com.yoho.search.consumer.service.logic.StorageSkuLogicService;
import com.yoho.search.consumer.service.logic.tools.SpecialDealLogicService;
import com.yoho.search.core.es.model.ESBluk;
import com.yoho.search.core.es.utils.IgnoreSomeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
public class StorageSkuIndexBulkService implements ApplicationEventPublisherAware {
... ...
package com.yoho.search.consumer.index.increment.rule;
import com.alibaba.fastjson.JSONArray;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.base.GoodsService;
import com.yoho.search.consumer.service.base.SizeService;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.logic.productIndex.ProductGoodsLogicService;
import com.yoho.search.dal.model.Storage;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Created by ginozhang on 2017/2/8.
* 将库存相关的增量更新代码抽象到父类,被Storage和Goods的MqListener共用。
*/
@Component
public abstract class AbstractStorageRelatedMqListener extends AbstractMqListener {
@Autowired
private StorageService storageService;
@Autowired
private SizeService sizeService;
@Autowired
private GoodsService goodsService;
@Autowired
private ProductGoodsLogicService productGoodsLogicService;
protected void fillStorageNumAndSizeInfo(Integer productId, Map<String, Object> indexData) {
List<Storage> storageList = storageService.getStoragesByProductId(productId);
if (CollectionUtils.isNotEmpty(storageList)) {
// 过滤掉下架的无库存的storage
storageList = storageList.stream()
.filter(storage -> Integer.valueOf(1).equals(storage.getStatus()))
.filter(storage -> storage.getStorageNum() != null && storage.getStorageNum().intValue() > 0)
.collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(storageList)) {
indexData.put("storageNum", 0);
indexData.put("isSoonSoldOut", "Y");
indexData.put("isSoldOut", "Y");
indexData.put("soldOut", 0);
indexData.put("sizeIds", null);
} else {
int storageNum = 0;
Set<String> sizeSet = new HashSet<String>();
for (Storage stor : storageList) {
storageNum += stor.getStorageNum();
if (stor.getGoodsDimensionId() != null) {
sizeSet.add(stor.getGoodsDimensionId() + "");
}
}
indexData.put("storageNum", storageNum);
indexData.put("isSoonSoldOut", storageNum <= 2 ? "Y" : "N");
indexData.put("isSoldOut", storageNum == 0 ? "Y" : "N");
indexData.put("soldOut", storageNum == 0 ? 0 : 1);
if (!sizeSet.isEmpty()) {
// 设置尺码信息
indexData.put("sizeIds", StringUtils.join(sizeSet, ","));
indexData.put("sizeNames", sizeService.getSizeNamesBySizeIds(sizeSet.stream().map(Integer::valueOf).collect(Collectors.toList())));
} else {
indexData.put("sizeIds", null);
indexData.put("sizeNames", null);
}
}
}
protected void fillColor(Map<String, Object> indexData,Integer productId){
Set<String> colorIdSet = new HashSet<String>();
Set<String> colorNameSet = new HashSet<String>();
// 第一步:获取goodsList
List<ProductGoodsBO> productGoodsBOList = goodsService.getProductGoodsByProductId(productId);
// 第二步、组装goods数据
if (productGoodsBOList != null && productGoodsBOList.size() == 1) {
ProductGoodsBO productGoodsBO = productGoodsBOList.get(0);
String goodsListJsonArrayStr = productGoodsBO.getGoodsList();
JSONArray goodsListJsonArray = JSONArray.parseArray(goodsListJsonArrayStr);
productGoodsLogicService.getColorSet(goodsListJsonArray, colorIdSet, colorNameSet);//获取有库存且状态正常的color
indexData.put("goodsList", goodsListJsonArray);
indexData.put("colorIds", StringUtils.join(colorIdSet, ","));
indexData.put("colorNames", StringUtils.join(colorNameSet, ","));
} else {
indexData.put("goodsList", "");
indexData.put("colorIds", "");
indexData.put("colorNames", "");
}
}
}
... ...
package com.yoho.search.consumer.index.increment.rule;
import org.apache.curator.framework.CuratorFramework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
import javax.annotation.Resource;
import java.util.Map;
import org.apache.curator.framework.CuratorFramework;
import org.springframework.stereotype.Component;
/**
* 负责持久化rule的值到ZK。
... ... @@ -15,8 +14,6 @@ import java.util.Map;
@Component
public class DynamicRulePersistenceService {
private static final Logger logger = LoggerFactory.getLogger(DynamicRulePersistenceService.class);
private static final String CONFIG_ROOT_PATH = "/yh/config";
@Resource(name = "curatorFramework")
... ...
... ... @@ -27,11 +27,11 @@ public class RebuildFlagService {
rebuildFlag.setRebuilding(true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
}finally{
writeLock.unlock();
}
}
public void updateIsBuildingFalse() {
try {
writeLock.lock();
... ... @@ -39,7 +39,7 @@ public class RebuildFlagService {
rebuildFlag.setRebuilding(false);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
}finally{
writeLock.unlock();
}
}
... ...
package com.yoho.search.consumer.job;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
... ...
package com.yoho.search.consumer.suggests.discover;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.suggests.common.SuggestSearchParamBuilder;
... ... @@ -8,13 +16,6 @@ import com.yoho.search.consumer.suggests.counter.KeywordCounterService;
import com.yoho.search.core.es.agg.IAggregation;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Created by ginozhang on 2016/11/25.
... ... @@ -36,23 +37,20 @@ public abstract class AbstractAggSuggestionDiscoverer extends AbstractSuggestion
if (countMap == null || countMap.isEmpty()) {
return 0;
}
if (tokenList != null) {
return tokenList.size();
}
synchronized (this) {
if (tokenList != null) {
return tokenList.size();
}
tokenList = countMap.keySet().stream().collect(Collectors.toList());
}
return tokenList.size();
}
private Map<String, Integer> findSuggestionTokenByAgg(IAggregation aggregation) {
@SuppressWarnings("unchecked")
private Map<String, Integer> findSuggestionTokenByAgg(IAggregation aggregation) {
SearchParam searchParam = SuggestSearchParamBuilder.build("", CountUsage.PC);
searchParam.addAbstractAggregationBuilder(aggregation.getBuilder());
SearchResult searchResult = yohoIndexService.search(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParam);
... ... @@ -70,11 +68,9 @@ public abstract class AbstractAggSuggestionDiscoverer extends AbstractSuggestion
if (end > tokenList.size()) {
end = tokenList.size();
}
if (start > end) {
return sortNameSet;
}
tokenList.subList(start, end).forEach((item) -> sortNameSet.add(item));
return sortNameSet;
}
... ...
package com.yoho.search.consumer.suggests.discover;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.yoho.core.redis.YHHashOperations;
import com.yoho.core.redis.YHZSetOperations;
import com.yoho.search.consumer.suggests.common.KeywordType;
import com.yoho.search.consumer.suggests.common.SuggestionConstants;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Set;
/**
* Created by ginozhang on 2016/11/25.
... ...
... ... @@ -10,7 +10,6 @@ import org.springframework.stereotype.Component;
import com.yoho.search.consumer.service.base.TblSortService;
import com.yoho.search.consumer.suggests.common.KeywordType;
import com.yoho.search.dal.model.ProductSort;
import com.yoho.search.dal.model.TblSort;
@Component
... ...
{
"productindex": {
"_all":{
"enabled":false
"_all": {
"enabled": false
},
"_source":{
"enabled":true
"_source": {
"enabled": true
},
"properties": {
"id": {
... ... @@ -25,7 +25,7 @@
},
"isSoonSoldOut": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -33,7 +33,7 @@
},
"isSoldOut": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -83,7 +83,7 @@
},
"shelveDay": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -161,7 +161,7 @@
},
"isStudentPrice": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -169,7 +169,7 @@
},
"isstudentrebate": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -177,7 +177,7 @@
},
"isSeckill": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -185,7 +185,7 @@
},
"isInstalment": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -193,14 +193,14 @@
},
"islimited": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"fielddata": {
"format": "doc_values"
}
},
"isnew": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"fielddata": {
"format": "doc_values"
}
... ... @@ -228,15 +228,15 @@
},
"cnAlphabet": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"isAuditing": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"brandAlif": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -246,8 +246,11 @@
"fields": {
"productName": {
"type": "string",
"index": "not_analyzed",
"copy_to": ["searchField","searchField_ansj"]
"index": "not_analyzed",
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"productName_ansj": {
"type": "string",
... ... @@ -263,7 +266,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"brandName": {
"fields": {
... ... @@ -272,7 +278,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"brandName_lowercase": {
"type": "string",
... ... @@ -290,7 +299,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"brandNameCn_pinyin": {
"type": "string",
... ... @@ -306,7 +318,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"brandKeyword": {
"type": "string",
... ... @@ -324,7 +339,10 @@
"type": "string",
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"hotKeyword": {
"type": "string",
... ... @@ -342,7 +360,7 @@
"fields": {
"productSkn": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -359,7 +377,7 @@
},
"maxSortName": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -367,7 +385,7 @@
},
"middleSortName": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -375,7 +393,7 @@
},
"smallSortName": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -388,7 +406,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"maxSort_pinyin": {
"type": "string",
... ... @@ -406,7 +427,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"middleSort_pinyin": {
"type": "string",
... ... @@ -424,7 +448,10 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"smallSort_pinyin": {
"type": "string",
... ... @@ -458,7 +485,7 @@
},
"gender": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -469,11 +496,14 @@
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"isSpecial": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -481,7 +511,7 @@
},
"isDiscount": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -489,7 +519,7 @@
},
"specialoffer": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -497,7 +527,7 @@
},
"sellChannels": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -505,7 +535,7 @@
},
"isDown": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -513,7 +543,7 @@
},
"isAdvance": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -521,7 +551,7 @@
},
"isSales": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -529,7 +559,7 @@
},
"isHot": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -551,7 +581,7 @@
},
"isDepositAdvance": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -559,7 +589,7 @@
},
"isLimitbuy": {
"type": "string",
"index": "not_analyzed",
"index": "not_analyzed",
"doc_values": true,
"fielddata": {
"format": "doc_values"
... ... @@ -567,7 +597,7 @@
},
"poolId": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"isrecommend": {
"type": "long",
... ... @@ -631,7 +661,10 @@
"fielddata": {
"format": "doc_values"
},
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"specialSearchField": {
"type": "string",
... ... @@ -641,11 +674,11 @@
},
"colorIds": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"ageLevel": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"appType": {
"type": "long",
... ... @@ -663,42 +696,54 @@
},
"seasons": {
"type": "string",
"analyzer":"comma_spliter",
"copy_to": ["searchField","searchField_ansj"]
"analyzer": "comma_spliter",
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"colorNames": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"sizeNames": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"sizeIds": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"standardIds": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"standardNames": {
"type": "string",
"analyzer":"comma_spliter",
"copy_to": ["searchField","searchField_ansj"]
"analyzer": "comma_spliter",
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"standardOnlyNames": {
"fields": {
"standardOnlyNames": {
"type": "string",
"index": "not_analyzed",
"copy_to": "searchField_ansj"
"index": "not_analyzed",
"copy_to": "searchField_ansj"
},
"standardOnlyNames_ansj": {
"type": "string",
... ... @@ -717,13 +762,16 @@
},
"styleIds": {
"type": "string",
"analyzer":"comma_spliter"
"analyzer": "comma_spliter"
},
"genderS": {
"type": "string",
"analyzer":"comma_spliter",
"analyzer": "comma_spliter",
"search_analyzer": "ik_complex",
"copy_to": ["searchField","searchField_ansj"]
"copy_to": [
"searchField",
"searchField_ansj"
]
},
"defaultImages": {
"type": "string"
... ... @@ -779,44 +827,44 @@
"properties": {
"color_code": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"color_id": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"color_name": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"color_value": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"goods_id": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"images_url": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"is_default": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"product_skc": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
},
"status": {
"type": "string",
"index": "not_analyzed"
"index": "not_analyzed"
}
}
},
"activities": {
"type" : "nested",
"type": "nested",
"properties": {
"activity_id": {
"type": "integer"
... ... @@ -874,7 +922,11 @@
"marketPhrase": {
"type": "string",
"store": false,
"analyzer": "ik_complex",
"analyzer": "ik_complex"
},
"physicalChannels": {
"type": "string",
"analyzer": "comma_spliter"
}
}
}
... ...
... ... @@ -18,15 +18,14 @@ import java.util.Map;
public class ProductIndexService {
@Autowired
private SpecialDealLogicService specialDealLogicService;
private SpecialDealLogicService specialDealLogicService;
private final Logger logger = LoggerFactory.getLogger(ProductIndexService.class);
@SuppressWarnings({"rawtypes", "unchecked"})
public Map<String, Object> beanToMap(ProductIndexBO productIndexBO) {
//对productIndexBO做特殊处理
specialDealLogicService.specialDealProductIndex(productIndexBO);
private final Logger logger = LoggerFactory.getLogger(ProductIndexService.class);
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map<String, Object> beanToMap(ProductIndexBO productIndexBO) {
// 对productIndexBO做特殊处理
specialDealLogicService.specialDealProductIndex(productIndexBO);
Map map = new HashMap();
map.put("id", productIndexBO.getId());
map.put("productId", productIndexBO.getProductId());
... ... @@ -162,6 +161,7 @@ public class ProductIndexService {
map.put("isSeckill", productIndexBO.getIsSeckill());
map.put("storageUpdateTime", productIndexBO.getStorageUpdateTime());
String goodsListStr = productIndexBO.getGoodsList();
if (StringUtils.isNotBlank(goodsListStr)) {
try {
... ... @@ -188,7 +188,9 @@ public class ProductIndexService {
map.put("tblCountryName", productIndexBO.getTblCountryName());
map.put("pools", productIndexBO.getPools());
map.put("marketPhrase", productIndexBO.getMarketPhrase());
map.put("physicalChannels", productIndexBO.getPhysicalChannels());
return map;
}
}
... ...
package com.yoho.search.consumer.service.base;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.dal.SalesCategoryMapper;
import com.yoho.search.dal.model.SalesCategory;
@Component
public class SalesCategoryService {
@Autowired
private SalesCategoryMapper salesCategoryMapper;
public SalesCategory selectById(Integer categoryId) {
return salesCategoryMapper.selectByPrimaryKey(categoryId);
}
public int deleteById(Integer categoryId) {
return salesCategoryMapper.deleteByPrimaryKey(categoryId);
}
public int saveOrUpdate(SalesCategory salesCategory) {
if (salesCategory.getCategoryId() == null || salesCategoryMapper.selectByPrimaryKey(salesCategory.getCategoryId()) == null) {
return salesCategoryMapper.insert(salesCategory);
} else {
return salesCategoryMapper.updateByPrimaryKey(salesCategory);
}
}
public List<SalesCategory> selectAll() {
return salesCategoryMapper.selectAll();
}
}
... ...
... ... @@ -2,10 +2,12 @@ package com.yoho.search.consumer.service.base;
import com.yoho.search.dal.SizeMapper;
import com.yoho.search.dal.model.Size;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
@Component
//@Transactional
... ... @@ -45,4 +47,17 @@ public class SizeService {
public int count() {
return sizeMapper.count();
}
public String getSizeNamesBySizeIds(List<Integer> sizeIds){
if(CollectionUtils.isEmpty(sizeIds)){
return "";
}
List<Size> sizeList = sizeMapper.getByIds(sizeIds);
if(CollectionUtils.isEmpty(sizeList)){
return "";
}
// 和以前的数据保持一致 在末尾也加个逗号
return sizeList.stream().map(Size::getSizeName).collect(Collectors.joining(",","",","));
}
}
... ...
... ... @@ -8,602 +8,605 @@ import java.io.Serializable;
*/
public class ProductIBO implements Serializable {
private static final long serialVersionUID = 5550525695217052845L;
// from product
private Integer id;
private Integer productId;
private Integer productSkn;
private Integer shopId;
private String productName;
private String cnAlphabet;
private String salesPhrase;
private Integer brandId;
private Integer maxSortId;
private Integer middleSortId;
private Integer smallSortId;
private Integer seriesId;
private String gender;
private String genderS;
private String style;
private String isnew;
private String islimited;
private Integer ishot;
private String isHot;
private String isSpecial;
private Integer isspecial;
private String isSales;
private Integer issales;
private String isAdvance;
private Integer isadvance;
private String isDepositAdvance;
private String isLimitbuy;
private String isAuditing;
private Integer isauditing;
private Integer isrecommend;
private Integer ispromotion;
private Integer attribute;
private String seasons;
private Integer seasonsS;
private Integer firstShelveTime;
private Integer shelveTime;
private String shelveDay;
private Integer editTime;
private String isDown;
private Integer isdown;
private Integer status;
private Integer isOutlets;
private Integer folderId;
private String sellChannels;
private String ageLevel;
private Integer appType;
private String isInstalment;
private String isSeckill;
private static final long serialVersionUID = 5550525695217052845L;
// from product
private Integer id;
private Integer productId;
private Integer productSkn;
private Integer shopId;
private String productName;
private String cnAlphabet;
private String salesPhrase;
private Integer brandId;
private Integer maxSortId;
private Integer middleSortId;
private Integer smallSortId;
private Integer seriesId;
private String gender;
private String genderS;
private String style;
private String isnew;
private String islimited;
private Integer ishot;
private String isHot;
private String isSpecial;
private Integer isspecial;
private String isSales;
private Integer issales;
private String isAdvance;
private Integer isadvance;
private String isDepositAdvance;
private String isLimitbuy;
private String isAuditing;
private Integer isauditing;
private Integer isrecommend;
private Integer ispromotion;
private Integer attribute;
private String seasons;
private Integer seasonsS;
private Integer firstShelveTime;
private Integer shelveTime;
private String shelveDay;
private Integer editTime;
private String isDown;
private Integer isdown;
private Integer status;
private Integer isOutlets;
private Integer folderId;
private String sellChannels;
private String ageLevel;
private Integer appType;
private String isInstalment;
private String isSeckill;
private String marketPhrase;
// inner join brand
private String brandNameCn;
private String brandNameEn;
private String brandKeyword;
private String hotKeyword;
private String brandName;
private String brandDomain;
private String brandAlif;
private Integer countryId;
// inner join product_sort
private String maxSort;
private String maxSortName;
private String middleSort;
private String middleSortName;
private String smallSort;
private String smallSortName;
private String specialSearchField;// 特殊搜索字段
private Integer isForbiddenSortBrand;// 是否是品类+品牌的屏蔽字段
// from quanqiugou
// inner join brand
private String brandNameCn;
private String brandNameEn;
private String brandKeyword;
private String hotKeyword;
private String brandName;
private String brandDomain;
private String brandAlif;
private Integer countryId;
// inner join product_sort
private String maxSort;
private String maxSortName;
private String middleSort;
private String middleSortName;
private String smallSort;
private String smallSortName;
private String specialSearchField;// 特殊搜索字段
private Integer isForbiddenSortBrand;// 是否是品类+品牌的屏蔽字段
// from quanqiugou
private String isGlobal = "N";
public Integer getId() {
return id;
}
// from sales_category
private String physicalChannels;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public Integer getProductId() {
return productId;
}
public void setId(Integer id) {
this.id = id;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getProductId() {
return productId;
}
public Integer getShopId() {
return shopId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getShopId() {
return shopId;
}
public Integer getShelveTime() {
return shelveTime;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public void setShelveTime(Integer shelveTime) {
this.shelveTime = shelveTime;
}
public Integer getShelveTime() {
return shelveTime;
}
public String getShelveDay() {
return shelveDay;
}
public void setShelveTime(Integer shelveTime) {
this.shelveTime = shelveTime;
}
public void setShelveDay(String shelveDay) {
this.shelveDay = shelveDay;
}
public String getShelveDay() {
return shelveDay;
}
public String getCnAlphabet() {
return cnAlphabet;
}
public void setShelveDay(String shelveDay) {
this.shelveDay = shelveDay;
}
public void setCnAlphabet(String cnAlphabet) {
this.cnAlphabet = cnAlphabet == null ? null : cnAlphabet.trim();
}
public String getCnAlphabet() {
return cnAlphabet;
}
public String getProductName() {
return productName;
}
public void setCnAlphabet(String cnAlphabet) {
this.cnAlphabet = cnAlphabet == null ? null : cnAlphabet.trim();
}
public void setProductName(String productName) {
this.productName = productName == null ? null : productName.trim();
}
public String getProductName() {
return productName;
}
public String getStyle() {
return style;
}
public void setProductName(String productName) {
this.productName = productName == null ? null : productName.trim();
}
public void setStyle(String style) {
this.style = style == null ? null : style.trim();
}
public String getStyle() {
return style;
}
public String getSalesPhrase() {
return salesPhrase;
}
public void setStyle(String style) {
this.style = style == null ? null : style.trim();
}
public void setSalesPhrase(String salesPhrase) {
this.salesPhrase = salesPhrase == null ? null : salesPhrase.trim();
}
public String getSalesPhrase() {
return salesPhrase;
}
public Integer getMaxSortId() {
return maxSortId;
}
public void setSalesPhrase(String salesPhrase) {
this.salesPhrase = salesPhrase == null ? null : salesPhrase.trim();
}
public void setMaxSortId(Integer maxSortId) {
this.maxSortId = maxSortId;
}
public Integer getMaxSortId() {
return maxSortId;
}
public String getMaxSortName() {
return maxSortName;
}
public void setMaxSortId(Integer maxSortId) {
this.maxSortId = maxSortId;
}
public void setMaxSortName(String maxSortName) {
this.maxSortName = maxSortName == null ? null : maxSortName.trim();
}
public String getMaxSortName() {
return maxSortName;
}
public Integer getMiddleSortId() {
return middleSortId;
}
public void setMaxSortName(String maxSortName) {
this.maxSortName = maxSortName == null ? null : maxSortName.trim();
}
public void setMiddleSortId(Integer middleSortId) {
this.middleSortId = middleSortId;
}
public Integer getMiddleSortId() {
return middleSortId;
}
public String getMiddleSortName() {
return middleSortName;
}
public void setMiddleSortId(Integer middleSortId) {
this.middleSortId = middleSortId;
}
public void setMiddleSortName(String middleSortName) {
this.middleSortName = middleSortName == null ? null : middleSortName.trim();
}
public String getMiddleSortName() {
return middleSortName;
}
public Integer getSmallSortId() {
return smallSortId;
}
public void setMiddleSortName(String middleSortName) {
this.middleSortName = middleSortName == null ? null : middleSortName.trim();
}
public void setSmallSortId(Integer smallSortId) {
this.smallSortId = smallSortId;
}
public Integer getSmallSortId() {
return smallSortId;
}
public String getSmallSortName() {
return smallSortName;
}
public void setSmallSortId(Integer smallSortId) {
this.smallSortId = smallSortId;
}
public void setSmallSortName(String smallSortName) {
this.smallSortName = smallSortName == null ? null : smallSortName.trim();
}
public String getSmallSortName() {
return smallSortName;
}
public String getGender() {
return gender;
}
public void setSmallSortName(String smallSortName) {
this.smallSortName = smallSortName == null ? null : smallSortName.trim();
}
public void setGender(String gender) {
this.gender = gender == null ? null : gender.trim();
}
public String getGender() {
return gender;
}
public String getGenderS() {
return genderS;
}
public void setGender(String gender) {
this.gender = gender == null ? null : gender.trim();
}
public void setGenderS(String genderS) {
this.genderS = genderS == null ? null : genderS.trim();
}
public String getGenderS() {
return genderS;
}
public Integer getBrandId() {
return brandId;
}
public void setGenderS(String genderS) {
this.genderS = genderS == null ? null : genderS.trim();
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public Integer getBrandId() {
return brandId;
}
public String getIsSpecial() {
return isSpecial;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public void setIsSpecial(String isSpecial) {
this.isSpecial = isSpecial == null ? null : isSpecial.trim();
}
public String getIsSpecial() {
return isSpecial;
}
public Integer getStatus() {
return status;
}
public void setIsSpecial(String isSpecial) {
this.isSpecial = isSpecial == null ? null : isSpecial.trim();
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return status;
}
public Integer getSeasonsS() {
return seasonsS;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setSeasonsS(Integer seasonsS) {
this.seasonsS = seasonsS;
}
public Integer getSeasonsS() {
return seasonsS;
}
public Integer getIsspecial() {
return isspecial;
}
public void setSeasonsS(Integer seasonsS) {
this.seasonsS = seasonsS;
}
public void setIsspecial(Integer isspecial) {
this.isspecial = isspecial;
}
public Integer getIsspecial() {
return isspecial;
}
public String getIsHot() {
return isHot;
}
public void setIsspecial(Integer isspecial) {
this.isspecial = isspecial;
}
public void setIsHot(String isHot) {
this.isHot = isHot == null ? null : isHot.trim();
}
public String getIsHot() {
return isHot;
}
public Integer getFolderId() {
return folderId;
}
public void setIsHot(String isHot) {
this.isHot = isHot == null ? null : isHot.trim();
}
public void setFolderId(Integer folderId) {
this.folderId = folderId;
}
public Integer getFolderId() {
return folderId;
}
public Integer getIshot() {
return ishot;
}
public void setFolderId(Integer folderId) {
this.folderId = folderId;
}
public void setIshot(Integer ishot) {
this.ishot = ishot;
}
public Integer getIshot() {
return ishot;
}
public Integer getIspromotion() {
return ispromotion;
}
public void setIshot(Integer ishot) {
this.ishot = ishot;
}
public void setIspromotion(Integer ispromotion) {
this.ispromotion = ispromotion;
}
public Integer getIspromotion() {
return ispromotion;
}
public Integer getSeriesId() {
return seriesId;
}
public void setIspromotion(Integer ispromotion) {
this.ispromotion = ispromotion;
}
public void setSeriesId(Integer seriesId) {
this.seriesId = seriesId;
}
public Integer getSeriesId() {
return seriesId;
}
public String getIsSales() {
return isSales;
}
public void setSeriesId(Integer seriesId) {
this.seriesId = seriesId;
}
public void setIsSales(String isSales) {
this.isSales = isSales == null ? null : isSales.trim();
}
public String getIsSales() {
return isSales;
}
public Integer getIssales() {
return issales;
}
public void setIsSales(String isSales) {
this.isSales = isSales == null ? null : isSales.trim();
}
public void setIssales(Integer issales) {
this.issales = issales;
}
public Integer getIssales() {
return issales;
}
public String getIsAdvance() {
return isAdvance;
}
public void setIssales(Integer issales) {
this.issales = issales;
}
public void setIsAdvance(String isAdvance) {
this.isAdvance = isAdvance == null ? null : isAdvance.trim();
}
public String getIsAdvance() {
return isAdvance;
}
public Integer getIsadvance() {
return isadvance;
}
public void setIsAdvance(String isAdvance) {
this.isAdvance = isAdvance == null ? null : isAdvance.trim();
}
public void setIsadvance(Integer isadvance) {
this.isadvance = isadvance;
}
public Integer getIsadvance() {
return isadvance;
}
public String getIsAuditing() {
return isAuditing;
}
public void setIsadvance(Integer isadvance) {
this.isadvance = isadvance;
}
public void setIsAuditing(String isAuditing) {
this.isAuditing = isAuditing == null ? null : isAuditing.trim();
}
public String getIsAuditing() {
return isAuditing;
}
public Integer getIsauditing() {
return isauditing;
}
public void setIsAuditing(String isAuditing) {
this.isAuditing = isAuditing == null ? null : isAuditing.trim();
}
public void setIsauditing(Integer isauditing) {
this.isauditing = isauditing;
}
public Integer getIsauditing() {
return isauditing;
}
public Integer getAttribute() {
return attribute;
}
public void setIsauditing(Integer isauditing) {
this.isauditing = isauditing;
}
public void setAttribute(Integer attribute) {
this.attribute = attribute;
}
public Integer getAttribute() {
return attribute;
}
public String getSeasons() {
return seasons;
}
public void setAttribute(Integer attribute) {
this.attribute = attribute;
}
public void setSeasons(String seasons) {
this.seasons = seasons == null ? null : seasons.trim();
}
public String getSeasons() {
return seasons;
}
public String getIsDown() {
return isDown;
}
public void setSeasons(String seasons) {
this.seasons = seasons == null ? null : seasons.trim();
}
public void setIsDown(String isDown) {
this.isDown = isDown == null ? null : isDown.trim();
}
public String getIsDown() {
return isDown;
}
public Integer getIsdown() {
return isdown;
}
public void setIsDown(String isDown) {
this.isDown = isDown == null ? null : isDown.trim();
}
public void setIsdown(Integer isdown) {
this.isdown = isdown;
}
public Integer getIsdown() {
return isdown;
}
public Integer getIsrecommend() {
return isrecommend;
}
public void setIsdown(Integer isdown) {
this.isdown = isdown;
}
public void setIsrecommend(Integer isrecommend) {
this.isrecommend = isrecommend;
}
public Integer getIsrecommend() {
return isrecommend;
}
public Integer getIsOutlets() {
return isOutlets;
}
public void setIsrecommend(Integer isrecommend) {
this.isrecommend = isrecommend;
}
public void setIsOutlets(Integer isOutlets) {
this.isOutlets = isOutlets;
}
public Integer getIsOutlets() {
return isOutlets;
}
public Integer getFirstShelveTime() {
return firstShelveTime;
}
public void setIsOutlets(Integer isOutlets) {
this.isOutlets = isOutlets;
}
public void setFirstShelveTime(Integer firstShelveTime) {
this.firstShelveTime = firstShelveTime;
}
public Integer getFirstShelveTime() {
return firstShelveTime;
}
public String getSellChannels() {
return sellChannels;
}
public void setFirstShelveTime(Integer firstShelveTime) {
this.firstShelveTime = firstShelveTime;
}
public void setSellChannels(String sellChannels) {
this.sellChannels = sellChannels == null ? null : sellChannels.trim();
}
public String getSellChannels() {
return sellChannels;
}
public Integer getProductSkn() {
return productSkn;
}
public void setSellChannels(String sellChannels) {
this.sellChannels = sellChannels == null ? null : sellChannels.trim();
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public Integer getProductSkn() {
return productSkn;
}
public String getIsnew() {
return isnew;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public void setIsnew(String isnew) {
this.isnew = isnew;
}
public String getIsnew() {
return isnew;
}
public String getBrandNameCn() {
return brandNameCn;
}
public void setIsnew(String isnew) {
this.isnew = isnew;
}
public void setBrandNameCn(String brandNameCn) {
this.brandNameCn = brandNameCn == null ? null : brandNameCn.trim();
}
public String getBrandNameCn() {
return brandNameCn;
}
public String getBrandNameEn() {
return brandNameEn;
}
public void setBrandNameCn(String brandNameCn) {
this.brandNameCn = brandNameCn == null ? null : brandNameCn.trim();
}
public void setBrandNameEn(String brandNameEn) {
this.brandNameEn = brandNameEn == null ? null : brandNameEn.trim();
}
public String getBrandNameEn() {
return brandNameEn;
}
public String getBrandKeyword() {
return brandKeyword;
}
public void setBrandNameEn(String brandNameEn) {
this.brandNameEn = brandNameEn == null ? null : brandNameEn.trim();
}
public void setBrandKeyword(String brandKeyword) {
this.brandKeyword = brandKeyword == null ? null : brandKeyword.trim();
}
public String getBrandKeyword() {
return brandKeyword;
}
public String getHotKeyword() {
return hotKeyword;
}
public void setBrandKeyword(String brandKeyword) {
this.brandKeyword = brandKeyword == null ? null : brandKeyword.trim();
}
public void setHotKeyword(String hotKeyword) {
this.hotKeyword = hotKeyword == null ? null : hotKeyword.trim();
}
public String getHotKeyword() {
return hotKeyword;
}
public String getBrandName() {
return brandName;
}
public void setHotKeyword(String hotKeyword) {
this.hotKeyword = hotKeyword == null ? null : hotKeyword.trim();
}
public void setBrandName(String brandName) {
this.brandName = brandName == null ? null : brandName.trim();
}
public String getBrandName() {
return brandName;
}
public String getBrandDomain() {
return brandDomain;
}
public void setBrandName(String brandName) {
this.brandName = brandName == null ? null : brandName.trim();
}
public void setBrandDomain(String brandDomain) {
this.brandDomain = brandDomain == null ? null : brandDomain.trim();
}
public String getBrandDomain() {
return brandDomain;
}
public String getBrandAlif() {
return brandAlif;
}
public void setBrandDomain(String brandDomain) {
this.brandDomain = brandDomain == null ? null : brandDomain.trim();
}
public void setBrandAlif(String brandAlif) {
this.brandAlif = brandAlif == null ? null : brandAlif.trim();
}
public String getBrandAlif() {
return brandAlif;
}
public Integer getEditTime() {
return editTime;
}
public void setBrandAlif(String brandAlif) {
this.brandAlif = brandAlif == null ? null : brandAlif.trim();
}
public void setEditTime(Integer editTime) {
this.editTime = editTime;
}
public Integer getEditTime() {
return editTime;
}
public String getIslimited() {
return islimited;
}
public void setEditTime(Integer editTime) {
this.editTime = editTime;
}
public void setIslimited(String islimited) {
this.islimited = islimited;
}
public String getIslimited() {
return islimited;
}
public String getMaxSort() {
return maxSort;
}
public void setIslimited(String islimited) {
this.islimited = islimited;
}
public void setMaxSort(String maxSort) {
this.maxSort = maxSort;
}
public String getMaxSort() {
return maxSort;
}
public String getMiddleSort() {
return middleSort;
}
public void setMaxSort(String maxSort) {
this.maxSort = maxSort;
}
public void setMiddleSort(String middleSort) {
this.middleSort = middleSort;
}
public String getMiddleSort() {
return middleSort;
}
public String getSmallSort() {
return smallSort;
}
public void setMiddleSort(String middleSort) {
this.middleSort = middleSort;
}
public void setSmallSort(String smallSort) {
this.smallSort = smallSort;
}
public String getSmallSort() {
return smallSort;
}
public String getAgeLevel() {
return ageLevel;
}
public void setSmallSort(String smallSort) {
this.smallSort = smallSort;
}
public void setAgeLevel(String ageLevel) {
this.ageLevel = ageLevel;
}
public String getAgeLevel() {
return ageLevel;
}
public Integer getAppType() {
return appType;
}
public void setAgeLevel(String ageLevel) {
this.ageLevel = ageLevel;
}
public void setAppType(Integer appType) {
this.appType = appType;
}
public Integer getAppType() {
return appType;
}
public String getIsInstalment() {
return isInstalment;
}
public void setAppType(Integer appType) {
this.appType = appType;
}
public void setIsInstalment(String isInstalment) {
this.isInstalment = isInstalment;
}
public String getIsInstalment() {
return isInstalment;
}
public Integer getCountryId() {
return countryId;
}
public void setIsInstalment(String isInstalment) {
this.isInstalment = isInstalment;
}
public void setCountryId(Integer countryId) {
this.countryId = countryId;
}
public Integer getCountryId() {
return countryId;
}
public String getIsSeckill() {
return isSeckill;
}
public void setCountryId(Integer countryId) {
this.countryId = countryId;
}
public void setIsSeckill(String isSeckill) {
this.isSeckill = isSeckill;
}
public String getIsSeckill() {
return isSeckill;
}
public String getIsDepositAdvance() {
return isDepositAdvance;
}
public void setIsSeckill(String isSeckill) {
this.isSeckill = isSeckill;
}
public String getIsDepositAdvance() {
return isDepositAdvance;
}
public void setIsDepositAdvance(String isDepositAdvance) {
this.isDepositAdvance = isDepositAdvance;
}
public void setIsDepositAdvance(String isDepositAdvance) {
this.isDepositAdvance = isDepositAdvance;
}
public String getIsLimitbuy() {
return isLimitbuy;
}
public String getIsLimitbuy() {
return isLimitbuy;
}
public void setIsLimitbuy(String isLimitbuy) {
this.isLimitbuy = isLimitbuy;
}
public void setIsLimitbuy(String isLimitbuy) {
this.isLimitbuy = isLimitbuy;
}
public String getSpecialSearchField() {
return specialSearchField;
}
public String getSpecialSearchField() {
return specialSearchField;
}
public void setSpecialSearchField(String specialSearchField) {
this.specialSearchField = specialSearchField;
}
public void setSpecialSearchField(String specialSearchField) {
this.specialSearchField = specialSearchField;
}
public Integer getIsForbiddenSortBrand() {
return isForbiddenSortBrand;
}
public Integer getIsForbiddenSortBrand() {
return isForbiddenSortBrand;
}
public void setIsForbiddenSortBrand(Integer isForbiddenSortBrand) {
this.isForbiddenSortBrand = isForbiddenSortBrand;
}
public void setIsForbiddenSortBrand(Integer isForbiddenSortBrand) {
this.isForbiddenSortBrand = isForbiddenSortBrand;
}
public String getIsGlobal() {
return isGlobal;
}
public String getIsGlobal() {
return isGlobal;
}
public void setIsGlobal(String isGlobal) {
this.isGlobal = isGlobal;
}
public void setIsGlobal(String isGlobal) {
this.isGlobal = isGlobal;
}
public String getMarketPhrase() {
return marketPhrase;
... ... @@ -612,4 +615,12 @@ public class ProductIBO implements Serializable {
public void setMarketPhrase(String marketPhrase) {
this.marketPhrase = marketPhrase;
}
public String getPhysicalChannels() {
return physicalChannels;
}
public void setPhysicalChannels(String physicalChannels) {
this.physicalChannels = physicalChannels;
}
}
\ No newline at end of file
... ...
... ... @@ -13,452 +13,452 @@ import com.alibaba.fastjson.JSONArray;
public class ProductIndexBO extends ProductIBO implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
// from product_price
private BigDecimal specialPrice;
private BigDecimal marketPrice;
private Integer vipDiscountType;
private BigDecimal vipPrice;
private BigDecimal vip1Price;
private BigDecimal vip2Price;
private BigDecimal vip3Price;
private BigDecimal salesPrice;
private BigDecimal studentPrice;
private String isStudentPrice;
private Long promotionDiscountInt;
private BigDecimal promotionDiscount;
private String specialoffer;
private String isDiscount;
// from product_keywords
private String productKeyword;
// from product_colors
private String colorIds;
private String colorNames;
// from product_standards
private String standardIds;
private String standardNames;
private String standardOnlyNames;
// from product_sizes
// private BigDecimal salesNum;
private BigDecimal storageNum;
private String isSoonSoldOut;
private String isSoldOut;
private Integer soldOut;
private String sizeIds;
private String sizeNames;
// from product_price
private BigDecimal specialPrice;
private BigDecimal marketPrice;
private Integer vipDiscountType;
private BigDecimal vipPrice;
private BigDecimal vip1Price;
private BigDecimal vip2Price;
private BigDecimal vip3Price;
private BigDecimal salesPrice;
private BigDecimal studentPrice;
private String isStudentPrice;
private Long promotionDiscountInt;
private BigDecimal promotionDiscount;
private String specialoffer;
private String isDiscount;
// from product_15day_salesnum
private Integer salesNum;
// from product_styles
private String styleIds;
// from product_goods
private String goodsList;
// from product_default_image
private String defaultImages;
// from product_keywords
private String productKeyword;
// from product_activities
private String activities;
// from product_search
private Long sortWeight;
private Long brandWeight;
private Long shopWeight;
// from product_colors
private String colorIds;
private String colorNames;
// from product_activities_link
private String yohoodId;
// from base_pin_ratio
private double basePinRatio;
// from broken_code
private double breakingRate;
// from discount_product_skn
private double discountScore;
private String poolId;
private String isStudentRebate;
// form storage
private Integer storageUpdateTime;
// from tbl_product
private Integer tblCountryId;
private String tblCountryName;
private String productFeatureFactor;
// from product_standards
private String standardIds;
private String standardNames;
private String standardOnlyNames;
// from product_pool_detail
private JSONArray pools;
// get
public BigDecimal getSpecialPrice() {
return specialPrice;
}
// from product_sizes
//private BigDecimal salesNum;
private BigDecimal storageNum;
private String isSoonSoldOut;
private String isSoldOut;
private Integer soldOut;
private String sizeIds;
private String sizeNames;
public BigDecimal getMarketPrice() {
return marketPrice;
}
//from product_15day_salesnum
private Integer salesNum;
public Integer getVipDiscountType() {
return vipDiscountType;
}
// from product_styles
private String styleIds;
public BigDecimal getVipPrice() {
return vipPrice;
}
public BigDecimal getVip1Price() {
return vip1Price;
}
// from product_goods
private String goodsList;
public BigDecimal getVip2Price() {
return vip2Price;
}
// from product_default_image
private String defaultImages;
public BigDecimal getVip3Price() {
return vip3Price;
}
// from product_activities
private String activities;
public BigDecimal getSalesPrice() {
return salesPrice;
}
// from product_search
private Long sortWeight;
private Long brandWeight;
private Long shopWeight;
public Long getPromotionDiscountInt() {
return promotionDiscountInt;
}
// from product_activities_link
private String yohoodId;
public BigDecimal getPromotionDiscount() {
return promotionDiscount;
}
// from base_pin_ratio
private double basePinRatio;
public String getSpecialoffer() {
return specialoffer;
}
// from broken_code
private double breakingRate;
public String getIsDiscount() {
return isDiscount;
}
// from discount_product_skn
private double discountScore;
private String poolId;
public String getProductKeyword() {
return productKeyword;
}
private String isStudentRebate;
public String getColorIds() {
return colorIds;
}
//form storage
private Integer storageUpdateTime;
public String getColorNames() {
return colorNames;
}
//from tbl_product
private Integer tblCountryId;
private String tblCountryName;
public String getStandardIds() {
return standardIds;
}
public String getStandardNames() {
return standardNames;
}
private String productFeatureFactor;
public String getStandardOnlyNames() {
return standardOnlyNames;
}
//
private JSONArray pools;
public Integer getSalesNum() {
return salesNum;
}
// get
public BigDecimal getSpecialPrice() {
return specialPrice;
}
public BigDecimal getStorageNum() {
return storageNum;
}
public BigDecimal getMarketPrice() {
return marketPrice;
}
public String getIsSoonSoldOut() {
return isSoonSoldOut;
}
public Integer getVipDiscountType() {
return vipDiscountType;
}
public String getIsSoldOut() {
return isSoldOut;
}
public BigDecimal getVipPrice() {
return vipPrice;
}
public Integer getSoldOut() {
return soldOut;
}
public BigDecimal getVip1Price() {
return vip1Price;
}
public String getSizeIds() {
return sizeIds;
}
public BigDecimal getVip2Price() {
return vip2Price;
}
public String getStyleIds() {
return styleIds;
}
public String getGoodsList() {
return goodsList;
}
public BigDecimal getVip3Price() {
return vip3Price;
}
public String getDefaultImages() {
return defaultImages;
}
public BigDecimal getSalesPrice() {
return salesPrice;
}
public String getActivities() {
return activities;
}
public Long getPromotionDiscountInt() {
return promotionDiscountInt;
}
public Long getSortWeight() {
return sortWeight;
}
public BigDecimal getPromotionDiscount() {
return promotionDiscount;
}
public Long getBrandWeight() {
return brandWeight;
}
public String getSpecialoffer() {
return specialoffer;
}
public String getYohoodId() {
return yohoodId;
}
public String getIsDiscount() {
return isDiscount;
}
public double getBasePinRatio() {
return basePinRatio;
}
public String getProductKeyword() {
return productKeyword;
}
public double getBreakingRate() {
return breakingRate;
}
public String getColorIds() {
return colorIds;
}
public double getDiscountScore() {
return discountScore;
}
public String getColorNames() {
return colorNames;
}
public String getPoolId() {
return poolId;
}
public String getStandardIds() {
return standardIds;
}
// set
public void setSpecialPrice(BigDecimal specialPrice) {
this.specialPrice = specialPrice;
}
public String getStandardNames() {
return standardNames;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public String getStandardOnlyNames() {
return standardOnlyNames;
}
public void setVipDiscountType(Integer vipDiscountType) {
this.vipDiscountType = vipDiscountType;
}
public Integer getSalesNum() {
return salesNum;
}
public void setVipPrice(BigDecimal vipPrice) {
this.vipPrice = vipPrice;
}
public BigDecimal getStorageNum() {
return storageNum;
}
public void setVip1Price(BigDecimal vip1Price) {
this.vip1Price = vip1Price;
}
public String getIsSoonSoldOut() {
return isSoonSoldOut;
}
public void setVip2Price(BigDecimal vip2Price) {
this.vip2Price = vip2Price;
}
public String getIsSoldOut() {
return isSoldOut;
}
public void setVip3Price(BigDecimal vip3Price) {
this.vip3Price = vip3Price;
}
public Integer getSoldOut() {
return soldOut;
}
public void setSalesPrice(BigDecimal salesPrice) {
this.salesPrice = salesPrice;
}
public String getSizeIds() {
return sizeIds;
}
public void setPromotionDiscountInt(Long promotionDiscountInt) {
this.promotionDiscountInt = promotionDiscountInt;
}
public String getStyleIds() {
return styleIds;
}
public String getGoodsList() {
return goodsList;
}
public void setPromotionDiscount(BigDecimal promotionDiscount) {
this.promotionDiscount = promotionDiscount;
}
public String getDefaultImages() {
return defaultImages;
}
public void setSpecialoffer(String specialoffer) {
this.specialoffer = specialoffer;
}
public String getActivities() {
return activities;
}
public void setIsDiscount(String isDiscount) {
this.isDiscount = isDiscount;
}
public Long getSortWeight() {
return sortWeight;
}
public void setProductKeyword(String productKeyword) {
this.productKeyword = productKeyword;
}
public Long getBrandWeight() {
return brandWeight;
}
public void setColorIds(String colorIds) {
this.colorIds = colorIds == null ? null : colorIds.trim();
}
public String getYohoodId() {
return yohoodId;
}
public void setColorNames(String colorNames) {
this.colorNames = colorNames == null ? null : colorNames.trim();
}
public double getBasePinRatio() {
return basePinRatio;
}
public void setStandardIds(String standardIds) {
this.standardIds = standardIds == null ? null : standardIds.trim();
}
public double getBreakingRate() {
return breakingRate;
}
public void setStandardNames(String standardNames) {
this.standardNames = standardNames == null ? null : standardNames.trim();
}
public double getDiscountScore() {
return discountScore;
}
public void setStandardOnlyNames(String standardOnlyNames) {
this.standardOnlyNames = standardOnlyNames == null ? null : standardOnlyNames.trim();
}
public String getPoolId() {
return poolId;
}
public void setSalesNum(Integer salesNum) {
this.salesNum = salesNum;
}
// set
public void setSpecialPrice(BigDecimal specialPrice) {
this.specialPrice = specialPrice;
}
public void setStorageNum(BigDecimal storageNum) {
this.storageNum = storageNum;
}
public void setMarketPrice(BigDecimal marketPrice) {
this.marketPrice = marketPrice;
}
public void setIsSoonSoldOut(String isSoonSoldOut) {
this.isSoonSoldOut = isSoonSoldOut;
}
public void setVipDiscountType(Integer vipDiscountType) {
this.vipDiscountType = vipDiscountType;
}
public void setIsSoldOut(String isSoldOut) {
this.isSoldOut = isSoldOut;
}
public void setVipPrice(BigDecimal vipPrice) {
this.vipPrice = vipPrice;
}
public void setSoldOut(Integer soldOut) {
this.soldOut = soldOut;
}
public void setVip1Price(BigDecimal vip1Price) {
this.vip1Price = vip1Price;
}
public void setSizeIds(String sizeIds) {
this.sizeIds = sizeIds == null ? null : sizeIds.trim();
}
public void setVip2Price(BigDecimal vip2Price) {
this.vip2Price = vip2Price;
}
public void setStyleIds(String styleIds) {
this.styleIds = styleIds == null ? null : styleIds.trim();
}
public void setVip3Price(BigDecimal vip3Price) {
this.vip3Price = vip3Price;
}
public void setGoodsList(String goodsList) {
this.goodsList = goodsList == null ? null : goodsList.trim();
}
public void setSalesPrice(BigDecimal salesPrice) {
this.salesPrice = salesPrice;
}
public void setDefaultImages(String defaultImages) {
this.defaultImages = defaultImages == null ? null : defaultImages.trim();
}
public void setPromotionDiscountInt(Long promotionDiscountInt) {
this.promotionDiscountInt = promotionDiscountInt;
}
public void setActivities(String activities) {
this.activities = activities;
}
public void setPromotionDiscount(BigDecimal promotionDiscount) {
this.promotionDiscount = promotionDiscount;
}
public void setSortWeight(Long sortWeight) {
this.sortWeight = sortWeight;
}
public void setSpecialoffer(String specialoffer) {
this.specialoffer = specialoffer;
}
public void setBrandWeight(Long brandWeight) {
this.brandWeight = brandWeight;
}
public void setIsDiscount(String isDiscount) {
this.isDiscount = isDiscount;
}
public void setYohoodId(String yohoodId) {
this.yohoodId = yohoodId;
}
public void setProductKeyword(String productKeyword) {
this.productKeyword = productKeyword;
}
public void setBasePinRatio(double basePinRatio) {
this.basePinRatio = basePinRatio;
}
public void setColorIds(String colorIds) {
this.colorIds = colorIds == null ? null : colorIds.trim();
}
public void setBreakingRate(double breakingRate) {
this.breakingRate = breakingRate;
}
public void setColorNames(String colorNames) {
this.colorNames = colorNames == null ? null : colorNames.trim();
}
public void setDiscountScore(double discountScore) {
this.discountScore = discountScore;
}
public void setStandardIds(String standardIds) {
this.standardIds = standardIds == null ? null : standardIds.trim();
}
public void setPoolId(String poolId) {
this.poolId = poolId;
}
public void setStandardNames(String standardNames) {
this.standardNames = standardNames == null ? null : standardNames.trim();
}
public BigDecimal getStudentPrice() {
return studentPrice;
}
public void setStandardOnlyNames(String standardOnlyNames) {
this.standardOnlyNames = standardOnlyNames == null ? null : standardOnlyNames.trim();
}
public void setStudentPrice(BigDecimal studentPrice) {
this.studentPrice = studentPrice;
}
public void setSalesNum(Integer salesNum) {
this.salesNum = salesNum;
}
public String getSizeNames() {
return sizeNames;
}
public void setStorageNum(BigDecimal storageNum) {
this.storageNum = storageNum;
}
public String getIsStudentPrice() {
return isStudentPrice;
}
public void setIsSoonSoldOut(String isSoonSoldOut) {
this.isSoonSoldOut = isSoonSoldOut;
}
public void setSizeNames(String sizeNames) {
this.sizeNames = sizeNames;
}
public void setIsSoldOut(String isSoldOut) {
this.isSoldOut = isSoldOut;
}
public void setIsStudentPrice(String isStudentPrice) {
this.isStudentPrice = isStudentPrice;
}
public void setSoldOut(Integer soldOut) {
this.soldOut = soldOut;
}
public Long getShopWeight() {
return shopWeight;
}
public void setSizeIds(String sizeIds) {
this.sizeIds = sizeIds == null ? null : sizeIds.trim();
}
public void setStyleIds(String styleIds) {
this.styleIds = styleIds == null ? null : styleIds.trim();
}
public void setGoodsList(String goodsList) {
this.goodsList = goodsList == null ? null : goodsList.trim();
}
public void setShopWeight(Long shopWeight) {
this.shopWeight = shopWeight;
}
public void setDefaultImages(String defaultImages) {
this.defaultImages = defaultImages == null ? null : defaultImages.trim();
}
public String getIsStudentRebate() {
return isStudentRebate;
}
public void setActivities(String activities) {
this.activities = activities;
}
public void setIsStudentRebate(String isStudentRebate) {
this.isStudentRebate = isStudentRebate;
}
public void setSortWeight(Long sortWeight) {
this.sortWeight = sortWeight;
}
public Integer getStorageUpdateTime() {
return storageUpdateTime;
}
public void setStorageUpdateTime(Integer storageUpdateTime) {
this.storageUpdateTime = storageUpdateTime;
}
public String getProductFeatureFactor() {
return productFeatureFactor;
}
public void setProductFeatureFactor(String productFeatureFactor) {
this.productFeatureFactor = productFeatureFactor;
}
public Integer getTblCountryId() {
return tblCountryId;
}
public void setTblCountryId(Integer tblCountryId) {
this.tblCountryId = tblCountryId;
}
public String getTblCountryName() {
return tblCountryName;
}
public void setTblCountryName(String tblCountryName) {
this.tblCountryName = tblCountryName;
}
public JSONArray getPools() {
return pools;
}
public void setPools(JSONArray pools) {
this.pools = pools;
}
public void setBrandWeight(Long brandWeight) {
this.brandWeight = brandWeight;
}
public void setYohoodId(String yohoodId) {
this.yohoodId = yohoodId;
}
public void setBasePinRatio(double basePinRatio) {
this.basePinRatio = basePinRatio;
}
public void setBreakingRate(double breakingRate) {
this.breakingRate = breakingRate;
}
public void setDiscountScore(double discountScore) {
this.discountScore = discountScore;
}
public void setPoolId(String poolId) {
this.poolId = poolId;
}
public BigDecimal getStudentPrice() {
return studentPrice;
}
public void setStudentPrice(BigDecimal studentPrice) {
this.studentPrice = studentPrice;
}
public String getSizeNames() {
return sizeNames;
}
public String getIsStudentPrice() {
return isStudentPrice;
}
public void setSizeNames(String sizeNames) {
this.sizeNames = sizeNames;
}
public void setIsStudentPrice(String isStudentPrice) {
this.isStudentPrice = isStudentPrice;
}
public Long getShopWeight() {
return shopWeight;
}
public void setShopWeight(Long shopWeight) {
this.shopWeight = shopWeight;
}
public String getIsStudentRebate() {
return isStudentRebate;
}
public void setIsStudentRebate(String isStudentRebate) {
this.isStudentRebate = isStudentRebate;
}
public Integer getStorageUpdateTime() {
return storageUpdateTime;
}
public void setStorageUpdateTime(Integer storageUpdateTime) {
this.storageUpdateTime = storageUpdateTime;
}
public String getProductFeatureFactor() {
return productFeatureFactor;
}
public void setProductFeatureFactor(String productFeatureFactor) {
this.productFeatureFactor = productFeatureFactor;
}
public Integer getTblCountryId() {
return tblCountryId;
}
public void setTblCountryId(Integer tblCountryId) {
this.tblCountryId = tblCountryId;
}
public String getTblCountryName() {
return tblCountryName;
}
public void setTblCountryName(String tblCountryName) {
this.tblCountryName = tblCountryName;
}
public JSONArray getPools() {
return pools;
}
public void setPools(JSONArray pools) {
this.pools = pools;
}
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.search.consumer.service.bo.ProductIBO;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.consumer.service.logic.productIndex.ProductILogicService;
import com.yoho.search.consumer.service.logic.viewBuilder.GeneralDataBuilder;
import com.yoho.search.consumer.service.logic.viewBuilder.ProductColorsBuilder;
import com.yoho.search.consumer.service.logic.viewBuilder.ViewBuilder;
import com.yoho.search.dal.BrandMapper;
import com.yoho.search.dal.ProductMapper;
... ... @@ -11,6 +12,7 @@ import com.yoho.search.dal.ProductSortMapper;
import com.yoho.search.dal.model.Brand;
import com.yoho.search.dal.model.Product;
import com.yoho.search.dal.model.ProductSort;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -132,6 +134,9 @@ public class ProductIndexLogicService implements ApplicationContextAware {
List<Integer> skns = productIBOs.stream().map(ProductIBO::getProductSkn).collect(Collectors.toList());
generalDataBuilder.buildDataFromProductI(productIndexBOs, productIBOs);
viewBuilderList.stream().forEach(viewBuilder -> {
if(viewBuilder instanceof ProductColorsBuilder){
return;
}
viewBuilder.build(productIndexBOs, ids, skns);
});
return productIndexBOs;
... ...
package com.yoho.search.consumer.service.logic;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yoho.search.consumer.service.base.SalesCategoryService;
import com.yoho.search.dal.model.SalesCategory;
@Component
public class SalesCategoryLogicService {
private static final Logger logger = LoggerFactory.getLogger(SalesCategoryLogicService.class);
@Autowired
private SalesCategoryService salesCategoryService;
// 一级销售类目和物理小分类之间的关系
private Map<Integer, Set<Integer>> physicalChannelToSortIds;
// 判断是否是有效的有货物理分类
private boolean isLegalYohoCategory(SalesCategory salesCategory) {
if (salesCategory.getState() == null || salesCategory.getState() == 0) {
return false;
}
// BLK的忽视
if (salesCategory.getAppType() == null || salesCategory.getAppType() == 1) {
return false;
}
return true;
}
public void doReload() {
// 1、获取所有的销售分类
List<SalesCategory> salesCategorys = salesCategoryService.selectAll();
// 2、过滤出所有有货的一级销售分类
List<Integer> yohoFirstPhysicalChannels = new ArrayList<Integer>();
for (SalesCategory salesCategory : salesCategorys) {
if (isLegalYohoCategory(salesCategory) && new Integer(0).equals(salesCategory.getParentId())) {
yohoFirstPhysicalChannels.add(salesCategory.getCategoryId());
}
}
// 3、获取一级销售分类对应的物理分类
Map<Integer, Set<Integer>> temps = new ConcurrentHashMap<Integer, Set<Integer>>();
for (SalesCategory salesCategory : salesCategorys) {
try {
// 1、判断销售类目是否合法
if (!isLegalYohoCategory(salesCategory)) {
continue;
}
// 2、获取一级销售类目
String categoryCode = salesCategory.getCategoryCode();
if (StringUtils.isBlank(categoryCode)) {
continue;
}
String[] categorys = categoryCode.split(",", 2);
if (categorys.length != 2) {
continue;
}
// 3、判断分割出来的一级销售类目是否合法
Integer physicalChannel = Integer.valueOf(categorys[0]);
if(!yohoFirstPhysicalChannels.contains(physicalChannel)){
continue;
}
// 获取全部物理分类
String relation_parameter = salesCategory.getRelationParameter();
if (StringUtils.isBlank(relation_parameter)) {
continue;
}
String[] smallSortIds = relation_parameter.split(",");
Set<Integer> results = temps.get(physicalChannel);
if (results == null) {
results = new HashSet<Integer>();
temps.put(physicalChannel, results);
}
for (String smallSortId : smallSortIds) {
results.add(Integer.valueOf(smallSortId));
}
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
}
physicalChannelToSortIds = temps;
}
public SalesCategory selectById(Integer categoryId) {
return salesCategoryService.selectById(categoryId);
}
public int deleteById(Integer categoryId) {
return salesCategoryService.deleteById(categoryId);
}
public int saveOrUpdate(SalesCategory salesCategory) {
return salesCategoryService.saveOrUpdate(salesCategory);
}
/**
* 根据小物理分类获取对应的一级销售类目
*
* @param smallSortId
* @return
*/
public List<Integer> getPhysicalChannelsBySmallSortId(Integer smallSortId) {
if (smallSortId == null) {
return new ArrayList<Integer>();
}
if (physicalChannelToSortIds == null || physicalChannelToSortIds.isEmpty()) {
doReload();
}
List<Integer> channels = new ArrayList<Integer>();
for (Map.Entry<Integer, Set<Integer>> entry : physicalChannelToSortIds.entrySet()) {
if (entry.getValue().contains(smallSortId)) {
channels.add(entry.getKey());
}
}
return channels;
}
}
... ...
... ... @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.search.consumer.service.base.StorageService;
import com.yoho.search.consumer.service.bo.ProductGoodBO;
import com.yoho.search.consumer.service.bo.ProductGoodsBO;
import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.dal.GoodsCoverImageMapper;
import com.yoho.search.dal.GoodsMapper;
import com.yoho.search.dal.ProductColorMapper;
... ... @@ -12,6 +13,7 @@ import com.yoho.search.dal.model.Goods;
import com.yoho.search.dal.model.GoodsCoverImage;
import com.yoho.search.dal.model.ProductColor;
import com.yoho.search.dal.model.Storage;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -19,8 +21,10 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Created by wangnan on 2016/6/30.
... ... @@ -147,4 +151,29 @@ public class ProductGoodsLogicService {
return productGoodsBOs;
}
/**
* 获取有库存且状态正常的color
* @param goodsListJsonArray
* @param colorIdSet
* @param colorNameSet
*/
public void getColorSet(JSONArray goodsListJsonArray,Set<String> colorIdSet,Set<String> colorNameSet){
for (int i = 0; i < goodsListJsonArray.size(); i++) {
JSONObject jsonObject = goodsListJsonArray.getJSONObject(i);
//去除无库存和非正常状态的
if (!jsonObject.containsKey("status")||!jsonObject.get("status").toString().equals("1")) {
continue;
}
if (!jsonObject.containsKey("storage_num")||((Integer)jsonObject.get("storage_num"))<1) {
continue;
}
if (jsonObject.containsKey("color_id")) {
colorIdSet.add(jsonObject.get("color_id").toString());
}
if (jsonObject.containsKey("color_name")) {
colorNameSet.add(jsonObject.get("color_name").toString());
}
}
}
}
... ...