Showing
1 changed file
with
34 additions
and
25 deletions
@@ -4,6 +4,8 @@ import com.yoho.search.consumer.service.bo.ProductIndexBO; | @@ -4,6 +4,8 @@ import com.yoho.search.consumer.service.bo.ProductIndexBO; | ||
4 | import com.yoho.search.dal.model.ProductSort; | 4 | import com.yoho.search.dal.model.ProductSort; |
5 | import com.yoho.search.dal.model.UfoProduct; | 5 | import com.yoho.search.dal.model.UfoProduct; |
6 | import com.yoho.search.dal.model.UfoSearchSortRelation; | 6 | import com.yoho.search.dal.model.UfoSearchSortRelation; |
7 | +import org.slf4j.Logger; | ||
8 | +import org.slf4j.LoggerFactory; | ||
7 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
8 | 10 | ||
9 | import java.util.Map; | 11 | import java.util.Map; |
@@ -17,36 +19,43 @@ import java.util.Map; | @@ -17,36 +19,43 @@ import java.util.Map; | ||
17 | @Component | 19 | @Component |
18 | public class UfoToYohoSortService { | 20 | public class UfoToYohoSortService { |
19 | 21 | ||
22 | + private static final Logger logger = LoggerFactory.getLogger(UfoToYohoSortService.class); | ||
23 | + | ||
20 | public void build(ProductIndexBO productIndexBO, UfoProduct ufoProduct, Map<Integer, ProductSort> productSortMap, Map<Integer, UfoSearchSortRelation> ufoSortRelationMap) { | 24 | public void build(ProductIndexBO productIndexBO, UfoProduct ufoProduct, Map<Integer, ProductSort> productSortMap, Map<Integer, UfoSearchSortRelation> ufoSortRelationMap) { |
21 | - //处理大分类 | ||
22 | - if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMaxSortId()))) { | ||
23 | - UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMaxSortId())); | ||
24 | - if (ufoSearchSortRelation != null) { | ||
25 | - ProductSort productSort = productSortMap.get(ufoSearchSortRelation.getUfoSortId()); | ||
26 | - if (productSort != null) { | ||
27 | - productIndexBO.setMaxSortId(productSort.getId()); | ||
28 | - productIndexBO.setMaxSortName(productSort.getId() + ":" + productSort.getSortName() + ":" + productSort.getOrderBy()); | ||
29 | - productIndexBO.setMaxSort(productSort.getSortName()); | 25 | + try { |
26 | + //处理大分类 | ||
27 | + if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMaxSortId()))) { | ||
28 | + UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMaxSortId())); | ||
29 | + if (ufoSearchSortRelation != null) { | ||
30 | + ProductSort productSort = productSortMap.get(ufoSearchSortRelation.getYohoSortId()); | ||
31 | + if (productSort != null) { | ||
32 | + productIndexBO.setMaxSortId(productSort.getId()); | ||
33 | + productIndexBO.setMaxSortName(productSort.getId() + ":" + productSort.getSortName() + ":" + productSort.getOrderBy()); | ||
34 | + productIndexBO.setMaxSort(productSort.getSortName()); | ||
35 | + } | ||
30 | } | 36 | } |
31 | } | 37 | } |
32 | - } | ||
33 | - //处理中分类和小分类 | ||
34 | - if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMidSortId()))) { | ||
35 | - UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMidSortId())); | ||
36 | - if (ufoSearchSortRelation != null) { | ||
37 | - ProductSort productSortMid = productSortMap.get(ufoSearchSortRelation.getUfoSortId()); | ||
38 | - if (productSortMid != null) { | ||
39 | - productIndexBO.setMiddleSortId(productSortMid.getId()); | ||
40 | - productIndexBO.setMiddleSortName(productSortMid.getId() + ":" + productSortMid.getSortName() + ":" + productSortMid.getOrderBy()); | ||
41 | - productIndexBO.setMiddleSort(productSortMid.getSortName()); | ||
42 | - } | ||
43 | - ProductSort productSortSmall = productSortMap.get(ufoSearchSortRelation.getYohoSmallSortId()); | ||
44 | - if (productSortSmall != null) { | ||
45 | - productIndexBO.setSmallSortId(productSortSmall.getId()); | ||
46 | - productIndexBO.setSmallSortName(productSortSmall.getId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy()); | ||
47 | - productIndexBO.setSmallSort(productSortSmall.getSortName()); | 38 | + //处理中分类和小分类 |
39 | + if (ufoSortRelationMap.containsKey(Integer.valueOf(ufoProduct.getMidSortId()))) { | ||
40 | + UfoSearchSortRelation ufoSearchSortRelation = ufoSortRelationMap.get(Integer.valueOf(ufoProduct.getMidSortId())); | ||
41 | + if (ufoSearchSortRelation != null) { | ||
42 | + ProductSort productSortMid = productSortMap.get(ufoSearchSortRelation.getYohoSortId()); | ||
43 | + if (productSortMid != null) { | ||
44 | + productIndexBO.setMiddleSortId(productSortMid.getId()); | ||
45 | + productIndexBO.setMiddleSortName(productSortMid.getId() + ":" + productSortMid.getSortName() + ":" + productSortMid.getOrderBy()); | ||
46 | + productIndexBO.setMiddleSort(productSortMid.getSortName()); | ||
47 | + } | ||
48 | + ProductSort productSortSmall = productSortMap.get(ufoSearchSortRelation.getYohoSmallSortId()); | ||
49 | + if (productSortSmall != null) { | ||
50 | + productIndexBO.setSmallSortId(productSortSmall.getId()); | ||
51 | + productIndexBO.setSmallSortName(productSortSmall.getId() + ":" + productSortSmall.getSortName() + ":" + productSortSmall.getOrderBy()); | ||
52 | + productIndexBO.setSmallSort(productSortSmall.getSortName()); | ||
53 | + } | ||
48 | } | 54 | } |
49 | } | 55 | } |
56 | + } catch (Exception e) { | ||
57 | + logger.error(e.getMessage(), e); | ||
50 | } | 58 | } |
59 | + | ||
51 | } | 60 | } |
52 | } | 61 | } |
-
Please register or login to post a comment