Authored by hugufei

解决循环引用反序列化,list返回null的问题

... ... @@ -38,6 +38,23 @@ public class BigdataSimilarSknService {
@Autowired
private ProductIndexBaseService productIndexBaseService;
/**
* 获取非重复skn
* @param productSknStr
* @return
*/
private List<String> getDistinctSknList(String productSknStr){
List<String> results = new ArrayList<>();
String [] productSkns = productSknStr.split(",");
for (String productSkn : productSkns){
if(!results.contains(productSkn) && StringUtils.isNumeric(productSkn)){
results.add(productSkn);
}
}
return results;
}
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR", includeParams = { "product_skn", "viewNum" })
public SearchApiResult searchLikeSimilarSknNotInShop(Map<String, String> paramMap) {
try {
... ... @@ -62,14 +79,14 @@ public class BigdataSimilarSknService {
//5.1)图片[性别+不同店铺]
List<String> diffShopImgSimilarSkns = new ArrayList<>();
if (StringUtils.isNotEmpty(similarSkn.getDiffShopImgSimilarSkns())) {
diffShopImgSimilarSkns = CollectionUtils.arrayToList(similarSkn.getDiffShopImgSimilarSkns().split(","));
diffShopImgSimilarSkns = this.getDistinctSknList(similarSkn.getDiffShopImgSimilarSkns());
}
searchParams.add(this.builderSimilarSknSearchParam(productInfoInEs, diffShopImgSimilarSkns, true));
//5.2)行为[性别+不同店铺+同品类]
List<String> diffShopActionSimilarSkns = new ArrayList<>();
if (StringUtils.isNotEmpty(similarSkn.getDiffShopActionSimilarSkns())) {
diffShopActionSimilarSkns = CollectionUtils.arrayToList(similarSkn.getDiffShopActionSimilarSkns().split(","));
diffShopActionSimilarSkns = this.getDistinctSknList(similarSkn.getDiffShopActionSimilarSkns());
}
searchParams.add(this.builderSimilarSknSearchParam(productInfoInEs, diffShopActionSimilarSkns, true));
... ... @@ -115,7 +132,7 @@ public class BigdataSimilarSknService {
}
/**
* 按productSkn顺序截取商品条数
* 按productSkn顺序截取商品条数-注意循环引用的问题
* @param esProductList
* @param sortedProductSkns
* @param size
... ... @@ -137,7 +154,7 @@ public class BigdataSimilarSknService {
});
for (String productSkn : sortedProductSkns){
if(productMap.containsKey(productSkn)){
results.add(productMap.get(productSkn));
results.add(new HashMap<>(productMap.get(productSkn)));//注意循环引用
}
if(results.size()>=size){
break;
... ...