|
|
@@ -2,6 +2,8 @@ package com.uas.platform.b2c.prod.product.component.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.platform.b2c.common.search.rpc.service.SearchService;
|
|
|
+import com.uas.platform.b2c.common.search.service.impl.SearcherServiceImpl;
|
|
|
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
|
|
|
@@ -16,7 +18,6 @@ import com.uas.platform.b2c.common.search.util.PageParams.FilterField;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -48,7 +49,7 @@ public class ComponentGoodsServiceImpl implements ComponentGoodsService {
|
|
|
@Override
|
|
|
public Page<ComponentGoods> getCompGoodsByKindid(final PageInfo info) {
|
|
|
Map<String, Object> filter = info.getFilters();
|
|
|
- Map<String, Object> searchResult = null;
|
|
|
+ String searchResult = "";
|
|
|
//只能显示20页的数据
|
|
|
if(info.getPageNumber() > Constant.PAGEMAX) {
|
|
|
info.setPageNumber(Constant.PAGEMAX);
|
|
|
@@ -72,18 +73,14 @@ public class ComponentGoodsServiceImpl implements ComponentGoodsService {
|
|
|
filter.remove("code");
|
|
|
}
|
|
|
searchResult = searchService.getComponentIds(code, pageParams);
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<Integer> componentIds = (List<Integer>) searchResult.get("componentIds");
|
|
|
- List<Long> componentIdsLong = new ArrayList<>();
|
|
|
- for (Integer cid:componentIds) {
|
|
|
- componentIdsLong.add(cid.longValue());
|
|
|
- }
|
|
|
+ SearcherServiceImpl.ComponentIdsResult componentIdsResult = FastjsonUtils.fromJson(searchResult, SearcherServiceImpl.ComponentIdsResult.class);
|
|
|
+ Long[] componentIds = componentIdsResult.getComponentIds();
|
|
|
+
|
|
|
List<ComponentGoods> componentGoods = new ArrayList<>();
|
|
|
- if (componentIds.size() > 0) {
|
|
|
- Long[] idArr = new Long[componentIdsLong.size()];
|
|
|
- componentGoods = componentGoodsDao.findByIdsInOrder(componentIdsLong.toArray(idArr));
|
|
|
+ if (componentIds.length > 0) {
|
|
|
+ componentGoods = componentGoodsDao.findByIdsInOrder(componentIds);
|
|
|
}
|
|
|
- int length = (int)searchResult.get("total");
|
|
|
+ int length = componentIdsResult.getTotal();
|
|
|
if(length < componentGoods.size()) {
|
|
|
length = componentGoods.size();
|
|
|
}
|