Authored by hugufei

品类映射的bug

... ... @@ -4,6 +4,8 @@ import com.yoho.search.consumer.service.bo.ProductIndexBO;
import com.yoho.search.dal.model.ProductSort;
import com.yoho.search.dal.model.UfoProduct;
import com.yoho.search.dal.model.UfoSearchSortRelation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
... ... @@ -17,36 +19,43 @@ import java.util.Map;
@Component
public class UfoToYohoSortService {
private static final Logger logger = LoggerFactory.getLogger(UfoToYohoSortService.class);
public void build(ProductIndexBO productIndexBO, UfoProduct ufoProduct, Map<Integer, ProductSort> productSortMap, Map<Integer, UfoSearchSortRelation> ufoSortRelationMap) {
//处理大分类
if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMaxSortId()))) {
UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMaxSortId()));
if (ufoSearchSortRelation != null) {
ProductSort productSort = productSortMap.get(ufoSearchSortRelation.getUfoSortId());
if (productSort != null) {
productIndexBO.setMaxSortId(productSort.getId());
productIndexBO.setMaxSortName(productSort.getId() + ":" + productSort.getSortName() + ":" + productSort.getOrderBy());
productIndexBO.setMaxSort(productSort.getSortName());
try {
//处理大分类
if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMaxSortId()))) {
UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMaxSortId()));
if (ufoSearchSortRelation != null) {
ProductSort productSort = productSortMap.get(ufoSearchSortRelation.getYohoSortId());
if (productSort != null) {
productIndexBO.setMaxSortId(productSort.getId());
productIndexBO.setMaxSortName(productSort.getId() + ":" + productSort.getSortName() + ":" + productSort.getOrderBy());
productIndexBO.setMaxSort(productSort.getSortName());
}
}
}
}
//处理中分类和小分类
if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMidSortId()))) {
UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMidSortId()));
if (ufoSearchSortRelation != null) {
ProductSort productSortMid = productSortMap.get(ufoSearchSortRelation.getUfoSortId());
if (productSortMid != null) {
productIndexBO.setMiddleSortId(productSortMid.getId());
productIndexBO.setMiddleSortName(productSortMid.getId() + ":" + productSortMid.getSortName() + ":" + productSortMid.getOrderBy());
productIndexBO.setMiddleSort(productSortMid.getSortName());
}
ProductSort productSortSmall = productSortMap.get(ufoSearchSortRelation.getYohoSmallSortId());
if (productSortSmall != null) {
productIndexBO.setSmallSortId(productSortSmall.getId());
productIndexBO.setSmallSortName(productSortSmall.getId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
productIndexBO.setSmallSort(productSortSmall.getSortName());
//处理中分类和小分类
if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMidSortId()))) {
UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMidSortId()));
if (ufoSearchSortRelation != null) {
ProductSort productSortMid = productSortMap.get(ufoSearchSortRelation.getYohoSortId());
if (productSortMid != null) {
productIndexBO.setMiddleSortId(productSortMid.getId());
productIndexBO.setMiddleSortName(productSortMid.getId() + ":" + productSortMid.getSortName() + ":" + productSortMid.getOrderBy());
productIndexBO.setMiddleSort(productSortMid.getSortName());
}
ProductSort productSortSmall = productSortMap.get(ufoSearchSortRelation.getYohoSmallSortId());
if (productSortSmall != null) {
productIndexBO.setSmallSortId(productSortSmall.getId());
productIndexBO.setSmallSortName(productSortSmall.getId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy());
productIndexBO.setSmallSort(productSortSmall.getSortName());
}
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
... ...